mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 14:35:23 +02:00
feat: reorganize tabs, add Article Details, and enhance filters/search
This commit is contained in:
@@ -41,6 +41,13 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat
|
||||
sourceRow: ExcelRow,
|
||||
fieldType: 'outer' | 'units' | 'moq' | 'all'
|
||||
} | null>(null);
|
||||
const [clusterSelections, setClusterSelections] = useState<Record<number, Set<number>>>({});
|
||||
const [clusterSyncTargets, setClusterSyncTargets] = useState<Record<number, string>>({});
|
||||
const [pendingNearDupSync, setPendingNearDupSync] = useState<{
|
||||
clusterIndex: number;
|
||||
targetGroupKey: string;
|
||||
selectedIndices: number[];
|
||||
} | null>(null);
|
||||
|
||||
const groups = useMemo(() => {
|
||||
const groupMap = new Map<string, { row: ExcelRow; index: number }[]>();
|
||||
@@ -177,6 +184,38 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat
|
||||
setPendingAction({ group, sourceRow, fieldType: 'all' });
|
||||
};
|
||||
|
||||
const executeNearDupSync = async () => {
|
||||
if (!pendingNearDupSync) return;
|
||||
const { clusterIndex, targetGroupKey, selectedIndices } = pendingNearDupSync;
|
||||
|
||||
const cluster = nearDuplicateClusters[clusterIndex];
|
||||
const targetGroup = cluster.groups.find(g => g.key === targetGroupKey);
|
||||
if (!targetGroup) return;
|
||||
|
||||
const sourceRow = targetGroup.rows[0].row;
|
||||
const innerL = sourceRow[COLUMNS.INNER_L];
|
||||
const innerW = sourceRow[COLUMNS.INNER_W];
|
||||
const innerH = sourceRow[COLUMNS.INNER_H];
|
||||
|
||||
onCaptureState(`Synced inner dimensions to ${targetGroupKey} cm for ${selectedIndices.length} products`);
|
||||
setPendingNearDupSync(null);
|
||||
|
||||
for (const idx of selectedIndices) {
|
||||
const row = data[idx];
|
||||
const updatedRow = [...row];
|
||||
updatedRow[COLUMNS.INNER_L] = innerL;
|
||||
updatedRow[COLUMNS.INNER_W] = innerW;
|
||||
updatedRow[COLUMNS.INNER_H] = innerH;
|
||||
await onSaveRow(idx, updatedRow);
|
||||
}
|
||||
|
||||
setClusterSelections(prev => {
|
||||
const next = { ...prev };
|
||||
delete next[clusterIndex];
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const executeSync = async () => {
|
||||
if (!pendingAction) return;
|
||||
const { group, sourceRow, fieldType } = pendingAction;
|
||||
|
||||
Reference in New Issue
Block a user