feat: auto-open LitterForm with prefill when navigated from BreedingCalendar

This commit is contained in:
2026-03-09 20:53:37 -05:00
parent 7a6b770999
commit 50deb6174b

View File

@@ -14,6 +14,17 @@ function LitterList() {
useEffect(() => {
fetchLitters()
// Auto-open form with prefill from BreedingCalendar "Record Litter" CTA
const stored = sessionStorage.getItem('prefillLitter')
if (stored) {
try {
const data = JSON.parse(stored)
setPrefill(data)
setEditingLitter(null)
setShowForm(true)
} catch (e) { /* ignore */ }
sessionStorage.removeItem('prefillLitter')
}
}, [])
const fetchLitters = async () => {
@@ -96,7 +107,7 @@ function LitterList() {
<div style={{ display: 'flex', gap: '1.5rem', flexWrap: 'wrap', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
<span>📅 Bred: {new Date(litter.breeding_date).toLocaleDateString()}</span>
{litter.whelping_date && (
<span>🐕 Whelped: {new Date(litter.whelping_date).toLocaleDateString()}</span>
<span>💕 Whelped: {new Date(litter.whelping_date).toLocaleDateString()}</span>
)}
<span style={{ color: 'var(--accent)', fontWeight: 600 }}>
{litter.actual_puppy_count ?? litter.puppies?.length ?? litter.puppy_count ?? 0} puppies