This commit is contained in:
2025-03-22 21:05:24 -04:00
parent a51a48ce89
commit 387e7e5e73
10 changed files with 14 additions and 27 deletions

View File

@@ -223,7 +223,7 @@ export const UploadFlow = ({ state, onNext, onBack }: Props) => {
onBack(); onBack();
} }
}} }}
onNext={(validatedData) => { onNext={(validatedData: any[]) => {
// Go to image upload step with the validated data // Go to image upload step with the validated data
onNext({ onNext({
type: StepType.imageUpload, type: StepType.imageUpload,

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect, useCallback, useMemo } from 'react' import React, { useState, useEffect, useCallback, useMemo } from 'react'
import { Template } from '../hooks/useValidationState' import { Template } from '../hooks/validationTypes'
import { Button } from '@/components/ui/button' import { Button } from '@/components/ui/button'
import { import {
Command, Command,
@@ -50,7 +50,6 @@ const SearchableTemplateSelect: React.FC<SearchableTemplateSelectProps> = ({
const [searchTerm, setSearchTerm] = useState(""); const [searchTerm, setSearchTerm] = useState("");
const [selectedBrand, setSelectedBrand] = useState<string | null>(null); const [selectedBrand, setSelectedBrand] = useState<string | null>(null);
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [] = useState<string | null>(null);
// Set default brand when component mounts or defaultBrand changes // Set default brand when component mounts or defaultBrand changes
useEffect(() => { useEffect(() => {

View File

@@ -1,8 +1,8 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import type { Field, Fields, RowHook, TableHook } from '../../../types'; import type { Field, Fields, RowHook } from '../../../types';
import type { Meta } from '../types'; import type { Meta } from '../types';
import { ErrorSources, ErrorType, ValidationError } from '../../../types'; import { ErrorType, ValidationError } from '../../../types';
import { RowData, InfoWithSource, isEmpty } from './validationTypes'; import { RowData, isEmpty } from './validationTypes';
// Create a cache for validation results to avoid repeated validation of the same data // Create a cache for validation results to avoid repeated validation of the same data
const validationResultCache = new Map(); const validationResultCache = new Map();
@@ -34,8 +34,7 @@ export const clearAllUniquenessCaches = () => {
export const useFieldValidation = <T extends string>( export const useFieldValidation = <T extends string>(
fields: Fields<T>, fields: Fields<T>,
rowHook?: RowHook<T>, rowHook?: RowHook<T>
tableHook?: TableHook<T>
) => { ) => {
// Validate a single field // Validate a single field
const validateField = useCallback(( const validateField = useCallback((

View File

@@ -2,7 +2,6 @@ import { useCallback } from 'react';
import type { Fields } from '../../../types'; import type { Fields } from '../../../types';
import { ErrorSources, ErrorType } from '../../../types'; import { ErrorSources, ErrorType } from '../../../types';
import { RowData, InfoWithSource, isEmpty } from './validationTypes'; import { RowData, InfoWithSource, isEmpty } from './validationTypes';
import { clearValidationCacheForField } from './useFieldValidation';
export const useUniqueValidation = <T extends string>( export const useUniqueValidation = <T extends string>(
fields: Fields<T> fields: Fields<T>

View File

@@ -84,13 +84,6 @@ export const useUpcValidation = (
}, 0); }, 0);
}, [setData]); }, [setData]);
// Mark a row as being validated
const startValidatingRow = useCallback((rowIndex: number) => {
validationStateRef.current.validatingRows.add(rowIndex);
setValidatingRows(new Set(validationStateRef.current.validatingRows));
setIsValidatingUpc(true);
}, []);
// Mark a row as no longer being validated // Mark a row as no longer being validated
const stopValidatingRow = useCallback((rowIndex: number) => { const stopValidatingRow = useCallback((rowIndex: number) => {
validationStateRef.current.validatingRows.delete(rowIndex); validationStateRef.current.validatingRows.delete(rowIndex);

View File

@@ -1,5 +1,5 @@
import { useCallback } from 'react' import { useCallback } from 'react'
import type { Field, Fields, RowHook, TableHook } from '../../../types' import type { Field, Fields, RowHook } from '../../../types'
import { ErrorSources } from '../../../types' import { ErrorSources } from '../../../types'
import { RowData, InfoWithSource } from './validationTypes' import { RowData, InfoWithSource } from './validationTypes'
import { useFieldValidation, clearValidationCacheForField, clearAllUniquenessCaches } from './useFieldValidation' import { useFieldValidation, clearValidationCacheForField, clearAllUniquenessCaches } from './useFieldValidation'
@@ -8,11 +8,10 @@ import { useUniqueValidation } from './useUniqueValidation'
// Main validation hook that brings together field and uniqueness validation // Main validation hook that brings together field and uniqueness validation
export const useValidation = <T extends string>( export const useValidation = <T extends string>(
fields: Fields<T>, fields: Fields<T>,
rowHook?: RowHook<T>, rowHook?: RowHook<T>
tableHook?: TableHook<T>
) => { ) => {
// Use the field validation hook // Use the field validation hook
const { validateField, validateRow } = useFieldValidation(fields, rowHook, tableHook); const { validateField, validateRow } = useFieldValidation(fields, rowHook);
// Use the uniqueness validation hook // Use the uniqueness validation hook
const { const {

View File

@@ -23,8 +23,7 @@ export const useValidationState = <T extends string>({
// Import validateField from useValidation // Import validateField from useValidation
const { validateField: validateFieldFromHook } = useValidation<T>( const { validateField: validateFieldFromHook } = useValidation<T>(
fields, fields,
rowHook, rowHook
tableHook
); );
// Add ref to track template application state // Add ref to track template application state

View File

@@ -1,7 +1,6 @@
import type { Data, Field } from "../../../types"; import type { Data } from "../../../types";
import { ErrorSources, ErrorType, ValidationError } from "../../../types"; import { ErrorSources, ErrorType } from "../../../types";
import config from "@/config"; import config from "@/config";
import { RowSelectionState } from "@tanstack/react-table";
// Define the Props interface for ValidationStepNew // Define the Props interface for ValidationStepNew
export interface Props<T extends string> { export interface Props<T extends string> {

View File

@@ -1,5 +1,5 @@
import ValidationContainer from './components/ValidationContainer' import ValidationContainer from './components/ValidationContainer'
import { Props } from './hooks/useValidationState' import { Props } from './hooks/validationTypes'
/** /**
* ValidationStepNew component - modern implementation of the validation step * ValidationStepNew component - modern implementation of the validation step

File diff suppressed because one or more lines are too long