mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +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
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import { Box, Button } from '@material-ui/core';
|
|
import useStyles from './grid.styles';
|
|
import { usePhotos } from '../../hooks/usePhotos';
|
|
import AddIcon from '@material-ui/icons/Add';
|
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
|
import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation';
|
|
import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl';
|
|
import { PhotoEvents } from '../../../../../../typings/photo';
|
|
|
|
export const GalleryGrid = () => {
|
|
const classes = useStyles();
|
|
const history = useHistory();
|
|
const query = useQueryParams();
|
|
|
|
const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image';
|
|
|
|
const photos = usePhotos();
|
|
|
|
const handleCamera = () => {
|
|
Nui.send(PhotoEvents.TAKE_PHOTO, {});
|
|
};
|
|
|
|
const handlePhotoOpen = (photo) => {
|
|
history.push(addQueryToLocation(getLocationFromUrl(referal), 'image', photo.image));
|
|
};
|
|
|
|
if (!photos)
|
|
return (
|
|
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
|
|
<Box>
|
|
<Button onClick={handleCamera} style={{ borderRadius: 0 }} className={classes.photo}>
|
|
<AddIcon fontSize="large" />
|
|
</Button>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
|
|
return (
|
|
<div>
|
|
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
|
|
<Box>
|
|
<Button onClick={handleCamera} style={{ borderRadius: 0 }} className={classes.photo}>
|
|
<AddIcon fontSize="large" />
|
|
</Button>
|
|
</Box>
|
|
{photos.map((photo) => (
|
|
<Box key={photo.id} onClick={() => handlePhotoOpen(photo)}>
|
|
<div style={{ backgroundImage: `url(${photo.image})` }} className={classes.photo} />
|
|
</Box>
|
|
))}
|
|
</Box>
|
|
</div>
|
|
);
|
|
};
|