mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 13:45:24 +02:00
UI: Add group verification for Dimensions inconsistencies and persist to DB
This commit is contained in:
+10
-2
@@ -119,7 +119,8 @@ export default function App() {
|
|||||||
COLUMNS.DETAILS_DE, COLUMNS.DETAILS_EN,
|
COLUMNS.DETAILS_DE, COLUMNS.DETAILS_EN,
|
||||||
COLUMNS.INNER_L, COLUMNS.INNER_W, COLUMNS.INNER_H,
|
COLUMNS.INNER_L, COLUMNS.INNER_W, COLUMNS.INNER_H,
|
||||||
COLUMNS.OUTER_L, COLUMNS.OUTER_W, COLUMNS.OUTER_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) => {
|
headers.forEach((h: any, i: number) => {
|
||||||
@@ -282,7 +283,14 @@ export default function App() {
|
|||||||
const handleExport = () => {
|
const handleExport = () => {
|
||||||
if (appState.data.length === 0) return;
|
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 ws = XLSX.utils.aoa_to_sheet(wsData);
|
||||||
const wb = XLSX.utils.book_new();
|
const wb = XLSX.utils.book_new();
|
||||||
XLSX.utils.book_append_sheet(wb, ws, 'Products');
|
XLSX.utils.book_append_sheet(wb, ws, 'Products');
|
||||||
|
|||||||
@@ -101,13 +101,15 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat
|
|||||||
|
|
||||||
const parts = key.split('x').map(Number);
|
const parts = key.split('x').map(Number);
|
||||||
const volume = parts[0] * parts[1] * parts[2];
|
const volume = parts[0] * parts[1] * parts[2];
|
||||||
|
|
||||||
|
const isVerified = rows.some(({ row }) => row[COLUMNS.VERIFIED_DIMS] === true);
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
key,
|
key,
|
||||||
innerDims: key,
|
innerDims: key,
|
||||||
rows,
|
rows,
|
||||||
volume,
|
volume,
|
||||||
isInconsistent: !outerMatch || !unitsMatch || !moqMatch,
|
isInconsistent: (!outerMatch || !unitsMatch || !moqMatch) && !isVerified,
|
||||||
discrepancies: {
|
discrepancies: {
|
||||||
outer: !outerMatch,
|
outer: !outerMatch,
|
||||||
units: !unitsMatch,
|
units: !unitsMatch,
|
||||||
@@ -221,6 +223,16 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat
|
|||||||
setPendingAction({ group, sourceRow, fieldType: 'all' });
|
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 () => {
|
const executeNearDupSync = async () => {
|
||||||
if (!pendingNearDupSync) return;
|
if (!pendingNearDupSync) return;
|
||||||
const { clusterKey, targetGroupKey, selectedIndices } = pendingNearDupSync;
|
const { clusterKey, targetGroupKey, selectedIndices } = pendingNearDupSync;
|
||||||
@@ -584,6 +596,17 @@ export function DimensionsView({ data, headers, onEdit, onSaveRow, onCaptureStat
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{group.isInconsistent && (
|
||||||
|
<button
|
||||||
|
onClick={(e) => handleVerifyGroup(e, group)}
|
||||||
|
className="px-2 py-1 bg-emerald-600/10 hover:bg-emerald-600 hover:text-white text-emerald-500 rounded border border-emerald-600/30 text-[10px] font-bold transition-colors flex items-center gap-1"
|
||||||
|
title="Mark as correct to hide from inconsistent list"
|
||||||
|
>
|
||||||
|
<CheckCircle2 className="w-3 h-3" />
|
||||||
|
Mark Correct
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
{group.isInconsistent && !expandedGroups.has(group.key) && (
|
{group.isInconsistent && !expandedGroups.has(group.key) && (
|
||||||
<div className="text-[10px] font-bold text-blue-400 bg-blue-400/5 px-2 py-1 rounded border border-blue-400/20">
|
<div className="text-[10px] font-bold text-blue-400 bg-blue-400/5 px-2 py-1 rounded border border-blue-400/20">
|
||||||
OPEN TO SYNC FIELDS
|
OPEN TO SYNC FIELDS
|
||||||
|
|||||||
+2
-1
@@ -35,5 +35,6 @@ export const COLUMNS = {
|
|||||||
INNER_H: 44,
|
INNER_H: 44,
|
||||||
OUTER_W: 47,
|
OUTER_W: 47,
|
||||||
OUTER_L: 48,
|
OUTER_L: 48,
|
||||||
OUTER_H: 49
|
OUTER_H: 49,
|
||||||
|
VERIFIED_DIMS: 100
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user