1 import { c } from 'ttag';
3 import SettingsParagraph from '@proton/components/containers/account/SettingsParagraph';
5 import DateField from './fields/DateField';
6 import TimeField from './fields/TimeField';
7 import TimeZoneField from './fields/TimeZoneField';
8 import type { AutoReplyFormModel } from './interfaces';
11 model: AutoReplyFormModel;
12 updateModel: (key: string) => (value: any) => void;
15 const AutoReplyFormFixed = ({ model: { start, end, timezone }, updateModel }: Props) => {
16 // Min date is used to calculate options.
17 // In order to have rounded options such as 9:00AM or 9:30AM, we need to round the min date we give to the TimeInput
18 const getMinTimeField = (date: Date) => {
19 const dateMin = new Date(date);
20 const minutes = dateMin.getMinutes();
23 dateMin.setMinutes(30);
25 dateMin.setMinutes(0);
26 dateMin.setHours(dateMin.getHours() + 1);
34 {c('Info').t`Auto-reply is active from the start time to the end time.`}
38 label={c('Label').t`Start date`}
40 onChange={updateModel('start.date')}
44 onChange={updateModel('start.time')}
45 label={c('Label').t`Start time`}
50 label={c('Label').t`End date`}
53 onChange={updateModel('end.date')}
57 onChange={updateModel('end.time')}
58 label={c('Label').t`End time`}
61 start.time && start.date?.getTime() === end.date?.getTime()
62 ? getMinTimeField(start.time)
65 preventNextDayOverflow
67 <TimeZoneField value={timezone} onChange={updateModel('timezone')} />
72 export default AutoReplyFormFixed;