import React from 'react'; import Button from '@material-ui/core/Button'; import Input from '@material-ui/core/Input'; import Dialog from '@material-ui/core/Dialog'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; import { Snackbar, Container, CircularProgress } from '@material-ui/core'; import { beeDebugApi } from '../services/bee'; import EthereumAddress from './EthereumAddress'; export default function DepositModal() { const [open, setOpen] = React.useState(false); const [peerId, setPeerId] = React.useState(''); const [loadingCashout, setLoadingCashout] = React.useState(false); const [showToast, setToastVisibility] = React.useState(false); const [toastContent, setToastContent] = React.useState(null); const handleClickOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; const handleCashout = () => { if (peerId) { setLoadingCashout(true) beeDebugApi.chequebook.peerCashout(peerId) .then(res => { setOpen(false); handleToast(Successfully cashed out cheque. Transaction ) }) .catch(error => { handleToast(Error with cashout) }) .finally(() => { setLoadingCashout(false) }) } else { handleToast(Peer Id invalid) } }; const handleToast = (text: JSX.Element) => { setToastContent(text) setToastVisibility(true); setTimeout( () => setToastVisibility(false), 7000 ); }; return (
Cashout Cheque {loadingCashout ? : Specify the peer Id of the peer you would like to cashout. setPeerId(e.target.value)} /> }
); }