diff --git a/client/src/components/LitterForm.jsx b/client/src/components/LitterForm.jsx index a86430a..ca921bd 100644 --- a/client/src/components/LitterForm.jsx +++ b/client/src/components/LitterForm.jsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react' import { X } from 'lucide-react' import axios from 'axios' -function LitterForm({ litter, onClose, onSave }) { +function LitterForm({ litter, prefill, onClose, onSave }) { const [formData, setFormData] = useState({ sire_id: '', dam_id: '', @@ -26,8 +26,16 @@ function LitterForm({ litter, onClose, onSave }) { puppy_count: litter.puppy_count || 0, notes: litter.notes || '' }) + } else if (prefill) { + // Pre-populate from BreedingCalendar "Record Litter" flow + setFormData(prev => ({ + ...prev, + dam_id: prefill.dam_id ? String(prefill.dam_id) : '', + breeding_date: prefill.breeding_date || '', + whelping_date: prefill.whelping_date || '', + })) } - }, [litter]) + }, [litter, prefill]) const fetchDogs = async () => { try { @@ -69,7 +77,7 @@ function LitterForm({ litter, onClose, onSave }) {