feat: pump tracker, photo log, milk stock, medication profiles, calendar, reminders, audit log, edit events

New pages:
- /calendar — monthly grid with event dots, day detail on tap
- /medications — CRUD for medication profiles (presets + custom, dose/unit/intervals/crisis mode)
- /milk — milk stock management with location-based expiry, alerts, mark-as-used
- /reminders — recurring medication reminder CRUD with Pushover notifications

New APIs:
- /api/medication-profiles — profiles CRUD + last-intakes endpoint (auto-seeds 10 presets per family)
- /api/milk — milk stock CRUD with auto-calculated expiry
- /api/reminders + /api/reminders/check — reminder CRUD + cron-callable check endpoint
- /api/upload — multipart photo upload to public/uploads/
- /api/invite/send-email — email invitation with family invite link
- /api/admin/audit — last 100 audit log entries (superadmin only)

Event modal improvements:
- PUMP event type (side selector + volume + timer)
- MEDICATION: profile chip picker, next-dose timing status, crisis mode toggle
- Photo attachment (upload + thumbnail preview)
- Datetime inputs split into date + time (iOS Safari datetime-local fix)
- Edit mode via initialEvent prop (pre-fills all fields, saves via PATCH)
- Timer now shows h:mm:ss when >= 1 hour

Timeline:
- Modify button opens pre-filled edit modal per event
- Photo thumbnail in expanded view

Dashboard:
- PUMP in quick-log
- Medication status card (too-soon / available with next-dose time)

Schema additions: MedicationProfile, MedcationReminder, MilkStock, AuditLog models

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 15:01:38 +02:00
parent 091af949ee
commit 020539e2e2
31 changed files with 2206 additions and 63 deletions
+45 -8
View File
@@ -7,7 +7,9 @@ import { EventIcon } from "@/components/event-icon";
import { useBaby } from "@/contexts/baby-context";
import { format, isToday, isYesterday } from "date-fns";
import { fr } from "date-fns/locale";
import { Trash2, StickyNote } from "lucide-react";
import { Trash2, StickyNote, Pencil } from "lucide-react";
import Image from "next/image";
import { EventModal } from "@/components/event-modal";
interface Event {
id: string;
@@ -46,6 +48,12 @@ function getEventSummary(event: Event): string {
return side;
}
if (event.type === "BOTTLE") return [meta.volume ? `${meta.volume} mL` : "", meta.bottleType === "maternal" ? "maternel" : "artificiel"].filter(Boolean).join(" · ");
if (event.type === "PUMP") {
const side = meta.side === "left" ? "gauche" : meta.side === "right" ? "droite" : "les deux";
const parts = [meta.volume ? `${meta.volume} mL` : "", side];
if (event.endedAt) parts.unshift(formatDuration(new Date(event.startedAt), new Date(event.endedAt)));
return parts.filter(Boolean).join(" · ");
}
if (event.type === "DIAPER_STOOL") return String(meta.color ?? "");
if (event.type === "TEMPERATURE") return meta.value ? `${meta.value}°${meta.unit ?? "C"}` : "";
if (event.type === "MEDICATION") return String(meta.name ?? "");
@@ -60,6 +68,7 @@ export default function TimelinePage() {
const { selectedBaby } = useBaby();
const [expandedId, setExpandedId] = useState<string | null>(null);
const [editingNotes, setEditingNotes] = useState<{ id: string; notes: string } | null>(null);
const [editingEvent, setEditingEvent] = useState<Event | null>(null);
const [filterType, setFilterType] = useState<EventType | "">("");
const [page, setPage] = useState(0);
@@ -221,13 +230,28 @@ export default function TimelinePage() {
</button>
)}
<button
onClick={() => { if (confirm("Supprimer cet événement ?")) deleteEvent(ev.id); }}
className="flex items-center gap-1.5 text-xs text-red-400 hover:text-red-600 transition"
>
<Trash2 className="w-3.5 h-3.5" />
Supprimer
</button>
{ev.metadata?.photo && (
<div className="relative w-full h-48 rounded-xl overflow-hidden border border-slate-200 dark:border-slate-600">
<Image src={String(ev.metadata.photo)} alt="Photo" fill className="object-cover" unoptimized />
</div>
)}
<div className="flex items-center gap-3">
<button
onClick={() => { setEditingEvent(ev); setExpandedId(null); }}
className="flex items-center gap-1.5 text-xs text-slate-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition"
>
<Pencil className="w-3.5 h-3.5" />
Modifier
</button>
<button
onClick={() => { if (confirm("Supprimer cet événement ?")) deleteEvent(ev.id); }}
className="flex items-center gap-1.5 text-xs text-red-400 hover:text-red-600 transition"
>
<Trash2 className="w-3.5 h-3.5" />
Supprimer
</button>
</div>
</div>
)}
</div>
@@ -252,6 +276,19 @@ export default function TimelinePage() {
</div>
)}
</div>
{editingEvent && (
<EventModal
type={editingEvent.type}
babyId={selectedBaby!.id}
initialEvent={editingEvent}
onClose={() => setEditingEvent(null)}
onSaved={() => {
qc.invalidateQueries({ queryKey: ["events"] });
setEditingEvent(null);
}}
/>
)}
</div>
);
}