frontend/containers/ShareEvent/index.tsx (view raw)
1import Icon from '@mui/material/Icon';
2import Button, {ButtonProps} from '@mui/material/Button';
3import {useTranslation} from 'react-i18next';
4import useShare from '../../hooks/useShare';
5import Box from '@mui/material/Box';
6
7interface Props {
8 title: string;
9}
10
11const ShareEvent = ({title, sx}: ButtonProps & Props) => {
12 const {t} = useTranslation();
13 const {share, navigatorHasShareCapability} = useShare();
14
15 const text = navigatorHasShareCapability
16 ? t('event.fields.share')
17 : t('event.fields.copyLink');
18
19 return (
20 <Box textAlign="center">
21 <Button
22 variant="outlined"
23 color="primary"
24 startIcon={<Icon>share</Icon>}
25 onClick={() => share({title})}
26 sx={sx}
27 >
28 {text}
29 </Button>
30 </Box>
31 );
32};
33
34export default ShareEvent;