import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { useWeb3React } from '@web3-react/core'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { Outlet } from 'react-router-dom'; import { Link } from 'react-router-dom'; import { EthConnectPrompt } from '../../components/eth-connect-prompt'; import { SplashLoader } from '../../components/splash-loader'; import { useAppState } from '../../contexts/app-state/app-state-context'; import { useContracts } from '../../contexts/contracts/contracts-context'; import { useTranches } from '../../hooks/use-tranches'; import { Routes as RoutesConfig } from '../router-config'; import { initialRedemptionState, RedemptionActionType, redemptionReducer, } from './redemption-reducer'; const RedemptionRouter = () => { const { t } = useTranslation(); const { vesting } = useContracts(); const [state, dispatch] = React.useReducer( redemptionReducer, initialRedemptionState ); const { appState: { trancheBalances }, } = useAppState(); const { account } = useWeb3React(); const { tranches, error } = useTranches(); React.useEffect(() => { const run = (address: string) => { const userTranches = tranches?.filter((t) => t.users.some( ({ address: a }) => a.toLowerCase() === address.toLowerCase() ) ); if (userTranches) { dispatch({ type: RedemptionActionType.SET_USER_TRANCHES, userTranches, }); } }; if (account) { run(account); } }, [account, tranches, vesting]); if (error) { return ( {error} ); } if (!tranches) { return ( ); } if (!account) { return (

{t( "Use the Ethereum wallet you want to send your tokens to. You'll also need enough Ethereum to pay gas." )}

); } if (!trancheBalances.length) { return ( <>

{t('You have no VEGA tokens currently vesting.')}

{t('viewAllTranches')} ); } return ; }; export default RedemptionRouter;