From 2b2a7db63c5c9b27bfdcb512c80cc0217be5e070 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Mon, 18 May 2026 21:37:24 +0200 Subject: [PATCH] feat(new): NewReportRoute wires forms + practitioner cache --- src/app/routes/NewReportRoute.tsx | 64 ++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/src/app/routes/NewReportRoute.tsx b/src/app/routes/NewReportRoute.tsx index 70880f83..db651781 100644 --- a/src/app/routes/NewReportRoute.tsx +++ b/src/app/routes/NewReportRoute.tsx @@ -1,3 +1,65 @@ +import { useEffect, useState } from 'react' +import { useNavigate } from 'react-router-dom' +import PractitionerForm from '@/components/report/PractitionerForm' +import AnimalForm from '@/components/report/AnimalForm' +import Brand from '@/components/brand/Brand' +import Button from '@/components/ui/Button' +import Input from '@/components/ui/Input' +import Label from '@/components/ui/Label' +import { todayIso } from '@/lib/dates' +import { readCachedPractitioner, writeCachedPractitioner } from '@/state/practitionerCache' +import { useReportStore } from '@/state/reportStore' + export default function NewReportRoute() { - return
NewReportRoute placeholder
+ const navigate = useNavigate() + const initReport = useReportStore((s) => s.initReport) + + const [practitioner, setPractitioner] = useState({ name: '' }) + const [animal, setAnimal] = useState({ speciesId: 'equine', name: '' }) + const [owner, setOwner] = useState({ name: '' }) + const [date, setDate] = useState(todayIso()) + + useEffect(() => { + const cached = readCachedPractitioner() + if (cached) setPractitioner(cached) + }, []) + + const canSubmit = practitioner.name.trim() && animal.name.trim() && owner.name.trim() + + function submit() { + if (!canSubmit) return + writeCachedPractitioner(practitioner) + initReport({ + date, + practitioner, + animal, + owner, + observations: [], + conclusion: '', + recommendations: '', + }) + navigate('/editor') + } + + return ( +
+
+ + +
+
+

Nouveau bilan

+
+ + setDate(e.target.value)} /> +
+ + +
+ + +
+
+
+ ) }