LITTER-MORTALITY-FE: deathsWithin8Weeks Feld im Wurf-Formular und -Detail (gated auf Pam BE)

This commit is contained in:
2026-06-07 03:28:11 +02:00
parent 25af10a736
commit 29e9c4cd64
6 changed files with 83 additions and 1 deletions

View File

@@ -92,6 +92,12 @@ export default function WurfDetailPage() {
{l.totalBorn != null ? ` / ${l.totalBorn}` : ''}
</dd>
</div>
{l.deathsWithin8Weeks != null && (
<div className="def-row">
<dt>{t.fields.deathsWithin8Weeks}</dt>
<dd>{l.deathsWithin8Weeks}</dd>
</div>
)}
<div className="def-row">
<dt>{t.fields.expectedGoHomeDate}</dt>
<dd>{formatDate(l.expectedGoHomeDate)}</dd>

View File

@@ -16,6 +16,7 @@ interface FormState {
motherId: string
motherName: string
totalBorn: string
deathsWithin8Weeks: string
expectedGoHomeDate: string
notes: string
}
@@ -28,6 +29,7 @@ const EMPTY: FormState = {
motherId: '',
motherName: '',
totalBorn: '',
deathsWithin8Weeks: '',
expectedGoHomeDate: '',
notes: '',
}
@@ -75,6 +77,7 @@ export default function WurfFormPage() {
motherId: l.motherId ?? '',
motherName: l.motherId ? (nameById.get(l.motherId) || de.pages.gerbils.nameless) : '',
totalBorn: l.totalBorn != null ? String(l.totalBorn) : '',
deathsWithin8Weeks: l.deathsWithin8Weeks != null ? String(l.deathsWithin8Weeks) : '',
expectedGoHomeDate: l.expectedGoHomeDate ?? '',
notes: l.notes ?? '',
})
@@ -109,12 +112,14 @@ export default function WurfFormPage() {
e.preventDefault()
if (!validate()) return
const totalBornNum = form.totalBorn.trim() === '' ? null : Number(form.totalBorn)
const deathsNum = form.deathsWithin8Weeks.trim() === '' ? null : Number(form.deathsWithin8Weeks)
const body: CreateLitter = {
name: form.name.trim(),
date: form.date,
fatherId: nn(form.fatherId),
motherId: nn(form.motherId),
totalBorn: totalBornNum != null && Number.isFinite(totalBornNum) ? totalBornNum : null,
deathsWithin8Weeks: deathsNum != null && Number.isFinite(deathsNum) ? deathsNum : null,
expectedGoHomeDate: nn(form.expectedGoHomeDate),
notes: nn(form.notes),
}
@@ -215,6 +220,26 @@ export default function WurfFormPage() {
/>
</label>
<label className="field">
<span>{t.fields.deathsWithin8Weeks}</span>
<input
type="number"
min="0"
className="input"
value={form.deathsWithin8Weeks}
onChange={(e) => set('deathsWithin8Weeks', e.target.value)}
/>
{(() => {
const d = Number(form.deathsWithin8Weeks)
const tb = Number(form.totalBorn)
return form.deathsWithin8Weeks.trim() !== '' &&
form.totalBorn.trim() !== '' &&
d > tb ? (
<small className="error-text">{t.validation.deathsExceedTotalBorn}</small>
) : null
})()}
</label>
<label className="field">
<span>{t.fields.expectedGoHomeDate}</span>
<input