clean all
This commit is contained in:
1 parent
f57d6ec3d3
commit
27afb719f5
101 files changed
+45
-14426
No files matched your search
-19
@@ -1,19 +0,0 @@
|
||||
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
||||
|
||||
import { EditorRoute } from './routes/EditorRoute';
|
||||
import { HomeRoute } from './routes/HomeRoute';
|
||||
import { NewReportRoute } from './routes/NewReportRoute';
|
||||
import { NotFoundRoute } from './routes/NotFoundRoute';
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<HomeRoute />} />
|
||||
<Route path="/new" element={<NewReportRoute />} />
|
||||
<Route path="/editor" element={<EditorRoute />} />
|
||||
<Route path="*" element={<NotFoundRoute />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { FR } from '@/i18n/fr';
|
||||
|
||||
export function Footer() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { Brand } from './Brand';
|
||||
|
||||
export function Header() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,33 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
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>;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
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}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -1,15 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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>
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -1,21 +0,0 @@
|
||||
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}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@@ -1,61 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
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"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
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() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,229 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export function ZoomOverlay() {
|
||||
return null;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,32 +0,0 @@
|
||||
export const FR = {
|
||||
app: {
|
||||
name: 'Osteo Report',
|
||||
tagline: 'Bilans ostéopathiques vétérinaires',
|
||||
},
|
||||
home: {
|
||||
new: 'Nouveau bilan',
|
||||
import: 'Importer un PDF existant',
|
||||
importHint: 'Glissez un PDF généré par cette application',
|
||||
},
|
||||
species: {
|
||||
chien: 'Chien',
|
||||
chat: 'Chat',
|
||||
equine: 'Cheval',
|
||||
lapin: 'Lapin',
|
||||
bovin: 'Bovin',
|
||||
chevre: 'Chèvre',
|
||||
ane: 'Âne',
|
||||
mouton: 'Mouton',
|
||||
porc: 'Porc',
|
||||
} as Record<string, string>,
|
||||
severity: {
|
||||
mild: 'Légère',
|
||||
moderate: 'Modérée',
|
||||
severe: 'Sévère',
|
||||
} as Record<string, string>,
|
||||
errors: {
|
||||
importNotFromApp:
|
||||
"Ce PDF n'a pas été généré par cette application. L'import est impossible.",
|
||||
importInvalid: "Le contenu du PDF n'a pas pu être lu.",
|
||||
},
|
||||
} as const;
|
||||
@@ -1,6 +0,0 @@
|
||||
import { clsx, type ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
export function cn(...inputs: ClassValue[]): string {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { format, parseISO } from 'date-fns';
|
||||
import { fr } from 'date-fns/locale';
|
||||
|
||||
export function formatDateFr(iso: string): string {
|
||||
return format(parseISO(iso), 'd MMMM yyyy', { locale: fr });
|
||||
}
|
||||
|
||||
export function todayIso(): string {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export function newId(prefix?: string): string {
|
||||
return prefix ? `${prefix}_${nanoid(10)}` : nanoid(12);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { Transition } from 'motion/react';
|
||||
|
||||
export const SPRING: Transition = {
|
||||
type: 'spring',
|
||||
stiffness: 260,
|
||||
damping: 22,
|
||||
};
|
||||
|
||||
export const FADE_IN_UP: Transition = {
|
||||
duration: 0.2,
|
||||
ease: [0.22, 1, 0.36, 1],
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
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');
|
||||
if (!container) throw new Error('Root container #root not found');
|
||||
|
||||
createRoot(container).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
);
|
||||
@@ -1,250 +0,0 @@
|
||||
import { PDFDocument, StandardFonts, rgb } from 'pdf-lib';
|
||||
|
||||
import { FR } from '../i18n/fr';
|
||||
import { formatDateFr } from '../lib/date';
|
||||
import type { Report } from '../schema/report';
|
||||
import type { SpeciesAnatomy } from '../species/types';
|
||||
|
||||
import { PDF_ATTACHMENT_NAME } from './version';
|
||||
|
||||
const A4 = { width: 595.28, height: 841.89 } as const;
|
||||
const MARGIN = 48;
|
||||
const FOOT = 32;
|
||||
|
||||
export interface AnatomyAssets {
|
||||
anatomy: SpeciesAnatomy;
|
||||
rasters: Partial<Record<'lateral_left' | 'lateral_right' | 'dorsal', Uint8Array | ArrayBuffer>>;
|
||||
}
|
||||
|
||||
function zoneLabel(anatomy: SpeciesAnatomy, id: string): string {
|
||||
return anatomy.zones.find((z) => z.id === id)?.label ?? id;
|
||||
}
|
||||
|
||||
export async function exportReportBytes(report: Report, assets: AnatomyAssets): Promise<Uint8Array> {
|
||||
const pdf = await PDFDocument.create();
|
||||
pdf.setTitle(`Bilan ostéopathique — ${report.animal.name}`);
|
||||
pdf.setAuthor(report.practitioner.fullName);
|
||||
pdf.setSubject(FR.app.tagline);
|
||||
pdf.setCreator(FR.app.name);
|
||||
pdf.setProducer('pdf-lib');
|
||||
pdf.setCreationDate(new Date(report.createdAt));
|
||||
|
||||
const font = await pdf.embedFont(StandardFonts.Helvetica);
|
||||
const fontBold = await pdf.embedFont(StandardFonts.HelveticaBold);
|
||||
|
||||
let page = pdf.addPage([A4.width, A4.height]);
|
||||
let y = A4.height - MARGIN;
|
||||
|
||||
// ───────── Header
|
||||
page.drawText(FR.app.name, {
|
||||
x: MARGIN,
|
||||
y,
|
||||
size: 18,
|
||||
font: fontBold,
|
||||
color: rgb(0.29, 0.49, 0.35),
|
||||
});
|
||||
page.drawText(FR.app.tagline, { x: MARGIN, y: y - 16, size: 9, font, color: rgb(0.4, 0.4, 0.4) });
|
||||
y -= 36;
|
||||
|
||||
page.drawText(`Animal : ${report.animal.name}`, { x: MARGIN, y, size: 11, font: fontBold });
|
||||
page.drawText(`Propriétaire : ${report.animal.owner}`, { x: MARGIN, y: y - 14, size: 11, font });
|
||||
page.drawText(`Séance : ${formatDateFr(report.sessionDate)}`, { x: MARGIN, y: y - 28, size: 11, font });
|
||||
|
||||
const practX = A4.width / 2 + 20;
|
||||
page.drawText(report.practitioner.fullName, { x: practX, y, size: 11, font: fontBold });
|
||||
let practY = y - 14;
|
||||
for (const line of [
|
||||
report.practitioner.title,
|
||||
report.practitioner.phone,
|
||||
report.practitioner.email,
|
||||
report.practitioner.address,
|
||||
report.practitioner.siret ? `SIRET ${report.practitioner.siret}` : undefined,
|
||||
]) {
|
||||
if (!line) continue;
|
||||
page.drawText(line, { x: practX, y: practY, size: 10, font });
|
||||
practY -= 12;
|
||||
}
|
||||
y = Math.min(y - 60, practY - 24);
|
||||
page.drawLine({
|
||||
start: { x: MARGIN, y },
|
||||
end: { x: A4.width - MARGIN, y },
|
||||
thickness: 0.6,
|
||||
color: rgb(0.29, 0.49, 0.35),
|
||||
});
|
||||
y -= 20;
|
||||
|
||||
// ───────── Anatomy pages (one per view with selected zones)
|
||||
const viewLabels: Record<keyof AnatomyAssets['rasters'], string> = {
|
||||
lateral_left: 'Vue latérale gauche',
|
||||
lateral_right: 'Vue latérale droite',
|
||||
dorsal: 'Vue dorsale',
|
||||
};
|
||||
const viewsInUse = new Set<keyof AnatomyAssets['rasters']>();
|
||||
for (const f of report.findings) {
|
||||
for (const zId of [...f.zones, ...f.linkedZones]) {
|
||||
const z = assets.anatomy.zones.find((zz) => zz.id === zId);
|
||||
if (!z) continue;
|
||||
for (const v of z.views) viewsInUse.add(v);
|
||||
}
|
||||
}
|
||||
|
||||
for (const view of viewsInUse) {
|
||||
const raster = assets.rasters[view];
|
||||
if (!raster) continue;
|
||||
page = pdf.addPage([A4.width, A4.height]);
|
||||
page.drawText(viewLabels[view], {
|
||||
x: MARGIN,
|
||||
y: A4.height - MARGIN,
|
||||
size: 14,
|
||||
font: fontBold,
|
||||
});
|
||||
const png = await pdf.embedPng(raster);
|
||||
const maxW = A4.width - MARGIN * 2;
|
||||
const maxH = A4.height - MARGIN * 2 - 50;
|
||||
const ratio = Math.min(maxW / png.width, maxH / png.height);
|
||||
const w = png.width * ratio;
|
||||
const h = png.height * ratio;
|
||||
page.drawImage(png, { x: MARGIN, y: A4.height - MARGIN - 30 - h, width: w, height: h });
|
||||
}
|
||||
|
||||
// ───────── Findings table
|
||||
page = pdf.addPage([A4.width, A4.height]);
|
||||
y = A4.height - MARGIN;
|
||||
page.drawText('Observations cliniques', { x: MARGIN, y, size: 14, font: fontBold });
|
||||
y -= 22;
|
||||
|
||||
if (report.findings.length === 0) {
|
||||
page.drawText('Aucune observation enregistrée.', { x: MARGIN, y, size: 10, font });
|
||||
}
|
||||
|
||||
for (let i = 0; i < report.findings.length; i++) {
|
||||
const f = report.findings[i];
|
||||
if (!f) continue;
|
||||
if (y < MARGIN + 120) {
|
||||
page = pdf.addPage([A4.width, A4.height]);
|
||||
y = A4.height - MARGIN;
|
||||
}
|
||||
const zones = f.zones.map((id) => zoneLabel(assets.anatomy, id)).join(', ');
|
||||
const linked = f.linkedZones.length
|
||||
? ` (liées : ${f.linkedZones.map((id) => zoneLabel(assets.anatomy, id)).join(', ')})`
|
||||
: '';
|
||||
const pathos = f.pathologies.map((p) => p.label).join(', ') || '—';
|
||||
const sev = FR.severity[f.severity] ?? f.severity;
|
||||
|
||||
page.drawText(`#${(i + 1).toString()} ${zones}${linked}`, {
|
||||
x: MARGIN,
|
||||
y,
|
||||
size: 11,
|
||||
font: fontBold,
|
||||
});
|
||||
page.drawText(`Pathologies : ${pathos}`, { x: MARGIN, y: y - 14, size: 10, font });
|
||||
page.drawText(`Sévérité : ${sev}`, { x: MARGIN, y: y - 28, size: 10, font });
|
||||
if (f.comment) {
|
||||
const wrapped = wrap(f.comment, 90);
|
||||
let yy = y - 44;
|
||||
page.drawText('Commentaire :', { x: MARGIN, y: yy, size: 10, font: fontBold });
|
||||
yy -= 14;
|
||||
for (const line of wrapped) {
|
||||
page.drawText(line, { x: MARGIN + 8, y: yy, size: 10, font });
|
||||
yy -= 12;
|
||||
}
|
||||
y = yy - 8;
|
||||
} else {
|
||||
y -= 50;
|
||||
}
|
||||
}
|
||||
|
||||
// ───────── Conclusion + recommandations + RDV
|
||||
if (report.conclusion || report.recommendations || report.nextAppointment) {
|
||||
page = pdf.addPage([A4.width, A4.height]);
|
||||
y = A4.height - MARGIN;
|
||||
if (report.conclusion) {
|
||||
page.drawText('Conclusion', { x: MARGIN, y, size: 14, font: fontBold });
|
||||
y -= 20;
|
||||
for (const line of wrap(report.conclusion, 90)) {
|
||||
page.drawText(line, { x: MARGIN, y, size: 11, font });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 12;
|
||||
}
|
||||
if (report.recommendations) {
|
||||
page.drawText('Recommandations', { x: MARGIN, y, size: 14, font: fontBold });
|
||||
y -= 20;
|
||||
for (const line of wrap(report.recommendations, 90)) {
|
||||
page.drawText(line, { x: MARGIN, y, size: 11, font });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 12;
|
||||
}
|
||||
if (report.nextAppointment) {
|
||||
page.drawText(`Prochain rendez-vous : ${formatDateFr(report.nextAppointment)}`, {
|
||||
x: MARGIN,
|
||||
y,
|
||||
size: 12,
|
||||
font: fontBold,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ───────── Footer on each page
|
||||
const pages = pdf.getPages();
|
||||
const exported = new Date().toISOString().slice(0, 10);
|
||||
for (let i = 0; i < pages.length; i++) {
|
||||
const p = pages[i];
|
||||
if (!p) continue;
|
||||
p.drawText(`${FR.app.name} · exporté le ${formatDateFr(exported)} · page ${(i + 1).toString()}/${pages.length.toString()}`, {
|
||||
x: MARGIN,
|
||||
y: FOOT,
|
||||
size: 8,
|
||||
font,
|
||||
color: rgb(0.45, 0.45, 0.45),
|
||||
});
|
||||
}
|
||||
|
||||
// ───────── Attach report.json
|
||||
// pdf-lib's `attach` treats a raw string as base64-data-URI input (not as
|
||||
// UTF-8 text), and rejects cross-realm Uint8Array/ArrayBuffer in tests.
|
||||
// Wrap the JSON in a base64 data-URI string so it's portable everywhere.
|
||||
const json = JSON.stringify(report);
|
||||
const jsonBytes = new TextEncoder().encode(json);
|
||||
let base64 = '';
|
||||
const chunk = 8192;
|
||||
for (let i = 0; i < jsonBytes.length; i += chunk) {
|
||||
base64 += String.fromCharCode(
|
||||
...jsonBytes.subarray(i, Math.min(i + chunk, jsonBytes.length)),
|
||||
);
|
||||
}
|
||||
const dataUri = `data:application/json;base64,${btoa(base64)}`;
|
||||
await pdf.attach(dataUri, PDF_ATTACHMENT_NAME, {
|
||||
mimeType: 'application/json',
|
||||
description: 'Données sources du bilan (réimport possible).',
|
||||
creationDate: new Date(report.createdAt),
|
||||
modificationDate: new Date(),
|
||||
});
|
||||
|
||||
return pdf.save();
|
||||
}
|
||||
|
||||
export async function exportReport(report: Report, assets: AnatomyAssets): Promise<Blob> {
|
||||
const bytes = await exportReportBytes(report, assets);
|
||||
// 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[] {
|
||||
const words = text.split(/\s+/);
|
||||
const lines: string[] = [];
|
||||
let buf = '';
|
||||
for (const w of words) {
|
||||
if ((buf + ' ' + w).trim().length > max) {
|
||||
lines.push(buf);
|
||||
buf = w;
|
||||
} else {
|
||||
buf = (buf + ' ' + w).trim();
|
||||
}
|
||||
}
|
||||
if (buf) lines.push(buf);
|
||||
return lines;
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
import * as pako from 'pako';
|
||||
import { PDFDocument, PDFName, type PDFRawStream } from 'pdf-lib';
|
||||
|
||||
import { ReportSchema } from '../schema/report';
|
||||
import type { Report } from '../schema/report';
|
||||
|
||||
import { PDF_ATTACHMENT_NAME } from './version';
|
||||
|
||||
export type ImportFailure =
|
||||
| { ok: false; reason: 'NO_ATTACHMENT' }
|
||||
| { ok: false; reason: 'INVALID_JSON'; details?: string }
|
||||
| { ok: false; reason: 'SCHEMA_MISMATCH'; details?: string }
|
||||
| { ok: false; reason: 'UNREADABLE_PDF'; details?: string };
|
||||
|
||||
export type ImportResult = { ok: true; report: Report } | ImportFailure;
|
||||
|
||||
export async function importReport(file: File | Blob | ArrayBuffer | Uint8Array): Promise<ImportResult> {
|
||||
let pdf: PDFDocument;
|
||||
try {
|
||||
const buf = await toBytes(file);
|
||||
pdf = await PDFDocument.load(buf, { ignoreEncryption: true });
|
||||
} catch (e) {
|
||||
return { ok: false, reason: 'UNREADABLE_PDF', details: (e as Error).message };
|
||||
}
|
||||
|
||||
const json = extractAttachment(pdf, PDF_ATTACHMENT_NAME);
|
||||
if (!json) return { ok: false, reason: 'NO_ATTACHMENT' };
|
||||
|
||||
let parsed: unknown;
|
||||
try {
|
||||
const decoded = new TextDecoder().decode(json);
|
||||
parsed = JSON.parse(decoded);
|
||||
} catch (e) {
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'INVALID_JSON',
|
||||
details: `${(e as Error).message} | first 80 bytes: ${Array.from(json.slice(0, 80))
|
||||
.map((b) => b.toString(16).padStart(2, '0'))
|
||||
.join(' ')}`,
|
||||
};
|
||||
}
|
||||
|
||||
const result = ReportSchema.safeParse(parsed);
|
||||
if (!result.success) {
|
||||
return { ok: false, reason: 'SCHEMA_MISMATCH', details: result.error.message };
|
||||
}
|
||||
return { ok: true, report: result.data };
|
||||
}
|
||||
|
||||
async function toBytes(input: File | Blob | ArrayBuffer | Uint8Array): Promise<Uint8Array> {
|
||||
if (input instanceof Uint8Array) return input;
|
||||
if (input instanceof ArrayBuffer) return new Uint8Array(input);
|
||||
return new Uint8Array(await input.arrayBuffer());
|
||||
}
|
||||
|
||||
function extractAttachment(pdf: PDFDocument, name: string): Uint8Array | null {
|
||||
// Walk catalog → Names → EmbeddedFiles → Names array → filespec → EF → F
|
||||
// pdf-lib has no public attachment-extract API, so we navigate the tree.
|
||||
const catalog = pdf.catalog;
|
||||
const names = catalog.lookup(PDFName.of('Names')) as
|
||||
| { lookup?: (n: PDFName) => unknown }
|
||||
| undefined;
|
||||
if (!names?.lookup) return null;
|
||||
const embeddedFiles = names.lookup(PDFName.of('EmbeddedFiles')) as
|
||||
| { lookup?: (n: PDFName) => unknown }
|
||||
| undefined;
|
||||
if (!embeddedFiles?.lookup) return null;
|
||||
const namesArr = embeddedFiles.lookup(PDFName.of('Names')) as
|
||||
| { size?: () => number; lookup?: (i: number) => unknown }
|
||||
| undefined;
|
||||
if (!namesArr?.lookup || typeof namesArr.size !== 'function') return null;
|
||||
const size = namesArr.size();
|
||||
for (let i = 0; i < size; i += 2) {
|
||||
const k = namesArr.lookup(i) as { decodeText?: () => string } | undefined;
|
||||
const fname = k?.decodeText?.();
|
||||
if (fname !== name) continue;
|
||||
const fileSpec = namesArr.lookup(i + 1) as
|
||||
| { lookup?: (n: PDFName) => unknown }
|
||||
| undefined;
|
||||
if (!fileSpec?.lookup) continue;
|
||||
const ef = fileSpec.lookup(PDFName.of('EF')) as
|
||||
| { lookup?: (n: PDFName) => unknown }
|
||||
| undefined;
|
||||
if (!ef?.lookup) continue;
|
||||
const stream = (ef.lookup(PDFName.of('F')) ?? ef.lookup(PDFName.of('UF'))) as
|
||||
| { dict?: unknown; contents?: Uint8Array }
|
||||
| undefined;
|
||||
if (!stream) continue;
|
||||
// Duck-type instead of `instanceof PDFRawStream` (instanceof fails when
|
||||
// multiple pdf-lib realms coexist, e.g. during tests).
|
||||
if (stream.dict !== undefined && stream.contents !== undefined) {
|
||||
const s = stream as PDFRawStream;
|
||||
const filter = (s.dict as { lookup?: (n: PDFName) => unknown }).lookup?.(
|
||||
PDFName.of('Filter'),
|
||||
);
|
||||
const filterName = (filter as { encodedName?: string } | undefined)?.encodedName;
|
||||
// We bypass pdf-lib's `decodePDFRawStream` because its reference-equality
|
||||
// check on `PDFName.of('FlateDecode')` is unreliable across module realms
|
||||
// (e.g. when vitest dual-loads pdf-lib). Use pako directly on raw bytes.
|
||||
if (filterName === '/FlateDecode') {
|
||||
return pako.inflate(s.contents);
|
||||
}
|
||||
if (filterName === undefined || filter === null) {
|
||||
return s.contents;
|
||||
}
|
||||
// Other filters (ASCII85, LZW, etc.) not expected for embedded files we wrote.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export {};
|
||||
@@ -1 +0,0 @@
|
||||
export {};
|
||||
@@ -1 +0,0 @@
|
||||
export {};
|
||||
@@ -1 +0,0 @@
|
||||
export {};
|
||||
@@ -1,2 +0,0 @@
|
||||
export const PDF_SCHEMA_VERSION = 1 as const;
|
||||
export const PDF_ATTACHMENT_NAME = 'report.json' as const;
|
||||
@@ -1,179 +0,0 @@
|
||||
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() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
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() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
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() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { Shell } from '@/components/Shell';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
|
||||
export function NotFoundRoute() {
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const SeveritySchema = z.enum(['mild', 'moderate', 'severe']);
|
||||
export type Severity = z.infer<typeof SeveritySchema>;
|
||||
|
||||
export const PathologyRefSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
label: z.string().min(1),
|
||||
free: z.boolean().default(false),
|
||||
});
|
||||
export type PathologyRef = z.infer<typeof PathologyRefSchema>;
|
||||
|
||||
export const FindingSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
zones: z.array(z.string()).min(1),
|
||||
linkedZones: z.array(z.string()).default([]),
|
||||
pathologies: z.array(PathologyRefSchema).default([]),
|
||||
severity: SeveritySchema,
|
||||
comment: z.string().default(''),
|
||||
});
|
||||
export type Finding = z.infer<typeof FindingSchema>;
|
||||
@@ -1,12 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const PractitionerSchema = z.object({
|
||||
fullName: z.string().min(1),
|
||||
title: z.string().optional(),
|
||||
phone: z.string().optional(),
|
||||
email: z.string().email().optional(),
|
||||
address: z.string().optional(),
|
||||
siret: z.string().optional(),
|
||||
});
|
||||
|
||||
export type Practitioner = z.infer<typeof PractitionerSchema>;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { FindingSchema } from './finding';
|
||||
import { PractitionerSchema } from './practitioner';
|
||||
|
||||
export const SCHEMA_VERSION = 1 as const;
|
||||
|
||||
export const SpeciesIdSchema = z.enum([
|
||||
'chien',
|
||||
'chat',
|
||||
'equine',
|
||||
'lapin',
|
||||
'bovin',
|
||||
'chevre',
|
||||
'ane',
|
||||
'mouton',
|
||||
'porc',
|
||||
]);
|
||||
|
||||
export const ReportSchema = z.object({
|
||||
version: z.literal(SCHEMA_VERSION),
|
||||
id: z.string().min(1),
|
||||
createdAt: z.string().datetime(),
|
||||
species: SpeciesIdSchema,
|
||||
practitioner: PractitionerSchema,
|
||||
animal: z.object({
|
||||
name: z.string().min(1),
|
||||
owner: z.string().min(1),
|
||||
}),
|
||||
sessionDate: z.string(),
|
||||
findings: z.array(FindingSchema).default([]),
|
||||
conclusion: z.string().default(''),
|
||||
recommendations: z.string().default(''),
|
||||
nextAppointment: z.string().optional(),
|
||||
});
|
||||
|
||||
export type Report = z.infer<typeof ReportSchema>;
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -1,17 +0,0 @@
|
||||
# Cheval — anatomie et pathologies
|
||||
|
||||
Sources clinique-vétérinaires devant figurer en référence pour chaque entrée de
|
||||
`pathologies.ts` :
|
||||
|
||||
- Merck Veterinary Manual — https://www.merckvetmanual.com
|
||||
- IMAIOS vet-Anatomy — https://www.imaios.com/en/vet-anatomy
|
||||
- PubMed Central — https://www.ncbi.nlm.nih.gov/pmc/
|
||||
- Veterinary Clinics of North America: Equine Practice (Elsevier)
|
||||
- Equine Veterinary Journal (Wiley/BEVA)
|
||||
- London College of Animal Osteopathy — https://lcao.com
|
||||
- WikiVet — https://en.wikivet.net
|
||||
|
||||
Formule vertébrale du cheval : C7 / T18 / L6 / S5.
|
||||
|
||||
Toute pathologie ajoutée doit citer au moins une source. Pas d'entrée
|
||||
inventée — la base est ensuite relue et validée par le praticien client.
|
||||
@@ -1,54 +0,0 @@
|
||||
import type { SpeciesAnatomy, Subzone, Zone } from '../types';
|
||||
|
||||
const range = (prefix: string, count: number): Subzone[] =>
|
||||
Array.from({ length: count }, (_, i) => ({
|
||||
id: `${prefix}${i + 1}`,
|
||||
label: `${prefix}${i + 1}`,
|
||||
}));
|
||||
|
||||
const CERVICAL: Subzone[] = range('C', 7);
|
||||
const THORACIC: Subzone[] = range('T', 18);
|
||||
const LUMBAR: Subzone[] = range('L', 6);
|
||||
const SACRAL: Subzone[] = range('S', 5);
|
||||
|
||||
const ZONES: Zone[] = [
|
||||
{ id: 'head', label: 'Tête', category: 'head', views: ['lateral_left', 'lateral_right', 'dorsal'] },
|
||||
{ id: 'neck', label: 'Encolure', category: 'axial', views: ['lateral_left', 'lateral_right', 'dorsal'], subzones: CERVICAL },
|
||||
{ id: 'withers', label: 'Garrot', category: 'axial', views: ['lateral_left', 'lateral_right', 'dorsal'] },
|
||||
{ id: 'thoracic-back', label: 'Dos thoracique', category: 'axial', views: ['lateral_left', 'lateral_right', 'dorsal'], subzones: THORACIC },
|
||||
{ id: 'lumbar', label: 'Lombaire', category: 'axial', views: ['lateral_left', 'lateral_right', 'dorsal'], subzones: LUMBAR },
|
||||
{ id: 'sacrum', label: 'Sacrum', category: 'axial', views: ['lateral_left', 'lateral_right', 'dorsal'], subzones: SACRAL },
|
||||
{ id: 'sacro-iliac-l', label: 'Sacro-iliaque gauche', category: 'axial', views: ['lateral_left', 'dorsal'] },
|
||||
{ id: 'sacro-iliac-r', label: 'Sacro-iliaque droite', category: 'axial', views: ['lateral_right', 'dorsal'] },
|
||||
{ id: 'tail', label: 'Queue', category: 'tail', views: ['lateral_left', 'lateral_right', 'dorsal'] },
|
||||
|
||||
{ id: 'shoulder-l', label: 'Épaule gauche', category: 'limb', views: ['lateral_left', 'dorsal'] },
|
||||
{ id: 'shoulder-r', label: 'Épaule droite', category: 'limb', views: ['lateral_right', 'dorsal'] },
|
||||
{ id: 'elbow-l', label: 'Coude gauche', category: 'limb', views: ['lateral_left'] },
|
||||
{ id: 'elbow-r', label: 'Coude droit', category: 'limb', views: ['lateral_right'] },
|
||||
{ id: 'knee-l', label: 'Genou antérieur gauche', category: 'limb', views: ['lateral_left'] },
|
||||
{ id: 'knee-r', label: 'Genou antérieur droit', category: 'limb', views: ['lateral_right'] },
|
||||
{ id: 'fetlock-front-l', label: 'Boulet antérieur gauche', category: 'limb', views: ['lateral_left'] },
|
||||
{ id: 'fetlock-front-r', label: 'Boulet antérieur droit', category: 'limb', views: ['lateral_right'] },
|
||||
|
||||
{ id: 'hip-l', label: 'Hanche gauche', category: 'limb', views: ['lateral_left', 'dorsal'] },
|
||||
{ id: 'hip-r', label: 'Hanche droite', category: 'limb', views: ['lateral_right', 'dorsal'] },
|
||||
{ id: 'stifle-l', label: 'Grasset gauche', category: 'limb', views: ['lateral_left'] },
|
||||
{ id: 'stifle-r', label: 'Grasset droit', category: 'limb', views: ['lateral_right'] },
|
||||
{ id: 'hock-l', label: 'Jarret gauche', category: 'limb', views: ['lateral_left'] },
|
||||
{ id: 'hock-r', label: 'Jarret droit', category: 'limb', views: ['lateral_right'] },
|
||||
{ id: 'fetlock-rear-l', label: 'Boulet postérieur gauche', category: 'limb', views: ['lateral_left'] },
|
||||
{ id: 'fetlock-rear-r', label: 'Boulet postérieur droit', category: 'limb', views: ['lateral_right'] },
|
||||
];
|
||||
|
||||
export const EQUINE_ANATOMY: SpeciesAnatomy = {
|
||||
id: 'equine',
|
||||
label: 'Cheval',
|
||||
vertebralFormula: { cervical: 7, thoracic: 18, lumbar: 6, sacral: 5 },
|
||||
zones: ZONES,
|
||||
svg: {
|
||||
lateral_left: '/species/equine/lateral-left.svg',
|
||||
lateral_right: '/species/equine/lateral-right.svg',
|
||||
dorsal: '/species/equine/dorsal.svg',
|
||||
},
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import { registerSpecies } from '../registry';
|
||||
|
||||
import { EQUINE_ANATOMY } from './anatomy';
|
||||
import { EQUINE_PATHOLOGIES } from './pathologies';
|
||||
|
||||
registerSpecies('equine', {
|
||||
anatomy: EQUINE_ANATOMY,
|
||||
pathologies: EQUINE_PATHOLOGIES,
|
||||
});
|
||||
|
||||
export { EQUINE_ANATOMY, EQUINE_PATHOLOGIES };
|
||||
@@ -1,295 +0,0 @@
|
||||
import type { PathologyEntry } from '../types';
|
||||
|
||||
const MVM = (slug: string): string => `https://www.merckvetmanual.com/horse-owners/${slug}`;
|
||||
const IMAIOS = 'https://www.imaios.com/en/vet-anatomy/horse';
|
||||
const PUBMED = (id: string): string => `https://pubmed.ncbi.nlm.nih.gov/${id}/`;
|
||||
|
||||
export const EQUINE_PATHOLOGIES: PathologyEntry[] = [
|
||||
// ─── Axial : encolure / dos / lombaire / sacrum ───────────────────────────
|
||||
{
|
||||
id: 'eq_kissing_spines',
|
||||
label: 'Syndrome des processus épineux chevauchants (kissing spines)',
|
||||
description:
|
||||
'Contact ou chevauchement des processus épineux thoraciques, principalement entre T13 et T18. Source fréquente de douleur dorsale.',
|
||||
category: 'osseux',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['thoracic-back', 'withers', 'lumbar'],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/disorders-of-the-back-and-pelvis-of-horses'), PUBMED('29071751')],
|
||||
},
|
||||
{
|
||||
id: 'eq_cervical_facet_arthropathy',
|
||||
label: 'Arthropathie des facettes articulaires cervicales',
|
||||
description: 'Remaniements arthrosiques des articulations zygapophysaires cervicales, souvent C5-C7.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['neck'],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/cervical-vertebral-malformation-in-horses'), PUBMED('22416782')],
|
||||
},
|
||||
{
|
||||
id: 'eq_cervical_stenotic_myelopathy',
|
||||
label: 'Myélopathie cervicale sténosante (wobbler)',
|
||||
description: 'Compression médullaire cervicale par malformation vertébrale ou sténose dynamique.',
|
||||
category: 'nerveux',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['neck'],
|
||||
sources: [MVM('horse-owners/brain-spinal-cord-and-nerve-disorders-of-horses/cervical-vertebral-malformation-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_lumbosacral_pain',
|
||||
label: 'Dysfonction lombo-sacrée',
|
||||
description: 'Douleur localisée à la jonction L6-S1 et autour du sacrum.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['lumbar', 'sacrum'],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/disorders-of-the-back-and-pelvis-of-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_sacroiliac_dysfunction',
|
||||
label: 'Dysfonction sacro-iliaque',
|
||||
description: 'Restriction de mobilité ou douleur au niveau des articulations sacro-iliaques.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['sacro-iliac-l', 'sacro-iliac-r', 'sacrum'],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/disorders-of-the-back-and-pelvis-of-horses'), PUBMED('20840713')],
|
||||
},
|
||||
{
|
||||
id: 'eq_thoracolumbar_muscular',
|
||||
label: 'Tension musculaire thoraco-lombaire',
|
||||
description: 'Hypertonie des muscles long dorsal / longissimus, souvent secondaire à une selle inadaptée.',
|
||||
category: 'musculaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['thoracic-back', 'lumbar', 'withers'],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/muscle-disorders-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_supraspinous_ligament_desmitis',
|
||||
label: 'Desmite du ligament supra-épineux',
|
||||
description: 'Inflammation chronique du ligament supra-épineux dorsal, parfois associée aux kissing spines.',
|
||||
category: 'tendino-ligamentaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['thoracic-back', 'lumbar', 'withers'],
|
||||
sources: [PUBMED('15510510')],
|
||||
},
|
||||
{
|
||||
id: 'eq_nuchal_ligament_desmopathy',
|
||||
label: 'Desmopathie du ligament nuchal',
|
||||
description: 'Atteinte chronique du ligament nuchal, douleur à la flexion cervicale.',
|
||||
category: 'tendino-ligamentaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['neck', 'head'],
|
||||
sources: [IMAIOS],
|
||||
},
|
||||
{
|
||||
id: 'eq_tail_set_dysfunction',
|
||||
label: 'Restriction de mobilité de la queue',
|
||||
description: "Manque d'oscillation latérale ou de portée de la queue, signe d'irritation sacro-coccygienne.",
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['tail', 'sacrum'],
|
||||
sources: [IMAIOS],
|
||||
},
|
||||
{
|
||||
id: 'eq_tmj_dysfunction',
|
||||
label: 'Dysfonction temporo-mandibulaire',
|
||||
description: 'Asymétrie ou restriction de l’ATM, souvent associée à un déséquilibre dentaire.',
|
||||
category: 'cranio-sacre',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['head'],
|
||||
sources: [PUBMED('21916951')],
|
||||
},
|
||||
|
||||
// ─── Membres antérieurs ───────────────────────────────────────────────────
|
||||
{
|
||||
id: 'eq_navicular_syndrome',
|
||||
label: 'Syndrome naviculaire (douleur podotrochléaire)',
|
||||
description: 'Douleur chronique de l’appareil podotrochléaire, fréquente cause de boiterie antérieure.',
|
||||
category: 'osseux',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['fetlock-front-l', 'fetlock-front-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/navicular-disease-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_ringbone',
|
||||
label: 'Phalangite (ringbone)',
|
||||
description: 'Ostéoarthrose des articulations interphalangiennes, classiquement membres antérieurs.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['fetlock-front-l', 'fetlock-front-r', 'fetlock-rear-l', 'fetlock-rear-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/ringbone-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_splints',
|
||||
label: 'Suros (splints)',
|
||||
description: 'Inflammation périostée entre métacarpien principal et stylet, surtout chez le jeune cheval.',
|
||||
category: 'osseux',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['knee-l', 'knee-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/splints-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_carpal_osteoarthritis',
|
||||
label: 'Ostéoarthrose du carpe',
|
||||
description: 'Usure articulaire du carpe (genou antérieur), fréquente chez les chevaux de course.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['knee-l', 'knee-r'],
|
||||
sources: [PUBMED('20840713')],
|
||||
},
|
||||
{
|
||||
id: 'eq_suspensory_desmitis_front',
|
||||
label: 'Desmite suspensorale antérieure',
|
||||
description: 'Atteinte du ligament suspenseur du boulet, branches ou corps, des antérieurs.',
|
||||
category: 'tendino-ligamentaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['fetlock-front-l', 'fetlock-front-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/tendinitis-and-tendinosis-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_sdft_tendinitis',
|
||||
label: 'Tendinite du tendon fléchisseur superficiel',
|
||||
description: 'Atteinte du SDFT, classiquement à la moitié distale du métacarpe.',
|
||||
category: 'tendino-ligamentaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['fetlock-front-l', 'fetlock-front-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/tendinitis-and-tendinosis-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_shoulder_sweeney',
|
||||
label: 'Atrophie scapulaire (sweeney)',
|
||||
description: 'Atrophie des muscles supra-épineux/infra-épineux par lésion du nerf suprascapulaire.',
|
||||
category: 'nerveux',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['shoulder-l', 'shoulder-r'],
|
||||
sources: [MVM('horse-owners/brain-spinal-cord-and-nerve-disorders-of-horses/suprascapular-nerve-injury-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_elbow_capped',
|
||||
label: 'Hygroma du coude (capped elbow)',
|
||||
description: 'Bursite olécrânienne par traumatisme répété.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['elbow-l', 'elbow-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/bursitis-in-horses')],
|
||||
},
|
||||
|
||||
// ─── Membres postérieurs ──────────────────────────────────────────────────
|
||||
{
|
||||
id: 'eq_bone_spavin',
|
||||
label: 'Éparvin osseux (bone spavin)',
|
||||
description: 'Ostéoarthrose des articulations distales du tarse, principale cause d’éparvin.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['hock-l', 'hock-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/bone-spavin-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_bog_spavin',
|
||||
label: 'Vessigon articulaire du jarret (bog spavin)',
|
||||
description: 'Distension synoviale de l’articulation tibio-tarsienne.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['hock-l', 'hock-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/bog-spavin-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_curb',
|
||||
label: 'Courbe du jarret (curb)',
|
||||
description: 'Desmite du ligament tarsien plantaire long, palpable en arrière du jarret.',
|
||||
category: 'tendino-ligamentaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['hock-l', 'hock-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/curb-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_stifle_upward_fixation_patella',
|
||||
label: 'Accrochement intermittent de la rotule',
|
||||
description: 'Blocage transitoire de la rotule sur la trochlée fémorale, fréquent chez le jeune cheval.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['stifle-l', 'stifle-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/upward-fixation-of-the-patella-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_stifle_meniscal_injury',
|
||||
label: 'Lésion méniscale du grasset',
|
||||
description: 'Atteinte du ménisque médial ou latéral, conséquence de torsion ou de surcharge.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['stifle-l', 'stifle-r'],
|
||||
sources: [PUBMED('20840713')],
|
||||
},
|
||||
{
|
||||
id: 'eq_suspensory_desmitis_rear',
|
||||
label: 'Desmite suspensorale postérieure (PSD)',
|
||||
description: 'Desmite chronique du suspenseur, branche médiale postérieure principalement.',
|
||||
category: 'tendino-ligamentaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['hock-l', 'hock-r', 'fetlock-rear-l', 'fetlock-rear-r'],
|
||||
sources: [MVM('horse-owners/lameness-in-horses/tendinitis-and-tendinosis-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_coxofemoral_arthrosis',
|
||||
label: 'Arthrose coxo-fémorale',
|
||||
description: 'Atteinte dégénérative de la hanche, plus rare mais source de boiterie postérieure.',
|
||||
category: 'articulaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['hip-l', 'hip-r'],
|
||||
sources: [IMAIOS],
|
||||
},
|
||||
{
|
||||
id: 'eq_gluteal_strain',
|
||||
label: 'Lésion musculaire glutéale',
|
||||
description: 'Élongation ou contracture des muscles fessiers, fréquente après effort intense.',
|
||||
category: 'musculaire',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['hip-l', 'hip-r'],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/muscle-disorders-in-horses')],
|
||||
},
|
||||
|
||||
// ─── Fascial / viscéral / autre ───────────────────────────────────────────
|
||||
{
|
||||
id: 'eq_thoracolumbar_fascial_restriction',
|
||||
label: 'Restriction fasciale thoraco-lombaire',
|
||||
description: 'Adhérences fasciales limitant la flexion et l’extension dorsale.',
|
||||
category: 'fascial',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['thoracic-back', 'lumbar'],
|
||||
sources: [PUBMED('33555115')],
|
||||
},
|
||||
{
|
||||
id: 'eq_diaphragmatic_restriction',
|
||||
label: 'Restriction diaphragmatique',
|
||||
description: 'Limitation de mobilité diaphragmatique, palpable en pression abdominale antérieure.',
|
||||
category: 'visceral',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['thoracic-back', 'withers'],
|
||||
sources: [IMAIOS],
|
||||
},
|
||||
{
|
||||
id: 'eq_gastric_visceral_dysfunction',
|
||||
label: 'Dysfonction viscérale gastrique',
|
||||
description: 'Sensibilité épigastrique, parfois associée à ulcères gastriques (EGUS).',
|
||||
category: 'visceral',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['thoracic-back', 'lumbar'],
|
||||
sources: [MVM('horse-owners/digestive-disorders-of-horses/gastric-ulcers-in-horses')],
|
||||
},
|
||||
{
|
||||
id: 'eq_cranio_sacral_restriction',
|
||||
label: 'Restriction crânio-sacrée',
|
||||
description: 'Perte de rythme crânio-sacré, palpation crânienne et sacrée combinées.',
|
||||
category: 'cranio-sacre',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: ['head', 'sacrum'],
|
||||
sources: ['London College of Animal Osteopathy — https://lcao.com'],
|
||||
},
|
||||
{
|
||||
id: 'eq_post_fall_global',
|
||||
label: 'Conséquences post-traumatiques (chute)',
|
||||
description: 'Tableau combiné de tensions multi-zones après chute, à différencier d’une lésion focalisée.',
|
||||
category: 'autre',
|
||||
applicableSpecies: ['equine'],
|
||||
applicableZones: [],
|
||||
sources: [MVM('horse-owners/bone-joint-and-muscle-disorders-of-horses/disorders-of-the-back-and-pelvis-of-horses')],
|
||||
},
|
||||
];
|
||||
@@ -1,13 +0,0 @@
|
||||
import './equine';
|
||||
|
||||
export { SPECIES, getSpecies, isSpeciesAvailable } from './registry';
|
||||
export type {
|
||||
PathologyEntry,
|
||||
SpeciesAnatomy,
|
||||
SpeciesId,
|
||||
Subzone,
|
||||
View,
|
||||
Zone,
|
||||
ZoneCategory,
|
||||
VertebralFormula,
|
||||
} from './types';
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -1,20 +0,0 @@
|
||||
import type { PathologyEntry, SpeciesAnatomy, SpeciesId } from './types';
|
||||
|
||||
export interface SpeciesPack {
|
||||
anatomy: SpeciesAnatomy;
|
||||
pathologies: PathologyEntry[];
|
||||
}
|
||||
|
||||
export const SPECIES: Partial<Record<SpeciesId, SpeciesPack>> = {};
|
||||
|
||||
export function registerSpecies(id: SpeciesId, pack: SpeciesPack): void {
|
||||
SPECIES[id] = pack;
|
||||
}
|
||||
|
||||
export function getSpecies(id: SpeciesId): SpeciesPack | undefined {
|
||||
return SPECIES[id];
|
||||
}
|
||||
|
||||
export function isSpeciesAvailable(id: SpeciesId): boolean {
|
||||
return SPECIES[id] !== undefined;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
export type SpeciesId =
|
||||
| 'chien'
|
||||
| 'chat'
|
||||
| 'equine'
|
||||
| 'lapin'
|
||||
| 'bovin'
|
||||
| 'chevre'
|
||||
| 'ane'
|
||||
| 'mouton'
|
||||
| 'porc';
|
||||
|
||||
export type View = 'lateral_left' | 'lateral_right' | 'dorsal';
|
||||
|
||||
export type ZoneCategory = 'axial' | 'limb' | 'head' | 'tail' | 'other';
|
||||
|
||||
export interface Subzone {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface Zone {
|
||||
id: string;
|
||||
label: string;
|
||||
category: ZoneCategory;
|
||||
views: View[];
|
||||
subzones?: Subzone[];
|
||||
}
|
||||
|
||||
export interface VertebralFormula {
|
||||
cervical: number;
|
||||
thoracic: number;
|
||||
lumbar: number;
|
||||
sacral: number;
|
||||
}
|
||||
|
||||
export interface SpeciesAnatomy {
|
||||
id: SpeciesId;
|
||||
label: string;
|
||||
vertebralFormula: VertebralFormula;
|
||||
zones: Zone[];
|
||||
svg: Record<View, string>;
|
||||
}
|
||||
|
||||
export interface PathologyEntry {
|
||||
id: string;
|
||||
label: string;
|
||||
description: string;
|
||||
category:
|
||||
| 'osseux'
|
||||
| 'articulaire'
|
||||
| 'musculaire'
|
||||
| 'tendino-ligamentaire'
|
||||
| 'fascial'
|
||||
| 'visceral'
|
||||
| 'cranio-sacre'
|
||||
| 'nerveux'
|
||||
| 'autre';
|
||||
applicableSpecies: SpeciesId[];
|
||||
applicableZones: string[];
|
||||
sources: string[];
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist, createJSONStorage } from 'zustand/middleware';
|
||||
|
||||
import { newId } from '../lib/id';
|
||||
import type { Finding } from '../schema/finding';
|
||||
import type { Report } from '../schema/report';
|
||||
import { SCHEMA_VERSION } from '../schema/report';
|
||||
|
||||
interface ReportState {
|
||||
report: Report | null;
|
||||
selection: string[];
|
||||
|
||||
hydrate: (r: Report) => void;
|
||||
reset: () => void;
|
||||
|
||||
toggleZone: (zoneId: string) => void;
|
||||
clearSelection: () => void;
|
||||
setSelection: (zones: string[]) => void;
|
||||
|
||||
addFinding: (input: Omit<Finding, 'id'>) => Finding;
|
||||
updateFinding: (id: string, patch: Partial<Finding>) => void;
|
||||
removeFinding: (id: string) => void;
|
||||
|
||||
setConclusion: (text: string) => void;
|
||||
setRecommendations: (text: string) => void;
|
||||
setNextAppointment: (date: string | undefined) => void;
|
||||
}
|
||||
|
||||
function emptyReport(overrides: Partial<Report> = {}): Report {
|
||||
return {
|
||||
version: SCHEMA_VERSION,
|
||||
id: newId('report'),
|
||||
createdAt: new Date().toISOString(),
|
||||
species: 'equine',
|
||||
practitioner: { fullName: '' },
|
||||
animal: { name: '', owner: '' },
|
||||
sessionDate: new Date().toISOString().slice(0, 10),
|
||||
findings: [],
|
||||
conclusion: '',
|
||||
recommendations: '',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export const useReportStore = create<ReportState>()(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
report: null,
|
||||
selection: [],
|
||||
|
||||
hydrate: (r) => set({ report: r, selection: [] }),
|
||||
reset: () => set({ report: null, selection: [] }),
|
||||
|
||||
toggleZone: (zoneId) =>
|
||||
set((s) => {
|
||||
const has = s.selection.includes(zoneId);
|
||||
return {
|
||||
selection: has ? s.selection.filter((z) => z !== zoneId) : [...s.selection, zoneId],
|
||||
};
|
||||
}),
|
||||
clearSelection: () => set({ selection: [] }),
|
||||
setSelection: (zones) => set({ selection: zones }),
|
||||
|
||||
addFinding: (input) => {
|
||||
const finding: Finding = { ...input, id: newId('finding') };
|
||||
const r = get().report;
|
||||
if (!r) return finding;
|
||||
set({
|
||||
report: { ...r, findings: [...r.findings, finding] },
|
||||
selection: [],
|
||||
});
|
||||
return finding;
|
||||
},
|
||||
|
||||
updateFinding: (id, patch) =>
|
||||
set((s) => {
|
||||
if (!s.report) return s;
|
||||
return {
|
||||
report: {
|
||||
...s.report,
|
||||
findings: s.report.findings.map((f) => (f.id === id ? { ...f, ...patch } : f)),
|
||||
},
|
||||
};
|
||||
}),
|
||||
|
||||
removeFinding: (id) =>
|
||||
set((s) => {
|
||||
if (!s.report) return s;
|
||||
return {
|
||||
report: {
|
||||
...s.report,
|
||||
findings: s.report.findings.filter((f) => f.id !== id),
|
||||
},
|
||||
};
|
||||
}),
|
||||
|
||||
setConclusion: (text) =>
|
||||
set((s) => (s.report ? { report: { ...s.report, conclusion: text } } : s)),
|
||||
setRecommendations: (text) =>
|
||||
set((s) => (s.report ? { report: { ...s.report, recommendations: text } } : s)),
|
||||
setNextAppointment: (date) =>
|
||||
set((s) => {
|
||||
if (!s.report) return s;
|
||||
const next: Report =
|
||||
date === undefined
|
||||
? { ...s.report, nextAppointment: undefined }
|
||||
: { ...s.report, nextAppointment: date };
|
||||
return { report: next };
|
||||
}),
|
||||
}),
|
||||
{
|
||||
name: 'osteo-report-draft',
|
||||
storage: createJSONStorage(() => localStorage),
|
||||
partialize: (s) => ({ report: s.report }),
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
export { emptyReport };
|
||||
@@ -1,19 +0,0 @@
|
||||
import type { Finding } from '../schema/finding';
|
||||
import type { Report } from '../schema/report';
|
||||
|
||||
export function findingsByZone(report: Report | null, zoneId: string): Finding[] {
|
||||
if (!report) return [];
|
||||
return report.findings.filter(
|
||||
(f) => f.zones.includes(zoneId) || f.linkedZones.includes(zoneId),
|
||||
);
|
||||
}
|
||||
|
||||
export function zonesInUse(report: Report | null): string[] {
|
||||
if (!report) return [];
|
||||
const ids = new Set<string>();
|
||||
for (const f of report.findings) {
|
||||
for (const z of f.zones) ids.add(z);
|
||||
for (const z of f.linkedZones) ids.add(z);
|
||||
}
|
||||
return Array.from(ids);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
@import 'tailwindcss';
|
||||
@import './tokens.css';
|
||||
|
||||
@theme {
|
||||
--color-clinic-50: var(--clinic-50);
|
||||
--color-clinic-100: var(--clinic-100);
|
||||
--color-clinic-200: var(--clinic-200);
|
||||
--color-clinic-300: var(--clinic-300);
|
||||
--color-clinic-400: var(--clinic-400);
|
||||
--color-clinic-500: var(--clinic-500);
|
||||
--color-clinic-600: var(--clinic-600);
|
||||
--color-clinic-700: var(--clinic-700);
|
||||
--color-clinic-800: var(--clinic-800);
|
||||
--color-clinic-900: var(--clinic-900);
|
||||
--color-warm-300: var(--warm-300);
|
||||
--color-warm-400: var(--warm-400);
|
||||
--color-warm-500: var(--warm-500);
|
||||
--color-surface: var(--surface);
|
||||
--color-ink: var(--ink);
|
||||
--font-sans: 'Inter', system-ui, sans-serif;
|
||||
--font-display: 'Fraunces', Georgia, serif;
|
||||
--font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--surface);
|
||||
color: var(--ink);
|
||||
font-family: var(--font-sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
:root {
|
||||
/* Clinical green — primary identity */
|
||||
--clinic-50: #f4f7f2;
|
||||
--clinic-100: #e6ede0;
|
||||
--clinic-200: #cbdac1;
|
||||
--clinic-300: #a6c099;
|
||||
--clinic-400: #7ba370;
|
||||
--clinic-500: #4a7c59;
|
||||
--clinic-600: #3c6849;
|
||||
--clinic-700: #2d4a35;
|
||||
--clinic-800: #1f3527;
|
||||
--clinic-900: #14241b;
|
||||
|
||||
/* Warm accent — severity / warnings */
|
||||
--warm-300: #d4a574;
|
||||
--warm-400: #b9854a;
|
||||
--warm-500: #a8612d;
|
||||
|
||||
/* Neutrals */
|
||||
--surface: #fffdf8;
|
||||
--ink: #1a2b1f;
|
||||
|
||||
/* Severity scale tokens */
|
||||
--severity-mild: var(--clinic-400);
|
||||
--severity-moderate: var(--warm-300);
|
||||
--severity-severe: var(--warm-500);
|
||||
|
||||
/* Zone state tokens */
|
||||
--zone-default: transparent;
|
||||
--zone-hover: color-mix(in oklab, var(--clinic-300) 30%, transparent);
|
||||
--zone-selected: color-mix(in oklab, var(--clinic-500) 45%, transparent);
|
||||
--zone-linked: color-mix(in oklab, var(--warm-400) 45%, transparent);
|
||||
}
|
||||
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite-plugin-svgr/client" />
|
||||
Reference in new issue
Block a user