From 7218e7cc3f954b3bdea7b970adf525e77c744dd0 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 19 Jan 2026 13:11:35 -0500 Subject: [PATCH] Validation step tweaks, remove remaining references to old version --- inventory-server/src/routes/import.js | 2 +- .../product-import/steps/UploadFlow.tsx | 2 +- .../components/ValidationTable.tsx | 144 ++++++++++++++++-- .../components/ValidationToolbar.tsx | 2 - .../ValidationStep/dialogs/AiDebugDialog.tsx | 2 +- .../ValidationStep/hooks/useUpcValidation.ts | 4 +- .../ValidationStep/utils/dataMutations.ts | 3 +- .../components/AiValidationDialogs.tsx | 0 .../components/BaseCellContent.tsx | 0 .../components/InitializingValidation.tsx | 0 .../components/SearchableTemplateSelect.tsx | 0 .../components/UpcValidationTableAdapter.tsx | 0 .../components/ValidationCell.tsx | 0 .../components/ValidationContainer.tsx | 0 .../components/ValidationTable.tsx | 0 .../components/cells/CheckboxCell.tsx | 0 .../components/cells/InputCell.tsx | 0 .../components/cells/MultiSelectCell.tsx | 0 .../components/cells/MultilineInput.tsx | 0 .../components/cells/SelectCell.tsx | 0 .../hooks/useAiValidation.tsx | 0 .../hooks/useFieldValidation.tsx | 0 .../hooks/useFilterManagement.tsx | 0 .../hooks/useInitialValidation.tsx | 0 .../hooks/useProductLinesFetching.tsx | 0 .../hooks/useRowOperations.tsx | 0 .../hooks/useTemplateManagement.tsx | 0 .../hooks/useUniqueItemNumbersValidation.tsx | 0 .../hooks/useUniqueValidation.tsx | 0 .../hooks/useUpcValidation.tsx | 0 .../hooks/useValidation.tsx | 0 .../hooks/useValidationState.tsx | 0 .../hooks/validationTypes.ts | 0 .../index.tsx | 0 .../types.ts | 0 .../types/index.ts | 0 .../utils/aiValidationUtils.ts | 0 .../utils/countryUtils.ts | 0 .../utils/dataMutations.ts | 0 .../utils/priceUtils.ts | 0 .../utils/upcUtils.ts | 0 .../src/components/product-import/types.ts | 8 +- inventory/src/pages/Import.tsx | 2 +- 43 files changed, 144 insertions(+), 25 deletions(-) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/AiValidationDialogs.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/BaseCellContent.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/InitializingValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/SearchableTemplateSelect.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/UpcValidationTableAdapter.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/ValidationCell.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/ValidationContainer.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/ValidationTable.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/cells/CheckboxCell.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/cells/InputCell.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/cells/MultiSelectCell.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/cells/MultilineInput.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/components/cells/SelectCell.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useAiValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useFieldValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useFilterManagement.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useInitialValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useProductLinesFetching.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useRowOperations.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useTemplateManagement.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useUniqueItemNumbersValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useUniqueValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useUpcValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useValidation.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/useValidationState.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/hooks/validationTypes.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/index.tsx (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/types.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/types/index.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/utils/aiValidationUtils.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/utils/countryUtils.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/utils/dataMutations.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/utils/priceUtils.ts (100%) rename inventory/src/components/product-import/steps/{ValidationStepNew => ValidationStepOLD}/utils/upcUtils.ts (100%) diff --git a/inventory-server/src/routes/import.js b/inventory-server/src/routes/import.js index ce2292c..cea4027 100644 --- a/inventory-server/src/routes/import.js +++ b/inventory-server/src/routes/import.js @@ -1394,7 +1394,7 @@ router.get('/check-upc-and-generate-sku', async (req, res) => { if (upcCheck.length > 0) { return res.status(409).json({ - error: 'UPC already exists', + error: 'A product with this UPC already exists', existingProductId: upcCheck[0].pid, existingItemNumber: upcCheck[0].itemnumber }); diff --git a/inventory/src/components/product-import/steps/UploadFlow.tsx b/inventory/src/components/product-import/steps/UploadFlow.tsx index 59fd34b..ac88f56 100644 --- a/inventory/src/components/product-import/steps/UploadFlow.tsx +++ b/inventory/src/components/product-import/steps/UploadFlow.tsx @@ -13,7 +13,7 @@ import { useRsi } from "../hooks/useRsi" import type { RawData, Data } from "../types" import { Progress } from "@/components/ui/progress" import { useToast } from "@/hooks/use-toast" -import { addErrorsAndRunHooks } from "./ValidationStepNew/utils/dataMutations" +import { addErrorsAndRunHooks } from "./ValidationStep/utils/dataMutations" export enum StepType { upload = "upload", diff --git a/inventory/src/components/product-import/steps/ValidationStep/components/ValidationTable.tsx b/inventory/src/components/product-import/steps/ValidationStep/components/ValidationTable.tsx index 337d24a..b88c093 100644 --- a/inventory/src/components/product-import/steps/ValidationStep/components/ValidationTable.tsx +++ b/inventory/src/components/product-import/steps/ValidationStep/components/ValidationTable.tsx @@ -324,20 +324,55 @@ const CellWrapper = memo(({ // Only check uniqueness if value is not empty if (stringValue !== '') { - const isDuplicate = rows.some((row, idx) => { - if (idx === rowIndex) return false; - const otherValue = String(row[field.key] ?? '').toLowerCase().trim(); - return otherValue === stringValue; + // Find ALL rows with the same value (including current row) + const duplicateRowIndices: number[] = []; + rows.forEach((row, idx) => { + // For current row, use the new value being saved; for other rows, use stored value + const cellValue = idx === rowIndex ? valueToSave : row[field.key]; + const otherValue = String(cellValue ?? '').toLowerCase().trim(); + if (otherValue === stringValue) { + duplicateRowIndices.push(idx); + } }); + const isDuplicate = duplicateRowIndices.length > 1; + if (isDuplicate) { - setError(rowIndex, field.key, { + // Set error on ALL duplicate rows (bidirectional) + const errorObj = { message: (uniqueValidation as { errorMessage?: string }).errorMessage || 'Must be unique', level: (uniqueValidation as { level?: 'error' | 'warning' | 'info' }).level || 'error', source: ErrorSource.Table, type: ErrorType.Unique, + }; + duplicateRowIndices.forEach((idx) => { + setError(idx, field.key, errorObj); }); hasError = true; + } else { + // Value is now unique - clear any existing unique errors on other rows + // that might have had this value before + rows.forEach((row, idx) => { + if (idx !== rowIndex) { + const existingErrors = useValidationStore.getState().errors.get(idx); + const fieldErrors = existingErrors?.[field.key]; + if (fieldErrors?.some(e => e.type === ErrorType.Unique)) { + // Re-validate this row's uniqueness + const otherValue = String(row[field.key] ?? '').toLowerCase().trim(); + if (otherValue !== '') { + const stillHasDuplicate = rows.some((r, i) => { + if (i === idx) return false; + const cellValue = i === rowIndex ? valueToSave : r[field.key]; + const v = String(cellValue ?? '').toLowerCase().trim(); + return v === otherValue; + }); + if (!stillHasDuplicate) { + clearFieldError(idx, field.key); + } + } + } + } + }); } } } @@ -348,6 +383,69 @@ const CellWrapper = memo(({ } } + // Trigger product lines fetch if company changed + if (field.key === 'company' && valueToSave) { + const companyId = String(valueToSave); + const state = useValidationStore.getState(); + const cached = state.productLinesCache.get(companyId); + + if (!cached) { + // Start loading state and fetch product lines + state.setLoadingProductLines(companyId, true); + fetch(`/api/import/product-lines/${companyId}`) + .then(res => res.json()) + .then(lines => { + const opts = lines.map((line: { name?: string; label?: string; value?: string | number; id?: string | number }) => ({ + label: line.name || line.label || String(line.value || line.id), + value: String(line.value || line.id), + })); + state.setProductLines(companyId, opts); + }) + .catch(err => { + console.error('Error prefetching product lines:', err); + state.setProductLines(companyId, []); + }) + .finally(() => { + state.setLoadingProductLines(companyId, false); + }); + } + + // Clear line and subline when company changes (they're no longer valid) + updateCell(rowIndex, 'line', ''); + updateCell(rowIndex, 'subline', ''); + } + + // Trigger sublines fetch if line changed + if (field.key === 'line' && valueToSave) { + const lineId = String(valueToSave); + const state = useValidationStore.getState(); + const cached = state.sublinesCache.get(lineId); + + if (!cached) { + // Start loading state and fetch sublines + state.setLoadingSublines(lineId, true); + fetch(`/api/import/sublines/${lineId}`) + .then(res => res.json()) + .then(sublines => { + const opts = sublines.map((subline: { name?: string; label?: string; value?: string | number; id?: string | number }) => ({ + label: subline.name || subline.label || String(subline.value || subline.id), + value: String(subline.value || subline.id), + })); + state.setSublines(lineId, opts); + }) + .catch(err => { + console.error('Error prefetching sublines:', err); + state.setSublines(lineId, []); + }) + .finally(() => { + state.setLoadingSublines(lineId, false); + }); + } + + // Clear subline when line changes (it's no longer valid) + updateCell(rowIndex, 'subline', ''); + } + // Trigger UPC validation if supplier or UPC changed if (field.key === 'supplier' || field.key === 'upc') { const currentRow = useValidationStore.getState().rows[rowIndex]; @@ -379,7 +477,7 @@ const CellWrapper = memo(({ if (response.status === 409) { // UPC already exists setError(rowIndex, 'upc', { - message: 'UPC already exists in database', + message: 'A product with this UPC already exists', level: 'error', source: ErrorSource.Upc, type: ErrorType.Unique, @@ -707,7 +805,7 @@ const TemplateCell = memo(({ rowIndex, currentTemplateId, defaultBrand }: Templa if (response.status === 409) { // UPC already exists setError(rowIndex, 'upc', { - message: 'UPC already exists in database', + message: 'A product with this UPC already exists', level: 'error', source: ErrorSource.Upc, type: ErrorType.Unique, @@ -809,6 +907,25 @@ const VirtualRow = memo(({ useCallback((state) => state.validatingCells.has(`${rowIndex}-item_number`), [rowIndex]) ); + // Subscribe to loading states for line/subline fields + // These need reactive updates so loading spinners clear when API calls complete + const company = rowData?.company; + const line = rowData?.line; + + const isLoadingProductLinesForCompany = useValidationStore( + useCallback( + (state) => (company ? state.loadingProductLines.has(String(company)) : false), + [company] + ) + ); + + const isLoadingSublineForLine = useValidationStore( + useCallback( + (state) => (line ? state.loadingSublines.has(String(line)) : false), + [line] + ) + ); + // Subscribe to selection status const isSelected = useValidationStore( useCallback((state) => state.selectedRows.has(rowId), [rowId]) @@ -821,8 +938,7 @@ const VirtualRow = memo(({ // DON'T subscribe to caches - read via getState() when needed // Subscribing to caches causes ALL rows with same company to re-render when cache updates! - const company = rowData?.company; - const line = rowData?.line; + // Note: company and line are already declared above for loading state subscriptions const supplier = rowData?.supplier; // Get action via getState() - no need to subscribe @@ -899,12 +1015,12 @@ const VirtualRow = memo(({ const needsLine = field.key === 'subline'; const needsSupplier = field.key === 'upc'; - // Check loading state for dependent dropdowns via getState() + // Check loading state for dependent dropdowns - uses subscribed values for reactivity let isLoadingOptions = false; - if (needsCompany && company) { - isLoadingOptions = useValidationStore.getState().loadingProductLines.has(String(company)); - } else if (needsLine && line) { - isLoadingOptions = useValidationStore.getState().loadingSublines.has(String(line)); + if (needsCompany) { + isLoadingOptions = isLoadingProductLinesForCompany; + } else if (needsLine) { + isLoadingOptions = isLoadingSublineForLine; } // Calculate copy-down state for this cell diff --git a/inventory/src/components/product-import/steps/ValidationStep/components/ValidationToolbar.tsx b/inventory/src/components/product-import/steps/ValidationStep/components/ValidationToolbar.tsx index 1205c3e..3a8f5b4 100644 --- a/inventory/src/components/product-import/steps/ValidationStep/components/ValidationToolbar.tsx +++ b/inventory/src/components/product-import/steps/ValidationStep/components/ValidationToolbar.tsx @@ -19,7 +19,6 @@ import { Badge } from '@/components/ui/badge'; import { useValidationStore } from '../store/validationStore'; import { useFilters, - useSelectedRowCount, useFields, } from '../store/selectors'; import { CreateProductCategoryDialog, type CreatedCategoryInfo } from '../../../CreateProductCategoryDialog'; @@ -38,7 +37,6 @@ export const ValidationToolbar = ({ rowsWithErrors, }: ValidationToolbarProps) => { const filters = useFilters(); - const selectedRowCount = useSelectedRowCount(); const fields = useFields(); // State for the product search template dialog diff --git a/inventory/src/components/product-import/steps/ValidationStep/dialogs/AiDebugDialog.tsx b/inventory/src/components/product-import/steps/ValidationStep/dialogs/AiDebugDialog.tsx index 72abd67..e6d88c2 100644 --- a/inventory/src/components/product-import/steps/ValidationStep/dialogs/AiDebugDialog.tsx +++ b/inventory/src/components/product-import/steps/ValidationStep/dialogs/AiDebugDialog.tsx @@ -10,7 +10,7 @@ * Only visible to users with admin:debug permission. */ -import { useState, useMemo } from 'react'; +import { useState } from 'react'; import { Dialog, DialogContent, diff --git a/inventory/src/components/product-import/steps/ValidationStep/hooks/useUpcValidation.ts b/inventory/src/components/product-import/steps/ValidationStep/hooks/useUpcValidation.ts index db88ef4..814ddb1 100644 --- a/inventory/src/components/product-import/steps/ValidationStep/hooks/useUpcValidation.ts +++ b/inventory/src/components/product-import/steps/ValidationStep/hooks/useUpcValidation.ts @@ -154,7 +154,7 @@ export const useUpcValidation = () => { // Set specific error for conflicts if (result.code === 'conflict') { setError(rowIndex, 'upc', { - message: 'UPC already exists in database', + message: 'A product with this UPC already exists', level: 'error', source: ErrorSource.Upc, type: ErrorType.Unique, @@ -262,7 +262,7 @@ export const useUpcValidation = () => { if (result.code === 'conflict') { setError(index, 'upc', { - message: 'UPC already exists in database', + message: 'A product with this UPC already exists', level: 'error', source: ErrorSource.Upc, type: ErrorType.Unique, diff --git a/inventory/src/components/product-import/steps/ValidationStep/utils/dataMutations.ts b/inventory/src/components/product-import/steps/ValidationStep/utils/dataMutations.ts index 309cddf..605be81 100644 --- a/inventory/src/components/product-import/steps/ValidationStep/utils/dataMutations.ts +++ b/inventory/src/components/product-import/steps/ValidationStep/utils/dataMutations.ts @@ -1,5 +1,4 @@ -import type { Data, Fields, Info, RowHook, TableHook } from "../../../types" -import type { Meta, Errors } from "../../ValidationStepNew/types" +import type { Data, Fields, Info, RowHook, TableHook, Meta, Errors } from "../../../types" import { v4 } from "uuid" import { ErrorSources, ErrorType } from "../../../types" diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/AiValidationDialogs.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/AiValidationDialogs.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/AiValidationDialogs.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/AiValidationDialogs.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/BaseCellContent.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/BaseCellContent.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/BaseCellContent.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/BaseCellContent.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/InitializingValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/InitializingValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/InitializingValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/InitializingValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/SearchableTemplateSelect.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/SearchableTemplateSelect.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/SearchableTemplateSelect.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/UpcValidationTableAdapter.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/UpcValidationTableAdapter.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/UpcValidationTableAdapter.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/UpcValidationTableAdapter.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/ValidationCell.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/ValidationCell.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/ValidationCell.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/ValidationCell.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/ValidationContainer.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/ValidationContainer.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/ValidationContainer.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/ValidationContainer.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/ValidationTable.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/ValidationTable.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/ValidationTable.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/ValidationTable.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/cells/CheckboxCell.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/CheckboxCell.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/cells/CheckboxCell.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/CheckboxCell.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/cells/InputCell.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/InputCell.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/cells/InputCell.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/InputCell.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/MultiSelectCell.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/cells/MultiSelectCell.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/MultiSelectCell.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/cells/MultilineInput.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/MultilineInput.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/cells/MultilineInput.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/MultilineInput.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/components/cells/SelectCell.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/SelectCell.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/components/cells/SelectCell.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/components/cells/SelectCell.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useAiValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useAiValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useAiValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useAiValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useFieldValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useFieldValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useFieldValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useFieldValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useFilterManagement.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useFilterManagement.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useFilterManagement.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useFilterManagement.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useInitialValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useInitialValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useInitialValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useInitialValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useProductLinesFetching.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useProductLinesFetching.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useProductLinesFetching.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useProductLinesFetching.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useRowOperations.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useRowOperations.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useRowOperations.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useRowOperations.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useTemplateManagement.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useTemplateManagement.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useTemplateManagement.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useTemplateManagement.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useUniqueItemNumbersValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useUniqueItemNumbersValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useUniqueItemNumbersValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useUniqueItemNumbersValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useUniqueValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useUniqueValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useUniqueValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useUniqueValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useUpcValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useUpcValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useUpcValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useUpcValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useValidation.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useValidation.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useValidation.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useValidation.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/useValidationState.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useValidationState.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/useValidationState.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/useValidationState.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/hooks/validationTypes.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/hooks/validationTypes.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/hooks/validationTypes.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/hooks/validationTypes.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/index.tsx b/inventory/src/components/product-import/steps/ValidationStepOLD/index.tsx similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/index.tsx rename to inventory/src/components/product-import/steps/ValidationStepOLD/index.tsx diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/types.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/types.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/types.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/types.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/types/index.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/types/index.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/types/index.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/types/index.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/utils/aiValidationUtils.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/utils/aiValidationUtils.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/utils/aiValidationUtils.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/utils/aiValidationUtils.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/utils/countryUtils.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/utils/countryUtils.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/utils/countryUtils.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/utils/countryUtils.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/utils/dataMutations.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/utils/dataMutations.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/utils/dataMutations.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/utils/dataMutations.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/utils/priceUtils.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/utils/priceUtils.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/utils/priceUtils.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/utils/priceUtils.ts diff --git a/inventory/src/components/product-import/steps/ValidationStepNew/utils/upcUtils.ts b/inventory/src/components/product-import/steps/ValidationStepOLD/utils/upcUtils.ts similarity index 100% rename from inventory/src/components/product-import/steps/ValidationStepNew/utils/upcUtils.ts rename to inventory/src/components/product-import/steps/ValidationStepOLD/utils/upcUtils.ts diff --git a/inventory/src/components/product-import/types.ts b/inventory/src/components/product-import/types.ts index af4799e..9d5ee65 100644 --- a/inventory/src/components/product-import/types.ts +++ b/inventory/src/components/product-import/types.ts @@ -1,9 +1,11 @@ -import type { Meta } from "./steps/ValidationStepNew/types" import type { DeepReadonly } from "ts-essentials" import type { TranslationsRSIProps } from "./translationsRSIProps" import type { Columns } from "./steps/MatchColumnsStep/types" import type { StepState } from "./steps/UploadFlow" +// Meta type for row data with unique index +export type Meta = { __index: string } + export type SubmitOptions = { targetEnvironment: "dev" | "prod" useTestDataSource: boolean @@ -200,6 +202,10 @@ export type InfoWithSource = Info & { type: ErrorType; } +// Legacy error types used by dataMutations utility +export type FieldError = { [key: string]: InfoWithSource } +export type Errors = { [id: string]: FieldError } + export type Result = { validData: Data[] invalidData: Data[] diff --git a/inventory/src/pages/Import.tsx b/inventory/src/pages/Import.tsx index 7cdfe35..561824a 100644 --- a/inventory/src/pages/Import.tsx +++ b/inventory/src/pages/Import.tsx @@ -431,7 +431,7 @@ export function Import() { // { // upc: "123456789012", // item_number: "ITEM-001", - // error_msg: "UPC already exists in the system", + // error_msg: "A product with this UPC already exists", // }, // { // upc: "234567890123",