feat(i18n): migrate site + PDF to locale-aware rendering
- formatDate(iso, locale) replaces formatDateFr in src/lib/dates.ts
- exportReportToPdf(report, { locale }) takes explicit locale option
- LanguageSwitcher segmented FR | EN toggle added; integrated in
ReportHeader, HomeRoute, NewReportRoute
- All routes (Home, NewReport, Editor, NotFound) + observation
components (FindingsTreePicker, ObservationCard, FreeTextFindingInput,
SeveritySelector, VertebraPicker, ObservationList) + report forms
(PractitionerForm, AnimalForm, ConclusionPanel, NextAppointmentPicker)
route hardcoded FR via useT()
- PDF render functions (export.ts, header.ts, footer.ts,
observationPage.ts, conclusionPage.ts) take a locale arg and read
static labels from the dict snapshot at call time
- Catalog finding leaf labels rendered via labelFr/EnSnapshot per locale
- description_fr / scope_disclaimer stay FR-only (out of scope —
vet-expert authoring needed for EN copy)
- LanguageSwitcher unit test (2) + lib.dates locale tests (7) cover
the new behavior
151/151 tests pass, lint 0, typecheck clean, vite build OK
(902KB main + 15KB lazy pathologies chunk).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
359104ce88
commit
d6027266bc
25 files changed
+390
-207
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
|
||||
const ITEMS: { value: Locale; label: string; ariaLabel: string }[] = [
|
||||
{ value: 'fr', label: 'FR', ariaLabel: 'Passer en français' },
|
||||
{ value: 'en', label: 'EN', ariaLabel: 'Switch to English' },
|
||||
]
|
||||
|
||||
export default function LanguageSwitcher() {
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const setLocale = useLocaleStore((s) => s.setLocale)
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-label="Language"
|
||||
className="inline-flex rounded-full border border-[var(--color-border)] overflow-hidden text-xs font-medium"
|
||||
>
|
||||
{ITEMS.map((item) => {
|
||||
const active = locale === item.value
|
||||
return (
|
||||
<button
|
||||
key={item.value}
|
||||
type="button"
|
||||
aria-label={item.ariaLabel}
|
||||
aria-pressed={active}
|
||||
onClick={() => setLocale(item.value)}
|
||||
className={[
|
||||
'px-2.5 py-1 transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]',
|
||||
active
|
||||
? 'bg-[var(--color-accent)] text-white'
|
||||
: 'text-[var(--color-ink)] hover:bg-[var(--color-surface-strong)]',
|
||||
].join(' ')}
|
||||
>
|
||||
{item.label}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import type {
|
||||
} from '@/domain/schema/findings'
|
||||
import type { Finding } from '@/domain/schema/observation'
|
||||
import Button from '@/components/ui/Button'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
export interface FindingsTreePickerProps {
|
||||
zoneId: string
|
||||
@@ -53,6 +55,13 @@ export default function FindingsTreePicker({
|
||||
selected,
|
||||
onChange,
|
||||
}: FindingsTreePickerProps) {
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const nameOf = (node: { name_fr: string; name_en: string }) =>
|
||||
locale === 'en' ? node.name_en : node.name_fr
|
||||
const descOf = (node: { description_fr?: string; description_en?: string }) =>
|
||||
locale === 'en' ? node.description_en : node.description_fr
|
||||
|
||||
const [path, setPath] = useState<string[]>([])
|
||||
|
||||
const currentNodes = useMemo<FindingNode[]>(() => {
|
||||
@@ -67,19 +76,21 @@ export default function FindingsTreePicker({
|
||||
)
|
||||
|
||||
const breadcrumb = useMemo<{ label: string; depth: number }[]>(() => {
|
||||
const pick = (z: { name_fr: string; name_en: string }) =>
|
||||
locale === 'en' ? z.name_en : z.name_fr
|
||||
const crumbs: { label: string; depth: number }[] = [
|
||||
{ label: tree.name_fr, depth: 0 },
|
||||
{ label: pick(tree), depth: 0 },
|
||||
]
|
||||
let nodes: FindingNode[] = tree.categories
|
||||
path.forEach((seg, i) => {
|
||||
const n = nodes.find((x) => x.id === seg)
|
||||
if (n) {
|
||||
crumbs.push({ label: n.name_fr, depth: i + 1 })
|
||||
crumbs.push({ label: pick(n), depth: i + 1 })
|
||||
nodes = n.children ?? []
|
||||
}
|
||||
})
|
||||
return crumbs
|
||||
}, [tree, path])
|
||||
}, [tree, path, locale])
|
||||
|
||||
function isLeafSelected(leafPath: string[]): boolean {
|
||||
return selected.some(
|
||||
@@ -141,9 +152,9 @@ export default function FindingsTreePicker({
|
||||
})}
|
||||
</div>
|
||||
|
||||
{focusedNode?.description_fr && (
|
||||
{focusedNode && descOf(focusedNode) && (
|
||||
<p className="text-xs italic text-[var(--color-ink-muted)]">
|
||||
{focusedNode.description_fr}
|
||||
{descOf(focusedNode)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -152,22 +163,24 @@ export default function FindingsTreePicker({
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => setPath(path.slice(0, -1))}
|
||||
aria-label="Retour au niveau précédent"
|
||||
aria-label={t('findings.back_to_parent')}
|
||||
>
|
||||
← Retour
|
||||
{t('findings.back')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<ul className="space-y-1.5 max-h-64 overflow-auto pr-1">
|
||||
{currentNodes.length === 0 ? (
|
||||
<li className="text-sm text-[var(--color-ink-muted)]">
|
||||
Aucune option disponible à ce niveau.
|
||||
{t('findings.no_options')}
|
||||
</li>
|
||||
) : (
|
||||
currentNodes.map((node) => {
|
||||
const nodePath = [...path, node.id]
|
||||
if (isLeaf(node)) {
|
||||
const checked = isLeafSelected(nodePath)
|
||||
const nodeLabel = nameOf(node)
|
||||
const nodeDesc = descOf(node)
|
||||
return (
|
||||
<li key={node.id}>
|
||||
<label className="flex items-start gap-2 cursor-pointer">
|
||||
@@ -176,26 +189,26 @@ export default function FindingsTreePicker({
|
||||
checked={checked}
|
||||
onChange={() => toggleLeaf(nodePath, node)}
|
||||
className="mt-1 accent-[var(--color-accent)]"
|
||||
aria-label={node.name_fr}
|
||||
aria-label={nodeLabel}
|
||||
/>
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm font-medium text-[var(--color-ink)]">
|
||||
{node.name_fr}
|
||||
{nodeLabel}
|
||||
</span>
|
||||
{node.requires_vet_referral && (
|
||||
<span
|
||||
title="Référer au vétérinaire"
|
||||
aria-label="Référer au vétérinaire"
|
||||
title={t('findings.vet_referral')}
|
||||
aria-label={t('findings.vet_referral')}
|
||||
className="text-[var(--color-danger)]"
|
||||
>
|
||||
⚠
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{node.description_fr && (
|
||||
{nodeDesc && (
|
||||
<div className="text-xs text-[var(--color-ink-muted)]">
|
||||
{node.description_fr}
|
||||
{nodeDesc}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -204,19 +217,25 @@ export default function FindingsTreePicker({
|
||||
)
|
||||
}
|
||||
const selectedCount = countSelectedUnder(nodePath)
|
||||
const nodeLabel = nameOf(node)
|
||||
const selectedAria = `${selectedCount} ${
|
||||
selectedCount > 1
|
||||
? t('findings.selected_plural')
|
||||
: t('findings.selected_singular')
|
||||
}`
|
||||
return (
|
||||
<li key={node.id}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setPath(nodePath)}
|
||||
className="flex items-center justify-between w-full text-left text-sm px-2 py-1.5 rounded hover:bg-[var(--color-surface-strong)] text-[var(--color-ink)]"
|
||||
aria-label={`Ouvrir ${node.name_fr}`}
|
||||
aria-label={`${t('findings.open')} ${nodeLabel}`}
|
||||
>
|
||||
<span className="flex items-center gap-2">
|
||||
<span>{node.name_fr}</span>
|
||||
<span>{nodeLabel}</span>
|
||||
{selectedCount > 0 && (
|
||||
<span
|
||||
aria-label={`${selectedCount} constat${selectedCount > 1 ? 's' : ''} sélectionné${selectedCount > 1 ? 's' : ''}`}
|
||||
aria-label={selectedAria}
|
||||
className="inline-flex items-center justify-center min-w-[20px] h-[20px] px-1.5 rounded-full text-[11px] font-semibold bg-[var(--color-accent)] text-white"
|
||||
>
|
||||
{selectedCount}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState } from 'react'
|
||||
import Input from '@/components/ui/Input'
|
||||
import Button from '@/components/ui/Button'
|
||||
import Badge from '@/components/ui/Badge'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface FreeTextFindingInputProps {
|
||||
items: string[]
|
||||
@@ -13,6 +14,7 @@ export default function FreeTextFindingInput({
|
||||
onChange,
|
||||
}: FreeTextFindingInputProps) {
|
||||
const [v, setV] = useState('')
|
||||
const t = useT()
|
||||
|
||||
function add() {
|
||||
const trimmed = v.trim()
|
||||
@@ -31,17 +33,17 @@ export default function FreeTextFindingInput({
|
||||
<Input
|
||||
value={v}
|
||||
onChange={(e) => setV(e.target.value)}
|
||||
placeholder="Observation additionnelle (texte libre)"
|
||||
placeholder={t('observation.free_placeholder')}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault()
|
||||
add()
|
||||
}
|
||||
}}
|
||||
aria-label="Observation libre"
|
||||
aria-label={t('observation.free_aria')}
|
||||
/>
|
||||
<Button onClick={add} variant="secondary">
|
||||
Ajouter
|
||||
{t('common.add')}
|
||||
</Button>
|
||||
</div>
|
||||
{items.length > 0 && (
|
||||
@@ -52,7 +54,7 @@ export default function FreeTextFindingInput({
|
||||
{it}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Retirer ${it}`}
|
||||
aria-label={`${t('observation.remove_zone')} ${it}`}
|
||||
onClick={() => remove(i)}
|
||||
className="ml-1 text-[var(--color-accent-strong)] hover:text-[var(--color-danger)]"
|
||||
>
|
||||
|
||||
@@ -19,6 +19,8 @@ import Textarea from '@/components/ui/Textarea'
|
||||
import FindingsTreePicker from './FindingsTreePicker'
|
||||
import FreeTextFindingInput from './FreeTextFindingInput'
|
||||
import SeveritySelector from './SeveritySelector'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
export interface ObservationCardProps {
|
||||
observation: Observation
|
||||
@@ -66,6 +68,11 @@ export default function ObservationCard({
|
||||
onOpenVertebraPicker,
|
||||
onRemoveZone,
|
||||
}: ObservationCardProps) {
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const nameOf = (z: { name_fr: string; name_en: string }) =>
|
||||
locale === 'en' ? z.name_en : z.name_fr
|
||||
|
||||
// Per-zone picker accordion — only one tree picker open at a time,
|
||||
// matching the observation-card accordion semantics. Closed by default
|
||||
// so the card stays compact when first expanded.
|
||||
@@ -75,6 +82,15 @@ export default function ObservationCard({
|
||||
const findingCount =
|
||||
observation.findings.length + observation.freeTextFindings.length
|
||||
|
||||
const zoneCountLabel =
|
||||
zoneCount > 1
|
||||
? t('observation.zone_label_plural')
|
||||
: t('observation.zone_label_singular')
|
||||
const findingCountLabel =
|
||||
findingCount > 1
|
||||
? t('observation.finding_label_plural')
|
||||
: t('observation.finding_label_singular')
|
||||
|
||||
function onHeaderKey(event: React.KeyboardEvent<HTMLDivElement>) {
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault()
|
||||
@@ -89,11 +105,6 @@ export default function ObservationCard({
|
||||
}
|
||||
}
|
||||
|
||||
// SVG data-anno-id values are opaque generator strings (e.g.
|
||||
// "point-mpbyk..."); the JSON catalog keys observations by stable
|
||||
// human zone names (e.g. "sphenoid"). Bridge the two by matching the
|
||||
// bone's FR/EN labels against the catalog labels — EN exact first,
|
||||
// then FR, then small typos / abbreviations via fuzzy scoring.
|
||||
const zonesArray = useMemo(
|
||||
() => (findings ? Object.values(findings.zones) : []),
|
||||
[findings],
|
||||
@@ -131,14 +142,14 @@ export default function ObservationCard({
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-expanded={expanded}
|
||||
aria-label={`${expanded ? 'Réduire' : 'Développer'} l'observation ${index + 1}`}
|
||||
aria-label={`${expanded ? t('observation.collapse_aria') : t('observation.expand_aria')} ${index + 1}`}
|
||||
onClick={onToggle}
|
||||
onKeyDown={onHeaderKey}
|
||||
className="flex items-start justify-between gap-3 p-4 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]/40 rounded-2xl"
|
||||
>
|
||||
<div className="flex-1 min-h-[60px] text-left">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge tone="neutral">Observation #{index + 1}</Badge>
|
||||
<Badge tone="neutral">{t('observation.badge_n')}{index + 1}</Badge>
|
||||
{observation.severity && (
|
||||
<Badge
|
||||
tone={
|
||||
@@ -149,13 +160,12 @@ export default function ObservationCard({
|
||||
: 'neutral'
|
||||
}
|
||||
>
|
||||
{observation.severity}
|
||||
{t(`severity.${observation.severity}`)}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--color-ink-muted)]">
|
||||
{zoneCount} zone{zoneCount > 1 ? 's' : ''} · {findingCount} constat
|
||||
{findingCount > 1 ? 's' : ''}
|
||||
{zoneCount} {zoneCountLabel} · {findingCount} {findingCountLabel}
|
||||
</div>
|
||||
{!expanded && observation.comment && (
|
||||
<p className="mt-2 text-sm line-clamp-2 text-[var(--color-ink)]">
|
||||
@@ -172,7 +182,7 @@ export default function ObservationCard({
|
||||
variant="ghost"
|
||||
disabled={!canMoveUp}
|
||||
onClick={stop(onMoveUp)}
|
||||
aria-label="Monter"
|
||||
aria-label={t('common.move_up')}
|
||||
>
|
||||
↑
|
||||
</Button>
|
||||
@@ -181,7 +191,7 @@ export default function ObservationCard({
|
||||
variant="ghost"
|
||||
disabled={!canMoveDown}
|
||||
onClick={stop(onMoveDown)}
|
||||
aria-label="Descendre"
|
||||
aria-label={t('common.move_down')}
|
||||
>
|
||||
↓
|
||||
</Button>
|
||||
@@ -189,7 +199,7 @@ export default function ObservationCard({
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={stop(onDelete)}
|
||||
aria-label="Supprimer"
|
||||
aria-label={t('common.delete')}
|
||||
>
|
||||
🗑
|
||||
</Button>
|
||||
@@ -197,7 +207,7 @@ export default function ObservationCard({
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={stop(onToggle)}
|
||||
aria-label={expanded ? 'Réduire' : 'Développer'}
|
||||
aria-label={expanded ? t('common.collapse') : t('common.expand')}
|
||||
>
|
||||
{expanded ? '▲' : '▼'}
|
||||
</Button>
|
||||
@@ -216,11 +226,10 @@ export default function ObservationCard({
|
||||
>
|
||||
<div className="px-4 pb-4 pt-2 border-t border-[var(--color-border)] space-y-6">
|
||||
<section>
|
||||
<Label>Zones sélectionnées</Label>
|
||||
<Label>{t('observation.zones_label')}</Label>
|
||||
{observation.zones.length === 0 ? (
|
||||
<p className="text-sm text-[var(--color-ink-muted)]">
|
||||
Cliquez sur les zones du schéma pour les ajouter à cette
|
||||
observation.
|
||||
{t('observation.zones_empty')}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="flex flex-wrap gap-2">
|
||||
@@ -237,14 +246,14 @@ export default function ObservationCard({
|
||||
type="button"
|
||||
onClick={() => onOpenVertebraPicker(i)}
|
||||
className="underline text-xs text-[var(--color-accent-strong)]"
|
||||
title="Préciser les vertèbres pour cette zone"
|
||||
title={t('observation.vertebrae_button_title')}
|
||||
>
|
||||
Vertèbres…
|
||||
{t('observation.vertebrae_button')}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Retirer ${b?.fr ?? z.boneId}`}
|
||||
aria-label={`${t('observation.remove_zone')} ${b?.fr ?? z.boneId}`}
|
||||
onClick={() => onRemoveZone(i)}
|
||||
className="ml-1 text-[var(--color-accent-strong)]"
|
||||
>
|
||||
@@ -259,12 +268,12 @@ export default function ObservationCard({
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<Label>Constats (référentiel)</Label>
|
||||
<Label>{t('observation.findings_catalog_label')}</Label>
|
||||
{zonesWithTree.length === 0 ? (
|
||||
<p className="text-sm text-[var(--color-ink-muted)]">
|
||||
{observation.zones.length === 0
|
||||
? 'Sélectionnez une zone pour accéder au référentiel.'
|
||||
: 'Aucun référentiel disponible pour ces zones. Utilisez le texte libre ci-dessous.'}
|
||||
? t('observation.findings_pick_zone_first')
|
||||
: t('observation.findings_no_catalog')}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="space-y-2">
|
||||
@@ -273,6 +282,11 @@ export default function ObservationCard({
|
||||
const selectedCount = observation.findings.filter(
|
||||
(f) => f.zoneId === tree.id,
|
||||
).length
|
||||
const selectedAria = `${selectedCount} ${
|
||||
selectedCount > 1
|
||||
? t('findings.selected_plural')
|
||||
: t('findings.selected_singular')
|
||||
}`
|
||||
return (
|
||||
<li
|
||||
key={tree.id}
|
||||
@@ -294,11 +308,11 @@ export default function ObservationCard({
|
||||
>
|
||||
<span className="flex items-center gap-2">
|
||||
<span className="text-sm font-medium text-[var(--color-ink)]">
|
||||
{tree.name_fr}
|
||||
{nameOf(tree)}
|
||||
</span>
|
||||
{selectedCount > 0 && (
|
||||
<span
|
||||
aria-label={`${selectedCount} constat${selectedCount > 1 ? 's' : ''} sélectionné${selectedCount > 1 ? 's' : ''}`}
|
||||
aria-label={selectedAria}
|
||||
className="inline-flex items-center justify-center min-w-[20px] h-[20px] px-1.5 rounded-full text-[11px] font-semibold bg-[var(--color-accent)] text-white"
|
||||
>
|
||||
{selectedCount}
|
||||
@@ -344,7 +358,7 @@ export default function ObservationCard({
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<Label>Constats (texte libre)</Label>
|
||||
<Label>{t('observation.findings_free_label')}</Label>
|
||||
<FreeTextFindingInput
|
||||
items={observation.freeTextFindings}
|
||||
onChange={(items) =>
|
||||
@@ -354,7 +368,7 @@ export default function ObservationCard({
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<Label>Sévérité</Label>
|
||||
<Label>{t('observation.severity_label')}</Label>
|
||||
<SeveritySelector
|
||||
value={observation.severity}
|
||||
onChange={(s) => onChange({ ...observation, severity: s })}
|
||||
@@ -363,7 +377,7 @@ export default function ObservationCard({
|
||||
|
||||
<section>
|
||||
<Label htmlFor={`obs-comment-${observation.id}`}>
|
||||
Commentaire
|
||||
{t('observation.comment_label')}
|
||||
</Label>
|
||||
<Textarea
|
||||
id={`obs-comment-${observation.id}`}
|
||||
@@ -371,7 +385,7 @@ export default function ObservationCard({
|
||||
onChange={(e) =>
|
||||
onChange({ ...observation, comment: e.target.value })
|
||||
}
|
||||
placeholder="Notes cliniques détaillées…"
|
||||
placeholder={t('observation.comment_placeholder')}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { SpeciesFindings } from '@/domain/schema/findings'
|
||||
import type { Bone } from '@/anatomy/types'
|
||||
import ObservationCard from './ObservationCard'
|
||||
import Button from '@/components/ui/Button'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface ObservationListProps {
|
||||
observations: Observation[]
|
||||
@@ -34,20 +35,20 @@ export default function ObservationList({
|
||||
onOpenVertebraPicker,
|
||||
onRemoveZone,
|
||||
}: ObservationListProps) {
|
||||
const t = useT()
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="font-serif text-xl text-[var(--color-ink)]">
|
||||
Observations
|
||||
{t('observation.section_title')}
|
||||
</h2>
|
||||
<Button size="sm" onClick={onAdd}>
|
||||
+ Nouvelle observation
|
||||
{t('observation.add')}
|
||||
</Button>
|
||||
</div>
|
||||
{observations.length === 0 ? (
|
||||
<p className="text-sm text-[var(--color-ink-muted)]">
|
||||
Aucune observation. Cliquez sur "+ Nouvelle observation"
|
||||
puis sur les zones du schéma.
|
||||
{t('observation.empty')}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="space-y-2">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Severity } from '@/domain/schema/observation'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface SeveritySelectorProps {
|
||||
value: Severity | undefined
|
||||
@@ -13,8 +14,9 @@ const COLORS: Record<Severity, string> = {
|
||||
}
|
||||
|
||||
export default function SeveritySelector({ value, onChange }: SeveritySelectorProps) {
|
||||
const t = useT()
|
||||
return (
|
||||
<div role="radiogroup" aria-label="Sévérité" className="flex gap-2">
|
||||
<div role="radiogroup" aria-label={t('severity.aria')} className="flex gap-2">
|
||||
{SEVERITIES.map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
@@ -28,7 +30,7 @@ export default function SeveritySelector({ value, onChange }: SeveritySelectorPr
|
||||
: 'border-[var(--color-border)] text-[var(--color-ink-muted)]',
|
||||
].join(' ')}
|
||||
>
|
||||
{s}
|
||||
{t(`severity.${s}`)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -4,13 +4,15 @@ import Button from '@/components/ui/Button'
|
||||
import Chip from '@/components/ui/Chip'
|
||||
import type { Vertebra, VertebralRegion } from '@/domain/schema/observation'
|
||||
import type { VertebralFormula } from '@/domain/species/types'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
const REGION_LABELS: Record<VertebralRegion, string> = {
|
||||
C: 'Cervicales',
|
||||
T: 'Thoraciques',
|
||||
L: 'Lombaires',
|
||||
S: 'Sacrales',
|
||||
Cd: 'Caudales',
|
||||
const REGIONS: VertebralRegion[] = ['C', 'T', 'L', 'S', 'Cd']
|
||||
const REGION_KEY: Record<VertebralRegion, string> = {
|
||||
C: 'vertebra.region.C',
|
||||
T: 'vertebra.region.T',
|
||||
L: 'vertebra.region.L',
|
||||
S: 'vertebra.region.S',
|
||||
Cd: 'vertebra.region.Cd',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,8 +25,6 @@ export function regionFromLabel(label: string): VertebralRegion | undefined {
|
||||
.normalize('NFD')
|
||||
.replace(/\p{Diacritic}/gu, '')
|
||||
.toLowerCase()
|
||||
// Order matters: 'caudal'/'coccyg' before 'cervic' is fine; just be
|
||||
// explicit so no root subsumes another.
|
||||
if (norm.includes('cervic')) return 'C'
|
||||
if (norm.includes('thorac') || norm.includes('dors')) return 'T'
|
||||
if (norm.includes('lombair') || norm.includes('lumbar')) return 'L'
|
||||
@@ -53,6 +53,7 @@ export default function VertebraPicker({
|
||||
title,
|
||||
initialRegion,
|
||||
}: VertebraPickerProps) {
|
||||
const t = useT()
|
||||
const [selected, setSelected] = useState<Vertebra[]>(initial)
|
||||
const [activeRegion, setActiveRegion] = useState<VertebralRegion>(
|
||||
() => initial[0]?.region ?? initialRegion ?? 'C',
|
||||
@@ -84,7 +85,7 @@ export default function VertebraPicker({
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} title={title} size="lg">
|
||||
<div role="tablist" className="flex flex-wrap gap-2 mb-4">
|
||||
{(Object.keys(REGION_LABELS) as VertebralRegion[]).map((r) => (
|
||||
{REGIONS.map((r) => (
|
||||
<button
|
||||
key={r}
|
||||
role="tab"
|
||||
@@ -97,7 +98,7 @@ export default function VertebraPicker({
|
||||
: 'bg-white text-[var(--color-ink)] border-[var(--color-border)]',
|
||||
].join(' ')}
|
||||
>
|
||||
{REGION_LABELS[r]}
|
||||
{t(REGION_KEY[r])}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
@@ -115,13 +116,17 @@ export default function VertebraPicker({
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2 mb-6">
|
||||
<Button variant="ghost" size="sm" onClick={() => all(activeRegion, count)}>Tout cocher</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => none(activeRegion)}>Tout décocher</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => all(activeRegion, count)}>
|
||||
{t('vertebra.check_all')}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={() => none(activeRegion)}>
|
||||
{t('vertebra.uncheck_all')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="ghost" onClick={onClose}>Annuler</Button>
|
||||
<Button onClick={() => onConfirm(selected)}>Valider</Button>
|
||||
<Button variant="ghost" onClick={onClose}>{t('common.cancel')}</Button>
|
||||
<Button onClick={() => onConfirm(selected)}>{t('common.confirm')}</Button>
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ import Label from '@/components/ui/Label'
|
||||
import Input from '@/components/ui/Input'
|
||||
import Select from '@/components/ui/Select'
|
||||
import { getAllSpecies } from '@/domain/species/registry'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface AnimalFormProps {
|
||||
animal: Animal
|
||||
@@ -12,13 +13,16 @@ export interface AnimalFormProps {
|
||||
}
|
||||
|
||||
export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwner }: AnimalFormProps) {
|
||||
const t = useT()
|
||||
const species = getAllSpecies()
|
||||
const setA = (patch: Partial<Animal>) => onChangeAnimal({ ...animal, ...patch })
|
||||
return (
|
||||
<fieldset className="space-y-3">
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">Animal & propriétaire</legend>
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">
|
||||
{t('form.animal.legend')}
|
||||
</legend>
|
||||
<div>
|
||||
<Label htmlFor="an-species">Espèce *</Label>
|
||||
<Label htmlFor="an-species">{t('form.animal.species')}</Label>
|
||||
<Select
|
||||
id="an-species"
|
||||
value={animal.speciesId}
|
||||
@@ -30,19 +34,19 @@ export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwne
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="an-name">Nom de l'animal *</Label>
|
||||
<Label htmlFor="an-name">{t('form.animal.name')}</Label>
|
||||
<Input id="an-name" required value={animal.name} onChange={(e) => setA({ name: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="an-breed">Race</Label>
|
||||
<Label htmlFor="an-breed">{t('form.animal.breed')}</Label>
|
||||
<Input id="an-breed" value={animal.breed ?? ''} onChange={(e) => setA({ breed: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="an-age">Âge</Label>
|
||||
<Label htmlFor="an-age">{t('form.animal.age')}</Label>
|
||||
<Input id="an-age" value={animal.age ?? ''} onChange={(e) => setA({ age: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="own-name">Nom du propriétaire *</Label>
|
||||
<Label htmlFor="own-name">{t('form.owner.name')}</Label>
|
||||
<Input id="own-name" required value={owner.name} onChange={(e) => onChangeOwner({ name: e.target.value })} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Report } from '@/domain/schema/report'
|
||||
import Label from '@/components/ui/Label'
|
||||
import Textarea from '@/components/ui/Textarea'
|
||||
import NextAppointmentPicker from './NextAppointmentPicker'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface ConclusionPanelProps {
|
||||
conclusion: string
|
||||
@@ -20,15 +21,18 @@ export default function ConclusionPanel({
|
||||
onChangeRecommendations,
|
||||
onChangeNextAppointment,
|
||||
}: ConclusionPanelProps) {
|
||||
const t = useT()
|
||||
return (
|
||||
<section className="space-y-4">
|
||||
<h2 className="font-serif text-xl text-[var(--color-ink)]">Conclusion & recommandations</h2>
|
||||
<h2 className="font-serif text-xl text-[var(--color-ink)]">
|
||||
{t('conclusion.section_title')}
|
||||
</h2>
|
||||
<div>
|
||||
<Label htmlFor="conclusion">Conclusion</Label>
|
||||
<Label htmlFor="conclusion">{t('conclusion.conclusion')}</Label>
|
||||
<Textarea id="conclusion" value={conclusion} onChange={(e) => onChangeConclusion(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="recommendations">Recommandations</Label>
|
||||
<Label htmlFor="recommendations">{t('conclusion.recommendations')}</Label>
|
||||
<Textarea id="recommendations" value={recommendations} onChange={(e) => onChangeRecommendations(e.target.value)} />
|
||||
</div>
|
||||
<NextAppointmentPicker value={nextAppointment} onChange={onChangeNextAppointment} />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import Input from '@/components/ui/Input'
|
||||
import Label from '@/components/ui/Label'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface NextAppointmentPickerProps {
|
||||
value: Report['nextAppointment']
|
||||
@@ -11,10 +12,11 @@ export default function NextAppointmentPicker({
|
||||
value,
|
||||
onChange,
|
||||
}: NextAppointmentPickerProps) {
|
||||
const t = useT()
|
||||
const kind = value?.kind
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Label>Prochain rendez-vous</Label>
|
||||
<Label>{t('conclusion.next_appointment')}</Label>
|
||||
<div className="flex gap-2 mb-2">
|
||||
<label className="text-sm flex items-center gap-1">
|
||||
<input
|
||||
@@ -22,7 +24,7 @@ export default function NextAppointmentPicker({
|
||||
checked={kind === 'date'}
|
||||
onChange={() => onChange({ kind: 'date', date: '' })}
|
||||
/>
|
||||
Date
|
||||
{t('conclusion.next_kind_date')}
|
||||
</label>
|
||||
<label className="text-sm flex items-center gap-1">
|
||||
<input
|
||||
@@ -30,7 +32,7 @@ export default function NextAppointmentPicker({
|
||||
checked={kind === 'period'}
|
||||
onChange={() => onChange({ kind: 'period', text: '' })}
|
||||
/>
|
||||
Période libre
|
||||
{t('conclusion.next_kind_period')}
|
||||
</label>
|
||||
<label className="text-sm flex items-center gap-1">
|
||||
<input
|
||||
@@ -38,7 +40,7 @@ export default function NextAppointmentPicker({
|
||||
checked={value === undefined}
|
||||
onChange={() => onChange(undefined)}
|
||||
/>
|
||||
Aucun
|
||||
{t('conclusion.next_kind_none')}
|
||||
</label>
|
||||
</div>
|
||||
{value?.kind === 'date' && (
|
||||
@@ -51,7 +53,7 @@ export default function NextAppointmentPicker({
|
||||
{value?.kind === 'period' && (
|
||||
<Input
|
||||
value={value.text}
|
||||
placeholder="ex. dans 3 semaines"
|
||||
placeholder={t('conclusion.next_period_placeholder')}
|
||||
onChange={(e) => onChange({ kind: 'period', text: e.target.value })}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Practitioner } from '@/domain/schema/practitioner'
|
||||
import Label from '@/components/ui/Label'
|
||||
import Input from '@/components/ui/Input'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface PractitionerFormProps {
|
||||
value: Practitioner
|
||||
@@ -8,24 +9,27 @@ export interface PractitionerFormProps {
|
||||
}
|
||||
|
||||
export default function PractitionerForm({ value, onChange }: PractitionerFormProps) {
|
||||
const t = useT()
|
||||
const set = (patch: Partial<Practitioner>) => onChange({ ...value, ...patch })
|
||||
return (
|
||||
<fieldset className="space-y-3">
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">Praticien</legend>
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">
|
||||
{t('form.practitioner.legend')}
|
||||
</legend>
|
||||
<div>
|
||||
<Label htmlFor="prac-name">Nom complet *</Label>
|
||||
<Label htmlFor="prac-name">{t('form.practitioner.name')}</Label>
|
||||
<Input id="prac-name" required value={value.name} onChange={(e) => set({ name: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="prac-cabinet">Cabinet / clinique</Label>
|
||||
<Label htmlFor="prac-cabinet">{t('form.practitioner.cabinet')}</Label>
|
||||
<Input id="prac-cabinet" value={value.cabinet ?? ''} onChange={(e) => set({ cabinet: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="prac-contact">Contact (téléphone, email…)</Label>
|
||||
<Label htmlFor="prac-contact">{t('form.practitioner.contact')}</Label>
|
||||
<Input id="prac-contact" value={value.contact ?? ''} onChange={(e) => set({ contact: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="prac-siret">SIRET</Label>
|
||||
<Label htmlFor="prac-siret">{t('form.practitioner.siret')}</Label>
|
||||
<Input id="prac-siret" value={value.siret ?? ''} onChange={(e) => set({ siret: e.target.value || undefined })} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import Brand from '@/components/brand/Brand'
|
||||
import LanguageSwitcher from '@/components/brand/LanguageSwitcher'
|
||||
import Button from '@/components/ui/Button'
|
||||
import { formatDateFr } from '@/lib/dates'
|
||||
import { formatDate } from '@/lib/dates'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
export interface ReportHeaderProps {
|
||||
report: Report
|
||||
@@ -11,6 +14,8 @@ export interface ReportHeaderProps {
|
||||
|
||||
export default function ReportHeader({ report, onEditInfos }: ReportHeaderProps) {
|
||||
const navigate = useNavigate()
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
return (
|
||||
<header className="flex items-center justify-between gap-4 px-6 py-3 border-b border-[var(--color-border)] bg-[var(--color-surface)]">
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -18,28 +23,29 @@ export default function ReportHeader({ report, onEditInfos }: ReportHeaderProps)
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/')}
|
||||
aria-label="Retour à l'accueil"
|
||||
aria-label={t('common.back_to_home')}
|
||||
>
|
||||
← Accueil
|
||||
← {t('common.home')}
|
||||
</Button>
|
||||
<Link
|
||||
to="/"
|
||||
aria-label="Retour à l'accueil"
|
||||
aria-label={t('common.back_to_home')}
|
||||
className="rounded-md px-1 py-0.5 hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]"
|
||||
>
|
||||
<Brand />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<LanguageSwitcher />
|
||||
<div className="text-sm text-right text-[var(--color-ink-muted)]">
|
||||
<div className="text-[var(--color-ink)] font-medium">
|
||||
{report.animal.name} · {report.owner.name}
|
||||
</div>
|
||||
<div>{formatDateFr(report.date)}</div>
|
||||
<div>{formatDate(report.date, locale)}</div>
|
||||
</div>
|
||||
{onEditInfos && (
|
||||
<Button variant="secondary" size="sm" onClick={onEditInfos}>
|
||||
Modifier les infos
|
||||
{t('editor.edit_infos')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user