1 import { c } from 'ttag';
3 import { useUserSettings } from '@proton/account/userSettings/hooks';
4 import { Button } from '@proton/atoms';
5 import type { ModalProps } from '@proton/components/components/modalTwo/Modal';
6 import ModalTwo from '@proton/components/components/modalTwo/Modal';
7 import ModalTwoContent from '@proton/components/components/modalTwo/ModalContent';
8 import ModalTwoFooter from '@proton/components/components/modalTwo/ModalFooter';
9 import ModalTwoHeader from '@proton/components/components/modalTwo/ModalHeader';
10 import useApi from '@proton/components/hooks/useApi';
11 import useEventManager from '@proton/components/hooks/useEventManager';
12 import useNotifications from '@proton/components/hooks/useNotifications';
13 import { useLoading } from '@proton/hooks';
14 import { updateDensity } from '@proton/shared/lib/api/settings';
15 import type { DENSITY } from '@proton/shared/lib/constants';
17 import DensityRadiosCards from '../layouts/DensityRadiosCards';
19 import './ModalSettingsLayoutCards.scss';
21 const MailDensityModal = (props: ModalProps) => {
23 const { call } = useEventManager();
24 const [{ Density }] = useUserSettings();
25 const [loading, withLoading] = useLoading();
26 const { createNotification } = useNotifications();
27 const title = c('Title').t`Mailbox density`;
29 const { onClose } = props;
31 const handleChangeDensity = async (density: DENSITY) => {
32 await api(updateDensity(density));
34 createNotification({ text: c('Success').t`Preference saved` });
37 const handleSubmit = () => onClose?.();
41 <ModalTwoHeader title={title} />
43 <div className="flex flex-column flex-nowrap mb-4">
44 <span className="mb-4" id="densityMode_desc">
45 {c('Label').t`Select what your list of messages looks like by default.`}
49 describedByID="densityMode_desc"
50 onChange={(value) => withLoading(handleChangeDensity(value))}
53 className="layoutCards-two-per-row"
58 <Button className="ml-auto" color="norm" onClick={handleSubmit}>{c('Action').t`OK`}</Button>
64 export default MailDensityModal;