1 import { memo, useState } from 'react';
3 import { c } from 'ttag';
5 import type { Label } from '@proton/shared/lib/interfaces/Label';
7 import type { ApplyLabelsParams } from '../../hooks/actions/label/useApplyLabels';
8 import type { MoveParams } from '../../hooks/actions/move/useMoveToFolder';
9 import type { UnreadCounts } from './MailSidebarList';
10 import SidebarItem from './SidebarItem';
11 import SidebarLabelActions from './SidebarLabelActions';
13 interface LabelProps {
14 currentLabelID: string;
15 counterMap: UnreadCounts;
17 updateFocusItem: (item: string) => void;
18 moveToFolder: (params: MoveParams) => void;
19 applyLabels: (params: ApplyLabelsParams) => void;
22 const SidebarLabel = ({
30 const [isOptionDropdownOpened, setIsOptionDropdownOpened] = useState(false);
34 currentLabelID={currentLabelID}
36 isOptionDropdownOpened={isOptionDropdownOpened}
43 unreadCount={counterMap[label.ID]}
45 onFocus={updateFocusItem}
46 moveToFolder={moveToFolder}
47 applyLabels={applyLabels}
49 <SidebarLabelActions type={'label'} element={label} onToggleDropdown={setIsOptionDropdownOpened} />
55 interface LabelsProps {
56 currentLabelID: string;
57 counterMap: UnreadCounts;
59 updateFocusItem: (item: string) => void;
60 moveToFolder: (params: MoveParams) => void;
61 applyLabels: (params: ApplyLabelsParams) => void;
64 const SidebarLabels = ({
72 return labels.length === 0 ? (
73 <div className="py-2 ml-7 text-sm color-weak">{c('Description').t`No labels`}</div>
76 {labels.map((label) => (
80 updateFocusItem={updateFocusItem}
81 currentLabelID={currentLabelID}
82 counterMap={counterMap}
83 moveToFolder={moveToFolder}
84 applyLabels={applyLabels}
91 export default memo(SidebarLabels);