hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import type { HomeworkReportEntry } from "@/api/client"; |
| 2 | |
| 3 | const WEEK_MS = 7 * 24 * 60 * 60 * 1000; |
| 4 | |
| 5 | export type ChildHomeworkSummary = { |
| 6 | /** Past due and not handed in, most overdue first. */ |
| 7 | missing: HomeworkReportEntry[]; |
| 8 | /** Not handed in and due within the next seven days, soonest first. */ |
| 9 | dueSoon: HomeworkReportEntry[]; |
| 10 | }; |
| 11 | |
| 12 | /** A parent's view of a child's homework report: what is late and what is next. */ |
| 13 | export function summarizeChildHomework(entries: HomeworkReportEntry[], now: number): ChildHomeworkSummary { |
| 14 | return { |
| 15 | missing: entries.filter((entry) => entry.missing).sort((a, b) => a.due_at - b.due_at), |
| 16 | dueSoon: entries |
| 17 | .filter((entry) => !entry.submitted && !entry.missing && entry.due_at >= now && entry.due_at < now + WEEK_MS) |
| 18 | .sort((a, b) => a.due_at - b.due_at), |
| 19 | }; |
| 20 | } |