Start integrating the onboarding flow with backend 15

This commit is contained in:
Urtzi Alfaro
2025-09-07 22:58:58 +02:00
parent 0060b9cccb
commit 4c5bc0b636
3 changed files with 89 additions and 19 deletions

View File

@@ -122,16 +122,6 @@ export const SmartInventorySetupStep: React.FC<OnboardingStepProps> = ({
const result = Boolean(hasAuth && (hasTenantId || tenantCreatedSuccessfully || tenantCreatedInOnboarding));
console.log('🔄 SmartInventorySetup - isTenantAvailable check:', {
hasAuth,
authLoading,
hasUser: !!user,
hasTenantId,
tenantId: getTenantId(),
tenantCreatedSuccessfully,
tenantCreatedInOnboarding,
finalResult: result
});
return result;
};
@@ -160,7 +150,8 @@ export const SmartInventorySetupStep: React.FC<OnboardingStepProps> = ({
console.log('🔄 SmartInventorySetup - suggestions effect:', {
suggestionsLength: suggestions?.length || 0,
productsLength: products.length,
suggestions: suggestions,
suggestionsIsArray: Array.isArray(suggestions),
suggestionsType: typeof suggestions,
});
if (suggestions && suggestions.length > 0 && products.length === 0) {
@@ -286,10 +277,20 @@ export const SmartInventorySetupStep: React.FC<OnboardingStepProps> = ({
if (success) {
console.log('✅ File processed successfully, setting stage to review');
setLocalStage('review');
toast.addToast('El archivo se procesó correctamente. Revisa los productos detectados.', {
title: 'Procesamiento completado',
type: 'success'
});
// Check if there was a suggestion error (AI service timeout)
const stepData = data.allStepData?.['smart-inventory-setup'];
if (stepData?.suggestionError) {
toast.addToast(`Archivo procesado. ${stepData.suggestionError} Se crearon sugerencias básicas que puedes editar.`, {
title: 'Procesamiento completado con advertencias',
type: 'warning'
});
} else {
toast.addToast('El archivo se procesó correctamente. Revisa los productos detectados.', {
title: 'Procesamiento completado',
type: 'success'
});
}
} else {
console.error('❌ File processing failed - processSalesFile returned false');
throw new Error('Error procesando el archivo');