import { useMemo } from 'react'; import { Avatar, Box, Button, Divider, Paper, Stack, Typography, ButtonBase, alpha, } from '@mui/material'; import ScheduleIcon from '@mui/icons-material/Schedule'; import LinkIcon from '@mui/icons-material/Link'; import NotesIcon from '@mui/icons-material/Notes'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; import dayjs from 'dayjs'; import tz from 'dayjs/plugin/timezone'; import utc from 'dayjs/plugin/utc'; import advancedFormat from 'dayjs/plugin/advancedFormat'; import { BookMeetingResponse } from '../api/deals/types'; import useCopyToClipboard from '../hooks/useCopyToClipboard'; import { useTimezoneStateContext } from './timezone-select/TimezoneProvider'; import { parseEmailIntoEvent } from '../utils'; import { CONFIG } from '../config'; dayjs.extend(utc); dayjs.extend(advancedFormat); dayjs.extend(tz); function makeEventLink(uuid: string): string { return `${CONFIG.CLIENT_URL}/m/${uuid}`; } function DetailsRow({ icon, label, text, }: { icon: React.ReactNode; label: string; text: React.ReactNode; }) { return ( ({ [theme.breakpoints.up('md')]: { display: 'grid', gridTemplateColumns: '150px 1fr', alignItems: 'center', }, })} > ({ [theme.breakpoints.down('md')]: { marginBottom: theme.spacing(1), }, })} > ({ width: 32, height: 32, borderRadius: 1, bgcolor: 'background.paper', display: 'flex', justifyContent: 'center', alignItems: 'center', border: `1px solid ${theme.palette.divider}`, boxShadow: theme.shadows[2], '& svg': { width: 16, height: 16, display: 'block', }, })} > {icon} {label} {typeof text === 'string' ? ( {text} ) : ( text )} ); } function UserDetailsRow({ user }: { user: BookMeetingResponse['user'] }) { const { name, avatar } = user; return ( You are meeting with {name} ); } function TimeRow({ startTime, endTime }: { startTime: string; endTime: string }) { const [timezone] = useTimezoneStateContext(); const formattedStartTime = dayjs(startTime).tz(timezone).format('dddd, MMM D, h:mma'); const formattedEndTime = dayjs(endTime).tz(timezone).format('h:mma (zzz)'); return ( } label="Time" text={`${formattedStartTime}-${formattedEndTime}`} /> ); } function LinkRow({ uuid }: { uuid: string }) { const { copied, copyToClipboard } = useCopyToClipboard(); const link = makeEventLink(uuid); const onClick = () => { copyToClipboard(link); }; return ( } label="Link" text={ ({ ...theme.typography.body1, width: 1, display: 'block', color: theme.palette.text.secondary, overflow: 'hidden', textOverflow: 'ellipsis', textAlign: 'left', '&:hover': { textDecoration: 'underline', }, })} onClick={onClick} > {link} {copied && ( Copied! )} } /> ); } function AddToCalendarAlert({ email, response }: { email: string; response: BookMeetingResponse }) { const { event, meeting } = response; const { url, isICS } = useMemo( () => parseEmailIntoEvent(email, { title: event.title, start: dayjs(event.startTime).toDate(), end: dayjs(event.endTime).toDate(), url: makeEventLink(meeting.uuid), }), [email, event, meeting] ); return ( ({ gap: 2, p: 2, borderRadius: 1, alignSelf: 'stretch', bgcolor: theme.palette.mode === 'light' ? alpha(theme.palette.success.lighter, 0.7) : theme.palette.success.darker, })} > A confirmation email is on its way to {email}. Please open it and add the event to your calendar. If that doesn't work, feel free to use the button below to add it manually. ); } export default function ConfirmationScreen({ meeting, contactEmail, confirmationMessage = 'Thank you! Your meeting has been scheduled', }: { meeting: BookMeetingResponse; contactEmail: string; confirmationMessage?: string; }) { const { event, user } = meeting; return ( ({ height: 1, py: 4, px: 6, [theme.breakpoints.down('md')]: { py: 2, px: 3, }, })} > 🎉 {confirmationMessage} 🎉 }> } label="Details" text="We sent you an email with your meeting details." /> ); }