IMPORVE ONBOARDING STEPS
This commit is contained in:
@@ -49,12 +49,15 @@ ONBOARDING_STEPS = [
|
||||
# Phase 2: Core Setup
|
||||
"setup", # Basic bakery setup and tenant creation
|
||||
|
||||
# Phase 2a: AI-Assisted Path (ONLY PATH - manual path removed)
|
||||
"smart-inventory-setup", # Sales data upload and AI analysis
|
||||
"product-categorization", # Categorize products as ingredients vs finished products
|
||||
# Phase 2a: AI-Assisted Inventory Setup (REFACTORED - split into 3 focused steps)
|
||||
"upload-sales-data", # File upload, validation, and AI classification
|
||||
"inventory-review", # Review and confirm AI-detected products with type selection
|
||||
"initial-stock-entry", # Capture initial stock levels
|
||||
|
||||
# Phase 2b: Suppliers (shared by all paths)
|
||||
# Phase 2b: Product Categorization (optional advanced categorization)
|
||||
"product-categorization", # Advanced categorization (may be deprecated)
|
||||
|
||||
# Phase 2c: Suppliers (shared by all paths)
|
||||
"suppliers-setup", # Suppliers configuration
|
||||
|
||||
# Phase 3: Advanced Configuration (all optional)
|
||||
@@ -78,13 +81,16 @@ STEP_DEPENDENCIES = {
|
||||
# Core setup - no longer depends on data-source-choice (removed)
|
||||
"setup": ["user_registered", "bakery-type-selection"],
|
||||
|
||||
# AI-Assisted path dependencies (ONLY path now)
|
||||
"smart-inventory-setup": ["user_registered", "setup"],
|
||||
"product-categorization": ["user_registered", "setup", "smart-inventory-setup"],
|
||||
"initial-stock-entry": ["user_registered", "setup", "smart-inventory-setup", "product-categorization"],
|
||||
# AI-Assisted Inventory Setup - REFACTORED into 3 sequential steps
|
||||
"upload-sales-data": ["user_registered", "setup"],
|
||||
"inventory-review": ["user_registered", "setup", "upload-sales-data"],
|
||||
"initial-stock-entry": ["user_registered", "setup", "upload-sales-data", "inventory-review"],
|
||||
|
||||
# Suppliers (after AI inventory setup)
|
||||
"suppliers-setup": ["user_registered", "setup", "smart-inventory-setup"],
|
||||
# Advanced product categorization (optional, may be deprecated)
|
||||
"product-categorization": ["user_registered", "setup", "upload-sales-data"],
|
||||
|
||||
# Suppliers (after inventory review)
|
||||
"suppliers-setup": ["user_registered", "setup", "inventory-review"],
|
||||
|
||||
# Advanced configuration (optional, minimal dependencies)
|
||||
"recipes-setup": ["user_registered", "setup"],
|
||||
@@ -92,8 +98,8 @@ STEP_DEPENDENCIES = {
|
||||
"quality-setup": ["user_registered", "setup"],
|
||||
"team-setup": ["user_registered", "setup"],
|
||||
|
||||
# ML Training - requires AI path completion
|
||||
"ml-training": ["user_registered", "setup", "smart-inventory-setup"],
|
||||
# ML Training - requires AI path completion (upload-sales-data with inventory review)
|
||||
"ml-training": ["user_registered", "setup", "upload-sales-data", "inventory-review"],
|
||||
|
||||
# Review and completion
|
||||
"setup-review": ["user_registered", "setup"],
|
||||
@@ -277,20 +283,24 @@ class OnboardingService:
|
||||
|
||||
# SPECIAL VALIDATION FOR ML TRAINING STEP
|
||||
if step_name == "ml-training":
|
||||
# ML training requires AI-assisted path completion (only path available now)
|
||||
ai_path_complete = user_progress_data.get("smart-inventory-setup", {}).get("completed", False)
|
||||
# ML training requires AI-assisted path completion
|
||||
# Check if upload-sales-data and inventory-review are completed
|
||||
upload_complete = user_progress_data.get("upload-sales-data", {}).get("completed", False)
|
||||
inventory_complete = user_progress_data.get("inventory-review", {}).get("completed", False)
|
||||
|
||||
if ai_path_complete:
|
||||
if upload_complete and inventory_complete:
|
||||
# Validate sales data was imported
|
||||
smart_inventory_data = user_progress_data.get("smart-inventory-setup", {}).get("data", {})
|
||||
sales_import_result = smart_inventory_data.get("salesImportResult", {})
|
||||
has_sales_data_imported = (
|
||||
sales_import_result.get("records_created", 0) > 0 or
|
||||
sales_import_result.get("success", False) or
|
||||
sales_import_result.get("imported", False)
|
||||
upload_data = user_progress_data.get("upload-sales-data", {}).get("data", {})
|
||||
inventory_data = user_progress_data.get("inventory-review", {}).get("data", {})
|
||||
|
||||
# Check if sales data was processed
|
||||
has_sales_data = (
|
||||
upload_data.get("validationResult", {}).get("is_valid", False) or
|
||||
upload_data.get("aiSuggestions", []) or
|
||||
inventory_data.get("inventoryItemsCreated", 0) > 0
|
||||
)
|
||||
|
||||
if has_sales_data_imported:
|
||||
if has_sales_data:
|
||||
logger.info(f"ML training allowed for user {user_id}: AI path with sales data")
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user