1 import { useState } from 'react';
3 import { c } from 'ttag';
5 import Select from '@proton/components/components/select/Select';
6 import useApi from '@proton/components/hooks/useApi';
7 import useEventManager from '@proton/components/hooks/useEventManager';
8 import useNotifications from '@proton/components/hooks/useNotifications';
9 import { useLoading } from '@proton/hooks';
10 import { updateDelaySend } from '@proton/shared/lib/api/mailSettings';
11 import { DELAY_IN_SECONDS } from '@proton/shared/lib/mail/mailSettings';
15 delaySendSeconds: number;
18 const DelaySendSecondsSelect = ({ id, delaySendSeconds }: Props) => {
19 const { createNotification } = useNotifications();
20 const [loading, withLoading] = useLoading();
21 const { call } = useEventManager();
23 const [delay, setDelay] = useState(delaySendSeconds);
25 { text: c('Option delay send seconds').t`0 seconds`, value: DELAY_IN_SECONDS.NONE },
26 { text: c('Option delay send seconds').t`5 seconds`, value: DELAY_IN_SECONDS.SMALL },
27 { text: c('Option delay send seconds').t`10 seconds`, value: DELAY_IN_SECONDS.MEDIUM },
28 { text: c('Option delay send seconds').t`20 seconds`, value: DELAY_IN_SECONDS.LARGE },
31 const handleChange = async (delay: number) => {
32 await api(updateDelaySend(delay));
35 createNotification({ text: c('Success').t`Preference saved` });
43 onChange={({ target }) => withLoading(handleChange(+target.value))}
49 export default DelaySendSecondsSelect;