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:
1 parent
7169840000
commit
c74bbffccb
20 files changed
+461
-44
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user