Three issues from manual QA: 1. UX restructure — observations are now an accordion list. Each card has a header that's always visible (title + chips + chevron + action buttons) and a body that expands inline showing zones / pathologies / severity / comment. Click the header (or the chevron) to toggle. ObservationEditor has been merged into ObservationCard so each card owns its own details. Only one observation is expanded at a time; the chevron on the active card collapses everything. EditorRoute uses activeObservationIndex === -1 to represent "all collapsed". 2. App used to start with 2 observations instead of 1. Root cause: EditorRoute had a "seed first observation" useEffect that fired twice under React 19 StrictMode in dev, both invocations seeing length=0 and queueing addObservation(). Fixed by moving the seed into the store's initReport (synchronous, one-shot) and removing the useEffect entirely. Store tests updated to assert the seed behaviour (90/90 pass). 3. PDF export still failed with "The input is not a PNG file!" — canvg was returning bytes that pdf-lib rejected at embedPng(). Switched rasterizeSvg to the browser-native pipeline: serialize the SVG into a Blob URL, load it with an Image element, drawImage onto a 2D canvas, then toBlob → PNG bytes (with a toDataURL fallback). Validates the PNG signature before returning. Tree-shaking dropped canvg from the bundle (979 kB → 874 kB JS). Tests updated for the new initReport behaviour and the new svgToPng pipeline (Image mock + dataURL fallback case). lint + typecheck + build all clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84 lines
2.5 KiB
TypeScript
84 lines
2.5 KiB
TypeScript
import type { Observation } from '@/domain/schema/observation'
|
|
import type { Pathology } from '@/domain/schema/pathology'
|
|
import type { Bone } from '@/anatomy/types'
|
|
import ObservationCard from './ObservationCard'
|
|
import Button from '@/components/ui/Button'
|
|
|
|
export interface ObservationListProps {
|
|
observations: Observation[]
|
|
activeIndex: number
|
|
onToggle: (i: number) => void
|
|
onAdd: () => void
|
|
onDelete: (i: number) => void
|
|
onMoveUp: (i: number) => void
|
|
onMoveDown: (i: number) => void
|
|
// Editor body props forwarded to each card
|
|
bones: Map<string, Bone>
|
|
speciesId: string
|
|
pathologyPool: Pathology[]
|
|
onChange: (i: number, next: Observation) => void
|
|
onOpenVertebraPicker: (i: number, zoneIndex: number) => void
|
|
onRemoveZone: (i: number, zoneIndex: number) => void
|
|
}
|
|
|
|
export default function ObservationList({
|
|
observations,
|
|
activeIndex,
|
|
onToggle,
|
|
onAdd,
|
|
onDelete,
|
|
onMoveUp,
|
|
onMoveDown,
|
|
bones,
|
|
speciesId,
|
|
pathologyPool,
|
|
onChange,
|
|
onOpenVertebraPicker,
|
|
onRemoveZone,
|
|
}: ObservationListProps) {
|
|
return (
|
|
<div className="space-y-3">
|
|
<div className="flex items-center justify-between">
|
|
<h2 className="font-serif text-xl text-[var(--color-ink)]">
|
|
Observations
|
|
</h2>
|
|
<Button size="sm" onClick={onAdd}>
|
|
+ Nouvelle observation
|
|
</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.
|
|
</p>
|
|
) : (
|
|
<ul className="space-y-2">
|
|
{observations.map((obs, i) => (
|
|
<li key={obs.id}>
|
|
<ObservationCard
|
|
observation={obs}
|
|
index={i}
|
|
expanded={i === activeIndex}
|
|
onToggle={() => onToggle(i)}
|
|
onDelete={() => onDelete(i)}
|
|
onMoveUp={() => onMoveUp(i)}
|
|
onMoveDown={() => onMoveDown(i)}
|
|
canMoveUp={i > 0}
|
|
canMoveDown={i < observations.length - 1}
|
|
bones={bones}
|
|
speciesId={speciesId}
|
|
pathologyPool={pathologyPool}
|
|
onChange={(next) => onChange(i, next)}
|
|
onOpenVertebraPicker={(zoneIndex) =>
|
|
onOpenVertebraPicker(i, zoneIndex)
|
|
}
|
|
onRemoveZone={(zoneIndex) => onRemoveZone(i, zoneIndex)}
|
|
/>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|