1 import type { ChangeEvent } from 'react';
3 import { c } from 'ttag';
5 import Toggle from '@proton/components/components/toggle/Toggle';
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 { useMailSettings } from '@proton/mail/mailSettings/hooks';
11 import { updateInheritParentFolderColor } from '@proton/shared/lib/api/mailSettings';
18 const ToggleInheritParentFolderColor = ({ id, className }: Props) => {
20 const { call } = useEventManager();
21 const { createNotification } = useNotifications();
22 const [loading, withLoading] = useLoading();
23 const [mailSettings] = useMailSettings();
25 const handleChange = async ({ target }: ChangeEvent<HTMLInputElement>) => {
26 await api(updateInheritParentFolderColor(+target.checked));
29 text: c('label/folder notification').t`Preference saved`,
36 checked={!!mailSettings?.InheritParentFolderColor}
38 onChange={(e) => withLoading(handleChange(e))}
44 export default ToggleInheritParentFolderColor;