diff --git a/src/components/observation/FreeTextPathologyInput.tsx b/src/components/observation/FreeTextPathologyInput.tsx index 1d598709..b70324d8 100644 --- a/src/components/observation/FreeTextPathologyInput.tsx +++ b/src/components/observation/FreeTextPathologyInput.tsx @@ -1,3 +1,58 @@ -export default function FreeTextPathologyInput() { - return
FreeTextPathologyInput placeholder
+import { useState } from 'react' +import Input from '@/components/ui/Input' +import Button from '@/components/ui/Button' +import Badge from '@/components/ui/Badge' + +export interface FreeTextPathologyInputProps { + items: string[] + onChange: (next: string[]) => void +} + +export default function FreeTextPathologyInput({ + items, + onChange, +}: FreeTextPathologyInputProps) { + const [v, setV] = useState('') + function add() { + const trimmed = v.trim() + if (!trimmed) return + onChange([...items, trimmed]) + setV('') + } + function remove(i: number) { + onChange(items.filter((_, k) => k !== i)) + } + return ( +
+
+ setV(e.target.value)} + placeholder="Pathologie additionnelle (texte libre)" + onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); add() } }} + aria-label="Pathologie libre" + /> + +
+ {items.length > 0 && ( + + )} +
+ ) }