external dogs

This commit is contained in:
2026-03-12 07:21:44 -05:00
parent 13185a5281
commit 5ca594fdc7

View File

@@ -29,8 +29,8 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
const effectiveExternal = isExternal || (dog && dog.is_external) const effectiveExternal = isExternal || (dog && dog.is_external)
useEffect(() => { useEffect(() => {
if (!effectiveExternal) {
fetchDogs() fetchDogs()
if (!effectiveExternal) {
fetchLitters() fetchLitters()
} }
if (dog) { if (dog) {
@@ -55,7 +55,7 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
const fetchDogs = async () => { const fetchDogs = async () => {
try { try {
const res = await axios.get('/api/dogs') const res = await axios.get('/api/dogs/all')
setDogs(res.data || []) setDogs(res.data || [])
} catch (e) { } catch (e) {
setDogs([]) setDogs([])
@@ -112,8 +112,8 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
...formData, ...formData,
is_champion: formData.is_champion ? 1 : 0, is_champion: formData.is_champion ? 1 : 0,
is_external: effectiveExternal ? 1 : 0, is_external: effectiveExternal ? 1 : 0,
sire_id: effectiveExternal ? null : (formData.sire_id || null), sire_id: formData.sire_id || null,
dam_id: effectiveExternal ? null : (formData.dam_id || null), dam_id: formData.dam_id || null,
litter_id: (effectiveExternal || useManualParents) ? null : (formData.litter_id || null), litter_id: (effectiveExternal || useManualParents) ? null : (formData.litter_id || null),
registration_number: formData.registration_number || null, registration_number: formData.registration_number || null,
birth_date: formData.birth_date || null, birth_date: formData.birth_date || null,
@@ -162,7 +162,7 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
gap: '0.5rem', gap: '0.5rem',
}}> }}>
<ExternalLink size={14} /> <ExternalLink size={14} />
External dog not part of your kennel roster. Litter and parent fields are not applicable. External dog not part of your kennel roster.
</div> </div>
)} )}
@@ -250,8 +250,7 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
</div> </div>
</div> </div>
{/* Parent Section — hidden for external dogs */} {/* Parent Section */}
{!effectiveExternal && (
<div style={{ <div style={{
marginTop: '1.5rem', padding: '1rem', marginTop: '1.5rem', padding: '1rem',
background: 'rgba(194, 134, 42, 0.04)', background: 'rgba(194, 134, 42, 0.04)',
@@ -260,7 +259,7 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
}}> }}>
<label className="label" style={{ marginBottom: '0.75rem', display: 'block', fontWeight: '600' }}>Parent Information</label> <label className="label" style={{ marginBottom: '0.75rem', display: 'block', fontWeight: '600' }}>Parent Information</label>
{littersAvailable && ( {!effectiveExternal && littersAvailable && (
<div style={{ display: 'flex', gap: '1.5rem', marginBottom: '1rem', flexWrap: 'wrap' }}> <div style={{ display: 'flex', gap: '1.5rem', marginBottom: '1rem', flexWrap: 'wrap' }}>
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', cursor: 'pointer', fontSize: '0.95rem' }}> <label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', cursor: 'pointer', fontSize: '0.95rem' }}>
<input type="radio" name="parentMode" checked={!useManualParents} <input type="radio" name="parentMode" checked={!useManualParents}
@@ -275,7 +274,7 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
</div> </div>
)} )}
{!useManualParents && littersAvailable ? ( {!useManualParents && littersAvailable && !effectiveExternal ? (
<div className="form-group" style={{ marginTop: '0.5rem' }}> <div className="form-group" style={{ marginTop: '0.5rem' }}>
<label className="label">Select Litter</label> <label className="label">Select Litter</label>
<select name="litter_id" className="input" <select name="litter_id" className="input"
@@ -314,7 +313,6 @@ function DogForm({ dog, onClose, onSave, isExternal = false }) {
</div> </div>
)} )}
</div> </div>
)}
<div className="form-group" style={{ marginTop: '1rem' }}> <div className="form-group" style={{ marginTop: '1rem' }}>
<label className="label">Notes</label> <label className="label">Notes</label>