import { useState } from "react"; import { X, Save } from "lucide-react"; import type { Pet } from "../mockData.js"; interface Props { pet?: Pet; onSave: (pet: Pet) => void; onCancel: () => void; } export function PetForm({ pet, onSave, onCancel }: Props) { const [name, setName] = useState(pet?.name ?? ""); const [breed, setBreed] = useState(pet?.breed ?? ""); const [weight, setWeight] = useState(pet?.weight ?? 0); const [notes, setNotes] = useState(pet?.allergies ?? ""); function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!pet) return; onSave({ ...pet, name, breed, weight, allergies: notes }); } return (

{pet ? "Edit Pet" : "Add Pet"}

setName(e.target.value)} className="w-full border border-stone-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-(--color-accent)" />
setBreed(e.target.value)} className="w-full border border-stone-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-(--color-accent)" />
setWeight(Number(e.target.value))} className="w-full border border-stone-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-(--color-accent)" />