import { Result, ok, err } from '@shared/kernel/fp'; import { ValidIntake } from '../domain/intake.machine'; import { ApiClient } from '@shared/infrastructure/api-client'; import { problemDetail } from '@shared/infrastructure/api-error'; /** * Command: POST the intake questionnaire to the backend (`/api/intakes`). The * "uren must be > 0" rule now lives server-side; the backend returns a 422 * ProblemDetails on rejection, which we surface as the error. */ export async function submitIntake(client: ApiClient, data: ValidIntake): Promise> { try { await client.intakes({ uren: data.uren }); return ok(undefined); } catch (e) { return err(problemDetail(e, 'Het indienen is niet gelukt. Probeer het later opnieuw.')); } }