Files
faunosteo/apps/app/src/components/observation/ObservationList.tsx
T

78 lines
2.3 KiB
TypeScript

import type { Observation } from '@faunosteo/domain'
import ObservationCard from './ObservationCard'
import Button from '@/components/ui/Button'
import type { SheetIndex } from '@/services/sheetIndex'
import { useT } from '@/i18n/useT'
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
sheet: SheetIndex
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,
sheet,
onChange,
onOpenVertebraPicker,
onRemoveZone,
}: ObservationListProps) {
const t = useT()
return (
<div className="space-y-3">
<div className="flex items-center justify-between">
<h2 className="font-serif text-lg sm:text-xl text-[var(--color-ink)]">
{t('observation.section_title')}
</h2>
<Button size="sm" onClick={onAdd}>
{t('observation.add')}
</Button>
</div>
{observations.length === 0 ? (
<p className="text-sm text-[var(--color-ink-muted)]">
{t('observation.empty')}
</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}
sheet={sheet}
onChange={(next) => onChange(i, next)}
onOpenVertebraPicker={(zoneIndex) =>
onOpenVertebraPicker(i, zoneIndex)
}
onRemoveZone={(zoneIndex) => onRemoveZone(i, zoneIndex)}
/>
</li>
))}
</ul>
)}
</div>
)
}