Skip to content

Commit

Permalink
Update spawnpoint popup to support Copy ID
Browse files Browse the repository at this point in the history
  • Loading branch information
mkl committed Mar 20, 2024
1 parent bc6e7c6 commit dcfab70
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/features/spawnpoint/SpawnpointPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,48 @@ import { dayCheck } from '@utils/dayCheck'
* @param {import('@rm/types').Spawnpoint} props
* @returns
*/
export function SpawnpointPopup({ despawn_sec, lat, lon, updated }) {
export function SpawnpointPopup({ id, despawn_sec, lat, lon, updated }) {
const { t } = useTranslation()
const { perms } = useMemory((s) => s.auth)

const minute = despawn_sec > 60 ? Math.round(despawn_sec / 60) : despawn_sec
const minuteFixed = minute < 10 ? `0${minute}` : minute

const handleClose = () => {
setAnchorEl(null)
}

const copyId = () => {
setAnchorEl(null)
navigator.clipboard.writeText(id)
}

const options = []

if (perms.admin) {
options.push({ name: 'Copy ID', action: copyId })
}

return (
<ErrorBoundary noRefresh style={{}} variant="h5">
<Menu
anchorEl={anchorEl}
keepMounted
open={!!anchorEl}
onClose={handleClose}
PaperProps={{
style: {
maxHeight: 216,
minWidth: '20ch',
},
}}
>
{options.map((option) => (
<MenuItem key={option.key || option.name} onClick={option.action}>
{typeof option.name === 'string' ? t(option.name) : option.name}
</MenuItem>
))}
</Menu>
<Typography variant="h5" align="center">
{t('spawnpoint')}
</Typography>
Expand Down

0 comments on commit dcfab70

Please sign in to comment.