93af7f35a3
* feat: altered the design of the tabs and redid the download tab * feat: redesign the upload file * fix: styles of tabs on hover * fix: display troubleshoot component when the status of the node is not OK * fix: when removing the file, remove the reference upload reference as well * fix: on inputs the label should not be selectable * feat: add placeholder to inputs and make the label non-selectable * refactor: improved the readability of the upload file component * chore: removed PeerDetail component * fix: replaced "batch" with (postage) "stamp" for clarity * refactor: address PR review comments * feat: disable the download button if there is no value
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import React, { ReactElement } from 'react'
|
|
import { Button, ListItemIcon, Typography, Menu, MenuItem } from '@material-ui/core'
|
|
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}
|
|
onClick={() => {
|
|
setSelected(stamp)
|
|
handleClose()
|
|
}}
|
|
selected={stamp.batchID === selectedStamp?.batchID}
|
|
>
|
|
<ListItemIcon>{stamp.usageText}</ListItemIcon>
|
|
<Typography variant="body2">{stamp.batchID.substr(0, 8)}[…]</Typography>
|
|
</MenuItem>
|
|
))}
|
|
</Menu>
|
|
</div>
|
|
)
|
|
}
|