+
+
{
);
}
- // For UPC fields, include validation state in comparison
- if (prev.fieldKey === 'upc' || prev.fieldKey === 'barcode') {
- return (
- prev.value === next.value &&
- prevErrorsStr === nextErrorsStr &&
- prev.isValidating === next.isValidating
- );
- }
-
// For all other fields, compare core props
return (
prev.value === next.value &&
diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx
index 7d53443..333fbfb 100644
--- a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx
+++ b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/components/ValidationContainer.tsx
@@ -10,6 +10,7 @@ import { ProductSearchDialog } from '@/components/products/ProductSearchDialog'
import SearchableTemplateSelect from './SearchableTemplateSelect'
import { useAiValidation } from '../hooks/useAiValidation'
import { AiValidationDialogs } from './AiValidationDialogs'
+import config from '@/config'
/**
* ValidationContainer component - the main wrapper for the validation step
@@ -187,7 +188,7 @@ const ValidationContainer = ({
}
// Make API call to validate UPC
- const response = await fetch(`/api/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplierId)}`);
+ const response = await fetch(`${config.apiUrl}/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplierId)}`);
// Process the response
if (response.status === 409) {
diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx
index d2f7270..9385d76 100644
--- a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx
+++ b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useUpcValidation.tsx
@@ -1,4 +1,5 @@
import { useState, useCallback, useRef } from 'react'
+import config from '@/config'
interface UpcValidationResult {
error?: boolean
@@ -67,7 +68,7 @@ export const useUpcValidation = () => {
try {
// Call the UPC validation API
- const response = await fetch(`/api/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplier)}`);
+ const response = await fetch(`${config.apiUrl}/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplier)}`);
if (response.status === 409) {
const errorData = await response.json();
diff --git a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx
index fec32da..dc5866b 100644
--- a/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx
+++ b/inventory/src/lib/react-spreadsheet-import/src/steps/ValidationStepNew/hooks/useValidationState.tsx
@@ -76,7 +76,7 @@ declare global {
}
// Use a helper to get API URL consistently
-export const getApiUrl = () => window.config?.apiUrl || '/api';
+export const getApiUrl = () => config.apiUrl;
// Main validation state hook
export const useValidationState = ({
@@ -125,7 +125,7 @@ export const useValidationState = ({
const fetchProductByUpc = useCallback(async (supplier: string, upc: string): Promise => {
try {
// Use the correct endpoint and parameter names
- const response = await fetch(`${getApiUrl()}/check-upc-and-generate-sku?supplierId=${encodeURIComponent(supplier)}&upc=${encodeURIComponent(upc)}`, {
+ const response = await fetch(`${getApiUrl()}/import/check-upc-and-generate-sku?supplierId=${encodeURIComponent(supplier)}&upc=${encodeURIComponent(upc)}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -224,7 +224,7 @@ export const useValidationState = ({
}
// Make API call to validate UPC
- const response = await fetch(`/api/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplierId)}`);
+ const response = await fetch(`${config.apiUrl}/import/check-upc-and-generate-sku?upc=${encodeURIComponent(upcValue)}&supplierId=${encodeURIComponent(supplierId)}`);
if (response.status === 409) {
// UPC already exists - show validation error