changes: add test data and remove chat
This commit is contained in:
@@ -321,7 +321,7 @@ export function getProductHighlight(product: Product) {
|
||||
if (!product.clusterHighlights || Object.keys(product.clusterHighlights).length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Show the highlight from clusterHighlights
|
||||
const highlight = Object.values(product.clusterHighlights)[0];
|
||||
return {
|
||||
@@ -330,4 +330,29 @@ export function getProductHighlight(product: Product) {
|
||||
icon: '⭐',
|
||||
type: 'promotion'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads test product data from JSON file
|
||||
* Used when SKU detection returns "test_product"
|
||||
*
|
||||
* The test product data is stored in /public/test-product.json
|
||||
* and can be edited manually without changing code
|
||||
*/
|
||||
export async function fetchTestProduct(): Promise<Product | null> {
|
||||
try {
|
||||
const response = await fetch('/test-product.json');
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Failed to load test product JSON:', response.status);
|
||||
return null;
|
||||
}
|
||||
|
||||
const testProduct: Product = await response.json();
|
||||
console.log('✅ Test product loaded from JSON successfully');
|
||||
return testProduct;
|
||||
} catch (error) {
|
||||
console.error('Error loading test product:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -142,15 +142,23 @@ export class SKUIdentificationService {
|
||||
}
|
||||
|
||||
console.log('✓ Respuesta recibida - Status:', response.status);
|
||||
console.log('✓ Headers:', Object.fromEntries(response.headers.entries()));
|
||||
|
||||
// Try to get response as text first
|
||||
const responseText = await response.text();
|
||||
console.log('📄 RESPUESTA RAW del servidor Python:');
|
||||
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
||||
console.log(responseText);
|
||||
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
||||
|
||||
// Try to parse as JSON
|
||||
let data: any;
|
||||
try {
|
||||
data = JSON.parse(responseText);
|
||||
console.log('✓ Respuesta parseada:', data);
|
||||
console.log('✓ Respuesta parseada como JSON:');
|
||||
console.log(' - status:', data.status, '(tipo:', typeof data.status, ')');
|
||||
console.log(' - SKU:', data.SKU, '(tipo:', typeof data.SKU, ')');
|
||||
console.log(' - Objeto completo:', JSON.stringify(data, null, 2));
|
||||
} catch (parseError) {
|
||||
console.error('❌ Error al parsear JSON:', parseError);
|
||||
console.error(' Respuesta recibida:', responseText);
|
||||
@@ -158,25 +166,41 @@ export class SKUIdentificationService {
|
||||
}
|
||||
|
||||
// Validate response format
|
||||
console.log('🔍 Validando formato de respuesta...');
|
||||
if (!this.validateResponse(data)) {
|
||||
console.error('❌ Validación de formato falló');
|
||||
throw new Error('Response format validation failed');
|
||||
}
|
||||
console.log('✓ Formato de respuesta válido');
|
||||
|
||||
// ONLY return SKU if status is EXACTLY true (not false, not null, not undefined)
|
||||
console.log('🔍 Evaluando condiciones para detectar zapato:');
|
||||
console.log(' - ¿data.status === true?', data.status === true);
|
||||
console.log(' - ¿data.SKU existe?', !!data.SKU);
|
||||
console.log(' - ¿data.SKU es string?', typeof data.SKU === 'string');
|
||||
console.log(' - Valor de data.status:', data.status);
|
||||
console.log(' - Valor de data.SKU:', data.SKU);
|
||||
|
||||
if (data.status === true && data.SKU) {
|
||||
console.log('✅ ZAPATO ENCONTRADO - SKU:', data.SKU);
|
||||
console.log('✅✅✅ ZAPATO ENCONTRADO ✅✅✅');
|
||||
console.log('📦 SKU DETECTADO:', data.SKU);
|
||||
console.log('=========================================\n');
|
||||
return data.SKU;
|
||||
} else {
|
||||
console.log('❌❌❌ ZAPATO NO ENCONTRADO ❌❌❌');
|
||||
// Log detailed reason for not finding shoe
|
||||
if (data.status === false) {
|
||||
console.log('❌ ZAPATO NO ENCONTRADO - El servidor reportó status: false');
|
||||
console.log('💡 RAZÓN: El servidor reportó status: false');
|
||||
} else if (data.status === null) {
|
||||
console.log('❌ ZAPATO NO ENCONTRADO - El servidor reportó status: null');
|
||||
console.log('💡 RAZÓN: El servidor reportó status: null');
|
||||
} else if (data.status !== true) {
|
||||
console.log('💡 RAZÓN: status no es exactamente true, es:', data.status, 'tipo:', typeof data.status);
|
||||
} else if (!data.SKU) {
|
||||
console.log('❌ ZAPATO NO ENCONTRADO - status: true pero SKU es null/vacío');
|
||||
console.log('💡 RAZÓN: status es true pero SKU es null/vacío/undefined');
|
||||
console.log(' SKU value:', data.SKU);
|
||||
console.log(' SKU type:', typeof data.SKU);
|
||||
} else {
|
||||
console.log('❌ ZAPATO NO ENCONTRADO - status:', data.status, 'SKU:', data.SKU);
|
||||
console.log('💡 RAZÓN: Condición desconocida - status:', data.status, 'SKU:', data.SKU);
|
||||
}
|
||||
console.log('=========================================\n');
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user