1 import { useEffect } from 'react';
3 import { createSelector } from '@reduxjs/toolkit';
5 import { baseUseSelector } from '@proton/react-redux-store';
6 import { createHooks } from '@proton/redux-utilities';
8 import { type FeeSettings, networkFeesThunk, selectNetworkFees } from '../slices';
10 const hooks = createHooks(networkFeesThunk, selectNetworkFees);
12 export const useGetNetworkFees = hooks.useGet;
14 export const useNetworkFees = () => {
15 const getNetworkFees = useGetNetworkFees();
16 const [, loading] = hooks.useValue();
18 const networkFeesSelector = createSelector(selectNetworkFees, (result): [FeeSettings | undefined, boolean] => {
19 const { value } = result;
21 return [value, loading];
25 void getNetworkFees();
28 return baseUseSelector(networkFeesSelector);