| 1 | import type { TaskCheck } from "@g1t/contracts/tasks"; |
| 2 | |
| 3 | /** |
| 4 | * The box a `check-task` form names (components/markdown.tsx posts it): |
| 5 | * its number, its text as the page showed it, and whether to tick it. |
| 6 | * Anything else is left for the work service to refuse. |
| 7 | */ |
| 8 | export function taskCheckOf(form: FormData): TaskCheck { |
| 9 | const task = Number(form.get("task")); |
| 10 | const expected = String(form.get("expected") ?? ""); |
| 11 | return { |
| 12 | ...(Number.isInteger(task) && task > 0 ? { task } : {}), |
| 13 | ...(expected ? { expected } : {}), |
| 14 | checked: form.get("checked") === "1", |
| 15 | }; |
| 16 | } |