import { useEffect, useState } from 'react' import { useTranslation } from 'next-i18next' import mangoStore from '@store/mangoStore' import useMangoAccount from 'hooks/useMangoAccount' import Tooltip from './Tooltip' import { IconButton } from './Button' import { ArrowPathIcon } from '@heroicons/react/20/solid' const ManualRefresh = ({ classNames, hideBg = false, size, }: { classNames?: string hideBg?: boolean size?: 'small' | 'medium' | 'large' }) => { const { t } = useTranslation('common') const [spin, setSpin] = useState(false) const actions = mangoStore((s) => s.actions) const { mangoAccountAddress } = useMangoAccount() const handleRefreshData = async () => { setSpin(true) await actions.fetchGroup() if (mangoAccountAddress) { await actions.reloadMangoAccount() actions.fetchOpenOrders() } } useEffect(() => { let timer: NodeJS.Timeout if (spin) { timer = setTimeout(() => setSpin(false), 5000) } return () => { clearTimeout(timer) } }, [spin]) return (
) } export default ManualRefresh