1 import type { ChangeEvent } from 'react';
3 import Toggle from '@proton/components/components/toggle/Toggle';
4 import useToggle from '@proton/components/hooks/useToggle';
5 import { STICKY_LABELS } from '@proton/shared/lib/mail/mailSettings';
7 const { ENABLED, DISABLED } = STICKY_LABELS;
11 stickyLabels: STICKY_LABELS;
12 onToggle: (value: STICKY_LABELS) => void;
17 const StickyLabelsToggle = ({ id, stickyLabels, onToggle, loading, ...rest }: Props) => {
18 const { state, toggle } = useToggle(stickyLabels === ENABLED);
20 const handleToggle = ({ target }: ChangeEvent<HTMLInputElement>) => {
21 onToggle(target.checked ? ENABLED : DISABLED);
25 return <Toggle id={id} checked={state} onChange={handleToggle} loading={loading} {...rest} />;
28 export default StickyLabelsToggle;