refactor(meds): wire the edit form through the v1.5 picker primitives

Drops the legacy weekday grid in favour of the cadence picker, the
times-of-day chips, and the course-window row. Pre-v1.5 medications
read-fall-back through inferCadenceFromLegacy; writes go to both
shapes so the v1.5.x dual-write window stays intact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-28 09:19:46 +02:00
1 parent a87a48a7c3
commit bb1a587f8b
4 files changed
+962 -340

No files matched your search

+33
View File
@@ -56,6 +56,14 @@ interface Schedule {
label: string | null;
dose: string | null;
daysOfWeek: string | null;
/** v1.5 — first-class times-of-day. */
timesOfDay?: string[];
/** v1.5 — RFC 5545 RRULE string for calendar-anchored cadences. */
rrule?: string | null;
/** v1.5 — flexible-rolling interval in days. */
rollingIntervalDays?: number | null;
/** v1.5 — reminder grace window in minutes. */
reminderGraceMinutes?: number | null;
}
interface Medication {
@@ -71,6 +79,12 @@ interface Medication {
notificationsEnabled: boolean;
pausedAt: string | null;
lastTakenAt: string | null;
/** v1.5 — medication-level course start date (ISO string). */
startsOn?: string | null;
/** v1.5 — medication-level course end date (ISO string). */
endsOn?: string | null;
/** v1.5 — single-administration medication. */
oneShot?: boolean;
schedules: Schedule[];
}
@@ -297,12 +311,31 @@ export default function MedicationsPage() {
dosesPerUnit: editingMed.dosesPerUnit ?? null,
active: editingMed.active,
notificationsEnabled: editingMed.notificationsEnabled,
// v1.5 — medication-level course window + one-shot
// flag. Pass-through so the form can hydrate the
// CourseWindowRow + oneShot Switch with the row's
// current values.
startsOn: editingMed.startsOn
? new Date(editingMed.startsOn)
: null,
endsOn: editingMed.endsOn
? new Date(editingMed.endsOn)
: null,
oneShot: editingMed.oneShot ?? false,
schedules: editingMed.schedules.map((s) => ({
windowStart: s.windowStart,
windowEnd: s.windowEnd,
label: s.label ?? "",
dose: s.dose ?? "",
...parseScheduleRecurrence(s.daysOfWeek),
// v1.5 — pass-through the new scheduling fields so
// the form can render the CadencePicker + chips in
// the row's actual cadence rather than the
// legacy-inferred fallback.
timesOfDay: s.timesOfDay,
rrule: s.rrule,
rollingIntervalDays: s.rollingIntervalDays,
reminderGraceMinutes: s.reminderGraceMinutes,
})),
}
: undefined