Make backend robust with comprehensive onboarding steps
Backend Changes (services/auth/app/api/onboarding_progress.py): - Expanded ONBOARDING_STEPS to include all 19 frontend steps - Phase 0: user_registered (system) - Phase 1: bakery-type-selection, data-source-choice (discovery) - Phase 2: setup, smart-inventory-setup, product-categorization, initial-stock-entry (core setup & AI path) - Phase 2b: suppliers-setup, inventory-setup, recipes-setup, production-processes (manual path) - Phase 3: quality-setup, team-setup (advanced config) - Phase 4: ml-training, setup-review, completion (finalization) - Updated STEP_DEPENDENCIES with granular requirements - AI path: smart-inventory-setup → product-categorization → initial-stock-entry - Manual path: Independent setup for suppliers, inventory, recipes, processes - Flexible ML training: accepts either AI or manual inventory path - Enhanced ML training validation - Supports both AI-assisted path (sales data) and manual inventory path - More flexible validation logic for multi-path onboarding Frontend Changes (UnifiedOnboardingWizard.tsx): - Fixed auto-complete step name: 'suppliers' → 'suppliers-setup' - All step IDs now match backend ONBOARDING_STEPS exactly - Removed temporary step mapping workarounds Frontend Changes (apiClient.ts): - Fixed tenant ID requirement warnings for onboarding endpoints - Added noTenantEndpoints list for user-level endpoints: - /auth/me/onboarding (tenant created during onboarding) - /auth/me (user profile) - /auth/register, /auth/login - Eliminated false warnings during onboarding flow This makes the onboarding system fully functional with: ✅ Backend validates all 19 onboarding steps ✅ Proper dependency tracking for multi-path onboarding ✅ No more "Invalid step name" errors ✅ No more tenant ID warnings for onboarding ✅ Robust state tracking for complete user journey
This commit is contained in:
@@ -57,6 +57,7 @@ const OnboardingWizardContent: React.FC = () => {
|
||||
const wizardContext = useWizardContext();
|
||||
|
||||
// All possible steps with conditional visibility
|
||||
// All step IDs match backend ONBOARDING_STEPS exactly
|
||||
const ALL_STEPS: StepConfig[] = [
|
||||
// Phase 1: Discovery
|
||||
{
|
||||
@@ -368,19 +369,19 @@ const OnboardingWizardContent: React.FC = () => {
|
||||
// Special handling for smart-inventory-setup
|
||||
if (currentStep.id === 'smart-inventory-setup' && data?.shouldAutoCompleteSuppliers) {
|
||||
try {
|
||||
console.log('🔄 Auto-completing suppliers step...');
|
||||
console.log('🔄 Auto-completing suppliers-setup step...');
|
||||
await markStepCompleted.mutateAsync({
|
||||
userId: user.id,
|
||||
stepName: 'suppliers',
|
||||
stepName: 'suppliers-setup',
|
||||
data: {
|
||||
auto_completed: true,
|
||||
completed_at: new Date().toISOString(),
|
||||
source: 'inventory_creation_auto_completion',
|
||||
}
|
||||
});
|
||||
console.log('✅ Suppliers step auto-completed successfully');
|
||||
console.log('✅ Suppliers-setup step auto-completed successfully');
|
||||
} catch (supplierError) {
|
||||
console.warn('⚠️ Could not auto-complete suppliers step:', supplierError);
|
||||
console.warn('⚠️ Could not auto-complete suppliers-setup step:', supplierError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user