feat(observation): ObservationCard with reorder + delete affordances
This commit is contained in:
1 parent
c78fe004dd
commit
1e4e56d2e2
1 file changed
+69
-2
@@ -1,3 +1,70 @@
|
||||
export default function ObservationCard() {
|
||||
return <div>ObservationCard placeholder</div>
|
||||
import type { Observation } from '@/domain/schema/observation'
|
||||
import Card from '@/components/ui/Card'
|
||||
import Badge from '@/components/ui/Badge'
|
||||
import Button from '@/components/ui/Button'
|
||||
|
||||
export interface ObservationCardProps {
|
||||
observation: Observation
|
||||
index: number
|
||||
active: boolean
|
||||
onSelect: () => void
|
||||
onDelete: () => void
|
||||
onMoveUp: () => void
|
||||
onMoveDown: () => void
|
||||
canMoveUp: boolean
|
||||
canMoveDown: boolean
|
||||
}
|
||||
|
||||
export default function ObservationCard({
|
||||
observation,
|
||||
index,
|
||||
active,
|
||||
onSelect,
|
||||
onDelete,
|
||||
onMoveUp,
|
||||
onMoveDown,
|
||||
canMoveUp,
|
||||
canMoveDown,
|
||||
}: ObservationCardProps) {
|
||||
const zoneCount = observation.zones.length
|
||||
const patCount =
|
||||
observation.pathologyIds.length + observation.freeTextPathologies.length
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={[
|
||||
'cursor-pointer p-4 transition',
|
||||
active ? 'ring-2 ring-[var(--color-accent)]' : 'hover:bg-[var(--color-surface-strong)]',
|
||||
].join(' ')}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onSelect}
|
||||
className="flex-1 text-left"
|
||||
aria-label={`Sélectionner l'observation ${index + 1}`}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<Badge tone="neutral">Observation #{index + 1}</Badge>
|
||||
{observation.severity && (
|
||||
<Badge tone={observation.severity === 'sévère' ? 'danger' : observation.severity === 'modérée' ? 'warn' : 'neutral'}>
|
||||
{observation.severity}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--color-ink-muted)]">
|
||||
{zoneCount} zone{zoneCount > 1 ? 's' : ''} · {patCount} pathologie{patCount > 1 ? 's' : ''}
|
||||
</div>
|
||||
{observation.comment && (
|
||||
<p className="mt-2 text-sm line-clamp-2 text-[var(--color-ink)]">{observation.comment}</p>
|
||||
)}
|
||||
</button>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Button size="sm" variant="ghost" disabled={!canMoveUp} onClick={onMoveUp} aria-label="Monter">↑</Button>
|
||||
<Button size="sm" variant="ghost" disabled={!canMoveDown} onClick={onMoveDown} aria-label="Descendre">↓</Button>
|
||||
<Button size="sm" variant="ghost" onClick={onDelete} aria-label="Supprimer">🗑</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user