Start integrating the onboarding flow with backend 4

This commit is contained in:
Urtzi Alfaro
2025-09-05 12:55:26 +02:00
parent 0faaa25e58
commit 3fe1f17610
26 changed files with 2161 additions and 1002 deletions

View File

@@ -2,11 +2,11 @@
* API Response Types - Matching actual backend implementation
*/
// Standard FastAPI response structure
// Standard API response structure (matching client.ts transformResponse)
export interface ApiResponse<T = any> {
data?: T;
success?: boolean;
message?: string;
data: T;
success: boolean;
message: string;
detail?: string;
error?: string;
}

View File

@@ -177,4 +177,14 @@ export const isTokenResponse = (obj: any): obj is TokenResponse => {
export const isAuthError = (obj: any): obj is AuthError => {
return obj && typeof obj.detail === 'string';
};
};
// Onboarding status types (moved from onboarding)
export interface OnboardingStatus {
completed: boolean;
steps_completed: string[];
}
export interface OnboardingProgressRequest {
metadata?: any;
}

View File

@@ -437,4 +437,60 @@ export const isStock = (obj: any): obj is Stock => {
export const isStockMovement = (obj: any): obj is StockMovement => {
return obj && typeof obj.id === 'string' && obj.movement_type && obj.quantity !== undefined;
};
};
// Product classification and suggestion types (moved from onboarding)
export interface ProductSuggestion {
suggestion_id: string;
original_name: string;
suggested_name: string;
product_type: 'ingredient' | 'finished_product';
category: string;
unit_of_measure: string;
confidence_score: number;
estimated_shelf_life_days: number;
requires_refrigeration: boolean;
requires_freezing: boolean;
is_seasonal: boolean;
suggested_supplier?: string;
notes: string;
sales_data: {
total_quantity: number;
average_daily_sales: number;
peak_day: string;
frequency: number;
};
}
export interface BusinessModelAnalysis {
model: 'production' | 'retail' | 'hybrid';
confidence: number;
ingredient_count: number;
finished_product_count: number;
ingredient_ratio: number;
recommendations: string[];
}
export interface ProductSuggestionsResponse {
suggestions: ProductSuggestion[];
business_model_analysis: BusinessModelAnalysis;
total_products: number;
high_confidence_count: number;
low_confidence_count: number;
processing_time_seconds: number;
}
export interface InventoryCreationResponse {
created_items: any[];
failed_items: any[];
total_approved: number;
success_rate: number;
inventory_mapping?: { [productName: string]: string };
}
export interface BatchClassificationRequest {
products: Array<{
product_name: string;
sales_data?: any;
}>;
}

View File

@@ -599,4 +599,24 @@ export const isProductPerformance = (obj: any): obj is ProductPerformance => {
export const isSalesSummary = (obj: any): obj is SalesSummary => {
return obj && typeof obj.total_revenue === 'number' && typeof obj.total_quantity === 'number';
};
};
// Business model and onboarding guide types (moved from onboarding)
export interface BusinessModelGuide {
title: string;
description: string;
next_steps: string[];
recommended_features: string[];
sample_workflows: string[];
}
export enum BusinessModelType {
PRODUCTION = 'production',
RETAIL = 'retail',
HYBRID = 'hybrid',
}
// Utility function for downloading templates (moved from onboarding)
export interface TemplateData {
template: string | any;
}