1 import { c } from 'ttag';
3 import { Button } from '@proton/atoms';
4 import OrderableTable from '@proton/components/components/orderableTable/OrderableTable';
5 import '@proton/components/components/orderableTable/OrderableTableHeader.scss';
6 import TableCell from '@proton/components/components/table/TableCell';
7 import type { ContactFormatted } from '@proton/shared/lib/interfaces/contacts';
9 import MergeTableBody from './MergeTableBody';
11 const MergeTableHeader = () => {
13 <thead className="orderableTableHeader">
15 <TableCell type="header"> </TableCell>
16 <TableCell type="header">{c('TableHeader').t`Display name`}</TableCell>
17 <TableCell type="header" className="w-1/6">{c('TableHeader').t`First name`}</TableCell>
18 <TableCell type="header" className="w-1/6">{c('TableHeader').t`Last name`}</TableCell>
19 <TableCell type="header">{c('TableHeader').t`Address`}</TableCell>
20 <TableCell type="header">{c('TableHeader').t`Actions`}</TableCell>
27 contacts: ContactFormatted[][];
28 isChecked: { [ID: string]: boolean };
29 beDeleted: { [ID: string]: boolean };
30 onClickCheckbox: (ID: string) => void;
31 onClickDetails: (ID: string) => void;
32 onToggleDelete: (ID: string) => void;
33 onClickPreview: (beMergedID: string, beDeletedIDs: string[]) => void;
34 onSortEnd: (groupIndex: number) => ({ oldIndex, newIndex }: { oldIndex: number; newIndex: number }) => void;
49 {contacts.map((group, i) => {
50 const activeIDs = group
51 .map(({ ID }) => isChecked[ID] && !beDeleted[ID] && ID)
52 .filter(Boolean) as string[];
53 const beDeletedIDs = group.map(({ ID }) => beDeleted[ID] && ID).filter(Boolean) as string[];
54 const beMergedIDs = activeIDs.length > 1 ? activeIDs : [];
57 <div key={`${group && group[0].Name}`} className="mb-8 flex flex-column items-center">
59 onSortEnd={onSortEnd(i)}
61 helperClass="z-modals bg-norm color-norm"
66 highlightedID={beMergedIDs[0]}
69 onClickCheckbox={onClickCheckbox}
70 onClickDetails={onClickDetails}
71 onToggleDelete={onToggleDelete}
75 className="aligcenter"
76 disabled={!beMergedIDs.length}
78 onClick={() => onClickPreview(beMergedIDs[0], beDeletedIDs)}
79 data-testid="merge-model:preview-contact-button"
81 {c('Action').t`Preview contact`}
90 export default MergeTable;