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 { useLoading } from '@proton/hooks';
10 import { updateViewLayout } from '@proton/shared/lib/api/mailSettings';
11 import type { VIEW_LAYOUT } from '@proton/shared/lib/mail/mailSettings';
12 import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
14 import { useApi, useEventManager, useMailSettings, useNotifications } from '../../hooks';
15 import ViewLayoutCards from '../layouts/ViewLayoutCards';
17 import './ModalSettingsLayoutCards.scss';
19 const MailViewLayoutModal = (props: ModalProps) => {
21 const { call } = useEventManager();
22 const [{ ViewLayout } = DEFAULT_MAILSETTINGS] = useMailSettings();
23 const [loading, withLoading] = useLoading();
24 const { createNotification } = useNotifications();
25 const title = c('Title').t`Mailbox layout`;
27 const { onClose } = props;
29 const handleChangeViewLayout = async (layout: VIEW_LAYOUT) => {
30 await api(updateViewLayout(layout));
32 createNotification({ text: c('Success').t`Preference saved` });
35 const handleSubmit = () => onClose?.();
39 <ModalTwoHeader title={title} />
41 <div className="flex flex-column flex-nowrap mb-4">
42 <span className="mb-4" id="layoutMode_desc">
43 {c('Label').t`Select what your mailbox looks like by default.`}
46 describedByID="layoutMode_desc"
47 viewLayout={ViewLayout}
48 onChange={(value) => withLoading(handleChangeViewLayout(value))}
51 className="layoutCards-two-per-row"
56 <Button className="ml-auto" color="norm" onClick={handleSubmit}>{c('Action').t`OK`}</Button>
62 export default MailViewLayoutModal;