Start integrating the onboarding flow with backend 11
This commit is contained in:
@@ -22,25 +22,15 @@ export const DEFAULT_STEPS: OnboardingStep[] = [
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'data-processing',
|
||||
id: 'sales-validation',
|
||||
title: '📊 Validación de Ventas',
|
||||
description: 'Valida tus datos de ventas y detecta productos automáticamente',
|
||||
description: 'Sube, valida y aprueba tus datos de ventas históricas con IA',
|
||||
isRequired: true,
|
||||
isCompleted: false,
|
||||
validation: (data: OnboardingData) => {
|
||||
if (!data.files?.salesData) return 'Debes cargar el archivo de datos de ventas';
|
||||
if (data.processingStage !== 'completed') return 'El procesamiento debe completarse antes de continuar';
|
||||
if (data.processingStage !== 'completed' && data.processingStage !== 'review') return 'El procesamiento debe completarse antes de continuar';
|
||||
if (!data.processingResults?.is_valid) return 'Los datos deben ser válidos para continuar';
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'review',
|
||||
title: '📋 Revisión',
|
||||
description: 'Revisión de productos detectados por IA y resultados',
|
||||
isRequired: true,
|
||||
isCompleted: false,
|
||||
validation: (data: OnboardingData) => {
|
||||
if (!data.reviewCompleted) return 'Debes revisar y aprobar los productos detectados';
|
||||
const hasApprovedProducts = data.approvedProducts && data.approvedProducts.length > 0;
|
||||
if (!hasApprovedProducts) return 'Debes aprobar al menos un producto para continuar';
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface OnboardingData {
|
||||
files?: {
|
||||
salesData?: File;
|
||||
};
|
||||
processingStage?: 'upload' | 'validating' | 'analyzing' | 'completed' | 'error';
|
||||
processingStage?: 'upload' | 'validating' | 'analyzing' | 'review' | 'completed' | 'error';
|
||||
processingResults?: {
|
||||
is_valid: boolean;
|
||||
total_records: number;
|
||||
@@ -44,8 +44,9 @@ export interface OnboardingData {
|
||||
};
|
||||
};
|
||||
|
||||
// Step 3: Review
|
||||
// Step 3: Sales Validation (merged data processing + review)
|
||||
suggestions?: ProductSuggestionResponse[];
|
||||
detectedProducts?: any[]; // Products detected from AI analysis
|
||||
approvedSuggestions?: ProductSuggestionResponse[];
|
||||
approvedProducts?: ProductSuggestionResponse[];
|
||||
reviewCompleted?: boolean;
|
||||
|
||||
@@ -123,7 +123,7 @@ export const useOnboarding = () => {
|
||||
): Promise<boolean> => {
|
||||
const result = await salesProcessing.processFile(file, onProgress);
|
||||
if (result.success) {
|
||||
updateStepData('data-processing', {
|
||||
updateStepData('sales-validation', {
|
||||
files: { salesData: file },
|
||||
processingStage: 'completed',
|
||||
processingResults: result.validationResults,
|
||||
|
||||
@@ -152,14 +152,13 @@ export const useTrainingOrchestration = () => {
|
||||
const missingItems: string[] = [];
|
||||
|
||||
// Get data from previous steps
|
||||
const dataProcessingData = allStepData?.['data-processing'];
|
||||
const reviewData = allStepData?.['review'];
|
||||
const salesValidationData = allStepData?.['sales-validation'];
|
||||
const inventoryData = allStepData?.['inventory'];
|
||||
|
||||
// Check if sales data was processed
|
||||
const hasProcessingResults = dataProcessingData?.processingResults &&
|
||||
dataProcessingData.processingResults.is_valid &&
|
||||
dataProcessingData.processingResults.total_records > 0;
|
||||
const hasProcessingResults = salesValidationData?.processingResults &&
|
||||
salesValidationData.processingResults.is_valid &&
|
||||
salesValidationData.processingResults.total_records > 0;
|
||||
|
||||
// Check if sales data was imported (required for training)
|
||||
const hasImportResults = inventoryData?.salesImportResult &&
|
||||
@@ -176,10 +175,10 @@ export const useTrainingOrchestration = () => {
|
||||
missingItems.push('Datos de ventas importados');
|
||||
}
|
||||
|
||||
// Check if products were approved in review step
|
||||
const hasApprovedProducts = reviewData?.approvedProducts &&
|
||||
reviewData.approvedProducts.length > 0 &&
|
||||
reviewData.reviewCompleted;
|
||||
// Check if products were approved in sales validation step
|
||||
const hasApprovedProducts = salesValidationData?.approvedProducts &&
|
||||
salesValidationData.approvedProducts.length > 0 &&
|
||||
salesValidationData.reviewCompleted;
|
||||
|
||||
if (!hasApprovedProducts) {
|
||||
missingItems.push('Productos aprobados en revisión');
|
||||
@@ -195,8 +194,8 @@ export const useTrainingOrchestration = () => {
|
||||
}
|
||||
|
||||
// Check if we have enough data for training
|
||||
if (dataProcessingData?.processingResults?.total_records &&
|
||||
dataProcessingData.processingResults.total_records < 10) {
|
||||
if (salesValidationData?.processingResults?.total_records &&
|
||||
salesValidationData.processingResults.total_records < 10) {
|
||||
missingItems.push('Suficientes registros de ventas (mínimo 10)');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user