mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
* chore(scripts/twitter): Refactored twitter to use event enums * chore(scripts/marketplace): Refactored marketplace to use event enums * chore(scripts/messages): Refactored messages to use event enums * chore(scripts/contacts): Refactored contacts to use event enums * chore(scripts/calls): Refactored calls to use event enums * chore(scripts/notes): Refactored notes to use event enums * chore(scripts/photos): Refactored photos to use event enums * chore(scripts/bank): Refactored bank to use event enums * chore(scripts/phone): Refactored phone to use event enums * chore(events): Removed old events object * refactor(phone/nui-events): Attached NUI events to respective enum * tweak(event-enums): Added npwd prefix to all events * tweak(phone/serve): Added craco to override CRA without eject Also bumped react-scripts to 4.0.1, with seemingly no issues * fix(typings/twitter): Fixed method enums for twitter
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import React, { useMemo, useState, useCallback } from 'react';
|
|
import useStyles from './modal.styles';
|
|
import { Button, Paper } from '@material-ui/core';
|
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
|
import DeleteIcon from '@material-ui/icons/Delete';
|
|
import ShareIcon from '@material-ui/icons/Share';
|
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
|
import { ICameraPhoto } from '../../hooks/usePhotos';
|
|
import { ShareModal } from './ShareModal';
|
|
import { PhotoEvents } from '../../../../../../typings/photo';
|
|
|
|
export const GalleryModal = () => {
|
|
const classes = useStyles();
|
|
const history = useHistory();
|
|
const query = useQueryParams();
|
|
const referal = query.referal || '/camera';
|
|
|
|
const [shareOpen, setShareOpen] = useState(null);
|
|
|
|
const meta: ICameraPhoto = useMemo(
|
|
() => ({ id: query.id as string, image: query.image as string }),
|
|
[query],
|
|
);
|
|
|
|
const _handleClose = () => {
|
|
history.push(referal);
|
|
};
|
|
|
|
const handleDeletePhoto = () => {
|
|
Nui.send(PhotoEvents.DELETE_PHOTO, {
|
|
image: meta.image,
|
|
});
|
|
history.push(referal);
|
|
};
|
|
|
|
const handleSharePhoto = useCallback(() => {
|
|
setShareOpen(meta);
|
|
}, [meta]);
|
|
|
|
if (!meta) return null;
|
|
|
|
return (
|
|
<>
|
|
<ShareModal referal={referal} meta={shareOpen} onClose={() => setShareOpen(null)} />
|
|
<Paper className={classes.modal}>
|
|
<div className={shareOpen ? classes.backgroundModal : null} />
|
|
<Button onClick={_handleClose}>
|
|
<ArrowBackIcon />
|
|
</Button>
|
|
<div className={classes.image} style={{ backgroundImage: `url(${meta.image})` }} />
|
|
<div className={classes.actionDiv}>
|
|
<Button onClick={handleDeletePhoto}>
|
|
<DeleteIcon fontSize="large" />
|
|
</Button>
|
|
<Button onClick={handleSharePhoto}>
|
|
<ShareIcon fontSize="large" />
|
|
</Button>
|
|
</div>
|
|
</Paper>
|
|
</>
|
|
);
|
|
};
|