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