feat: Datumseingabe TT.MM.JJJJ (App) + Erinnerung an Folgeimpfung

Datum (found.md, iOS-Feedback): neue DateField-Komponente mit Ziffern-
tastatur und automatisch eingefügten Punkten (TT.MM.JJJJ) für Geburtstag,
Adoptionstag, Gewicht, Tierarzt und Impfungen. Parser akzeptiert weiter
"-" und "/" sowie einstellige Tage/Monate. Wheel-Picker bleibt in
PENDING-NATIVE-BUILD.md (natives Modul).

Impf-Erinnerung (found.md, iOS-Feedback): täglicher Cron
/api/cron/vaccine-reminders erinnert einmalig 30 Tage vor
Vaccine.nextDueDate per Mitteilung (VACCINE_DUE) + Push mit Impfname und
Datum. Schema: NotificationType.VACCINE_DUE, Notification.vaccineId
(Cascade), Vaccine.reminderSentAt (Claim gegen Doppelversand, wird bei
Fehler wieder freigegeben). Web + App zeigen die Mitteilung an, Tippen
öffnet die Gesundheitsseite. App: Schnellauswahl +1/+3 Jahre für den
Folgetermin plus Hinweis auf die Erinnerung.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-04 12:42:20 +02:00
1 parent 7169840000
commit c74bbffccb
20 files changed
+461 -44

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import type { TextInputProps } from "react-native";
import { TextField } from "./TextField";
import { formatDateInput } from "../lib/date-format";
const DISPLAY_DATE_LENGTH = 10; // DD.MM.YYYY
type DateFieldProps = Omit<TextInputProps, "onChangeText" | "keyboardType" | "maxLength"> & {
onChangeText: (value: string) => void;
};
/**
* Text date input with a DD.MM.YYYY mask: number pad only, the dots are
* inserted automatically (iOS' number pad has no "." key). A native wheel
* picker needs @react-native-community/datetimepicker → PENDING-NATIVE-BUILD.md.
*/
export function DateField({ onChangeText, ...props }: DateFieldProps) {
return (
<TextField
{...props}
keyboardType="number-pad"
maxLength={DISPLAY_DATE_LENGTH}
onChangeText={(text) => onChangeText(formatDateInput(text))}
/>
);
}
@@ -6,10 +6,14 @@ import { Plus, Trash2 } from "lucide-react-native";
import { useTRPC } from "../../api/trpc";
import { useTheme } from "../../context/ThemeContext";
import { TextField } from "../TextField";
import { DateField } from "../DateField";
import { Button } from "../Button";
import { Card } from "../Card";
import { getTypography, type ColorTokens, type Typography } from "../../theme/tokens";
import { displayDateToIso, todayAsDisplayDate } from "../../lib/date-format";
import { addYearsToDisplayDate, displayDateToIso, todayAsDisplayDate } from "../../lib/date-format";
/** Übliche Auffrisch-Intervalle (z. B. Tollwut 1–3 Jahre) als Schnellauswahl für den Folgetermin. */
const NEXT_DUE_PRESET_YEARS = [1, 3];
/** Port of web's health.ts vaccine CRUD — see health/page.tsx's Impfungen tab. */
export function VaccineSection({ petId }: { petId: string }) {
@@ -80,8 +84,24 @@ export function VaccineSection({ petId }: { petId: string }) {
{showForm && (
<Card style={styles.form}>
<TextField placeholder={t("health.vaccineNamePlaceholder")} value={name} onChangeText={setName} maxLength={100} />
<TextField placeholder={t("health.vaccineGivenPlaceholder")} value={dateGiven} onChangeText={setDateGiven} />
<TextField placeholder={t("health.vaccineNextDuePlaceholder")} value={nextDueDate} onChangeText={setNextDueDate} />
<DateField placeholder={t("health.vaccineGivenPlaceholder")} value={dateGiven} onChangeText={setDateGiven} />
<DateField placeholder={t("health.vaccineNextDuePlaceholder")} value={nextDueDate} onChangeText={setNextDueDate} />
<View style={styles.presetRow}>
{NEXT_DUE_PRESET_YEARS.map((years) => {
const suggestion = addYearsToDisplayDate(dateGiven, years);
return (
<Pressable
key={years}
style={[styles.preset, !suggestion && styles.presetDisabled]}
disabled={!suggestion}
onPress={() => suggestion && setNextDueDate(suggestion)}
>
<Text style={styles.presetText}>{t("health.vaccineNextDuePreset", { count: years })}</Text>
</Pressable>
);
})}
</View>
<Text style={styles.hint}>{t("health.vaccineReminderHint")}</Text>
<TextField placeholder={t("health.notesPlaceholder")} value={notes} onChangeText={setNotes} maxLength={200} />
<Button
title={addMutation.isPending ? "…" : t("common.save")}
@@ -134,5 +154,10 @@ function makeStyles(colors: ColorTokens) {
rowPrimary: { ...typography.body, fontFamily: typography.title.fontFamily },
rowSecondary: { ...typography.label, textTransform: "none", letterSpacing: 0 },
overdue: { color: colors.alertRed },
presetRow: { flexDirection: "row", gap: 8 },
preset: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 999, backgroundColor: colors.marigoldTint },
presetDisabled: { opacity: 0.4 },
presetText: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.ink },
hint: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.quietGray },
});
}
@@ -6,6 +6,7 @@ import { Plus, Trash2 } from "lucide-react-native";
import { useTRPC } from "../../api/trpc";
import { useTheme } from "../../context/ThemeContext";
import { TextField } from "../TextField";
import { DateField } from "../DateField";
import { Button } from "../Button";
import { Card } from "../Card";
import { getTypography, type ColorTokens, type Typography } from "../../theme/tokens";
@@ -72,7 +73,7 @@ export function VetVisitSection({ petId }: { petId: string }) {
{showForm && (
<Card style={styles.form}>
<TextField placeholder={t("health.weightDatePlaceholder")} value={date} onChangeText={setDate} />
<DateField placeholder={t("health.weightDatePlaceholder")} value={date} onChangeText={setDate} />
<TextField placeholder={t("health.vetReasonPlaceholder")} value={reason} onChangeText={setReason} maxLength={100} />
<TextField placeholder={t("health.vetNamePlaceholder")} value={vetName} onChangeText={setVetName} maxLength={100} />
<TextField placeholder={t("health.notesPlaceholder")} value={notes} onChangeText={setNotes} maxLength={500} multiline />
@@ -6,6 +6,7 @@ import { Plus, Trash2 } from "lucide-react-native";
import { useTRPC } from "../../api/trpc";
import { useTheme } from "../../context/ThemeContext";
import { TextField } from "../TextField";
import { DateField } from "../DateField";
import { Button } from "../Button";
import { Card } from "../Card";
import { getTypography, type ColorTokens, type Typography } from "../../theme/tokens";
@@ -65,7 +66,7 @@ export function WeightLogSection({ petId }: { petId: string }) {
{showForm && (
<Card style={styles.form}>
<TextField placeholder={t("health.weightDatePlaceholder")} value={date} onChangeText={setDate} />
<DateField placeholder={t("health.weightDatePlaceholder")} value={date} onChangeText={setDate} />
<TextField placeholder={t("health.weightKgPlaceholder")} value={weightKg} onChangeText={setWeightKg} keyboardType="decimal-pad" />
<TextField placeholder={t("health.notesPlaceholder")} value={notes} onChangeText={setNotes} maxLength={200} />
<Button
+10 -5
View File
@@ -66,7 +66,7 @@
"breedLabel": "Rasse",
"birthdayLabel": "Geburtstag (optional)",
"adoptedAtLabel": "Adoptionstag (optional)",
"invalidDate": "Bitte ein gültiges Datum im Format TT-MM-JJJJ eingeben oder leer lassen.",
"invalidDate": "Bitte ein gültiges Datum im Format TT.MM.JJJJ eingeben oder leer lassen.",
"deleteConfirmTitle": "Tier wirklich löschen?",
"deleteConfirmMessage": "{{name}} und alle zugehörigen Beiträge, Kommentare und Follower-Beziehungen werden unwiderruflich gelöscht.",
"deleteConfirmMessageFallback": "Dieses Tier",
@@ -139,19 +139,22 @@
"manageDesc": "Ein Widerruf löscht sofort und unwiderruflich alle Gesundheitsdaten dieses Haustiers.",
"revokeLink": "Widerrufen",
"weightTitle": "Gewicht",
"weightDatePlaceholder": "TT-MM-JJJJ",
"weightDatePlaceholder": "TT.MM.JJJJ",
"weightKgPlaceholder": "Gewicht (kg), z.B. 4,2",
"notesPlaceholder": "Notizen (optional)",
"weightEmpty": "Noch keine Gewichtseinträge",
"invalidDate": "Bitte ein gültiges Datum im Format TT-MM-JJJJ eingeben.",
"invalidDate": "Bitte ein gültiges Datum im Format TT.MM.JJJJ eingeben.",
"vetTitle": "Tierarzt",
"vetReasonPlaceholder": "Grund, z.B. Jahresuntersuchung",
"vetNamePlaceholder": "Tierarzt / Klinik (optional)",
"vetEmpty": "Noch keine Tierarztbesuche",
"vaccineTitle": "Impfungen",
"vaccineNamePlaceholder": "Impfstoff, z.B. Tollwut, DHPP",
"vaccineGivenPlaceholder": "Gegeben am (TT-MM-JJJJ)",
"vaccineNextDuePlaceholder": "Nächste Fälligkeit (optional, TT-MM-JJJJ)",
"vaccineGivenPlaceholder": "Gegeben am (TT.MM.JJJJ)",
"vaccineNextDuePlaceholder": "Nächste Fälligkeit (optional, TT.MM.JJJJ)",
"vaccineNextDuePreset_one": "+{{count}} Jahr",
"vaccineNextDuePreset_other": "+{{count}} Jahre",
"vaccineReminderHint": "Mit Folgetermin erinnern wir dich 30 Tage vorher.",
"vaccineEmpty": "Noch keine Impfungen eingetragen",
"vaccineGiven": "Gegeben {{date}}",
"vaccineDue": "Fällig {{date}}",
@@ -190,6 +193,8 @@
"moreActions": "Weitere Aktionen"
},
"notifications": {
"vaccineDue": "💉 Die Impfung „{{name}}“ ist am {{date}} fällig – Zeit, einen Termin zu vereinbaren.",
"vaccineDueGeneric": "💉 Eine Impfung wird bald fällig.",
"follow": "folgt dir jetzt.",
"reaction": "hat deinen Beitrag mit einer Pfote versehen.",
"comment": "hat deinen Beitrag kommentiert.",
+10 -5
View File
@@ -66,7 +66,7 @@
"breedLabel": "Breed",
"birthdayLabel": "Birthday (optional)",
"adoptedAtLabel": "Adoption date (optional)",
"invalidDate": "Please enter a valid date as DD-MM-YYYY, or leave it empty.",
"invalidDate": "Please enter a valid date as DD.MM.YYYY, or leave it empty.",
"deleteConfirmTitle": "Delete this pet?",
"deleteConfirmMessage": "{{name}} and all associated posts, comments, and follower relationships will be permanently deleted.",
"deleteConfirmMessageFallback": "This pet",
@@ -139,19 +139,22 @@
"manageDesc": "Revoking immediately and permanently deletes all health data for this pet.",
"revokeLink": "Revoke",
"weightTitle": "Weight",
"weightDatePlaceholder": "DD-MM-YYYY",
"weightDatePlaceholder": "DD.MM.YYYY",
"weightKgPlaceholder": "Weight (kg), e.g. 4.2",
"notesPlaceholder": "Notes (optional)",
"weightEmpty": "No weight entries yet",
"invalidDate": "Please enter a valid date in DD-MM-YYYY format.",
"invalidDate": "Please enter a valid date in DD.MM.YYYY format.",
"vetTitle": "Vet",
"vetReasonPlaceholder": "Reason, e.g. annual checkup",
"vetNamePlaceholder": "Vet / clinic (optional)",
"vetEmpty": "No vet visits yet",
"vaccineTitle": "Vaccinations",
"vaccineNamePlaceholder": "Vaccine, e.g. rabies, DHPP",
"vaccineGivenPlaceholder": "Given on (DD-MM-YYYY)",
"vaccineNextDuePlaceholder": "Next due (optional, DD-MM-YYYY)",
"vaccineGivenPlaceholder": "Given on (DD.MM.YYYY)",
"vaccineNextDuePlaceholder": "Next due (optional, DD.MM.YYYY)",
"vaccineNextDuePreset_one": "+{{count}} year",
"vaccineNextDuePreset_other": "+{{count}} years",
"vaccineReminderHint": "With a next due date, we'll remind you 30 days ahead.",
"vaccineEmpty": "No vaccinations recorded yet",
"vaccineGiven": "Given {{date}}",
"vaccineDue": "Due {{date}}",
@@ -190,6 +193,8 @@
"moreActions": "More actions"
},
"notifications": {
"vaccineDue": "💉 The \"{{name}}\" vaccination is due on {{date}} – time to book an appointment.",
"vaccineDueGeneric": "💉 A vaccination is due soon.",
"follow": "is now following you.",
"reaction": "pawed your post.",
"comment": "commented on your post.",
+40 -10
View File
@@ -1,25 +1,30 @@
/**
* The health forms take a free-text date field validated against the
* backend's strict `YYYY-MM-DD` regex (src/trpc/routers/health.ts). Typing
* dates in that order isn't the German convention (DD-MM-YYYY) — found.md:
* users typing the natural order got a validation error the mutations never
* surfaced (no onError handler), which looked exactly like "data isn't being
* saved". Both problems share one fix: accept DD-MM-YYYY in the UI, convert
* to ISO right before the mutation call, and reject anything that doesn't
* parse as a real calendar date instead of silently sending garbage.
* dates in that order isn't the German convention — found.md: users typing
* the natural order got a validation error the mutations never surfaced (no
* onError handler), which looked exactly like "data isn't being saved". Fix:
* accept DD.MM.YYYY in the UI, convert to ISO right before the mutation call,
* and reject anything that doesn't parse as a real calendar date instead of
* silently sending garbage.
*
* Display uses "." (found.md Neu7: "-" is unusual in German). Parsing still
* accepts "-" and "/" and one-digit day/month so older habits keep working.
*/
const DISPLAY_PATTERN = /^(\d{2})-(\d{2})-(\d{4})$/;
const DISPLAY_SEPARATOR = ".";
const DISPLAY_PATTERN = /^(\d{1,2})[.\-/](\d{1,2})[.\-/](\d{4})$/;
const ISO_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
const MAX_DATE_DIGITS = 8;
export function isoToDisplayDate(iso: string): string {
const match = ISO_PATTERN.exec(iso);
if (!match) return iso;
const [, year, month, day] = match;
return `${day}-${month}-${year}`;
return [day, month, year].join(DISPLAY_SEPARATOR);
}
/** Returns the equivalent `YYYY-MM-DD` string, or null if not a valid DD-MM-YYYY calendar date. */
/** Returns the equivalent `YYYY-MM-DD` string, or null if not a valid DD.MM.YYYY calendar date. */
export function displayDateToIso(display: string): string | null {
const match = DISPLAY_PATTERN.exec(display.trim());
if (!match) return null;
@@ -33,7 +38,32 @@ export function displayDateToIso(display: string): string | null {
date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
if (!isRealDate) return null;
return `${yearStr}-${monthStr}-${dayStr}`;
return `${yearStr}-${monthStr.padStart(2, "0")}-${dayStr.padStart(2, "0")}`;
}
/**
* Live mask for typing: keeps digits only and inserts the separators itself
* (so the number pad, which has no "." on iOS, is enough). A separator is only
* added once a following digit exists — otherwise backspace over "04." would
* immediately re-add the dot and the field would get stuck.
*/
export function formatDateInput(text: string): string {
const digits = text.replace(/\D/g, "").slice(0, MAX_DATE_DIGITS);
if (digits.length <= 2) return digits;
if (digits.length <= 4) return `${digits.slice(0, 2)}${DISPLAY_SEPARATOR}${digits.slice(2)}`;
return `${digits.slice(0, 2)}${DISPLAY_SEPARATOR}${digits.slice(2, 4)}${DISPLAY_SEPARATOR}${digits.slice(4)}`;
}
/**
* Folgetermin-Vorschlag „+1 / +3 Jahre“ für Impfungen. Null bei ungültigem
* Ausgangsdatum. 29.02. + 1 Jahr landet (wie Date selbst) auf dem 01.03.
*/
export function addYearsToDisplayDate(display: string, years: number): string | null {
const iso = displayDateToIso(display);
if (!iso) return null;
const [year, month, day] = iso.split("-").map(Number);
const shifted = new Date(Date.UTC(year + years, month - 1, day));
return isoToDisplayDate(shifted.toISOString().slice(0, 10));
}
export function todayAsDisplayDate(): string {