34d2dfda5a
* initial dashboard layout * add node status card * add accounting section, pull peer data * add file functionality with bee-js, first iteration of accounts page * Add balances and chequebook table * add blockie / identicon for addresses * add basic settlements table * implement theme overrides * cleanup logging * Add troubleshooting block * add initial dark theme support, add copy to clipboard, QR code support * show active element on sidebar * remove duplicate status page and make status page index * Update package.json Co-authored-by: Vojtech Simetka <vojtech@simetka.cz> * Update public/index.html Co-authored-by: Vojtech Simetka <vojtech@simetka.cz> * Update src/pages/accounting/AccountCard.tsx Co-authored-by: Vojtech Simetka <vojtech@simetka.cz> * change bee api client to use beeJS library * add initial setup workflow * breakout ethereum address component, define initial setup workflow * add types to responses, add additional node troubleshooting info to workflow * make setup steps nonlinear and interactive * make host endpoint dynamic on setup * split out api calls into custom hooks, add component loading indicators * add depost / withdrawl functionality, show transactions in BZZ * add multiOS code support troubleshooting, check for balance in chequebook on setup * add ability to change apis in settings page * show file loading status * Style active sidebar item * reload on theme change * modify troubleshooting verbage, add cashout functionality and details, * facilitate file upload with beeJS * update readme to show UI samples * remove nnPeersWatermark from peers page * split node steps into separate components, make status page visible at anytime * minor UI/UX enhancements * format accounting page * remove WIP wallet connection code * Update src/components/CashoutModal.tsx Co-authored-by: Vojtech Simetka <vojtech@simetka.cz> * use bigint for deposits/withdrawls * revise status card * clean up unused imports and variables * add api status to sidebar * obfuscate pages with troubleshooting component when apis not connected * add localhost OS detection for troubleshooting code * cleanup extra logos * monospace BZZ in tables * hide troubleshooting page while loading API status * Remove ability to remove peers * add null types to API responses Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
89 lines
2.6 KiB
TypeScript
89 lines
2.6 KiB
TypeScript
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 } from '@material-ui/core';
|
|
|
|
import { beeDebugApi } from '../services/bee';
|
|
|
|
export default function DepositModal() {
|
|
const [open, setOpen] = React.useState(false);
|
|
const [amount, setAmount] = React.useState(BigInt(0));
|
|
const [showToast, setToastVisibility] = React.useState(false);
|
|
const [toastContent, setToastContent] = React.useState('');
|
|
|
|
const handleClickOpen = () => {
|
|
setOpen(true);
|
|
};
|
|
|
|
const handleClose = () => {
|
|
setOpen(false);
|
|
};
|
|
|
|
const handleWithdraw = () => {
|
|
if (amount > 0) {
|
|
beeDebugApi.chequebook.deposit(amount)
|
|
.then(res => {
|
|
setOpen(false);
|
|
handleToast(`Successful Deposit. Transaction ${res.data.transactionHash}`)
|
|
})
|
|
.catch(error => {
|
|
handleToast('Error with Deposit')
|
|
})
|
|
} else {
|
|
handleToast('Must be amount of greater than 0')
|
|
}
|
|
};
|
|
|
|
const handleToast = (text: string) => {
|
|
setToastContent(text)
|
|
setToastVisibility(true);
|
|
setTimeout(
|
|
() => setToastVisibility(false),
|
|
7000
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<Button variant="outlined" color="primary" onClick={handleClickOpen} style={{marginLeft:'7px'}}>
|
|
Deposit
|
|
</Button>
|
|
<Snackbar
|
|
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
|
|
open={showToast}
|
|
message={toastContent}
|
|
/>
|
|
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
|
|
<DialogTitle id="form-dialog-title">Deposit Funds</DialogTitle>
|
|
<DialogContent>
|
|
<DialogContentText>
|
|
Specify the amount you would like to deposit to your node.
|
|
</DialogContentText>
|
|
<Input
|
|
autoFocus
|
|
margin="dense"
|
|
id="name"
|
|
type="number"
|
|
placeholder='Amount'
|
|
fullWidth
|
|
onChange={(e) => setAmount(BigInt(e.target.value))}
|
|
/>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<Button onClick={handleClose} color="primary">
|
|
Cancel
|
|
</Button>
|
|
<Button onClick={handleWithdraw} color="primary">
|
|
Deposit
|
|
</Button>
|
|
</DialogActions>
|
|
</Dialog>
|
|
</div>
|
|
);
|
|
}
|