/** * Onboarding Service - Mirror backend onboarding endpoints */ import { apiClient } from '../client'; import { UserProgress, UpdateStepRequest } from '../types/onboarding'; export class OnboardingService { private readonly baseUrl = '/users/me/onboarding'; async getUserProgress(userId: string): Promise { // Backend uses current user from auth token, so userId parameter is ignored return apiClient.get(`${this.baseUrl}/progress`); } async updateStep(userId: string, stepData: UpdateStepRequest): Promise { // Backend uses current user from auth token, so userId parameter is ignored return apiClient.put(`${this.baseUrl}/step`, stepData); } async markStepCompleted( userId: string, stepName: string, data?: Record ): Promise { // Backend uses current user from auth token, so userId parameter is ignored // Backend expects UpdateStepRequest format for completion return apiClient.put(`${this.baseUrl}/step`, { step_name: stepName, completed: true, data: data, }); } async resetProgress(userId: string): Promise { // Note: Backend doesn't have a reset endpoint, this might need to be implemented // For now, we'll throw an error throw new Error('Reset progress functionality not implemented in backend'); } async getStepDetails(stepName: string): Promise<{ name: string; description: string; dependencies: string[]; estimated_time_minutes: number; }> { // This endpoint doesn't exist in backend, we'll need to implement it or mock it throw new Error('getStepDetails functionality not implemented in backend'); } async getAllSteps(): Promise> { // This endpoint doesn't exist in backend, we'll need to implement it or mock it throw new Error('getAllSteps functionality not implemented in backend'); } async getNextStep(): Promise<{ step: string; completed?: boolean }> { // This endpoint exists in backend return apiClient.get(`${this.baseUrl}/next-step`); } async canAccessStep(stepName: string): Promise<{ can_access: boolean; reason?: string }> { // This endpoint exists in backend return apiClient.get(`${this.baseUrl}/can-access/${stepName}`); } async completeOnboarding(): Promise<{ success: boolean; message: string }> { // This endpoint exists in backend return apiClient.post(`${this.baseUrl}/complete`); } } export const onboardingService = new OnboardingService();