import React, { useEffect, useState } from 'react'; import Button from '@mui/material/Button'; import Paper from '@mui/material/Paper'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import TextField from '@mui/material/TextField'; import Alert from '@mui/material/Alert'; import Table from '@mui/material/Table'; import TableBody from '@mui/material/TableBody'; import TableCell from '@mui/material/TableCell'; import TableHead from '@mui/material/TableHead'; import TableRow from '@mui/material/TableRow'; import { useWalletContext } from './utils/wallet.context'; export const Delegations = () => { const { delegations, doDelegate, delegationLoader, unDelegateAll, unDelegateAllLoading, log } = useWalletContext(); const [delegationNodeId, setDelegationNodeId] = useState(); const [amountToBeDelegated, setAmountToBeDelegated] = useState(); const [infoText, setInfoText] = useState(''); const cleanFields = () => { setDelegationNodeId(''); setAmountToBeDelegated(''); setInfoText(''); }; useEffect( () => () => { cleanFields(); }, [], ); return ( Delegations Make a delegation setDelegationNodeId(e.target.value)} size="small" /> setAmountToBeDelegated(e.target.value)} size="small" /> Your delegations: {!delegations?.delegations?.length ? ( You do not have delegations ) : ( MixId Owner Amount Cumulative Reward Ratio {delegations?.delegations.map((delegation: any) => ( {delegation.mix_id} {delegation.owner} {delegation.amount.amount} {delegation.cumulative_reward_ratio} ))}
)}
{delegations?.delegations.length > 0 && ( )} {infoText && {infoText}}
{log?.node?.length > 0 && log.type === 'delegate' && ( Transaction Logs: {log.node} )}
); };