Work out the checkup due phrase on the same clock as the date beside it

The phrase read the device clock while the date printed under it read the profile clock. Set a laptop to another zone and the card could say a checkup was tomorrow above a date that was today. The zone is now something a caller has to state, and both screens state the one their dates are printed in.
This commit is contained in:
Marc-André Bombeck committed 2026-07-31 07:55:20 +02:00
1 parent c1b372de9c
commit e1ca6d9da2
5 files changed
+163 -83

No files matched your search

@@ -19,7 +19,7 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import { CalendarClock, CheckCircle2, Plus } from "lucide-react";
import { useTranslations } from "@/lib/i18n/context";
import { useTranslations, useDisplayTimezone } from "@/lib/i18n/context";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
@@ -50,6 +50,9 @@ function resolveLabel(
export function VorsorgeDashboardCard() {
const { t } = useTranslations();
// Issue #490 — the same profile zone the checkups page derives its due
// phrase in, so the two screens still agree when the device sits elsewhere.
const displayTz = useDisplayTimezone();
const router = useRouter();
const { data: reminders, isLoading } = useMeasurementReminders();
const { satisfy } = useMeasurementReminderMutations();
@@ -112,7 +115,7 @@ export function VorsorgeDashboardCard() {
) : (
<ul className="space-y-2">
{upcoming.map((reminder) => {
const due = relativeDueKey(reminder.nextDueAt, now);
const due = relativeDueKey(reminder.nextDueAt, now, displayTz);
const isLinked = reminder.measurementType != null;
const isScreening = isScreeningReminderType(
reminder.measurementType,
@@ -789,9 +789,12 @@ function VorsorgeCard({
const fmt = useFormatters();
// Issue #490 — day-boundary zone for the relative "today / yesterday"
// bucket must match the zone `fmt.date` renders in (mirror → Berlin).
// The next-due phrase reads off the SAME zone as the last-done date below
// it; they used to disagree by a day for anyone whose device sat in another
// zone from their profile.
const displayTz = useDisplayTimezone();
const [confirmDelete, setConfirmDelete] = useState(false);
const due = relativeDueKey(reminder.nextDueAt, now);
const due = relativeDueKey(reminder.nextDueAt, now, displayTz);
const cadence =
reminder.intervalDays != null
? t("measurementReminders.cadence.everyNDays", {