Skip to content

Commit

Permalink
fix: add types & onClose callback to CopyCoords
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Sep 12, 2024
1 parent d676875 commit 7eaf43d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/components/popups/Coords.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@ export function Coords({ lat, lon }) {
)
}

export function CopyCoords({ lat, lon }) {
/**
*
* @param {{ lat: number, lon: number } & import('@mui/material').MenuItemProps} props
* @returns
*/
export function CopyCoords({ lat, lon, onClick, ...props }) {
const { t } = useTranslation()

const copy = React.useCallback(
() => navigator.clipboard.writeText(`${lat}, ${lon}`),
[lat, lon],
const onClickWithCopy = React.useCallback(
(/** @type {React.MouseEvent<HTMLLIElement, MouseEvent>} */ e) => {
navigator.clipboard.writeText(`${lat}, ${lon}`)
if (onClick) onClick(e)
},
[lat, lon, onClick],
)

return (
<MenuItem dense onClick={copy}>
<MenuItem dense onClick={onClickWithCopy} {...props}>
{t('copy_coordinates')}
</MenuItem>
)
Expand Down
4 changes: 2 additions & 2 deletions src/features/station/StationPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function StationMenu({
{t(option.name)}
</MenuItem>
))}
{copyCoords && <CopyCoords lat={lat} lon={lon} />}
{copyCoords && <CopyCoords lat={lat} lon={lon} onClick={handleClose} />}
</Menu>
</>
)
Expand Down Expand Up @@ -316,7 +316,7 @@ function StationMons({ id }) {
return (
<CardContent sx={{ my: 1, p: 0, height: 130 }}>
<Typography variant="h6" align="center">
{t('stationed_pokemon')}
{t('placed_pokemon')}
</Typography>
<VirtualGrid data={mons} xs={6}>
{(index, mon) => {
Expand Down

0 comments on commit 7eaf43d

Please sign in to comment.