feat(report): AnimalForm + owner name with species select
This commit is contained in:
1 parent
2970e7fcf5
commit
71ecebfa72
1 file changed
+49
-2
@@ -1,3 +1,50 @@
|
||||
export default function AnimalForm() {
|
||||
return <div>AnimalForm placeholder</div>
|
||||
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>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user