'use server'; import { Result } from '@/lib/contracts/Result'; import { CompleteOnboardingMutation, CompleteOnboardingCommand } from '@/lib/mutations/onboarding/CompleteOnboardingMutation'; import { revalidatePath } from 'next/cache'; import { routes } from '@/lib/routing/RouteConfig'; /** * Complete onboarding - thin wrapper around mutation * * Pattern: Server Action → Mutation → Service → API Client * * Authentication is handled automatically by the API via cookies. * The BaseApiClient includes credentials: 'include', so cookies are sent automatically. * If authentication fails, the API returns 401/403 which gets converted to domain errors. */ export async function completeOnboardingAction( input: CompleteOnboardingCommand ): Promise> { const mutation = new CompleteOnboardingMutation(); const result = await mutation.execute(input); if (result.isErr()) { return Result.err(result.getError()); } revalidatePath(routes.protected.dashboard); return Result.ok({ success: true }); }