2026-06-17 20:26:43 -04:00
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
|
import FocusTrap from 'focus-trap-react';
|
|
|
|
|
import {
|
|
|
|
|
Box,
|
2026-06-17 20:49:24 -04:00
|
|
|
color,
|
|
|
|
|
config,
|
2026-06-17 20:26:43 -04:00
|
|
|
Header,
|
|
|
|
|
Icon,
|
|
|
|
|
IconButton,
|
|
|
|
|
Icons,
|
2026-06-17 20:49:24 -04:00
|
|
|
Line,
|
|
|
|
|
MenuItem,
|
2026-06-17 20:26:43 -04:00
|
|
|
Overlay,
|
|
|
|
|
OverlayBackdrop,
|
|
|
|
|
OverlayCenter,
|
|
|
|
|
Text,
|
|
|
|
|
} from 'folds';
|
|
|
|
|
import { stopPropagation } from '../../../utils/keyboard';
|
|
|
|
|
import { useReminders } from '../../../hooks/useReminders';
|
|
|
|
|
|
|
|
|
|
type RemindMeDialogProps = {
|
|
|
|
|
roomId: string;
|
|
|
|
|
eventId: string;
|
|
|
|
|
previewText: string;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getPresets(): Array<{ label: string; ms: number }> {
|
|
|
|
|
const tomorrow = new Date();
|
|
|
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
|
|
tomorrow.setHours(9, 0, 0, 0);
|
|
|
|
|
const timeLabel = tomorrow.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
|
|
|
return [
|
|
|
|
|
{ label: 'In 20 minutes', ms: 20 * 60_000 },
|
|
|
|
|
{ label: 'In 1 hour', ms: 60 * 60_000 },
|
|
|
|
|
{ label: 'In 3 hours', ms: 3 * 60 * 60_000 },
|
2026-06-17 20:49:24 -04:00
|
|
|
{ label: `Tomorrow at ${timeLabel}`, ms: tomorrow.getTime() - Date.now() },
|
2026-06-17 20:26:43 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function RemindMeDialog({ roomId, eventId, previewText, onClose }: RemindMeDialogProps) {
|
|
|
|
|
const { addReminder } = useReminders();
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
const presets = useMemo(() => getPresets(), []);
|
|
|
|
|
|
|
|
|
|
const handlePick = async (ms: number) => {
|
|
|
|
|
await addReminder({
|
|
|
|
|
roomId,
|
|
|
|
|
eventId,
|
|
|
|
|
timestamp: Date.now() + ms,
|
|
|
|
|
message: previewText || 'Reminder',
|
|
|
|
|
});
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
|
|
|
|
<OverlayCenter>
|
|
|
|
|
<FocusTrap
|
|
|
|
|
focusTrapOptions={{
|
|
|
|
|
initialFocus: false,
|
|
|
|
|
onDeactivate: onClose,
|
|
|
|
|
clickOutsideDeactivates: true,
|
|
|
|
|
escapeDeactivates: stopPropagation,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
2026-06-17 20:49:24 -04:00
|
|
|
role="dialog"
|
|
|
|
|
aria-modal="true"
|
|
|
|
|
aria-labelledby="remind-me-title"
|
2026-06-17 20:26:43 -04:00
|
|
|
direction="Column"
|
|
|
|
|
style={{
|
2026-06-17 20:49:24 -04:00
|
|
|
background: color.Surface.Container,
|
|
|
|
|
borderRadius: config.radii.R400,
|
|
|
|
|
boxShadow: color.Other.Shadow,
|
|
|
|
|
width: '100vw',
|
|
|
|
|
maxWidth: 280,
|
2026-06-17 20:26:43 -04:00
|
|
|
overflow: 'hidden',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-06-17 20:49:24 -04:00
|
|
|
<Header
|
|
|
|
|
variant="Surface"
|
|
|
|
|
size="500"
|
|
|
|
|
style={{
|
|
|
|
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
|
|
|
|
borderBottomWidth: config.borderWidth.B300,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-06-17 20:26:43 -04:00
|
|
|
<Box grow="Yes" alignItems="Center" gap="200">
|
2026-06-17 20:49:24 -04:00
|
|
|
<Icon src={Icons.Clock} size="100" />
|
|
|
|
|
<Text id="remind-me-title" size="H4">
|
|
|
|
|
Remind Me
|
|
|
|
|
</Text>
|
2026-06-17 20:26:43 -04:00
|
|
|
</Box>
|
2026-06-17 20:49:24 -04:00
|
|
|
<IconButton size="300" radii="300" onClick={onClose} aria-label="Close">
|
2026-06-17 20:26:43 -04:00
|
|
|
<Icon src={Icons.Cross} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Header>
|
|
|
|
|
{previewText && (
|
2026-06-17 20:49:24 -04:00
|
|
|
<>
|
|
|
|
|
<Box style={{ padding: `${config.space.S200} ${config.space.S400}` }}>
|
|
|
|
|
<Text size="T200" priority="300" truncate>
|
|
|
|
|
{previewText}
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
<Line size="300" />
|
|
|
|
|
</>
|
2026-06-17 20:26:43 -04:00
|
|
|
)}
|
2026-06-17 20:49:24 -04:00
|
|
|
<Box direction="Column" gap="100" style={{ padding: config.space.S200 }}>
|
2026-06-17 20:26:43 -04:00
|
|
|
{presets.map((p) => (
|
2026-06-17 20:49:24 -04:00
|
|
|
<MenuItem key={p.label} size="300" radii="300" onClick={() => handlePick(p.ms)}>
|
|
|
|
|
<Text size="T300" truncate>
|
|
|
|
|
{p.label}
|
|
|
|
|
</Text>
|
|
|
|
|
</MenuItem>
|
2026-06-17 20:26:43 -04:00
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</FocusTrap>
|
|
|
|
|
</OverlayCenter>
|
|
|
|
|
</Overlay>
|
|
|
|
|
);
|
|
|
|
|
}
|