otterscan/src/search/useFeeToggler.ts
2021-07-01 15:47:23 -03:00

20 lines
461 B
TypeScript

import { useState } from "react";
export enum FeeDisplay {
TX_FEE,
GAS_PRICE,
}
export const useFeeToggler = (): [FeeDisplay, () => void] => {
const [feeDisplay, setFeeDisplay] = useState<FeeDisplay>(FeeDisplay.TX_FEE);
const feeDisplayToggler = () => {
if (feeDisplay === FeeDisplay.TX_FEE) {
setFeeDisplay(FeeDisplay.GAS_PRICE);
} else {
setFeeDisplay(FeeDisplay.TX_FEE);
}
};
return [feeDisplay, feeDisplayToggler];
};