1 import { c } from 'ttag';
3 import { Button } from '@proton/atoms';
4 import type { ModalProps } from '@proton/components/components/modalTwo/Modal';
5 import ModalTwo from '@proton/components/components/modalTwo/Modal';
6 import ModalTwoContent from '@proton/components/components/modalTwo/ModalContent';
7 import ModalTwoFooter from '@proton/components/components/modalTwo/ModalFooter';
8 import ModalTwoHeader from '@proton/components/components/modalTwo/ModalHeader';
9 import useApi from '@proton/components/hooks/useApi';
10 import useEventManager from '@proton/components/hooks/useEventManager';
11 import useNotifications from '@proton/components/hooks/useNotifications';
12 import { useLoading } from '@proton/hooks';
13 import { useMailSettings } from '@proton/mail/mailSettings/hooks';
14 import { updateComposerMode } from '@proton/shared/lib/api/mailSettings';
15 import type { COMPOSER_MODE } from '@proton/shared/lib/mail/mailSettings';
16 import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
18 import ComposerModeCards from '../layouts/ComposerModeCards';
20 import './ModalSettingsLayoutCards.scss';
22 const MailComposerModeModal = (props: ModalProps) => {
24 const { call } = useEventManager();
25 const [{ ComposerMode } = DEFAULT_MAILSETTINGS] = useMailSettings();
26 const [loading, withLoading] = useLoading();
27 const { createNotification } = useNotifications();
28 const title = c('Title').t`Composer mode`;
30 const { onClose } = props;
32 const handleChangeComposerMode = async (mode: COMPOSER_MODE) => {
33 await api(updateComposerMode(mode));
35 createNotification({ text: c('Success').t`Preference saved` });
38 const handleSubmit = () => onClose?.();
42 <ModalTwoHeader title={title} />
44 <div className="flex flex-column flex-nowrap mb-4">
45 <span className="mb-4" id="composerMode_desc">
46 {c('Label').t`Select how your composer opens by default.`}
49 describedByID="composerMode_desc"
50 composerMode={ComposerMode}
51 onChange={(value) => withLoading(handleChangeComposerMode(value))}
54 className="layoutCards-two-per-row"
59 <Button className="ml-auto" color="norm" onClick={handleSubmit}>{c('Action').t`OK`}</Button>
65 export default MailComposerModeModal;