mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 00:12:18 +00:00
feat(medications): record scheduled doses automatically
This commit is contained in:
1 parent
5919a93c29
commit
c94e109bf0
37 files changed
+1105
-15
No files matched your search
@@ -197,6 +197,33 @@ export function Step8Summary({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* v1.42.2 — auto-mark-taken. Only meaningful while doses are due:
|
||||
hidden for as-needed and record-only medications. */}
|
||||
{payload.mode !== "asNeeded" && payload.trackIntake && (
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="space-y-1">
|
||||
<Label
|
||||
htmlFor="wizard-auto-mark-taken"
|
||||
className="text-sm font-medium"
|
||||
>
|
||||
{t("medications.autoMarkTaken.label")}
|
||||
</Label>
|
||||
<p className="text-muted-foreground text-xs">
|
||||
{t("medications.autoMarkTaken.helper")}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="wizard-auto-mark-taken"
|
||||
checked={payload.autoMarkTaken}
|
||||
onCheckedChange={(checked) =>
|
||||
applyPartial({ autoMarkTaken: checked })
|
||||
}
|
||||
data-slot="wizard-auto-mark-taken-toggle"
|
||||
aria-label={t("medications.autoMarkTaken.label")}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* v1.16.11 — an as-needed medication never reminds (no slots),
|
||||
so the reminders toggle is hidden alongside the schedules. */}
|
||||
{payload.mode !== "asNeeded" && payload.trackIntake && (
|
||||
|
||||
@@ -346,6 +346,11 @@ export interface WizardPayload {
|
||||
* schedule as a record: nothing due, no reminders, no adherence.
|
||||
*/
|
||||
trackIntake: boolean;
|
||||
/**
|
||||
* v1.42.2 — record each scheduled dose as taken automatically once its
|
||||
* time has passed. No reminder is sent while it is on.
|
||||
*/
|
||||
autoMarkTaken: boolean;
|
||||
/** Every parallel schedule under construction. Always >= 1 entry. */
|
||||
schedules: ScheduleDraft[];
|
||||
/** Which schedule Steps 5-7 currently edit. */
|
||||
@@ -395,6 +400,7 @@ export function emptyWizardPayload(): WizardPayload {
|
||||
endsOn: null,
|
||||
notificationsEnabled: true,
|
||||
trackIntake: true,
|
||||
autoMarkTaken: false,
|
||||
schedules: [draft],
|
||||
activeScheduleIndex: 0,
|
||||
};
|
||||
@@ -695,6 +701,12 @@ export interface CreateMedicationBody {
|
||||
* always tracks intake.
|
||||
*/
|
||||
trackIntake: boolean;
|
||||
/**
|
||||
* v1.42.2 — auto-mark-taken, sent on every create and edit (hydrated from
|
||||
* the stored value). The server stamps its floor only on an off→on flip,
|
||||
* so re-sending the stored value never moves it. Off for as-needed.
|
||||
*/
|
||||
autoMarkTaken: boolean;
|
||||
schedules: Array<{
|
||||
id?: string;
|
||||
windowStart: string;
|
||||
@@ -923,6 +935,8 @@ export function buildCreateBody(
|
||||
// medication kept as a record. Turning a medication into an as-needed
|
||||
// one means doses will be logged, so it tracks intake again.
|
||||
trackIntake: isAsNeeded ? true : committed.trackIntake,
|
||||
// An as-needed medication has no slot to record.
|
||||
autoMarkTaken: isAsNeeded ? false : committed.autoMarkTaken,
|
||||
schedules: draftsToEmit.map((draft) =>
|
||||
encodeScheduleDraft(draft, isOneShot),
|
||||
),
|
||||
@@ -1149,6 +1163,8 @@ export interface MedicationPayload {
|
||||
asNeeded?: boolean;
|
||||
/** v1.39.1 (#1033) — intake tracking; absent = tracked. */
|
||||
trackIntake?: boolean;
|
||||
/** v1.42.2 — auto-mark-taken; absent = off. */
|
||||
autoMarkTaken?: boolean;
|
||||
schedules: Array<{
|
||||
id?: string;
|
||||
windowStart: string;
|
||||
@@ -1301,6 +1317,7 @@ export function hydrateWizardPayload(
|
||||
endsOn: initial.endsOn,
|
||||
notificationsEnabled: initial.notificationsEnabled ?? true,
|
||||
trackIntake: initial.trackIntake !== false,
|
||||
autoMarkTaken: initial.autoMarkTaken === true,
|
||||
schedules: drafts,
|
||||
activeScheduleIndex: 0,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user