Clean up
This commit is contained in:
@@ -223,7 +223,7 @@ export const UploadFlow = ({ state, onNext, onBack }: Props) => {
|
||||
onBack();
|
||||
}
|
||||
}}
|
||||
onNext={(validatedData) => {
|
||||
onNext={(validatedData: any[]) => {
|
||||
// Go to image upload step with the validated data
|
||||
onNext({
|
||||
type: StepType.imageUpload,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 {
|
||||
Command,
|
||||
@@ -50,7 +50,6 @@ const SearchableTemplateSelect: React.FC<SearchableTemplateSelectProps> = ({
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [selectedBrand, setSelectedBrand] = useState<string | null>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [] = useState<string | null>(null);
|
||||
|
||||
// Set default brand when component mounts or defaultBrand changes
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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 { ErrorSources, ErrorType, ValidationError } from '../../../types';
|
||||
import { RowData, InfoWithSource, isEmpty } from './validationTypes';
|
||||
import { ErrorType, ValidationError } from '../../../types';
|
||||
import { RowData, isEmpty } from './validationTypes';
|
||||
|
||||
// Create a cache for validation results to avoid repeated validation of the same data
|
||||
const validationResultCache = new Map();
|
||||
@@ -34,8 +34,7 @@ export const clearAllUniquenessCaches = () => {
|
||||
|
||||
export const useFieldValidation = <T extends string>(
|
||||
fields: Fields<T>,
|
||||
rowHook?: RowHook<T>,
|
||||
tableHook?: TableHook<T>
|
||||
rowHook?: RowHook<T>
|
||||
) => {
|
||||
// Validate a single field
|
||||
const validateField = useCallback((
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useCallback } from 'react';
|
||||
import type { Fields } from '../../../types';
|
||||
import { ErrorSources, ErrorType } from '../../../types';
|
||||
import { RowData, InfoWithSource, isEmpty } from './validationTypes';
|
||||
import { clearValidationCacheForField } from './useFieldValidation';
|
||||
|
||||
export const useUniqueValidation = <T extends string>(
|
||||
fields: Fields<T>
|
||||
|
||||
@@ -84,13 +84,6 @@ export const useUpcValidation = (
|
||||
}, 0);
|
||||
}, [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
|
||||
const stopValidatingRow = useCallback((rowIndex: number) => {
|
||||
validationStateRef.current.validatingRows.delete(rowIndex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback } from 'react'
|
||||
import type { Field, Fields, RowHook, TableHook } from '../../../types'
|
||||
import type { Field, Fields, RowHook } from '../../../types'
|
||||
import { ErrorSources } from '../../../types'
|
||||
import { RowData, InfoWithSource } from './validationTypes'
|
||||
import { useFieldValidation, clearValidationCacheForField, clearAllUniquenessCaches } from './useFieldValidation'
|
||||
@@ -8,11 +8,10 @@ import { useUniqueValidation } from './useUniqueValidation'
|
||||
// Main validation hook that brings together field and uniqueness validation
|
||||
export const useValidation = <T extends string>(
|
||||
fields: Fields<T>,
|
||||
rowHook?: RowHook<T>,
|
||||
tableHook?: TableHook<T>
|
||||
rowHook?: RowHook<T>
|
||||
) => {
|
||||
// Use the field validation hook
|
||||
const { validateField, validateRow } = useFieldValidation(fields, rowHook, tableHook);
|
||||
const { validateField, validateRow } = useFieldValidation(fields, rowHook);
|
||||
|
||||
// Use the uniqueness validation hook
|
||||
const {
|
||||
|
||||
@@ -23,8 +23,7 @@ export const useValidationState = <T extends string>({
|
||||
// Import validateField from useValidation
|
||||
const { validateField: validateFieldFromHook } = useValidation<T>(
|
||||
fields,
|
||||
rowHook,
|
||||
tableHook
|
||||
rowHook
|
||||
);
|
||||
|
||||
// Add ref to track template application state
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { Data, Field } from "../../../types";
|
||||
import { ErrorSources, ErrorType, ValidationError } from "../../../types";
|
||||
import type { Data } from "../../../types";
|
||||
import { ErrorSources, ErrorType } from "../../../types";
|
||||
import config from "@/config";
|
||||
import { RowSelectionState } from "@tanstack/react-table";
|
||||
|
||||
// Define the Props interface for ValidationStepNew
|
||||
export interface Props<T extends string> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ValidationContainer from './components/ValidationContainer'
|
||||
import { Props } from './hooks/useValidationState'
|
||||
import { Props } from './hooks/validationTypes'
|
||||
|
||||
/**
|
||||
* ValidationStepNew component - modern implementation of the validation step
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user