feat: improve topup and dilute ux
Co-authored-by: Ferenc Sárai <ferenc.sarai@solarpunk.buzz>
This commit is contained in:
@@ -24,6 +24,9 @@ const useStyles = makeStyles((theme: Theme) =>
|
|||||||
},
|
},
|
||||||
contentLevel12: {
|
contentLevel12: {
|
||||||
marginTop: theme.spacing(0.25),
|
marginTop: theme.spacing(0.25),
|
||||||
|
'& > li:last-of-type': {
|
||||||
|
marginBottom: theme.spacing(2),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
infoText: {
|
infoText: {
|
||||||
color: '#c9c9c9',
|
color: '#c9c9c9',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { BeeDebug } from '@ethersphere/bee-js'
|
import { BeeDebug } from '@ethersphere/bee-js'
|
||||||
|
import { Box } from '@material-ui/core'
|
||||||
import Button from '@material-ui/core/Button'
|
import Button from '@material-ui/core/Button'
|
||||||
import Dialog from '@material-ui/core/Dialog'
|
import Dialog from '@material-ui/core/Dialog'
|
||||||
import DialogActions from '@material-ui/core/DialogActions'
|
import DialogActions from '@material-ui/core/DialogActions'
|
||||||
@@ -7,20 +8,19 @@ import DialogTitle from '@material-ui/core/DialogTitle'
|
|||||||
import Input from '@material-ui/core/Input'
|
import Input from '@material-ui/core/Input'
|
||||||
import { useSnackbar } from 'notistack'
|
import { useSnackbar } from 'notistack'
|
||||||
import { ReactElement, ReactNode, useState } from 'react'
|
import { ReactElement, ReactNode, useState } from 'react'
|
||||||
import { SwarmSelect } from './SwarmSelect'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label: string
|
type: 'Topup' | 'Dilute'
|
||||||
icon: ReactNode
|
icon: ReactNode
|
||||||
beeDebug: BeeDebug
|
beeDebug: BeeDebug
|
||||||
stamp: string
|
stamp: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function StampExtensionModal({ label, icon, beeDebug, stamp }: Props): ReactElement {
|
export default function StampExtensionModal({ type, icon, beeDebug, stamp }: Props): ReactElement {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [amount, setAmount] = useState('')
|
const [amount, setAmount] = useState('')
|
||||||
const [type, setType] = useState<'Topup' | 'Dilute'>('Topup')
|
|
||||||
const { enqueueSnackbar } = useSnackbar()
|
const { enqueueSnackbar } = useSnackbar()
|
||||||
|
const label = `${type} ${stamp.substring(0, 8)}`
|
||||||
|
|
||||||
const handleClickOpen = (e: React.MouseEvent<HTMLButtonElement>) => {
|
const handleClickOpen = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
setOpen(true)
|
setOpen(true)
|
||||||
@@ -56,22 +56,13 @@ export default function StampExtensionModal({ label, icon, beeDebug, stamp }: Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Box mb={2}>
|
||||||
<Button variant="contained" onClick={handleClickOpen} startIcon={icon}>
|
<Button variant="contained" onClick={handleClickOpen} startIcon={icon}>
|
||||||
{label}
|
{type}
|
||||||
</Button>
|
</Button>
|
||||||
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
|
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
|
||||||
<DialogTitle id="form-dialog-title">{label}</DialogTitle>
|
<DialogTitle id="form-dialog-title">{label}</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<SwarmSelect
|
|
||||||
label="Action"
|
|
||||||
defaultValue="Topup"
|
|
||||||
onChange={event => setType(event.target.value as 'Topup' | 'Dilute')}
|
|
||||||
options={[
|
|
||||||
{ value: 'Topup', label: 'Topup' },
|
|
||||||
{ value: 'Dilute', label: 'Dilute' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<Input
|
<Input
|
||||||
autoFocus
|
autoFocus
|
||||||
margin="dense"
|
margin="dense"
|
||||||
@@ -87,11 +78,11 @@ export default function StampExtensionModal({ label, icon, beeDebug, stamp }: Pr
|
|||||||
<Button onClick={handleClose} color="primary">
|
<Button onClick={handleClose} color="primary">
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleAction} color="primary">
|
<Button disabled={amount === ''} onClick={handleAction} color="primary">
|
||||||
{type}
|
{type}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</div>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ReactElement, useContext } from 'react'
|
import { ReactElement, useContext } from 'react'
|
||||||
import TimerFlash from 'remixicon-react/TimerFlashFillIcon'
|
import TimerFlashFill from 'remixicon-react/TimerFlashFillIcon'
|
||||||
|
import TimerFlashLine from 'remixicon-react/TimerFlashLineIcon'
|
||||||
import ExpandableElement from '../../components/ExpandableElement'
|
import ExpandableElement from '../../components/ExpandableElement'
|
||||||
import ExpandableList from '../../components/ExpandableList'
|
import ExpandableList from '../../components/ExpandableList'
|
||||||
import ExpandableListItem from '../../components/ExpandableListItem'
|
import ExpandableListItem from '../../components/ExpandableListItem'
|
||||||
@@ -50,8 +51,14 @@ function StampsTable({ postageStamps }: Props): ReactElement | null {
|
|||||||
<ExpandableListItem label="Purchase Block Number" value={stamp.blockNumber} />
|
<ExpandableListItem label="Purchase Block Number" value={stamp.blockNumber} />
|
||||||
<ExpandableListItemActions>
|
<ExpandableListItemActions>
|
||||||
<StampExtensionModal
|
<StampExtensionModal
|
||||||
label="Topup & Dilute"
|
type="Topup"
|
||||||
icon={<TimerFlash size="1rem" />}
|
icon={<TimerFlashFill size="1rem" />}
|
||||||
|
beeDebug={beeDebugApi}
|
||||||
|
stamp={stamp.batchID}
|
||||||
|
/>
|
||||||
|
<StampExtensionModal
|
||||||
|
type="Dilute"
|
||||||
|
icon={<TimerFlashLine size="1rem" />}
|
||||||
beeDebug={beeDebugApi}
|
beeDebug={beeDebugApi}
|
||||||
stamp={stamp.batchID}
|
stamp={stamp.batchID}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user