all repos — caroster @ 74feaa47d697b06162103be5cb9fa26bac349ef9

[Octree] Group carpool to your event https://caroster.io

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';
 5
 6interface Props {
 7  title: string;
 8  url: string;
 9}
10
11const ShareEvent = ({title, url, 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    <Button
21      variant="outlined"
22      color="primary"
23      startIcon={<Icon>share</Icon>}
24      onClick={() => share({title, url})}
25      sx={sx}
26    >
27      {text}
28    </Button>
29  );
30};
31
32export default ShareEvent;