/** * @ai-summary Mobile onboarding screen with multi-step wizard */ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { MobileContainer } from '../../../shared-minimal/components/mobile/MobileContainer'; import { GlassCard } from '../../../shared-minimal/components/mobile/GlassCard'; import { useSavePreferences, useCompleteOnboarding } from '../hooks/useOnboarding'; import { PreferencesStep } from '../components/PreferencesStep'; import { AddVehicleStep } from '../components/AddVehicleStep'; import { CompleteStep } from '../components/CompleteStep'; import { OnboardingStep, OnboardingPreferences } from '../types/onboarding.types'; import { CreateVehicleRequest } from '../../vehicles/types/vehicles.types'; import { vehiclesApi } from '../../vehicles/api/vehicles.api'; import toast from 'react-hot-toast'; export const OnboardingMobileScreen: React.FC = () => { const navigate = useNavigate(); const [currentStep, setCurrentStep] = useState('preferences'); const savePreferences = useSavePreferences(); const completeOnboarding = useCompleteOnboarding(); const [isAddingVehicle, setIsAddingVehicle] = useState(false); const stepNumbers: Record = { preferences: 1, vehicle: 2, complete: 3, }; const handleSavePreferences = async (data: OnboardingPreferences) => { try { await savePreferences.mutateAsync(data); setCurrentStep('vehicle'); } catch (error) { // Error is handled by the mutation hook } }; const handleAddVehicle = async (data: CreateVehicleRequest) => { setIsAddingVehicle(true); try { await vehiclesApi.create(data); toast.success('Vehicle added successfully'); setCurrentStep('complete'); } catch (error: any) { toast.error(error.response?.data?.error || 'Failed to add vehicle'); } finally { setIsAddingVehicle(false); } }; const handleSkipVehicle = () => { setCurrentStep('complete'); }; const handleComplete = async () => { try { await completeOnboarding.mutateAsync(); navigate('/garage'); } catch (error) { // Error is handled by the mutation hook } }; const handleBack = () => { if (currentStep === 'vehicle') { setCurrentStep('preferences'); } }; return (
{/* Header */}

Welcome to MotoVault Pro

Let's set up your account

{/* Progress Indicator */}
{(['preferences', 'vehicle', 'complete'] as OnboardingStep[]).map((step, index) => (
= stepNumbers[step] ? 'bg-primary-600 text-white dark:bg-primary-700 dark:text-white' : 'bg-gray-200 text-gray-500 dark:bg-gray-700 dark:text-gray-400' }`} > {stepNumbers[step]}
= stepNumbers[step] ? 'text-primary-600 dark:text-primary-400' : 'text-gray-500 dark:text-gray-400' }`} > {step === 'preferences' && 'Setup'} {step === 'vehicle' && 'Vehicle'} {step === 'complete' && 'Done'}
{index < 2 && (
stepNumbers[step] ? 'bg-primary-600 dark:bg-primary-700' : 'bg-gray-200 dark:bg-gray-700' }`} /> )} ))}
{/* Step Content */} {currentStep === 'preferences' && ( )} {currentStep === 'vehicle' && ( )} {currentStep === 'complete' && ( )}
); }; export default OnboardingMobileScreen;