import { useContext, useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { CheckBox } from "./common/CheckBox"; import { enableRefuel } from "../state/quotesSlice"; import { CustomizeContext } from "../providers/CustomizeProvider"; import useMappedChainData from "../hooks/useMappedChainData"; import { HelpCircle } from "react-feather"; import { Tooltip } from "./common/Tooltip"; export const Refuel = ({ selectivelyShowRefuel }) => { const [isChecked, setIsChecked] = useState(false); const destChainId = useSelector((state: any) => state.networks.destChainId); const sourceChainId = useSelector( (state: any) => state.networks.sourceChainId ); const mappedChainData = useMappedChainData(); const dispatch = useDispatch(); const customSettings = useContext(CustomizeContext); const { borderRadius } = customSettings.customization; useEffect(() => { dispatch(enableRefuel(isChecked)); }, [isChecked]); useEffect(() => { if (destChainId === 1 || destChainId === sourceChainId) { setIsChecked(false); dispatch(enableRefuel(false)); } }, [destChainId]); if ( selectivelyShowRefuel && (destChainId === 1 || destChainId === sourceChainId) ) return null; return (
Enable Refuel

{destChainId === 1 ? ( Refuel isn't supported on Ethereum ) : destChainId === sourceChainId ? ( Refuel isn't supported for same chain swaps ) : ( `Get Gas for transactions on ${mappedChainData?.[destChainId]?.name}` )}

); };