52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
|
|
/**
|
||
|
|
* Onboarding Service - Mirror backend onboarding endpoints
|
||
|
|
*/
|
||
|
|
import { apiClient } from '../client';
|
||
|
|
import { UserProgress, UpdateStepRequest } from '../types/onboarding';
|
||
|
|
|
||
|
|
export class OnboardingService {
|
||
|
|
private readonly baseUrl = '/onboarding';
|
||
|
|
|
||
|
|
async getUserProgress(userId: string): Promise<UserProgress> {
|
||
|
|
return apiClient.get<UserProgress>(`${this.baseUrl}/progress/${userId}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
async updateStep(userId: string, stepData: UpdateStepRequest): Promise<UserProgress> {
|
||
|
|
return apiClient.put<UserProgress>(`${this.baseUrl}/progress/${userId}/step`, stepData);
|
||
|
|
}
|
||
|
|
|
||
|
|
async markStepCompleted(
|
||
|
|
userId: string,
|
||
|
|
stepName: string,
|
||
|
|
data?: Record<string, any>
|
||
|
|
): Promise<UserProgress> {
|
||
|
|
return apiClient.post<UserProgress>(`${this.baseUrl}/progress/${userId}/complete`, {
|
||
|
|
step_name: stepName,
|
||
|
|
data: data,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
async resetProgress(userId: string): Promise<UserProgress> {
|
||
|
|
return apiClient.post<UserProgress>(`${this.baseUrl}/progress/${userId}/reset`);
|
||
|
|
}
|
||
|
|
|
||
|
|
async getStepDetails(stepName: string): Promise<{
|
||
|
|
name: string;
|
||
|
|
description: string;
|
||
|
|
dependencies: string[];
|
||
|
|
estimated_time_minutes: number;
|
||
|
|
}> {
|
||
|
|
return apiClient.get(`${this.baseUrl}/steps/${stepName}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
async getAllSteps(): Promise<Array<{
|
||
|
|
name: string;
|
||
|
|
description: string;
|
||
|
|
dependencies: string[];
|
||
|
|
estimated_time_minutes: number;
|
||
|
|
}>> {
|
||
|
|
return apiClient.get(`${this.baseUrl}/steps`);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export const onboardingService = new OnboardingService();
|