From 7ecd1c45d064cdbb980f60a2a0085061705feaf2 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Sat, 11 Apr 2026 11:48:56 +0200 Subject: [PATCH] UI: Add group verification for Dimensions inconsistencies and persist to DB --- src/App.tsx | 12 ++++++++++-- src/components/DimensionsView.tsx | 25 ++++++++++++++++++++++++- src/types.ts | 3 ++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index b9ff5f9..7f2dcb5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -119,7 +119,8 @@ export default function App() { COLUMNS.DETAILS_DE, COLUMNS.DETAILS_EN, COLUMNS.INNER_L, COLUMNS.INNER_W, COLUMNS.INNER_H, COLUMNS.OUTER_L, COLUMNS.OUTER_W, COLUMNS.OUTER_H, - COLUMNS.UNITS_OUTER, COLUMNS.MOQ + COLUMNS.UNITS_OUTER, COLUMNS.MOQ, + COLUMNS.VERIFIED_DIMS ]); headers.forEach((h: any, i: number) => { @@ -282,7 +283,14 @@ export default function App() { const handleExport = () => { if (appState.data.length === 0) return; - const wsData = [appState.headers, ...appState.data]; + const wsData = [ + appState.headers, + ...appState.data.map(row => { + const copy = [...row]; + delete copy[COLUMNS.VERIFIED_DIMS]; + return copy.slice(0, appState.headers.length); + }) + ]; const ws = XLSX.utils.aoa_to_sheet(wsData); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, 'Products'); diff --git a/src/components/DimensionsView.tsx b/src/components/DimensionsView.tsx index e7b92f7..fd96775 100644 --- a/src/components/DimensionsView.tsx +++ b/src/components/DimensionsView.tsx @@ -101,13 +101,15 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat const parts = key.split('x').map(Number); const volume = parts[0] * parts[1] * parts[2]; + + const isVerified = rows.some(({ row }) => row[COLUMNS.VERIFIED_DIMS] === true); result.push({ key, innerDims: key, rows, volume, - isInconsistent: !outerMatch || !unitsMatch || !moqMatch, + isInconsistent: (!outerMatch || !unitsMatch || !moqMatch) && !isVerified, discrepancies: { outer: !outerMatch, units: !unitsMatch, @@ -221,6 +223,16 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat setPendingAction({ group, sourceRow, fieldType: 'all' }); }; + const handleVerifyGroup = (e: React.MouseEvent, group: DimensionGroup) => { + e.stopPropagation(); + group.rows.forEach(({ row, index }) => { + const newRow = [...row]; + newRow[COLUMNS.VERIFIED_DIMS] = true; + onSaveRow(index, newRow); + }); + onCaptureState(`Verified dimensions for ${group.rows.length} products`); + }; + const executeNearDupSync = async () => { if (!pendingNearDupSync) return; const { clusterKey, targetGroupKey, selectedIndices } = pendingNearDupSync; @@ -584,6 +596,17 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat )} + {group.isInconsistent && ( + + )} + {group.isInconsistent && !expandedGroups.has(group.key) && (
OPEN TO SYNC FIELDS diff --git a/src/types.ts b/src/types.ts index 0c4d3fa..01f0852 100644 --- a/src/types.ts +++ b/src/types.ts @@ -35,5 +35,6 @@ export const COLUMNS = { INNER_H: 44, OUTER_W: 47, OUTER_L: 48, - OUTER_H: 49 + OUTER_H: 49, + VERIFIED_DIMS: 100 }; \ No newline at end of file