Escape French apostrophes/quotes in JSX text per react/no-unescaped-entities and replace the report?.observations.length dependency with a derived observationsCount value so react-hooks/exhaustive-deps is satisfied without re-firing on every report change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import type { Animal, Owner } from '@/domain/schema/animal'
|
|
import Label from '@/components/ui/Label'
|
|
import Input from '@/components/ui/Input'
|
|
import Select from '@/components/ui/Select'
|
|
import { getAllSpecies } from '@/domain/species/registry'
|
|
|
|
export interface AnimalFormProps {
|
|
animal: Animal
|
|
owner: Owner
|
|
onChangeAnimal: (next: Animal) => void
|
|
onChangeOwner: (next: Owner) => void
|
|
}
|
|
|
|
export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwner }: AnimalFormProps) {
|
|
const species = getAllSpecies()
|
|
const setA = (patch: Partial<Animal>) => onChangeAnimal({ ...animal, ...patch })
|
|
return (
|
|
<fieldset className="space-y-3">
|
|
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">Animal & propriétaire</legend>
|
|
<div>
|
|
<Label htmlFor="an-species">Espèce *</Label>
|
|
<Select
|
|
id="an-species"
|
|
value={animal.speciesId}
|
|
onChange={(e) => setA({ speciesId: e.target.value })}
|
|
>
|
|
{species.map((s) => (
|
|
<option key={s.id} value={s.id}>{s.labelFr}</option>
|
|
))}
|
|
</Select>
|
|
</div>
|
|
<div>
|
|
<Label htmlFor="an-name">Nom de l'animal *</Label>
|
|
<Input id="an-name" required value={animal.name} onChange={(e) => setA({ name: e.target.value })} />
|
|
</div>
|
|
<div>
|
|
<Label htmlFor="an-breed">Race</Label>
|
|
<Input id="an-breed" value={animal.breed ?? ''} onChange={(e) => setA({ breed: e.target.value || undefined })} />
|
|
</div>
|
|
<div>
|
|
<Label htmlFor="an-age">Âge</Label>
|
|
<Input id="an-age" value={animal.age ?? ''} onChange={(e) => setA({ age: e.target.value || undefined })} />
|
|
</div>
|
|
<div>
|
|
<Label htmlFor="own-name">Nom du propriétaire *</Label>
|
|
<Input id="own-name" required value={owner.name} onChange={(e) => onChangeOwner({ name: e.target.value })} />
|
|
</div>
|
|
</fieldset>
|
|
)
|
|
}
|