1249c0df71
* chore: initial commit * refactor: remove unnecessary wrappers * style: add missing newline * chore: bump bee-js * chore: ignore any cast in fdp * fix: remove cid import * fix: make TextEncoder and TextDecoder available in jest * refactor: dedupe stamp ttl second conversion * refactor: use convenience methods from bee-js * feat: update to bee-js for restored ens support * fix: bump bee-js to get download fix * fix: resolve feed before downloading reference * fix: fix token displays * fix: fix token input modal error message * refactor: remove wallet balance provider * chore: remove dead code * refactor: upcoming bee js 0.15.0 (#692) * chore: initial commit * fix: do not break page when duration seconds is 0 * ci: remove cache * chore: upgrade bee-js * feat: bee-js and bee v2.6 compatibility * chore: switch upcoming/bee-js to ethersphere/bee-js
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { Button, ListItemIcon, Menu, MenuItem, Typography } from '@material-ui/core'
|
|
import React, { ReactElement } from 'react'
|
|
import { EnrichedPostageBatch } from '../../providers/Stamps'
|
|
|
|
interface Props {
|
|
stamps: EnrichedPostageBatch[] | null
|
|
selectedStamp: EnrichedPostageBatch | null
|
|
setSelected: (stamp: EnrichedPostageBatch) => void
|
|
}
|
|
|
|
export default function SimpleMenu({ stamps, selectedStamp, setSelected }: Props): ReactElement | null {
|
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null)
|
|
|
|
if (!stamps) return null
|
|
|
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
setAnchorEl(event.currentTarget)
|
|
}
|
|
|
|
const handleClose = () => setAnchorEl(null)
|
|
|
|
return (
|
|
<div>
|
|
<Button variant="contained" aria-haspopup="true" onClick={handleClick}>
|
|
Change
|
|
</Button>
|
|
<Menu anchorEl={anchorEl} keepMounted open={Boolean(anchorEl)} onClose={handleClose}>
|
|
{stamps.map(stamp => (
|
|
<MenuItem
|
|
key={stamp.batchID.toHex()}
|
|
onClick={() => {
|
|
setSelected(stamp)
|
|
handleClose()
|
|
}}
|
|
selected={stamp.batchID === selectedStamp?.batchID}
|
|
>
|
|
<ListItemIcon>{stamp.usageText}</ListItemIcon>
|
|
<Typography variant="body2">{stamp.batchID.toHex().slice(0, 8)}[…]</Typography>
|
|
</MenuItem>
|
|
))}
|
|
</Menu>
|
|
</div>
|
|
)
|
|
}
|