Compare commits

..

3 Commits

Author SHA1 Message Date
40f3ce250d STATUS-MODEL-FE: Zucht/Liebhaber/Abzugeben wählbar; Verstorben+Abgegeben abgeleitet (gated auf Pam BE) 2026-06-07 03:36:10 +02:00
2d54cb901f Merge feature/litter-juvenile-details (LITTER-JUVENILE-DETAILS): pro Jungtier Farbschlag/Abgabedatum/Abnehmer/Todestag/Ursache im Wurf-Detail
Some checks failed
CI / Backend Tests (.NET) (push) Successful in 1m16s
CI / Docker Build & Push (push) Has been cancelled
CI / Frontend Tests (Node/Vite) (push) Has been cancelled
2026-06-07 03:25:53 +02:00
03f8e4de90 LITTER-JUVENILE-DETAILS: Farbschlag/Abgabe/Abnehmer/Todesdaten pro Jungtier im Wurf-Detail 2026-06-07 03:23:22 +02:00
13 changed files with 209 additions and 117 deletions

View File

@@ -0,0 +1,30 @@
/** LITTER-JUVENILE-DETAILS: Jungtier-Felder (Farbschlag/Abgabe/Verstorben) im Wurf-Detail. */
import { de, expect, skipUnlessMock, test } from './fixtures'
const t = de.pages.litters
test('Jungtier-Liste zeigt Farbschlag, Abgabedatum, Abnehmer, Todesdatum und Todesursache', async ({
page,
}) => {
skipUnlessMock()
await page.goto('/wuerfe/w-kruemel')
await expect(page.getByRole('heading', { name: 'Wurf K' })).toBeVisible()
// Krümel: Active, colorVarietyId cv-agouti → Farbschlag 'Agouti'
const kruemelCard = page.getByRole('link', { name: /Krümel/ })
await expect(kruemelCard).toBeVisible()
await expect(kruemelCard).toContainText(`${t.detail.juvenileFields.colorVariety}: Agouti`)
// Pippa: GivenAway, Gold, goHomeDate 2025-05-01, Abnehmer Familie Huber
const pippaCard = page.getByRole('link', { name: /Pippa/ })
await expect(pippaCard).toBeVisible()
await expect(pippaCard).toContainText(`${t.detail.juvenileFields.colorVariety}: Gold`)
await expect(pippaCard).toContainText(t.detail.juvenileFields.goHomeDate)
await expect(pippaCard).toContainText(`${t.detail.juvenileFields.receiver}: Familie Huber`)
// Benny: Deceased, no colorVarietyId, dateOfDeath + causeOfDeath
const bennyCard = page.getByRole('link', { name: /Benny/ })
await expect(bennyCard).toBeVisible()
await expect(bennyCard).toContainText(t.detail.juvenileFields.dateOfDeath)
await expect(bennyCard).toContainText(`${t.detail.juvenileFields.causeOfDeath}: Altersschwäche`)
})

View File

@@ -1,46 +0,0 @@
/** LITTER-MORTALITY: deathsWithin8Weeks im Wurf-Formular und -Detail. */
import { de, expect, skipUnlessMock, test, uniqueName } from './fixtures'
const t = de.pages.litters
test('Wurf-Detail zeigt Frühverluste wenn gesetzt', async ({ page }) => {
skipUnlessMock()
await page.goto('/wuerfe/w-kruemel')
await expect(page.getByRole('heading', { name: 'Wurf K' })).toBeVisible()
// Frühverluste-Zeile im def-list: Label + Wert '1'
const mortalityRow = page.locator('.def-row', {
has: page.locator('dt', { hasText: t.fields.deathsWithin8Weeks }),
})
await expect(mortalityRow).toBeVisible()
await expect(mortalityRow.locator('dd')).toHaveText('1')
})
test('Wurf-Formular speichert Frühverluste und zeigt sie im Detail', async ({ page }) => {
skipUnlessMock()
const name = uniqueName('WurfM')
await page.goto('/wuerfe/neu')
await page.getByLabel(`${t.fields.name} *`).fill(name)
await page.getByLabel(`${t.fields.date} *`).fill('2026-01-10')
// Frühverluste eingeben
await page.getByLabel(t.fields.deathsWithin8Weeks).fill('2')
await expect(page.getByText(t.validation.deathsExceedTotalBorn)).not.toBeVisible()
await page.getByRole('button', { name: t.form.save, exact: true }).click()
await expect(page.getByRole('heading', { name })).toBeVisible()
// Frühverluste-Zeile im Detail
const mortalityRow = page.locator('.def-row', {
has: page.locator('dt', { hasText: t.fields.deathsWithin8Weeks }),
})
await expect(mortalityRow).toBeVisible()
await expect(mortalityRow.locator('dd')).toHaveText('2')
})
test('Frühverluste > Wurfstärke zeigt Warnmeldung', async ({ page }) => {
skipUnlessMock()
await page.goto('/wuerfe/neu')
await page.getByLabel(t.fields.totalBorn).fill('3')
await page.getByLabel(t.fields.deathsWithin8Weeks).fill('5')
await expect(page.getByText(t.validation.deathsExceedTotalBorn)).toBeVisible()
})

View File

@@ -91,7 +91,7 @@ function gerbil(
id, id,
name, name,
gender, gender,
status: 'Active', status: 'Breeding',
dateOfBirth, dateOfBirth,
dateOfDeath: null, dateOfDeath: null,
causeOfDeath: null, causeOfDeath: null,
@@ -151,12 +151,25 @@ export function seedDb(): MockDb {
enclosureId: 'enc-leer', enclosureId: 'enc-leer',
notes: 'neugieriger Entdecker', notes: 'neugieriger Entdecker',
}, },
// LITTER-JUVENILE-DETAILS: Jungtiere für Wurf K mit Zusatzinfos.
{
...gerbil('pup-abgabe', 'Pippa', 'female', '2025-03-12', 'w-kruemel', 'cv-gold'),
status: 'GivenAway' as const,
goHomeDate: '2025-05-01',
receiverContactId: 'con-huber',
},
{
...gerbil('pup-verstorben', 'Benny', 'male', '2025-03-12', 'w-kruemel', null),
status: 'Deceased' as const,
dateOfDeath: '2025-04-15',
causeOfDeath: 'Altersschwäche',
},
// UI-POLISH-1: Import-Stub ohne Namen — testet den '(ohne Namen)'-Platzhalter in Liste + Detail. // UI-POLISH-1: Import-Stub ohne Namen — testet den '(ohne Namen)'-Platzhalter in Liste + Detail.
gerbil('nameless-stub', '', 'male', '2023-01-01', null, null), gerbil('nameless-stub', '', 'male', '2023-01-01', null, null),
] ]
const litters: Litter[] = [ const litters: Litter[] = [
{ id: 'w-kruemel', name: 'Wurf K', date: '2025-03-12', totalBorn: 5, expectedGoHomeDate: '2025-04-16', notes: null, fatherId: 'fridolin', motherId: 'luna', deathsWithin8Weeks: 1 }, { id: 'w-kruemel', name: 'Wurf K', date: '2025-03-12', totalBorn: 5, expectedGoHomeDate: '2025-04-16', notes: null, fatherId: 'fridolin', motherId: 'luna' },
{ id: 'w-fridolin', name: 'Wurf F', date: '2023-05-01', totalBorn: 4, expectedGoHomeDate: null, notes: null, fatherId: 'balu', motherId: 'maja' }, { id: 'w-fridolin', name: 'Wurf F', date: '2023-05-01', totalBorn: 4, expectedGoHomeDate: null, notes: null, fatherId: 'balu', motherId: 'maja' },
{ id: 'w-luna', name: 'Wurf L', date: '2023-08-15', totalBorn: 6, expectedGoHomeDate: null, notes: null, fatherId: 'karlsson', motherId: 'smilla' }, { id: 'w-luna', name: 'Wurf L', date: '2023-08-15', totalBorn: 6, expectedGoHomeDate: null, notes: null, fatherId: 'karlsson', motherId: 'smilla' },
{ id: 'w-balu', name: 'Wurf B', date: '2021-04-20', totalBorn: 3, expectedGoHomeDate: null, notes: null, fatherId: 'anton', motherId: 'greta' }, { id: 'w-balu', name: 'Wurf B', date: '2021-04-20', totalBorn: 3, expectedGoHomeDate: null, notes: null, fatherId: 'anton', motherId: 'greta' },

View File

@@ -0,0 +1,58 @@
/** STATUS-MODEL: Zucht/Liebhaber wählbar; Verstorben/Abgegeben abgeleitet (read-only). */
import { de, expect, skipUnlessMock, test, uniqueName } from './fixtures'
const t = de.pages.gerbils
test('Tier-Formular zeigt nur wählbare Statuswerte im Dropdown', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/neu')
const statusField = page.locator('label.field', {
has: page.locator(`span:text-is("${t.fields.status}")`),
})
// Zucht (Breeding) ist vorausgewählt
await expect(statusField.locator('select')).toHaveValue('Breeding')
// Optionen: nur Zucht, Liebhaber, Abzugeben (NICHT Verstorben/Abgegeben)
const opts = statusField.locator('select option')
await expect(opts.filter({ hasText: t.statusLabels.Breeding })).toHaveCount(1)
await expect(opts.filter({ hasText: t.statusLabels.Pet })).toHaveCount(1)
await expect(opts.filter({ hasText: t.statusLabels.ForSale })).toHaveCount(1)
await expect(opts.filter({ hasText: t.statusLabels.Deceased })).toHaveCount(0)
await expect(opts.filter({ hasText: t.statusLabels.GivenAway })).toHaveCount(0)
})
test('Tier-Formular zeigt abgeleiteten Status Verstorben als Text + Hinweis', async ({ page }) => {
skipUnlessMock()
// Willi ist Deceased
await page.goto('/rennmaeuse/willi/bearbeiten')
// Status-Select ist NICHT vorhanden (abgeleitet)
const statusField = page.locator('.field', {
has: page.locator(`span:text-is("${t.fields.status}")`),
})
await expect(statusField).toBeVisible()
await expect(statusField.locator('select')).toHaveCount(0)
await expect(statusField).toContainText(t.statusLabels.Deceased)
await expect(statusField).toContainText(t.form.statusDerivedHint.Deceased)
})
test('Tiere-Liste zeigt Zucht als Standard-Status-Filter', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse')
const statusSelect = page
.locator('label.field', { has: page.locator(`span:text-is("${t.filters.status}")`) })
.locator('select')
await expect(statusSelect).toHaveValue('Breeding')
})
test('Neues Tier anlegen mit Status Liebhaber', async ({ page }) => {
skipUnlessMock()
const name = uniqueName('Tier')
await page.goto('/rennmaeuse/neu')
await page.getByLabel(`${t.fields.name} *`).fill(name)
await page.getByLabel(`${t.fields.gender} *`).selectOption({ label: t.genderLabels.male })
const statusField = page.locator('label.field', {
has: page.locator(`span:text-is("${t.fields.status}")`),
})
await statusField.locator('select').selectOption({ label: t.statusLabels.Pet })
await page.getByRole('button', { name: t.form.save, exact: true }).click()
await expect(page.getByRole('heading', { name })).toBeVisible()
})

View File

@@ -10,9 +10,11 @@
export type Gender = 'unknown' | 'male' | 'female' export type Gender = 'unknown' | 'male' | 'female'
export const GENDERS: Gender[] = ['unknown', 'male', 'female'] export const GENDERS: Gender[] = ['unknown', 'male', 'female']
/** Gerbil.Status — C# enum { Active, Deceased, GivenAway, ForSale }. */ /** Gerbil.Status — C# enum { Breeding, Pet, Deceased, GivenAway, ForSale }. STATUS-MODEL: Active→Breeding (gated on Pam feature/status-model). */
export type GerbilStatus = 'Active' | 'Deceased' | 'GivenAway' | 'ForSale' export type GerbilStatus = 'Breeding' | 'Pet' | 'Deceased' | 'GivenAway' | 'ForSale'
export const GERBIL_STATUSES: GerbilStatus[] = ['Active', 'ForSale', 'Deceased', 'GivenAway'] export const GERBIL_STATUSES: GerbilStatus[] = ['Breeding', 'Pet', 'ForSale', 'Deceased', 'GivenAway']
/** Statuses the user can pick freely in the form; Deceased+GivenAway are derived by the backend. */
export const SELECTABLE_STATUSES: GerbilStatus[] = ['Breeding', 'Pet', 'ForSale']
/** ISO date string "YYYY-MM-DD" (maps to C# DateOnly). */ /** ISO date string "YYYY-MM-DD" (maps to C# DateOnly). */
export type DateOnlyString = string export type DateOnlyString = string
@@ -122,8 +124,6 @@ export interface Litter {
notes?: string | null notes?: string | null
fatherId: string | null fatherId: string | null
motherId: string | null motherId: string | null
/** LITTER-MORTALITY: pups that died within the first 8 weeks. */
deathsWithin8Weeks?: number | null
} }
/** Payload for POST /litters. */ /** Payload for POST /litters. */
@@ -135,7 +135,6 @@ export interface CreateLitter {
notes?: string | null notes?: string | null
fatherId?: string | null fatherId?: string | null
motherId?: string | null motherId?: string | null
deathsWithin8Weeks?: number | null
} }
export type UpdateLitter = Partial<CreateLitter> export type UpdateLitter = Partial<CreateLitter>

View File

@@ -3,7 +3,7 @@ import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom'
import { de } from '../strings/de' import { de } from '../strings/de'
import { createGerbil, getGerbil, updateGerbil } from '../api/gerbils' import { createGerbil, getGerbil, updateGerbil } from '../api/gerbils'
import { listColorVarieties, listContacts, listEnclosures, listLitters } from '../api/lookups' import { listColorVarieties, listContacts, listEnclosures, listLitters } from '../api/lookups'
import { GENDERS, GERBIL_STATUSES, type CreateGerbil, type Gender, type GerbilStatus } from '../api/types' import { GENDERS, SELECTABLE_STATUSES, type CreateGerbil, type Gender, type GerbilStatus } from '../api/types'
import { useApi, useMutation } from '../hooks/useApi' import { useApi, useMutation } from '../hooks/useApi'
import { genderLabel, statusLabel } from '../format/labels' import { genderLabel, statusLabel } from '../format/labels'
import { fromDisplayString, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG } from '../genetics' import { fromDisplayString, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG } from '../genetics'
@@ -34,7 +34,7 @@ interface FormState {
const EMPTY: FormState = { const EMPTY: FormState = {
name: '', name: '',
gender: '', gender: '',
status: 'Active', status: 'Breeding',
dateOfBirth: '', dateOfBirth: '',
dateOfDeath: '', dateOfDeath: '',
causeOfDeath: '', causeOfDeath: '',
@@ -245,16 +245,29 @@ export default function GerbilFormPage() {
{errors.gender && <small className="error-text">{errors.gender}</small>} {errors.gender && <small className="error-text">{errors.gender}</small>}
</label> </label>
<label className="field"> {/* STATUS-MODEL: Deceased/GivenAway are derived by the backend — show as read-only with hint */}
<span>{t.fields.status}</span> {form.status === 'Deceased' || form.status === 'GivenAway' ? (
<select value={form.status} onChange={(e) => set('status', e.target.value as GerbilStatus)}> <div className="field">
{GERBIL_STATUSES.map((s) => ( <span>{t.fields.status}</span>
<option key={s} value={s}> <span className="muted">
{statusLabel(s)} {statusLabel(form.status)}
</option> <small className="muted" style={{ marginLeft: '0.5rem' }}>
))} ({t.form.statusDerivedHint[form.status]})
</select> </small>
</label> </span>
</div>
) : (
<label className="field">
<span>{t.fields.status}</span>
<select value={form.status} onChange={(e) => set('status', e.target.value as GerbilStatus)}>
{SELECTABLE_STATUSES.map((s) => (
<option key={s} value={s}>
{statusLabel(s)}
</option>
))}
</select>
</label>
)}
<label className="field"> <label className="field">
<span>{t.fields.dateOfBirth}</span> <span>{t.fields.dateOfBirth}</span>

View File

@@ -29,7 +29,7 @@ const SORT_ORDER_BY: Record<SortKey, string> = {
export default function GerbilsPage() { export default function GerbilsPage() {
const t = de.pages.gerbils const t = de.pages.gerbils
const [search, setSearch] = useState('') const [search, setSearch] = useState('')
const [status, setStatus] = useState<GerbilStatus | ''>('Active') const [status, setStatus] = useState<GerbilStatus | ''>('Breeding')
const [gender, setGender] = useState<Gender | ''>('') const [gender, setGender] = useState<Gender | ''>('')
const [colorVarietyId, setColorVarietyId] = useState('') const [colorVarietyId, setColorVarietyId] = useState('')
const [originBreeder, setOriginBreeder] = useState('') const [originBreeder, setOriginBreeder] = useState('')
@@ -64,7 +64,7 @@ export default function GerbilsPage() {
const resetFilters = () => { const resetFilters = () => {
setSearch('') setSearch('')
setStatus('Active') setStatus('Breeding')
setGender('') setGender('')
setColorVarietyId('') setColorVarietyId('')
setOriginBreeder('') setOriginBreeder('')
@@ -85,7 +85,7 @@ export default function GerbilsPage() {
// UX-MOBILE-1: count non-default filter values for the badge. // UX-MOBILE-1: count non-default filter values for the badge.
const activeFilterCount = const activeFilterCount =
(status !== 'Active' ? 1 : 0) + (status !== 'Breeding' ? 1 : 0) +
(gender !== '' ? 1 : 0) + (gender !== '' ? 1 : 0) +
(colorVarietyId !== '' ? 1 : 0) + (colorVarietyId !== '' ? 1 : 0) +
(originBreeder !== '' ? 1 : 0) + (originBreeder !== '' ? 1 : 0) +

View File

@@ -1,13 +1,14 @@
import { useMemo } from 'react' import { useCallback, useMemo } from 'react'
import { Link, useParams } from 'react-router-dom' import { Link, useParams } from 'react-router-dom'
import { de } from '../strings/de' import { de } from '../strings/de'
import { getLitter } from '../api/litters' import { getLitter } from '../api/litters'
import { getGerbil, listGerbils } from '../api/gerbils' import { getGerbil, listGerbils } from '../api/gerbils'
import { listColorVarieties, listContacts } from '../api/lookups'
import { condition } from '../api/gridify' import { condition } from '../api/gridify'
import { useApi } from '../hooks/useApi' import { useApi } from '../hooks/useApi'
import { formatDate } from '../format/labels' import { formatDate, genderLabel } from '../format/labels'
import { isValidGenotype } from '../format/genotypeText' import { isValidGenotype } from '../format/genotypeText'
import { breed, fromDisplayString, type BreedingResult } from '../genetics' import { breed, fromDisplayString, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG, type BreedingResult } from '../genetics'
import BreedingResultView from '../components/BreedingResultView' import BreedingResultView from '../components/BreedingResultView'
export default function WurfDetailPage() { export default function WurfDetailPage() {
@@ -43,6 +44,38 @@ export default function WurfDetailPage() {
return breed(fromDisplayString(fg), fromDisplayString(mg)) return breed(fromDisplayString(fg), fromDisplayString(mg))
}, [father.data, mother.data]) }, [father.data, mother.data])
// Farbschlag + Abnehmer lookups for the juvenile list.
const colorVarieties = useApi(() => listColorVarieties(), [])
const contacts = useApi(() => listContacts(), [])
const colorNameById = useMemo(
() => new Map((colorVarieties.data ?? []).map((c) => [c.id, c.name])),
[colorVarieties.data],
)
const contactNameById = useMemo(
() => new Map((contacts.data ?? []).map((c) => [c.id, c.name])),
[contacts.data],
)
const farbschlagOf = useCallback(
(g: { colorVarietyId: string | null; genotype: string | null }): string | null => {
if (g.colorVarietyId) {
const name = colorNameById.get(g.colorVarietyId)
if (name) return name
}
if (g.genotype?.trim()) {
try {
const name = genotypeToFarbschlag(fromDisplayString(g.genotype))
return name === UNKNOWN_FARBSCHLAG ? null : name
} catch {
return null
}
}
return null
},
[colorNameById],
)
if (litter.loading) return <p className="muted">{de.common.loading}</p> if (litter.loading) return <p className="muted">{de.common.loading}</p>
if (litter.error || !litter.data) { if (litter.error || !litter.data) {
return ( return (
@@ -92,12 +125,6 @@ export default function WurfDetailPage() {
{l.totalBorn != null ? ` / ${l.totalBorn}` : ''} {l.totalBorn != null ? ` / ${l.totalBorn}` : ''}
</dd> </dd>
</div> </div>
{l.deathsWithin8Weeks != null && (
<div className="def-row">
<dt>{t.fields.deathsWithin8Weeks}</dt>
<dd>{l.deathsWithin8Weeks}</dd>
</div>
)}
<div className="def-row"> <div className="def-row">
<dt>{t.fields.expectedGoHomeDate}</dt> <dt>{t.fields.expectedGoHomeDate}</dt>
<dd>{formatDate(l.expectedGoHomeDate)}</dd> <dd>{formatDate(l.expectedGoHomeDate)}</dd>
@@ -123,14 +150,24 @@ export default function WurfDetailPage() {
{!juveniles.loading && registered === 0 && <p className="muted">{t.detail.noJuveniles}</p>} {!juveniles.loading && registered === 0 && <p className="muted">{t.detail.noJuveniles}</p>}
{registered > 0 && ( {registered > 0 && (
<ul className="card-list"> <ul className="card-list">
{(juveniles.data?.items ?? []).map((g) => ( {(juveniles.data?.items ?? []).map((g) => {
<li key={g.id}> const farbe = farbschlagOf(g)
<Link to={`/rennmaeuse/${g.id}`} className="gerbil-card"> const receiver = g.receiverContactId ? contactNameById.get(g.receiverContactId) : null
<span className="gerbil-card__name">{g.name}</span> const tJf = t.detail.juvenileFields
<span className="gerbil-card__meta">{de.pages.gerbils.genderLabels[g.gender]}</span> return (
</Link> <li key={g.id}>
</li> <Link to={`/rennmaeuse/${g.id}`} className="gerbil-card">
))} <span className="gerbil-card__name">{g.name}</span>
<span className="gerbil-card__meta">{genderLabel(g.gender)}</span>
{farbe && <span className="gerbil-card__meta">{tJf.colorVariety}: {farbe}</span>}
{g.goHomeDate && <span className="gerbil-card__meta">{tJf.goHomeDate}: {formatDate(g.goHomeDate)}</span>}
{receiver && <span className="gerbil-card__meta">{tJf.receiver}: {receiver}</span>}
{g.dateOfDeath && <span className="gerbil-card__meta">{tJf.dateOfDeath}: {formatDate(g.dateOfDeath)}</span>}
{g.causeOfDeath && <span className="gerbil-card__meta">{tJf.causeOfDeath}: {g.causeOfDeath}</span>}
</Link>
</li>
)
})}
</ul> </ul>
)} )}

View File

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

View File

@@ -22,7 +22,7 @@ function makeGerbil(id: string, name: string, litterId: string | null = null): G
id, id,
name, name,
gender: 'unknown', gender: 'unknown',
status: 'Active', status: 'Breeding',
dateOfBirth: null, dateOfBirth: null,
dateOfDeath: null, dateOfDeath: null,
causeOfDeath: null, causeOfDeath: null,

View File

@@ -27,7 +27,7 @@ function makeGerbil(over: Partial<Gerbil> & { id: string }): Gerbil {
return { return {
name: over.id, name: over.id,
gender: 'unknown', gender: 'unknown',
status: 'Active' as GerbilStatus, status: 'Breeding' as GerbilStatus,
dateOfBirth: null, dateOfBirth: null,
dateOfDeath: null, dateOfDeath: null,
causeOfDeath: null, causeOfDeath: null,

View File

@@ -83,7 +83,7 @@ export function farbschlagDistribution(
): NameCount[] { ): NameCount[] {
const byName = new Map<string | null, number>() const byName = new Map<string | null, number>()
for (const g of gerbils) { for (const g of gerbils) {
if (g.status !== 'Active') continue if (g.status !== 'Breeding' && g.status !== 'Pet') continue
const name = resolveName(g) const name = resolveName(g)
byName.set(name, (byName.get(name) ?? 0) + 1) byName.set(name, (byName.get(name) ?? 0) + 1)
} }

View File

@@ -124,6 +124,11 @@ export const de = {
isDeafUnknown: 'Unbekannt', isDeafUnknown: 'Unbekannt',
isDeafYes: 'Ja', isDeafYes: 'Ja',
isDeafNo: 'Nein', isDeafNo: 'Nein',
// STATUS-MODEL: Hinweis für abgeleitete Statuswerte
statusDerivedHint: {
Deceased: 'Wird automatisch gesetzt wenn Todesdatum erfasst.',
GivenAway: 'Wird automatisch gesetzt nach Abgabe.',
},
save: 'Speichern', save: 'Speichern',
cancel: 'Abbrechen', cancel: 'Abbrechen',
saving: 'Speichern …', saving: 'Speichern …',
@@ -141,8 +146,10 @@ export const de = {
male: 'Männlich', male: 'Männlich',
female: 'Weiblich', female: 'Weiblich',
}, },
// STATUS-MODEL: Breeding/Pet ersetzen Active; Deceased+GivenAway = abgeleitet (Backend)
statusLabels: { statusLabels: {
Active: 'Aktiv', Breeding: 'Zucht',
Pet: 'Liebhaber',
Deceased: 'Verstorben', Deceased: 'Verstorben',
GivenAway: 'Abgegeben', GivenAway: 'Abgegeben',
ForSale: 'Zur Abgabe', ForSale: 'Zur Abgabe',
@@ -172,7 +179,6 @@ export const de = {
father: 'Vater', father: 'Vater',
mother: 'Mutter', mother: 'Mutter',
totalBorn: 'Wurfstärke', totalBorn: 'Wurfstärke',
deathsWithin8Weeks: 'In den ersten 8 Wochen verstorben',
expectedGoHomeDate: 'Voraussichtliches Abgabedatum', expectedGoHomeDate: 'Voraussichtliches Abgabedatum',
notes: 'Notizen', notes: 'Notizen',
}, },
@@ -190,6 +196,14 @@ export const de = {
edit: 'Bearbeiten', edit: 'Bearbeiten',
back: 'Zurück zur Liste', back: 'Zurück zur Liste',
notFound: 'Dieser Wurf wurde nicht gefunden.', notFound: 'Dieser Wurf wurde nicht gefunden.',
// LITTER-JUVENILE-DETAILS: pro-Jungtier-Felder
juvenileFields: {
colorVariety: 'Farbschlag',
goHomeDate: 'Abgegeben',
receiver: 'Abnehmer',
dateOfDeath: 'Verstorben',
causeOfDeath: 'Todesursache',
},
}, },
// Formular // Formular
form: { form: {
@@ -205,7 +219,6 @@ export const de = {
nameRequired: 'Bitte eine Bezeichnung eingeben.', nameRequired: 'Bitte eine Bezeichnung eingeben.',
dateRequired: 'Bitte ein Wurfdatum angeben.', dateRequired: 'Bitte ein Wurfdatum angeben.',
invalidParentGender: 'Der Vater muss männlich und die Mutter weiblich sein.', invalidParentGender: 'Der Vater muss männlich und die Mutter weiblich sein.',
deathsExceedTotalBorn: 'Die Anzahl der Frühverluste darf die Wurfstärke nicht überschreiten.',
}, },
// Zuchtpaar-Übersicht // Zuchtpaar-Übersicht
pairs: { pairs: {