From 9271a79067b9a8a090d3d001235b2d89c044a855 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Mon, 18 May 2026 21:37:00 +0200 Subject: [PATCH] feat(home): HomeRoute with new + import PDF flows --- src/app/routes/HomeRoute.tsx | 65 +++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/app/routes/HomeRoute.tsx b/src/app/routes/HomeRoute.tsx index 76dd02aa..3fbc2d70 100644 --- a/src/app/routes/HomeRoute.tsx +++ b/src/app/routes/HomeRoute.tsx @@ -1,3 +1,66 @@ +import { useNavigate } from 'react-router-dom' +import { useRef, useState } from 'react' +import Brand from '@/components/brand/Brand' +import Button from '@/components/ui/Button' +import Card from '@/components/ui/Card' +import { useConfig } from '@/app/providers/ConfigProvider' +import { importReportFromPdf, ImportError } from '@/pdf/import' +import { useReportStore } from '@/state/reportStore' + export default function HomeRoute() { - return
HomeRoute placeholder
+ const navigate = useNavigate() + const cfg = useConfig() + const fileRef = useRef(null) + const hydrate = useReportStore((s) => s.hydrateReport) + const [error, setError] = useState(null) + const [busy, setBusy] = useState(false) + + async function onPickFile(e: React.ChangeEvent) { + const file = e.target.files?.[0] + if (!file) return + setBusy(true) + setError(null) + try { + const bytes = new Uint8Array(await file.arrayBuffer()) + const report = await importReportFromPdf(bytes) + hydrate(report) + navigate('/editor') + } catch (err) { + setError(err instanceof ImportError ? err.message : "Erreur de lecture du PDF.") + } finally { + setBusy(false) + if (fileRef.current) fileRef.current.value = '' + } + } + + return ( +
+
+ + {cfg.tagline} +
+
+
+ +

Nouveau bilan

+

+ Démarrer un nouveau bilan d'ostéopathie sur un animal. +

+ +
+ +

Importer un PDF

+

+ Reprendre un bilan précédent généré par cette application pour effectuer un suivi. +

+ + + {error &&

{error}

} +
+
+
+
+ ) }