import type { PlacesLibraryDuplicate } from '@trek/shared'; import { CopyCheck, Loader2, Undo2 } from 'lucide-react'; import React, { useId } from 'react'; import type { TranslationFn } from '../../types'; import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, } from '../shared/DialogShell'; import DuplicatePairCard from './DuplicatePairCard'; import { pairKey } from './usePlaceDuplicates'; interface DuplicatesDialogProps { pairs: PlacesLibraryDuplicate[]; hasMore: boolean; loading: boolean; busy: string | null; lastMerge: { id: number; name: string } | null; onMerge: (pair: PlacesLibraryDuplicate, leading: 'a' | 'b') => void; onDismiss: (pair: PlacesLibraryDuplicate) => void; onUndo: () => void; onClose: () => void; t: TranslationFn; } /** The places that look like one another (PLC-13), to merge or to set apart for good. */ export default function DuplicatesDialog({ pairs, hasMore, loading, busy, lastMerge, onMerge, onDismiss, onUndo, onClose, t, }: DuplicatesDialogProps): React.ReactElement { const labelId = useId(); return ( } tint={NEUTRAL_TINT} labelId={labelId} onClose={onClose} title={t('collections.duplicates.title')} /> } footer={ {lastMerge && ( }> {t('collections.duplicates.undo', { name: lastMerge.name })} )} {t('common.close')} } > {loading && pairs.length === 0 ? (
) : pairs.length === 0 ? (

{t('collections.duplicates.none')}

) : (

{t('collections.duplicates.sub')}

{pairs.map((pair) => ( onMerge(pair, leading)} onDismiss={() => onDismiss(pair)} variant="dialog" t={t} /> ))} {hasMore && (

{t('collections.duplicates.more')}

)}
)}
); }