feat(observation): ObservationList with add + per-card actions

This commit is contained in:
Bastien Chanot committed 2026-05-18 21:28:53 +02:00
1 parent 1e4e56d2e2
commit 10fa676f1e
1 file changed
+54 -2
+54 -2
View File
@@ -1,3 +1,55 @@
export default function ObservationList() {
return <div>ObservationList placeholder</div>
import type { Observation } from '@/domain/schema/observation'
import ObservationCard from './ObservationCard'
import Button from '@/components/ui/Button'
export interface ObservationListProps {
observations: Observation[]
activeIndex: number
onSelect: (i: number) => void
onAdd: () => void
onDelete: (i: number) => void
onMoveUp: (i: number) => void
onMoveDown: (i: number) => void
}
export default function ObservationList({
observations,
activeIndex,
onSelect,
onAdd,
onDelete,
onMoveUp,
onMoveDown,
}: 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}
active={i === activeIndex}
onSelect={() => onSelect(i)}
onDelete={() => onDelete(i)}
onMoveUp={() => onMoveUp(i)}
onMoveDown={() => onMoveDown(i)}
canMoveUp={i > 0}
canMoveDown={i < observations.length - 1}
/>
</li>
))}
</ul>
)}
</div>
)
}