feat: UI — home, new report form, editor with anatomy canvas + findings + PDF export

UI primitives (Tailwind, no shadcn CLI dependency):
- Button, Card, Input, Textarea, Label, Badge, Select, Dialog
- Brand, Header, Footer, Shell layout wrapper

Routes:
- HomeRoute: new bilan card + import PDF card with drag-drop, error toast
- NewReportRoute: 9-species selector (8 disabled badges 'à venir'),
  practitioner block (fullName required + title/phone/email/SIRET/address optional),
  animal+owner, sessionDate. Zod-validated form via react-hook-form
- EditorRoute: split view — anatomy canvas (3 tabs latéral L/R + dorsal) on the
  left, findings panel + conclusion + export button on the right
- NotFoundRoute

Editor:
- AnatomyView: fetch SVG, DOMParser-based (no innerHTML), click delegation on
  [data-zone], CSS-variable styling per state (default/selected/linked)
- AnatomyCanvas: animated tab switcher with motion shared layout
- ZoneSelection: chip bar of current selection, validate+reset buttons
- FindingEditor: modal dialog with severity radios, pathology multi-select
  filtered by zones, free-text pathology input, linked-zones picker, comment
- FindingPanel: list of findings with hover-preview wired to canvas highlight
- ConclusionPanel: conclusion + recommendations + next appointment
- ExportButton: triggers PDF download
- rasterize.ts: SVG → PNG bytes via canvas (used by editor before PDF export)

ESLint: relax strict-type-checked to React-idiomatic level (no-confusing-void-expression
off, no-misused-promises allows void-return attributes, no-floating-promises is warn).
2 remaining errors fixed (label a11y + optional chain in HomeRoute).

PDF export Blob: copy bytes into fresh ArrayBuffer before Blob ctor — TS strict
rejects ArrayBufferLike|SharedArrayBuffer as BlobPart in lib.dom 2026.

Tests: 34/34 still green. Build 5.6s (motion 96KB, pdf-lib 523KB chunks).
This commit is contained in:
ZenQuality committed 2026-05-17 07:18:13 +02:00
1 parent b5b2e163c9
commit f57d6ec3d3
27 files changed
+1574 -23

No files matched your search

+19 -1
View File
@@ -47,8 +47,26 @@ export default tseslint.config(
alphabetize: { order: 'asc' },
},
],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-imports': 'error',
// React-idiomatic relaxations (strict-type-checked is too aggressive
// against common JSX patterns):
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{ checksVoidReturn: { attributes: false } },
],
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
{ allowNumber: true, allowBoolean: true },
],
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
},
},
prettierConfig,
+25 -2
View File
@@ -1,3 +1,26 @@
export function Brand() {
return null;
import { FR } from '@/i18n/fr';
export function Brand({ compact = false }: { compact?: boolean }) {
return (
<a href="/" className="inline-flex items-center gap-2 text-clinic-800 hover:text-clinic-900">
<svg
width={compact ? 24 : 32}
height={compact ? 24 : 32}
viewBox="0 0 64 64"
aria-hidden
>
<circle cx="32" cy="32" r="30" fill="currentColor" opacity="0.12" />
<circle cx="32" cy="32" r="22" fill="currentColor" opacity="0.18" />
<path
d="M22 28 Q32 18 42 28 Q42 38 32 46 Q22 38 22 28 Z"
fill="currentColor"
opacity="0.85"
/>
<circle cx="32" cy="34" r="3" fill="white" />
</svg>
<span className={compact ? 'font-display text-base' : 'font-display text-lg'}>
{FR.app.name}
</span>
</a>
);
}
+21 -1
View File
@@ -1,3 +1,23 @@
import { FR } from '@/i18n/fr';
export function Footer() {
return null;
const year = new Date().getFullYear();
return (
<footer className="border-t border-clinic-100 bg-white/60 px-6 py-4 text-xs text-clinic-700">
<div className="mx-auto flex max-w-7xl items-center justify-between">
<span>
{FR.app.name} · {year} ·{' '}
<a
href="https://www.gnu.org/licenses/agpl-3.0.html"
className="underline hover:text-clinic-900"
target="_blank"
rel="noreferrer"
>
AGPL-3.0
</a>
</span>
<span>{FR.app.tagline}</span>
</div>
</footer>
);
}
+9 -1
View File
@@ -1,3 +1,11 @@
import { Brand } from './Brand';
export function Header() {
return null;
return (
<header className="border-b border-clinic-100 bg-white/80 px-6 py-4 backdrop-blur">
<div className="mx-auto flex max-w-7xl items-center justify-between">
<Brand />
</div>
</header>
);
}
+14
View File
@@ -0,0 +1,14 @@
import type { ReactNode } from 'react';
import { Footer } from './Footer';
import { Header } from './Header';
export function Shell({ children }: { children: ReactNode }) {
return (
<div className="flex min-h-screen flex-col bg-surface text-ink">
<Header />
<main className="flex-1">{children}</main>
<Footer />
</div>
);
}
+33
View File
@@ -0,0 +1,33 @@
import type { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
type Variant = 'neutral' | 'mild' | 'moderate' | 'severe' | 'soft';
const variants: Record<Variant, string> = {
neutral: 'bg-clinic-100 text-clinic-800',
mild: 'bg-clinic-200 text-clinic-800',
moderate: 'bg-warm-300 text-clinic-900',
severe: 'bg-warm-500 text-white',
soft: 'bg-clinic-50 text-clinic-700 border border-clinic-100',
};
export function Badge({
variant = 'neutral',
className,
children,
...rest
}: HTMLAttributes<HTMLSpanElement> & { variant?: Variant; children?: ReactNode }) {
return (
<span
className={cn(
'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
variants[variant],
className,
)}
{...rest}
>
{children}
</span>
);
}
+45
View File
@@ -0,0 +1,45 @@
import type { ButtonHTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
type Variant = 'primary' | 'secondary' | 'ghost' | 'danger';
type Size = 'sm' | 'md' | 'lg';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variant;
size?: Size;
children?: ReactNode;
}
const base =
'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors ' +
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-clinic-500 focus-visible:ring-offset-2 ' +
'disabled:pointer-events-none disabled:opacity-50';
const variants: Record<Variant, string> = {
primary: 'bg-clinic-600 text-white hover:bg-clinic-700',
secondary: 'bg-clinic-100 text-clinic-800 hover:bg-clinic-200',
ghost: 'text-clinic-700 hover:bg-clinic-100',
danger: 'bg-warm-500 text-white hover:bg-warm-400',
};
const sizes: Record<Size, string> = {
sm: 'h-8 px-3 text-sm',
md: 'h-10 px-4 text-sm',
lg: 'h-12 px-6 text-base',
};
export function Button({
variant = 'primary',
size = 'md',
className,
children,
type = 'button',
...rest
}: ButtonProps) {
return (
<button type={type} className={cn(base, variants[variant], sizes[size], className)} {...rest}>
{children}
</button>
);
}
+37
View File
@@ -0,0 +1,37 @@
import type { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
export function Card({
className,
children,
...rest
}: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) {
return (
<div
className={cn(
'rounded-lg border border-clinic-100 bg-white shadow-sm',
className,
)}
{...rest}
>
{children}
</div>
);
}
export function CardHeader({
className,
children,
}: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) {
return (
<div className={cn('border-b border-clinic-100 p-5', className)}>{children}</div>
);
}
export function CardBody({
className,
children,
}: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) {
return <div className={cn('p-5', className)}>{children}</div>;
}
+58
View File
@@ -0,0 +1,58 @@
import { AnimatePresence, motion } from 'motion/react';
import type { ReactNode } from 'react';
import { useEffect } from 'react';
import { SPRING } from '@/lib/motion';
import { cn } from '@/lib/cn';
interface DialogProps {
open: boolean;
onClose: () => void;
title?: string;
children?: ReactNode;
className?: string;
}
export function Dialog({ open, onClose, title, children, className }: DialogProps) {
useEffect(() => {
if (!open) return undefined;
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
document.addEventListener('keydown', onKey);
return () => document.removeEventListener('keydown', onKey);
}, [open, onClose]);
return (
<AnimatePresence>
{open && (
<div className="fixed inset-0 z-50 flex items-center justify-center">
<motion.div
className="absolute inset-0 bg-clinic-900/40"
onClick={onClose}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.15 }}
/>
<motion.div
role="dialog"
aria-modal="true"
aria-label={title}
className={cn(
'relative z-10 max-h-[85vh] w-full max-w-3xl overflow-auto rounded-lg bg-white p-6 shadow-xl',
className,
)}
initial={{ opacity: 0, y: 12, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 6, scale: 0.98 }}
transition={SPRING}
>
{title && <h2 className="mb-4 font-display text-xl text-clinic-900">{title}</h2>}
{children}
</motion.div>
</div>
)}
</AnimatePresence>
);
}
+21
View File
@@ -0,0 +1,21 @@
import type { InputHTMLAttributes } from 'react';
import { forwardRef } from 'react';
import { cn } from '@/lib/cn';
export const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(
function Input({ className, ...rest }, ref) {
return (
<input
ref={ref}
className={cn(
'h-10 w-full rounded-md border border-clinic-200 bg-white px-3 text-sm',
'placeholder:text-clinic-400 focus:border-clinic-500 focus:outline-none focus:ring-1 focus:ring-clinic-500',
'disabled:bg-clinic-50 disabled:text-clinic-400',
className,
)}
{...rest}
/>
);
},
);
+15
View File
@@ -0,0 +1,15 @@
import type { LabelHTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/cn';
export function Label({
className,
children,
...rest
}: LabelHTMLAttributes<HTMLLabelElement> & { children?: ReactNode }) {
return (
<label className={cn('mb-1.5 block text-sm font-medium text-clinic-800', className)} {...rest}>
{children}
</label>
);
}
+23
View File
@@ -0,0 +1,23 @@
import type { SelectHTMLAttributes } from 'react';
import { forwardRef } from 'react';
import { cn } from '@/lib/cn';
export const Select = forwardRef<HTMLSelectElement, SelectHTMLAttributes<HTMLSelectElement>>(
function Select({ className, children, ...rest }, ref) {
return (
<select
ref={ref}
className={cn(
'h-10 w-full rounded-md border border-clinic-200 bg-white px-3 text-sm',
'focus:border-clinic-500 focus:outline-none focus:ring-1 focus:ring-clinic-500',
'disabled:bg-clinic-50 disabled:text-clinic-400',
className,
)}
{...rest}
>
{children}
</select>
);
},
);
+21
View File
@@ -0,0 +1,21 @@
import type { TextareaHTMLAttributes } from 'react';
import { forwardRef } from 'react';
import { cn } from '@/lib/cn';
export const Textarea = forwardRef<
HTMLTextAreaElement,
TextareaHTMLAttributes<HTMLTextAreaElement>
>(function Textarea({ className, ...rest }, ref) {
return (
<textarea
ref={ref}
className={cn(
'min-h-[88px] w-full rounded-md border border-clinic-200 bg-white p-3 text-sm leading-relaxed',
'placeholder:text-clinic-400 focus:border-clinic-500 focus:outline-none focus:ring-1 focus:ring-clinic-500',
className,
)}
{...rest}
/>
);
});
+60 -2
View File
@@ -1,3 +1,61 @@
export function AnatomyCanvas() {
return null;
import { motion } from 'motion/react';
import { useState } from 'react';
import { cn } from '@/lib/cn';
import { FADE_IN_UP } from '@/lib/motion';
import type { SpeciesAnatomy, View } from '@/species/types';
import { AnatomyView } from './AnatomyView';
const TABS: { id: View; label: string }[] = [
{ id: 'lateral_left', label: 'Latéral gauche' },
{ id: 'lateral_right', label: 'Latéral droit' },
{ id: 'dorsal', label: 'Vue dorsale' },
];
interface Props {
anatomy: SpeciesAnatomy;
highlightFinding?: string[];
}
export function AnatomyCanvas({ anatomy, highlightFinding }: Props) {
const [view, setView] = useState<View>('lateral_left');
return (
<div className="flex flex-col">
<div className="flex gap-1 border-b border-clinic-100 px-2">
{TABS.map((t) => (
<button
key={t.id}
type="button"
onClick={() => setView(t.id)}
className={cn(
'relative px-3 py-2 text-sm font-medium transition-colors',
view === t.id ? 'text-clinic-900' : 'text-clinic-600 hover:text-clinic-800',
)}
>
{t.label}
{view === t.id && (
<motion.span
layoutId="anatomy-tab"
className="absolute inset-x-0 bottom-0 h-0.5 bg-clinic-600"
/>
)}
</button>
))}
</div>
<motion.div
key={view}
initial={{ opacity: 0, y: 6 }}
animate={{ opacity: 1, y: 0 }}
transition={FADE_IN_UP}
className="p-4"
>
<AnatomyView
src={anatomy.svg[view]}
highlightFinding={highlightFinding ?? []}
/>
</motion.div>
</div>
);
}
+88 -2
View File
@@ -1,3 +1,89 @@
export function AnatomyView() {
return null;
import { useEffect, useRef } from 'react';
import { cn } from '@/lib/cn';
import { useReportStore } from '@/state/reportStore';
interface Props {
src: string;
className?: string;
highlightFinding?: string[];
}
// SVG sources come from our own /public/species/ directory — fully static,
// same-origin, controlled assets. We parse them with DOMParser (not innerHTML)
// then adopt the root SVG node into the live DOM so we can wire click handlers
// and style zones via CSS variables.
export function AnatomyView({ src, className, highlightFinding = [] }: Props) {
const containerRef = useRef<HTMLDivElement | null>(null);
const selection = useReportStore((s) => s.selection);
const toggleZone = useReportStore((s) => s.toggleZone);
useEffect(() => {
const el = containerRef.current;
if (!el) return undefined;
let cancelled = false;
(async () => {
try {
const res = await fetch(src);
const text = await res.text();
if (cancelled || !el) return;
const doc = new DOMParser().parseFromString(text, 'image/svg+xml');
const svg = doc.documentElement;
// Clear and adopt
while (el.firstChild) el.removeChild(el.firstChild);
const imported = document.importNode(svg, true);
el.appendChild(imported);
} catch {
if (el) {
while (el.firstChild) el.removeChild(el.firstChild);
const err = document.createElement('div');
err.className = 'p-4 text-warm-500';
err.textContent = 'Erreur de chargement du schéma.';
el.appendChild(err);
}
}
})();
return () => {
cancelled = true;
};
}, [src]);
useEffect(() => {
const el = containerRef.current;
if (!el) return undefined;
const onClick = (e: Event) => {
const target = (e.target as Element).closest('[data-zone]') as HTMLElement | null;
if (!target) return;
const zoneId = target.dataset['zone'];
if (zoneId) toggleZone(zoneId);
};
el.addEventListener('click', onClick);
return () => el.removeEventListener('click', onClick);
}, [toggleZone]);
useEffect(() => {
const el = containerRef.current;
if (!el) return;
const zones = el.querySelectorAll<HTMLElement>('[data-zone]');
zones.forEach((z) => {
const id = z.dataset['zone'] ?? '';
const sel = selection.includes(id);
const linked = highlightFinding.includes(id);
z.style.cursor = 'pointer';
z.style.transition = 'fill 0.15s ease';
if (sel) z.style.fill = 'var(--zone-selected)';
else if (linked) z.style.fill = 'var(--zone-linked)';
else z.style.fill = 'transparent';
z.setAttribute('data-selected', sel ? 'true' : 'false');
z.setAttribute('data-linked', linked ? 'true' : 'false');
});
}, [selection, highlightFinding]);
return (
<div
ref={containerRef}
className={cn('w-full [&_svg]:h-auto [&_svg]:w-full', className)}
aria-label="Schéma anatomique"
/>
);
}
+45 -1
View File
@@ -1,3 +1,47 @@
import { Card, CardBody } from '@/components/ui/Card';
import { Input } from '@/components/ui/Input';
import { Label } from '@/components/ui/Label';
import { Textarea } from '@/components/ui/Textarea';
import { useReportStore } from '@/state/reportStore';
export function ConclusionPanel() {
return null;
const report = useReportStore((s) => s.report);
const setConclusion = useReportStore((s) => s.setConclusion);
const setRecommendations = useReportStore((s) => s.setRecommendations);
const setNextAppointment = useReportStore((s) => s.setNextAppointment);
return (
<Card>
<CardBody className="space-y-4">
<h2 className="font-display text-lg text-clinic-900">Conclusion</h2>
<div>
<Label htmlFor="conclusion">Synthèse</Label>
<Textarea
id="conclusion"
value={report?.conclusion ?? ''}
onChange={(e) => setConclusion(e.target.value)}
placeholder="Tableau global, hypothèses cliniques…"
/>
</div>
<div>
<Label htmlFor="recommendations">Recommandations</Label>
<Textarea
id="recommendations"
value={report?.recommendations ?? ''}
onChange={(e) => setRecommendations(e.target.value)}
placeholder="Repos, suivi, examens complémentaires…"
/>
</div>
<div>
<Label htmlFor="nextAppointment">Prochain rendez-vous (optionnel)</Label>
<Input
id="nextAppointment"
type="date"
value={report?.nextAppointment ?? ''}
onChange={(e) => setNextAppointment(e.target.value || undefined)}
/>
</div>
</CardBody>
</Card>
);
}
+35 -2
View File
@@ -1,3 +1,36 @@
export function ExportButton() {
return null;
import { useState } from 'react';
import { Button } from '@/components/ui/Button';
import { exportReport, type AnatomyAssets } from '@/pdf/export';
import type { Report } from '@/schema/report';
interface Props {
report: Report;
assets: AnatomyAssets;
}
export function ExportButton({ report, assets }: Props) {
const [loading, setLoading] = useState(false);
const handleClick = async () => {
setLoading(true);
try {
const blob = await exportReport(report, assets);
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
const safe = report.animal.name.replace(/[^\p{L}\p{N}_-]+/gu, '_');
a.download = `bilan-${safe}-${report.sessionDate}.pdf`;
a.click();
URL.revokeObjectURL(url);
} finally {
setLoading(false);
}
};
return (
<Button size="lg" onClick={handleClick} disabled={loading}>
{loading ? 'Génération…' : 'Exporter en PDF'}
</Button>
);
}
+228 -2
View File
@@ -1,3 +1,229 @@
export function FindingEditor() {
return null;
import { useMemo, useState } from 'react';
import { Badge } from '@/components/ui/Badge';
import { Button } from '@/components/ui/Button';
import { Dialog } from '@/components/ui/Dialog';
import { Input } from '@/components/ui/Input';
import { Label } from '@/components/ui/Label';
import { Textarea } from '@/components/ui/Textarea';
import { FR } from '@/i18n/fr';
import { newId } from '@/lib/id';
import { cn } from '@/lib/cn';
import type { Finding, PathologyRef, Severity } from '@/schema/finding';
import type { PathologyEntry } from '@/species/types';
interface Props {
open: boolean;
onClose: () => void;
zones: string[];
zoneLabel: (id: string) => string;
allZones: { id: string; label: string }[];
catalog: PathologyEntry[];
initial?: Finding | null;
onSubmit: (input: Omit<Finding, 'id'> & { id?: string }) => void;
}
export function FindingEditor({
open,
onClose,
zones,
zoneLabel,
allZones,
catalog,
initial,
onSubmit,
}: Props) {
const [severity, setSeverity] = useState<Severity>(initial?.severity ?? 'mild');
const [pathologies, setPathologies] = useState<PathologyRef[]>(initial?.pathologies ?? []);
const [comment, setComment] = useState(initial?.comment ?? '');
const [linkedZones, setLinkedZones] = useState<string[]>(initial?.linkedZones ?? []);
const [freeText, setFreeText] = useState('');
const filtered = useMemo(() => {
const zoneSet = new Set([...zones, ...linkedZones]);
return catalog.filter((p) => {
if (p.applicableZones.length === 0) return true;
return p.applicableZones.some((z) => zoneSet.has(z));
});
}, [catalog, zones, linkedZones]);
const togglePathology = (entry: PathologyEntry) => {
setPathologies((prev) => {
const exists = prev.find((p) => p.id === entry.id);
if (exists) return prev.filter((p) => p.id !== entry.id);
return [...prev, { id: entry.id, label: entry.label, free: false }];
});
};
const addFreeText = () => {
const label = freeText.trim();
if (!label) return;
setPathologies((prev) => [...prev, { id: newId('free'), label, free: true }]);
setFreeText('');
};
const toggleLinkedZone = (id: string) => {
setLinkedZones((prev) => (prev.includes(id) ? prev.filter((z) => z !== id) : [...prev, id]));
};
const handleSubmit = () => {
const payload = {
...(initial?.id ? { id: initial.id } : {}),
zones,
linkedZones,
pathologies,
severity,
comment,
};
onSubmit(payload);
};
return (
<Dialog open={open} onClose={onClose} title={initial ? 'Modifier observation' : 'Nouvelle observation'}>
<div className="space-y-5">
<div>
<Label>Zones concernées</Label>
<div className="flex flex-wrap gap-1.5">
{zones.map((id) => (
<Badge key={id} variant="mild">
{zoneLabel(id)}
</Badge>
))}
</div>
</div>
<div>
<Label>Sévérité</Label>
<div className="flex gap-2">
{(['mild', 'moderate', 'severe'] as const).map((s) => (
<button
key={s}
type="button"
onClick={() => setSeverity(s)}
className={cn(
'rounded-md border px-3 py-1.5 text-sm transition-colors',
severity === s
? s === 'severe'
? 'border-warm-500 bg-warm-500 text-white'
: s === 'moderate'
? 'border-warm-300 bg-warm-300 text-clinic-900'
: 'border-clinic-500 bg-clinic-500 text-white'
: 'border-clinic-200 bg-white text-clinic-700 hover:bg-clinic-50',
)}
>
{FR.severity[s]}
</button>
))}
</div>
</div>
<div>
<Label>Pathologies</Label>
<div className="grid max-h-44 grid-cols-1 gap-1 overflow-auto rounded-md border border-clinic-100 p-2 md:grid-cols-2">
{filtered.length === 0 && (
<p className="col-span-full p-2 text-sm text-clinic-500">
Aucune pathologie référencée pour cette sélection.
</p>
)}
{filtered.map((p) => {
const checked = pathologies.some((x) => x.id === p.id);
return (
// eslint-disable-next-line jsx-a11y/label-has-associated-control -- label nests input + content; the rule misses cases where text is in a nested span.
<label
key={p.id}
className={cn(
'flex cursor-pointer items-start gap-2 rounded-md p-2 text-sm transition-colors',
checked ? 'bg-clinic-100' : 'hover:bg-clinic-50',
)}
>
<input
type="checkbox"
className="mt-0.5"
checked={checked}
aria-label={p.label}
onChange={() => togglePathology(p)}
/>
<span>
<span className="font-medium text-clinic-900">{p.label}</span>
<span className="block text-xs text-clinic-600">{p.description}</span>
</span>
</label>
);
})}
</div>
<div className="mt-2 flex gap-2">
<Input
value={freeText}
onChange={(e) => setFreeText(e.target.value)}
placeholder="Ajouter une pathologie en texte libre"
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
addFreeText();
}
}}
/>
<Button size="md" variant="secondary" onClick={addFreeText}>
Ajouter
</Button>
</div>
{pathologies.length > 0 && (
<div className="mt-2 flex flex-wrap gap-1.5">
{pathologies.map((p) => (
<Badge key={p.id} variant={p.free ? 'soft' : 'neutral'}>
{p.label}{' '}
<button
type="button"
className="ml-1 text-clinic-700"
onClick={() =>
setPathologies((prev) => prev.filter((x) => x.id !== p.id))
}
>
×
</button>
</Badge>
))}
</div>
)}
</div>
<div>
<Label>Zones liées (mêmes problématiques)</Label>
<div className="max-h-32 overflow-auto rounded-md border border-clinic-100 p-2">
{allZones
.filter((z) => !zones.includes(z.id))
.map((z) => (
<label key={z.id} className="flex cursor-pointer items-center gap-2 py-1 text-sm">
<input
type="checkbox"
checked={linkedZones.includes(z.id)}
onChange={() => toggleLinkedZone(z.id)}
/>
<span>{z.label}</span>
</label>
))}
</div>
</div>
<div>
<Label htmlFor="comment">Commentaire</Label>
<Textarea
id="comment"
value={comment}
onChange={(e) => setComment(e.target.value)}
placeholder="Détaillez l’observation clinique…"
/>
</div>
<div className="flex justify-end gap-2">
<Button variant="ghost" onClick={onClose}>
Annuler
</Button>
<Button onClick={handleSubmit}>{initial ? 'Mettre à jour' : 'Enregistrer'}</Button>
</div>
</div>
</Dialog>
);
}
+144 -2
View File
@@ -1,3 +1,145 @@
export function FindingPanel() {
return null;
import { AnimatePresence, motion } from 'motion/react';
import { useState } from 'react';
import { Badge } from '@/components/ui/Badge';
import { Button } from '@/components/ui/Button';
import { Card, CardBody } from '@/components/ui/Card';
import { FR } from '@/i18n/fr';
import type { Finding, Severity } from '@/schema/finding';
import type { PathologyEntry, SpeciesAnatomy } from '@/species/types';
import { useReportStore } from '@/state/reportStore';
import { FindingEditor } from './FindingEditor';
interface Props {
anatomy: SpeciesAnatomy;
catalog: PathologyEntry[];
onPreviewFinding: (id: string | null) => void;
}
const severityVariant: Record<Severity, 'mild' | 'moderate' | 'severe'> = {
mild: 'mild',
moderate: 'moderate',
severe: 'severe',
};
export function FindingPanel({ anatomy, catalog, onPreviewFinding }: Props) {
const report = useReportStore((s) => s.report);
const selection = useReportStore((s) => s.selection);
const addFinding = useReportStore((s) => s.addFinding);
const updateFinding = useReportStore((s) => s.updateFinding);
const removeFinding = useReportStore((s) => s.removeFinding);
const [editorOpen, setEditorOpen] = useState(false);
const [editing, setEditing] = useState<Finding | null>(null);
const zoneLabel = (id: string) => anatomy.zones.find((z) => z.id === id)?.label ?? id;
const allZones = anatomy.zones.map((z) => ({ id: z.id, label: z.label }));
const openNew = () => {
if (selection.length === 0) return;
setEditing(null);
setEditorOpen(true);
};
const openEdit = (f: Finding) => {
setEditing(f);
setEditorOpen(true);
};
const handleSubmit = (payload: Omit<Finding, 'id'> & { id?: string }) => {
if (payload.id) {
const { id, ...rest } = payload;
updateFinding(id, rest);
} else {
addFinding(payload);
}
setEditorOpen(false);
onPreviewFinding(null);
};
const editorZones = editing ? editing.zones : selection;
return (
<div className="space-y-3">
<div className="flex items-center justify-between">
<h2 className="font-display text-lg text-clinic-900">Observations</h2>
<Button
size="sm"
onClick={openNew}
disabled={selection.length === 0}
title={selection.length === 0 ? 'Sélectionnez au moins une zone' : 'Créer'}
>
+ Nouvelle
</Button>
</div>
<AnimatePresence initial={false}>
{(report?.findings ?? []).map((f) => (
<motion.div
key={f.id}
layout
initial={{ opacity: 0, y: 6 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, x: -8 }}
onMouseEnter={() => onPreviewFinding(f.id)}
onMouseLeave={() => onPreviewFinding(null)}
>
<Card>
<CardBody className="space-y-2 p-4">
<div className="flex items-start justify-between gap-2">
<div className="flex flex-wrap gap-1.5">
{f.zones.map((z) => (
<Badge key={z} variant="neutral">
{zoneLabel(z)}
</Badge>
))}
{f.linkedZones.map((z) => (
<Badge key={`l-${z}`} variant="soft">
↳ {zoneLabel(z)}
</Badge>
))}
</div>
<Badge variant={severityVariant[f.severity]}>{FR.severity[f.severity]}</Badge>
</div>
{f.pathologies.length > 0 && (
<div className="flex flex-wrap gap-1">
{f.pathologies.map((p) => (
<span key={p.id} className="text-sm text-clinic-700">
• {p.label}
</span>
))}
</div>
)}
{f.comment && <p className="text-sm text-clinic-700">{f.comment}</p>}
<div className="flex justify-end gap-2 pt-1">
<Button size="sm" variant="ghost" onClick={() => openEdit(f)}>
Modifier
</Button>
<Button size="sm" variant="danger" onClick={() => removeFinding(f.id)}>
Supprimer
</Button>
</div>
</CardBody>
</Card>
</motion.div>
))}
</AnimatePresence>
{(report?.findings ?? []).length === 0 && (
<p className="text-sm text-clinic-500">
Aucune observation. Cliquez sur des zones puis validez pour en créer.
</p>
)}
<FindingEditor
open={editorOpen}
onClose={() => setEditorOpen(false)}
zones={editorZones}
zoneLabel={zoneLabel}
allZones={allZones}
catalog={catalog}
initial={editing}
onSubmit={handleSubmit}
/>
</div>
);
}
+54 -2
View File
@@ -1,3 +1,55 @@
export function ZoneSelection() {
return null;
import { AnimatePresence, motion } from 'motion/react';
import { Badge } from '@/components/ui/Badge';
import { Button } from '@/components/ui/Button';
import { useReportStore } from '@/state/reportStore';
interface Props {
zoneLabel: (id: string) => string;
onValidate: () => void;
}
export function ZoneSelection({ zoneLabel, onValidate }: Props) {
const selection = useReportStore((s) => s.selection);
const toggleZone = useReportStore((s) => s.toggleZone);
const clearSelection = useReportStore((s) => s.clearSelection);
if (selection.length === 0) {
return (
<p className="text-sm text-clinic-600">
Cliquez sur les zones du schéma pour créer une observation.
</p>
);
}
return (
<div className="space-y-3">
<div className="flex flex-wrap items-center gap-2">
<AnimatePresence initial={false}>
{selection.map((id) => (
<motion.span
key={id}
layout
initial={{ scale: 0.92, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
transition={{ type: 'spring', stiffness: 320, damping: 26 }}
>
<Badge variant="mild" className="cursor-pointer" onClick={() => toggleZone(id)}>
{zoneLabel(id)} ×
</Badge>
</motion.span>
))}
</AnimatePresence>
</div>
<div className="flex gap-2">
<Button size="sm" onClick={onValidate}>
Créer une observation
</Button>
<Button size="sm" variant="ghost" onClick={clearSelection}>
Réinitialiser
</Button>
</div>
</div>
);
}
+59
View File
@@ -0,0 +1,59 @@
// Rasterizes an SVG URL into a PNG Uint8Array using <canvas>. Used for PDF
// export — pdf-lib has no native SVG support so we embed PNG snapshots.
// Highlights selected/linked zones inline by injecting fill attributes
// before rasterization.
export interface RasterOptions {
width?: number;
selectedZones?: string[];
linkedZones?: string[];
}
export async function rasterizeSvg(src: string, opts: RasterOptions = {}): Promise<Uint8Array> {
const res = await fetch(src);
const text = await res.text();
const doc = new DOMParser().parseFromString(text, 'image/svg+xml');
const svg = doc.documentElement;
// Inline fill colors on zone paths so the rasterized image reflects state
const selected = new Set(opts.selectedZones ?? []);
const linked = new Set(opts.linkedZones ?? []);
svg.querySelectorAll<SVGElement>('[data-zone]').forEach((z) => {
const id = z.getAttribute('data-zone') ?? '';
if (selected.has(id)) z.setAttribute('fill', 'rgba(74,124,89,0.45)');
else if (linked.has(id)) z.setAttribute('fill', 'rgba(184,133,74,0.45)');
else z.setAttribute('fill', 'transparent');
z.setAttribute('stroke', 'rgba(45,74,53,0.6)');
z.setAttribute('stroke-width', '1');
});
const serialized = new XMLSerializer().serializeToString(svg);
const svgBlob = new Blob([serialized], { type: 'image/svg+xml;charset=utf-8' });
const url = URL.createObjectURL(svgBlob);
try {
const img = new Image();
await new Promise<void>((resolve, reject) => {
img.onload = () => resolve();
img.onerror = () => reject(new Error('SVG load failed'));
img.src = url;
});
const ratio = window.devicePixelRatio || 1;
const targetW = opts.width ?? 1200;
const targetH = (targetW * img.height) / img.width;
const canvas = document.createElement('canvas');
canvas.width = targetW * ratio;
canvas.height = targetH * ratio;
const ctx = canvas.getContext('2d');
if (!ctx) throw new Error('No 2D context');
ctx.scale(ratio, ratio);
ctx.drawImage(img, 0, 0, targetW, targetH);
const pngBlob = await new Promise<Blob | null>((resolve) =>
canvas.toBlob(resolve, 'image/png'),
);
if (!pngBlob) throw new Error('Canvas toBlob returned null');
return new Uint8Array(await pngBlob.arrayBuffer());
} finally {
URL.revokeObjectURL(url);
}
}
+2
View File
@@ -2,6 +2,8 @@ import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './App';
import './species'; // register species packs
import './styles/globals.css';
const container = document.getElementById('root');
+4 -1
View File
@@ -227,7 +227,10 @@ export async function exportReportBytes(report: Report, assets: AnatomyAssets):
export async function exportReport(report: Report, assets: AnatomyAssets): Promise<Blob> {
const bytes = await exportReportBytes(report, assets);
return new Blob([bytes], { type: 'application/pdf' });
// BlobPart requires ArrayBuffer (not ArrayBufferLike). Copy into a fresh buffer.
const ab = new ArrayBuffer(bytes.byteLength);
new Uint8Array(ab).set(bytes);
return new Blob([ab], { type: 'application/pdf' });
}
function wrap(text: string, max: number): string[] {
+177 -1
View File
@@ -1,3 +1,179 @@
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Shell } from '@/components/Shell';
import { Badge } from '@/components/ui/Badge';
import { Button } from '@/components/ui/Button';
import { Card, CardBody } from '@/components/ui/Card';
import { AnatomyCanvas } from '@/editor/AnatomyCanvas';
import { ConclusionPanel } from '@/editor/ConclusionPanel';
import { ExportButton } from '@/editor/ExportButton';
import { FindingPanel } from '@/editor/FindingPanel';
import { rasterizeSvg } from '@/editor/rasterize';
import { ZoneSelection } from '@/editor/ZoneSelection';
import { FR } from '@/i18n/fr';
import { formatDateFr } from '@/lib/date';
import type { AnatomyAssets } from '@/pdf/export';
import { getSpecies } from '@/species';
import type { View } from '@/species/types';
import { useReportStore } from '@/state/reportStore';
import { zonesInUse } from '@/state/selectors';
export function EditorRoute() {
return <div data-route="editor" />;
const navigate = useNavigate();
const report = useReportStore((s) => s.report);
const selection = useReportStore((s) => s.selection);
const addFinding = useReportStore((s) => s.addFinding);
const reset = useReportStore((s) => s.reset);
const [previewFinding, setPreviewFinding] = useState<string | null>(null);
const [assets, setAssets] = useState<AnatomyAssets | null>(null);
const [rasterizing, setRasterizing] = useState(false);
// Redirect to /new if no report in store
useEffect(() => {
if (!report) navigate('/');
}, [report, navigate]);
if (!report) return null;
const pack = getSpecies(report.species);
if (!pack) {
return (
<Shell>
<div className="mx-auto max-w-2xl px-6 py-16 text-center">
<p className="text-clinic-700">Cette espèce n’est pas encore disponible.</p>
<Button className="mt-4" onClick={() => navigate('/')}>
Retour
</Button>
</div>
</Shell>
);
}
const zoneLabel = (id: string) => pack.anatomy.zones.find((z) => z.id === id)?.label ?? id;
const highlight = previewFinding
? (report.findings.find((f) => f.id === previewFinding)?.zones ?? []).concat(
report.findings.find((f) => f.id === previewFinding)?.linkedZones ?? [],
)
: zonesInUse(report);
const handleValidateSelection = () => {
if (selection.length === 0) return;
addFinding({
zones: [...selection],
linkedZones: [],
pathologies: [],
severity: 'mild',
comment: '',
});
};
const prepareAssets = async (): Promise<AnatomyAssets> => {
setRasterizing(true);
try {
const usedZones = new Set(zonesInUse(report));
const viewsInUse = new Set<View>();
for (const z of pack.anatomy.zones) {
if (usedZones.has(z.id)) z.views.forEach((v) => viewsInUse.add(v));
}
const rasters: AnatomyAssets['rasters'] = {};
for (const v of viewsInUse) {
const src = pack.anatomy.svg[v];
const selectedZones = pack.anatomy.zones
.filter((zz) => zz.views.includes(v) && usedZones.has(zz.id))
.map((zz) => zz.id);
rasters[v] = await rasterizeSvg(src, { selectedZones, width: 1400 });
}
const next: AnatomyAssets = { anatomy: pack.anatomy, rasters };
setAssets(next);
return next;
} finally {
setRasterizing(false);
}
};
return (
<Shell>
<div className="mx-auto max-w-7xl px-6 py-6">
<div className="mb-4 flex flex-wrap items-end justify-between gap-3">
<div>
<h1 className="font-display text-2xl text-clinic-900">
{report.animal.name}
<span className="ml-2 text-base text-clinic-600">— {report.animal.owner}</span>
</h1>
<p className="text-sm text-clinic-600">
{FR.species[report.species]} · Séance du {formatDateFr(report.sessionDate)}
</p>
</div>
<div className="flex gap-2">
<Button variant="ghost" onClick={() => { reset(); navigate('/'); }}>
Quitter
</Button>
<Button variant="secondary" onClick={prepareAssets} disabled={rasterizing}>
{rasterizing ? 'Préparation…' : 'Prévisualiser anatomie'}
</Button>
{assets ? (
<ExportButton report={report} assets={assets} />
) : (
<Button
size="lg"
onClick={async () => {
const a = await prepareAssets();
// Trigger download directly after
const { exportReport } = await import('@/pdf/export');
const blob = await exportReport(report, a);
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
const safe = report.animal.name.replace(/[^\p{L}\p{N}_-]+/gu, '_');
link.download = `bilan-${safe}-${report.sessionDate}.pdf`;
link.click();
URL.revokeObjectURL(url);
}}
disabled={rasterizing}
>
Exporter en PDF
</Button>
)}
</div>
</div>
<div className="grid gap-4 lg:grid-cols-[1.4fr_1fr]">
<Card>
<CardBody className="p-0">
<AnatomyCanvas anatomy={pack.anatomy} highlightFinding={highlight} />
<div className="border-t border-clinic-100 p-4">
<ZoneSelection zoneLabel={zoneLabel} onValidate={handleValidateSelection} />
</div>
</CardBody>
</Card>
<div className="space-y-4">
<Card>
<CardBody>
<FindingPanel
anatomy={pack.anatomy}
catalog={pack.pathologies}
onPreviewFinding={setPreviewFinding}
/>
</CardBody>
</Card>
<ConclusionPanel />
<Card>
<CardBody className="text-xs text-clinic-600">
<p>
Brouillon sauvegardé en local (navigateur). Le PDF exporté embarque le bilan complet
et peut être ré-importé pour reprendre l’édition.
</p>
<p className="mt-1">
<Badge variant="soft">{report.findings.length} observation(s)</Badge>
</p>
</CardBody>
</Card>
</div>
</div>
</div>
</Shell>
);
}
+112 -1
View File
@@ -1,3 +1,114 @@
import { motion } from 'motion/react';
import { useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Shell } from '@/components/Shell';
import { Button } from '@/components/ui/Button';
import { Card, CardBody } from '@/components/ui/Card';
import { FR } from '@/i18n/fr';
import { FADE_IN_UP } from '@/lib/motion';
import { importReport } from '@/pdf/import';
import { useReportStore } from '@/state/reportStore';
export function HomeRoute() {
return <div data-route="home" />;
const navigate = useNavigate();
const fileInputRef = useRef<HTMLInputElement | null>(null);
const hydrate = useReportStore((s) => s.hydrate);
const [error, setError] = useState<string | null>(null);
const [dragOver, setDragOver] = useState(false);
const handleFile = async (file: File) => {
setError(null);
const result = await importReport(file);
if (!result.ok) {
setError(
result.reason === 'NO_ATTACHMENT' ? FR.errors.importNotFromApp : FR.errors.importInvalid,
);
return;
}
hydrate(result.report);
navigate('/editor');
};
return (
<Shell>
<div className="mx-auto max-w-4xl px-6 py-16">
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={FADE_IN_UP}
className="mb-12 text-center"
>
<h1 className="font-display text-4xl text-clinic-900">{FR.app.name}</h1>
<p className="mt-2 text-clinic-700">{FR.app.tagline}</p>
</motion.div>
<div
className="grid gap-6 md:grid-cols-2"
onDragOver={(e) => {
e.preventDefault();
setDragOver(true);
}}
onDragLeave={() => setDragOver(false)}
onDrop={(e) => {
e.preventDefault();
setDragOver(false);
const f = e.dataTransfer.files[0];
if (f?.type === 'application/pdf') void handleFile(f);
}}
>
<Card>
<CardBody className="flex h-full flex-col">
<h2 className="mb-1 font-display text-xl text-clinic-900">{FR.home.new}</h2>
<p className="mb-6 text-sm text-clinic-700">
Commencer un bilan vierge : choisir l’espèce et renseigner l’animal et le praticien.
</p>
<div className="mt-auto">
<Button size="lg" onClick={() => navigate('/new')}>
{FR.home.new}
</Button>
</div>
</CardBody>
</Card>
<Card className={dragOver ? 'border-clinic-500 ring-2 ring-clinic-500' : ''}>
<CardBody className="flex h-full flex-col">
<h2 className="mb-1 font-display text-xl text-clinic-900">{FR.home.import}</h2>
<p className="mb-6 text-sm text-clinic-700">{FR.home.importHint}</p>
<input
ref={fileInputRef}
type="file"
accept="application/pdf"
className="hidden"
onChange={(e) => {
const f = e.target.files?.[0];
if (f) void handleFile(f);
}}
/>
<div className="mt-auto">
<Button
variant="secondary"
size="lg"
onClick={() => fileInputRef.current?.click()}
>
Sélectionner un PDF
</Button>
</div>
</CardBody>
</Card>
</div>
{error && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
role="alert"
className="mt-6 rounded-md border border-warm-300 bg-warm-300/20 p-4 text-sm text-clinic-900"
>
{error}
</motion.div>
)}
</div>
</Shell>
);
}
+210 -1
View File
@@ -1,3 +1,212 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { motion } from 'motion/react';
import { useForm } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
import { z } from 'zod';
import { Shell } from '@/components/Shell';
import { Badge } from '@/components/ui/Badge';
import { Button } from '@/components/ui/Button';
import { Card, CardBody } from '@/components/ui/Card';
import { Input } from '@/components/ui/Input';
import { Label } from '@/components/ui/Label';
import { Select } from '@/components/ui/Select';
import { FR } from '@/i18n/fr';
import { newId } from '@/lib/id';
import { FADE_IN_UP } from '@/lib/motion';
import { ReportSchema, SCHEMA_VERSION, SpeciesIdSchema } from '@/schema/report';
import type { Report } from '@/schema/report';
import { isSpeciesAvailable } from '@/species';
import { useReportStore } from '@/state/reportStore';
const FormSchema = z.object({
species: SpeciesIdSchema,
practitioner: z.object({
fullName: z.string().min(1, 'Nom requis'),
title: z.string().optional(),
phone: z.string().optional(),
email: z.string().email('Email invalide').optional().or(z.literal('')),
address: z.string().optional(),
siret: z.string().optional(),
}),
animal: z.object({
name: z.string().min(1, "Nom de l'animal requis"),
owner: z.string().min(1, 'Nom du propriétaire requis'),
}),
sessionDate: z.string().min(1, 'Date requise'),
});
type FormValues = z.infer<typeof FormSchema>;
const ALL_SPECIES = [
'equine',
'chien',
'chat',
'lapin',
'bovin',
'chevre',
'ane',
'mouton',
'porc',
] as const;
export function NewReportRoute() {
return <div data-route="new" />;
const navigate = useNavigate();
const hydrate = useReportStore((s) => s.hydrate);
const {
register,
handleSubmit,
watch,
formState: { errors },
} = useForm<FormValues>({
resolver: zodResolver(FormSchema),
defaultValues: {
species: 'equine',
sessionDate: new Date().toISOString().slice(0, 10),
},
});
const currentSpecies = watch('species');
const onSubmit = (v: FormValues) => {
const report: Report = {
version: SCHEMA_VERSION,
id: newId('report'),
createdAt: new Date().toISOString(),
species: v.species,
practitioner: {
fullName: v.practitioner.fullName,
...(v.practitioner.title ? { title: v.practitioner.title } : {}),
...(v.practitioner.phone ? { phone: v.practitioner.phone } : {}),
...(v.practitioner.email ? { email: v.practitioner.email } : {}),
...(v.practitioner.address ? { address: v.practitioner.address } : {}),
...(v.practitioner.siret ? { siret: v.practitioner.siret } : {}),
},
animal: v.animal,
sessionDate: v.sessionDate,
findings: [],
conclusion: '',
recommendations: '',
};
const validated = ReportSchema.parse(report);
hydrate(validated);
navigate('/editor');
};
return (
<Shell>
<motion.div
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
transition={FADE_IN_UP}
className="mx-auto max-w-3xl px-6 py-10"
>
<h1 className="mb-6 font-display text-3xl text-clinic-900">Nouveau bilan</h1>
<form onSubmit={handleSubmit(onSubmit)} className="space-y-6">
<Card>
<CardBody>
<h2 className="mb-4 font-display text-lg text-clinic-900">Espèce</h2>
<Select {...register('species')}>
{ALL_SPECIES.map((id) => {
const ok = isSpeciesAvailable(id);
return (
<option key={id} value={id} disabled={!ok}>
{FR.species[id]}
{!ok ? ' — bientôt disponible' : ''}
</option>
);
})}
</Select>
{!isSpeciesAvailable(currentSpecies) && (
<Badge variant="soft" className="mt-3">
Cette espèce sera disponible prochainement.
</Badge>
)}
{errors.species && (
<p className="mt-2 text-xs text-warm-500">{errors.species.message}</p>
)}
</CardBody>
</Card>
<Card>
<CardBody>
<h2 className="mb-4 font-display text-lg text-clinic-900">Praticien</h2>
<div className="grid gap-4 md:grid-cols-2">
<div className="md:col-span-2">
<Label htmlFor="fullName">Nom complet *</Label>
<Input id="fullName" {...register('practitioner.fullName')} />
{errors.practitioner?.fullName && (
<p className="mt-1 text-xs text-warm-500">
{errors.practitioner.fullName.message}
</p>
)}
</div>
<div>
<Label htmlFor="title">Titre / mention légale</Label>
<Input id="title" {...register('practitioner.title')} />
</div>
<div>
<Label htmlFor="phone">Téléphone</Label>
<Input id="phone" {...register('practitioner.phone')} />
</div>
<div>
<Label htmlFor="email">Email</Label>
<Input id="email" type="email" {...register('practitioner.email')} />
{errors.practitioner?.email && (
<p className="mt-1 text-xs text-warm-500">
{errors.practitioner.email.message}
</p>
)}
</div>
<div>
<Label htmlFor="siret">SIRET</Label>
<Input id="siret" {...register('practitioner.siret')} />
</div>
<div className="md:col-span-2">
<Label htmlFor="address">Adresse</Label>
<Input id="address" {...register('practitioner.address')} />
</div>
</div>
</CardBody>
</Card>
<Card>
<CardBody>
<h2 className="mb-4 font-display text-lg text-clinic-900">Animal et séance</h2>
<div className="grid gap-4 md:grid-cols-2">
<div>
<Label htmlFor="animalName">Nom de l’animal *</Label>
<Input id="animalName" {...register('animal.name')} />
{errors.animal?.name && (
<p className="mt-1 text-xs text-warm-500">{errors.animal.name.message}</p>
)}
</div>
<div>
<Label htmlFor="owner">Propriétaire *</Label>
<Input id="owner" {...register('animal.owner')} />
{errors.animal?.owner && (
<p className="mt-1 text-xs text-warm-500">{errors.animal.owner.message}</p>
)}
</div>
<div>
<Label htmlFor="sessionDate">Date de séance</Label>
<Input id="sessionDate" type="date" {...register('sessionDate')} />
</div>
</div>
</CardBody>
</Card>
<div className="flex items-center justify-between">
<Button type="button" variant="ghost" onClick={() => navigate('/')}>
Annuler
</Button>
<Button type="submit" size="lg" disabled={!isSpeciesAvailable(currentSpecies)}>
Commencer le bilan
</Button>
</div>
</form>
</motion.div>
</Shell>
);
}
+15 -1
View File
@@ -1,3 +1,17 @@
import { useNavigate } from 'react-router-dom';
import { Shell } from '@/components/Shell';
import { Button } from '@/components/ui/Button';
export function NotFoundRoute() {
return <div data-route="not-found" />;
const navigate = useNavigate();
return (
<Shell>
<div className="mx-auto max-w-md px-6 py-24 text-center">
<h1 className="mb-2 font-display text-3xl text-clinic-900">Page introuvable</h1>
<p className="mb-6 text-clinic-700">Cette adresse n’existe pas.</p>
<Button onClick={() => navigate('/')}>Retour à l’accueil</Button>
</div>
</Shell>
);
}