Initial commit — Grow baby tracker

Next.js 16 App Router, Prisma + PostgreSQL, NextAuth v5 JWT.

Features: dashboard quick-log, timeline, growth charts (WHO percentiles),
stats, journal/notes, doctor notes, milestones, vaccinations, settings,
superadmin panel. Mobile-first with sidebar nav + bottom nav + quick-add FAB.
Dark mode, PWA push notifications, multi-family invite system.

Docker: multi-stage Dockerfile + docker-compose with postgres service.
This commit is contained in:
2026-06-13 01:52:46 +02:00
commit cd16c354c0
94 changed files with 14354 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
export async function PATCH(
req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const session = await auth();
if (!session?.user?.id)
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const role = (session.user as { role?: string }).role;
if (role === "READONLY") {
return NextResponse.json({ error: "Accès en lecture seule" }, { status: 403 });
}
const { id } = await params;
const body = await req.json();
const vaccination = await prisma.vaccination.update({
where: { id },
data: {
...(body.name !== undefined ? { name: body.name } : {}),
...(body.date !== undefined
? { date: body.date ? new Date(body.date) : null }
: {}),
...(body.dueDate !== undefined
? { dueDate: body.dueDate ? new Date(body.dueDate) : null }
: {}),
...(body.notes !== undefined ? { notes: body.notes } : {}),
...(body.done !== undefined ? { done: body.done } : {}),
},
});
return NextResponse.json(vaccination);
}
export async function DELETE(
_req: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const session = await auth();
if (!session?.user?.id)
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const role = (session.user as { role?: string }).role;
if (role === "READONLY") {
return NextResponse.json({ error: "Accès en lecture seule" }, { status: 403 });
}
const { id } = await params;
await prisma.vaccination.delete({ where: { id } });
return new NextResponse(null, { status: 204 });
}
+56
View File
@@ -0,0 +1,56 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
export async function GET(req: Request) {
const session = await auth();
if (!session?.user?.id)
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const { searchParams } = new URL(req.url);
const babyId = searchParams.get("babyId");
if (!babyId)
return NextResponse.json({ error: "babyId requis" }, { status: 400 });
const vaccinations = await prisma.vaccination.findMany({
where: { babyId },
orderBy: [{ dueDate: "asc" }, { date: "asc" }],
});
// Move nulls last for dueDate
const withDue = vaccinations.filter((v) => v.dueDate !== null);
const withoutDue = vaccinations.filter((v) => v.dueDate === null);
return NextResponse.json([...withDue, ...withoutDue]);
}
export async function POST(req: Request) {
const session = await auth();
if (!session?.user?.id)
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
const role = (session.user as { role?: string }).role;
if (role === "READONLY") {
return NextResponse.json({ error: "Accès en lecture seule" }, { status: 403 });
}
const body = await req.json();
const { babyId, name, date, dueDate, notes } = body;
if (!babyId || !name) {
return NextResponse.json({ error: "Champs requis manquants" }, { status: 400 });
}
const vaccination = await prisma.vaccination.create({
data: {
babyId,
name,
date: date ? new Date(date) : null,
dueDate: dueDate ? new Date(dueDate) : null,
notes: notes ?? null,
},
});
return NextResponse.json(vaccination, { status: 201 });
}