mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(vorsorge): drop trend strip, relative last-done, discreet due status
Remove the 7-day bar strip under the Vorsorge card last-done line and its backing component, query key, and i18n strings. Render the last-done value as a relative date (today / yesterday / absolute) through a shared relativeCalendarDate helper that reuses the medication today/yesterday keys. Show the next-due status as discreet coloured text - green today, orange overdue - leaving the card surface neutral.
This commit is contained in:
1 parent
a5b3715a46
commit
590b08286a
11 files changed
+69
-189
No files matched your search
@@ -47,3 +47,42 @@ export function formatRelativeTime(
|
||||
{ count: days },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* v1.18.9 — date-only relative label, shared with the medication card grammar.
|
||||
*
|
||||
* Buckets a calendar date against "now": same day → `medications.today`
|
||||
* ("Heute"), the day before → `medications.yesterday` ("Gestern"), otherwise
|
||||
* the absolute date through the caller's locale formatter. The today /
|
||||
* yesterday i18n keys are the SAME ones the medication card renders for its
|
||||
* last-taken line, so a Vorsorge "zuletzt erledigt" reads identically.
|
||||
*
|
||||
* Day-bucketing uses an `en-CA` (YYYY-MM-DD) day key — locale-independent and
|
||||
* string-comparable — formatted in the supplied IANA `timeZone` so the
|
||||
* boundary follows the user's zone, not the server's. `formatDate` renders the
|
||||
* absolute fallback (pass the locale `fmt.date`).
|
||||
*/
|
||||
export function relativeCalendarDate(
|
||||
iso: string,
|
||||
t: (key: string, params?: Record<string, string | number>) => string,
|
||||
formatDate: (value: Date) => string,
|
||||
timeZone?: string,
|
||||
): string {
|
||||
const target = new Date(iso);
|
||||
if (Number.isNaN(target.getTime())) return "";
|
||||
const dayFormatter = new Intl.DateTimeFormat("en-CA", {
|
||||
timeZone,
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
});
|
||||
const now = new Date();
|
||||
const yesterday = new Date(now);
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
const targetDay = dayFormatter.format(target);
|
||||
if (targetDay === dayFormatter.format(now)) return t("medications.today");
|
||||
if (targetDay === dayFormatter.format(yesterday))
|
||||
return t("medications.yesterday");
|
||||
return formatDate(target);
|
||||
}
|
||||
@@ -145,16 +145,6 @@ export const measurementKeys = {
|
||||
personalRecordsByMetric: (metric: string) =>
|
||||
["personal-records", "by-metric", metric] as const,
|
||||
|
||||
/**
|
||||
* v1.18.7 (Wave E) — bounded last-7 readings for one `MeasurementType`,
|
||||
* powering the discreet 7-day trend strip on a Vorsorge card. Rides under
|
||||
* the `["measurements"]` prefix so it lands in `measurementDependentKeys`
|
||||
* and a fresh reading (e.g. satisfying the very reminder) repaints the
|
||||
* strip. Keyed by type so each card caches its own thin window.
|
||||
*/
|
||||
measurementRecentValues: (type: string) =>
|
||||
["measurements", "recent-values", type] as const,
|
||||
|
||||
/**
|
||||
* v1.18.6 — batched dashboard daily series
|
||||
* (`GET /api/measurements/series-batch`). Shares the `chart-data`
|
||||
|
||||
Reference in new issue
Block a user