changes: Enable Dev mode with hardcoded propductId for test

This commit is contained in:
2025-10-11 17:26:28 -06:00
parent 4d1de941da
commit 048303ac43
2 changed files with 30 additions and 0 deletions

View File

@@ -80,6 +80,9 @@ function HomePageContent() {
useEffect(() => {
const initializeCamera = async () => {
try {
// Configure DEV mode if URL parameter is present
skuIdentificationService.setDevMode(isDev);
// Load history first
setHistory(getHistory());

View File

@@ -8,6 +8,8 @@ interface SKUResponse {
*/
export class SKUIdentificationService {
private readonly API_ENDPOINT: string;
private isDevMode: boolean = false;
private readonly DEV_SKU: string = '171312'; // Hardcoded SKU for DEV mode
constructor() {
// Construir endpoint correctamente, manejando si la URL base termina con / o no
@@ -20,6 +22,18 @@ export class SKUIdentificationService {
console.log(' Endpoint final:', this.API_ENDPOINT);
}
/**
* Enable or disable DEV mode
* In DEV mode, identifySKU will return a hardcoded SKU without calling the API
*/
setDevMode(isDev: boolean): void {
this.isDevMode = isDev;
console.log(`🔧 DEV Mode ${isDev ? 'ACTIVADO' : 'DESACTIVADO'}`);
if (isDev) {
console.log(` SKU hardcodeado: ${this.DEV_SKU}`);
}
}
/**
* Validate API response format
@@ -71,6 +85,19 @@ export class SKUIdentificationService {
try {
console.log('\n🔍 ========== IDENTIFICACIÓN DE SKU ==========');
console.log('📊 Dimensiones imagen:', imageData.width, 'x', imageData.height);
// DEV MODE: Return hardcoded SKU immediately
if (this.isDevMode) {
console.log('🧪 MODO DEV ACTIVADO');
console.log('✅ Retornando SKU hardcodeado:', this.DEV_SKU);
console.log('=========================================\n');
// Simulate small delay for realistic behavior
await new Promise(resolve => setTimeout(resolve, 500));
return this.DEV_SKU;
}
console.log('🌐 Endpoint:', this.API_ENDPOINT);
console.log('📡 Llamando al API Python (sin cache)...');