1 import { c } from 'ttag';
3 import Checkbox from '@proton/components/components/input/Checkbox';
4 import { getFormattedWeekdays } from '@proton/shared/lib/date/date';
5 import { dateLocale } from '@proton/shared/lib/i18n';
7 import SettingsLayout from '../../../account/SettingsLayout';
8 import SettingsLayoutLeft from '../../../account/SettingsLayoutLeft';
9 import SettingsLayoutRight from '../../../account/SettingsLayoutRight';
13 onChange: (days: number[]) => void;
16 const DaysOfWeekField = ({ value = [], onChange }: Props) => {
17 const handleChange = (weekday: number) => () =>
18 onChange(value.includes(weekday) ? value.filter((existing) => weekday !== existing) : [...value, weekday]);
23 <span id="label-days-of-week" className="label text-semibold">{c('Label').t`Days of the week`}</span>
26 <div className="flex flex-column pt-1">
27 {getFormattedWeekdays('iiii', { locale: dateLocale }).map((text, i) => (
32 checked={value.includes(i)}
33 onChange={handleChange(i)}
34 aria-describedby="label-days-of-week"
40 </SettingsLayoutRight>
45 export default DaysOfWeekField;