Compare commits
1 Commits
feature/li
...
a74bc1c76f
| Author | SHA1 | Date | |
|---|---|---|---|
| a74bc1c76f |
@@ -1,79 +0,0 @@
|
|||||||
/** FARBSCHLAG-GENOTYPE-SYNC: Bidirektionale Sync im Tier-Formular. */
|
|
||||||
import { de, expect, skipUnlessMock, test } from './fixtures'
|
|
||||||
|
|
||||||
const t = de.pages.gerbils
|
|
||||||
|
|
||||||
test('Farbschlag-Auswahl füllt Gencode automatisch aus', async ({ page }) => {
|
|
||||||
skipUnlessMock()
|
|
||||||
await page.goto('/rennmaeuse/neu')
|
|
||||||
|
|
||||||
const farbschlagSelect = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
|
|
||||||
.locator('select')
|
|
||||||
const genotypeInput = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
|
|
||||||
.locator('input')
|
|
||||||
|
|
||||||
// Vor der Auswahl ist das Gencode-Feld leer.
|
|
||||||
await expect(genotypeInput).toHaveValue('')
|
|
||||||
|
|
||||||
// 'Agouti' wählen → Gencode wird automatisch befüllt.
|
|
||||||
await farbschlagSelect.selectOption({ label: 'Agouti' })
|
|
||||||
await expect(genotypeInput).toHaveValue('AA CC DD EE GG PP spsp rere')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Gencode-Eingabe aktualisiert die Farbschlag-Auswahl', async ({ page }) => {
|
|
||||||
skipUnlessMock()
|
|
||||||
await page.goto('/rennmaeuse/neu')
|
|
||||||
|
|
||||||
const farbschlagSelect = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
|
|
||||||
.locator('select')
|
|
||||||
const genotypeInput = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
|
|
||||||
.locator('input')
|
|
||||||
|
|
||||||
// Gencode für Schwarz eintippen → Farbschlag-Select springt auf 'Schwarz'.
|
|
||||||
await genotypeInput.fill('aa CC DD EE GG PP spsp rere')
|
|
||||||
await expect(farbschlagSelect).toHaveValue('cv-schwarz')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Gencode ohne passende Farbschlag-Auswahl leert das Dropdown', async ({ page }) => {
|
|
||||||
skipUnlessMock()
|
|
||||||
await page.goto('/rennmaeuse/neu')
|
|
||||||
|
|
||||||
const farbschlagSelect = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
|
|
||||||
.locator('select')
|
|
||||||
const genotypeInput = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
|
|
||||||
.locator('input')
|
|
||||||
|
|
||||||
// Zuerst eine bekannte Farbe wählen, damit das Select belegt ist.
|
|
||||||
await farbschlagSelect.selectOption({ label: 'Agouti' })
|
|
||||||
await expect(farbschlagSelect).not.toHaveValue('')
|
|
||||||
|
|
||||||
// Marder-Genotyp: bekannte Farbe im Engine, aber NICHT im Mock-Dropdown
|
|
||||||
// → Select wird auf '' (kein Eintrag) zurückgesetzt.
|
|
||||||
await genotypeInput.fill('aa cchmcchm DD EE GG PP spsp rere')
|
|
||||||
await expect(farbschlagSelect).toHaveValue('')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Unbekannter Genotyp leert das Farbschlag-Dropdown (Unbekannt-Fall)', async ({ page }) => {
|
|
||||||
skipUnlessMock()
|
|
||||||
await page.goto('/rennmaeuse/neu')
|
|
||||||
|
|
||||||
const farbschlagSelect = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
|
|
||||||
.locator('select')
|
|
||||||
const genotypeInput = page
|
|
||||||
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
|
|
||||||
.locator('input')
|
|
||||||
|
|
||||||
await farbschlagSelect.selectOption({ label: 'Blau' })
|
|
||||||
await expect(farbschlagSelect).not.toHaveValue('')
|
|
||||||
|
|
||||||
// aa CC dd EE gg pp → Unbekannter Farbschlag (nicht im Katalog) → Select leert sich.
|
|
||||||
await genotypeInput.fill('aa CC dd EE gg pp spsp rere')
|
|
||||||
await expect(farbschlagSelect).toHaveValue('')
|
|
||||||
})
|
|
||||||
@@ -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()
|
|
||||||
})
|
|
||||||
@@ -108,6 +108,7 @@ function gerbil(
|
|||||||
notes: null,
|
notes: null,
|
||||||
// BESTAND-FILTER: default = eigener Bestand; einzelne externe Ahnen unten gesetzt.
|
// BESTAND-FILTER: default = eigener Bestand; einzelne externe Ahnen unten gesetzt.
|
||||||
isResident: true,
|
isResident: true,
|
||||||
|
profilePhotoUrl: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ export function seedDb(): MockDb {
|
|||||||
originContactId: 'con-meier',
|
originContactId: 'con-meier',
|
||||||
originBreeder: 'Clan-Kleine-Chaoten',
|
originBreeder: 'Clan-Kleine-Chaoten',
|
||||||
},
|
},
|
||||||
{ ...gerbil('fridolin', 'Fridolin', 'male', '2023-05-01', 'w-fridolin', 'cv-schwarz', 'aa CC DD EE GG PP spsp rere'), enclosureId: 'enc-gross', originBreeder: 'Zoohandlung Meier' },
|
{ ...gerbil('fridolin', 'Fridolin', 'male', '2023-05-01', 'w-fridolin', 'cv-schwarz', 'aa CC DD EE GG PP spsp rere'), enclosureId: 'enc-gross', originBreeder: 'Zoohandlung Meier', profilePhotoUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' },
|
||||||
gerbil('luna', 'Luna', 'female', '2023-08-15', 'w-luna', 'cv-gold', 'AA CC DD EE GG pp spsp rere'),
|
gerbil('luna', 'Luna', 'female', '2023-08-15', 'w-luna', 'cv-gold', 'AA CC DD EE GG pp spsp rere'),
|
||||||
gerbil('balu', 'Balu', 'male', '2021-04-20', 'w-balu', 'cv-agouti'),
|
gerbil('balu', 'Balu', 'male', '2021-04-20', 'w-balu', 'cv-agouti'),
|
||||||
gerbil('maja', 'Maja', 'female', '2021-06-11', null, 'cv-schwarz-schecke', 'aa CC DD EE GG PP Spsp rere'),
|
gerbil('maja', 'Maja', 'female', '2021-06-11', null, 'cv-schwarz-schecke', 'aa CC DD EE GG PP Spsp rere'),
|
||||||
@@ -156,7 +157,7 @@ export function seedDb(): MockDb {
|
|||||||
]
|
]
|
||||||
|
|
||||||
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' },
|
||||||
|
|||||||
@@ -138,19 +138,19 @@ test('Kein Würfe-Panel wenn Wurzeltier keine Würfe hat (STAMMBAUM-LITTERS)', a
|
|||||||
await expect(page.locator('.stammbaum-litters-panel')).not.toBeVisible()
|
await expect(page.locator('.stammbaum-litters-panel')).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Knoten-Karte zeigt volles Geburtsdatum (STAMMBAUM-FULLDATE)', async ({ page }) => {
|
test('Tier mit Foto zeigt Avatar-Bild, Tier ohne Foto zeigt Rennmaus-Icon (STAMMBAUM-AVATAR)', async ({ page }) => {
|
||||||
skipUnlessMock()
|
skipUnlessMock()
|
||||||
// Krümel: dateOfBirth '2025-03-12' → formatDate → '12.03.2025'
|
// Fridolin hat profilePhotoUrl (data URI) → <img.pedigree-card__avatar> sichtbar
|
||||||
|
// Krümel hat profilePhotoUrl=null → kein img, SVG-Icon sichtbar
|
||||||
await page.goto('/rennmaeuse/kruemel/stammbaum')
|
await page.goto('/rennmaeuse/kruemel/stammbaum')
|
||||||
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
||||||
await expect(page.locator('.pedigree-card__year').first()).toContainText('12.03.2025')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Gencode-Chip zeigt Genotyp statt Farbname (STAMMBAUM-GENCODE)', async ({ page }) => {
|
// Fridolin ist Vater von Krümel → seine Karte enthält ein <img>
|
||||||
skipUnlessMock()
|
|
||||||
// Fridolin ist Vater von Krümel — genotype 'aa CC DD EE GG PP spsp rere'
|
|
||||||
await page.goto('/rennmaeuse/kruemel/stammbaum')
|
|
||||||
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
|
||||||
const fridolinCard = page.locator('.pedigree-card').filter({ hasText: 'Fridolin' })
|
const fridolinCard = page.locator('.pedigree-card').filter({ hasText: 'Fridolin' })
|
||||||
await expect(fridolinCard.locator('.pedigree-chip')).toContainText('aa CC')
|
await expect(fridolinCard.locator('img.pedigree-card__avatar')).toBeVisible()
|
||||||
|
|
||||||
|
// Krümel (root) hat kein Foto → SVG-Icon im Foto-Slot
|
||||||
|
const rootCard = page.locator('.pedigree-card.pedigree-card--root')
|
||||||
|
await expect(rootCard.locator('img.pedigree-card__avatar')).not.toBeAttached()
|
||||||
|
await expect(rootCard.locator('svg[role="img"]')).toBeVisible()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ export interface Gerbil {
|
|||||||
isResident?: boolean
|
isResident?: boolean
|
||||||
/** FORM-FIELDS-1: true=gehörlos, false=hörend, null=unbekannt. */
|
/** FORM-FIELDS-1: true=gehörlos, false=hörend, null=unbekannt. */
|
||||||
isDeaf?: boolean | null
|
isDeaf?: boolean | null
|
||||||
|
/** STAMMBAUM-AVATAR: URL des Profilfotos (erstes Foto nach sortOrder); null = kein Foto. API-relativ oder absolut. */
|
||||||
|
profilePhotoUrl?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Payload for POST /gerbils. */
|
/** Payload for POST /gerbils. */
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import type { ReactNode } from 'react'
|
|
||||||
import { NavLink, Outlet } from 'react-router-dom'
|
import { NavLink, Outlet } from 'react-router-dom'
|
||||||
import { de } from '../strings/de'
|
import { de } from '../strings/de'
|
||||||
import GerbilIcon from './GerbilIcon'
|
|
||||||
import './appShell.css'
|
import './appShell.css'
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
to: string
|
to: string
|
||||||
label: string
|
label: string
|
||||||
icon: ReactNode
|
icon: string
|
||||||
end?: boolean
|
end?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// Primary items are always visible in the phone bottom bar; secondary items
|
// Primary items are always visible in the phone bottom bar; secondary items
|
||||||
// move into the "Mehr" sheet on phones and appear inline in the desktop sidebar.
|
// move into the "Mehr" sheet on phones and appear inline in the desktop sidebar.
|
||||||
const PRIMARY: NavItem[] = [
|
const PRIMARY: NavItem[] = [
|
||||||
{ to: '/rennmaeuse', label: de.nav.gerbils, icon: <GerbilIcon size="1.25em" /> },
|
{ to: '/rennmaeuse', label: de.nav.gerbils, icon: '🐭' },
|
||||||
{ to: '/wuerfe', label: de.nav.litters, icon: '🍼' },
|
{ to: '/wuerfe', label: de.nav.litters, icon: '🍼' },
|
||||||
{ to: '/genetik', label: de.nav.genetics, icon: '🧬' },
|
{ to: '/genetik', label: de.nav.genetics, icon: '🧬' },
|
||||||
]
|
]
|
||||||
@@ -48,7 +46,7 @@ export default function AppShell() {
|
|||||||
return (
|
return (
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<header className="app-header">
|
<header className="app-header">
|
||||||
<span className="app-logo" aria-hidden="true"><GerbilIcon size="1.5rem" /></span>
|
<span className="app-logo" aria-hidden="true">🐭</span>
|
||||||
<h1 className="app-title">{de.app.title}</h1>
|
<h1 className="app-title">{de.app.title}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { listColorVarieties, listContacts, listEnclosures, listLitters } from '.
|
|||||||
import { GENDERS, GERBIL_STATUSES, type CreateGerbil, type Gender, type GerbilStatus } from '../api/types'
|
import { GENDERS, GERBIL_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 } from '../genetics'
|
||||||
import FarbschlagImage from '../components/FarbschlagImage'
|
import FarbschlagImage from '../components/FarbschlagImage'
|
||||||
import NameSuggestPanel from '../components/NameSuggestPanel'
|
import NameSuggestPanel from '../components/NameSuggestPanel'
|
||||||
import '../components/NameSuggestPanel.css'
|
import '../components/NameSuggestPanel.css'
|
||||||
@@ -307,14 +307,7 @@ export default function GerbilFormPage() {
|
|||||||
<span className="farbschlag-value">
|
<span className="farbschlag-value">
|
||||||
<select
|
<select
|
||||||
value={form.colorVarietyId}
|
value={form.colorVarietyId}
|
||||||
onChange={(e) => {
|
onChange={(e) => set('colorVarietyId', e.target.value)}
|
||||||
const newId = e.target.value
|
|
||||||
set('colorVarietyId', newId)
|
|
||||||
if (newId) {
|
|
||||||
const variety = (colorVarieties.data ?? []).find((cv) => cv.id === newId)
|
|
||||||
if (variety?.canonicalGenotype) set('genotype', variety.canonicalGenotype)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<option value="">{t.form.none}</option>
|
<option value="">{t.form.none}</option>
|
||||||
{(colorVarieties.data ?? []).map((cv) => (
|
{(colorVarieties.data ?? []).map((cv) => (
|
||||||
@@ -394,23 +387,7 @@ export default function GerbilFormPage() {
|
|||||||
className="input"
|
className="input"
|
||||||
value={form.genotype}
|
value={form.genotype}
|
||||||
placeholder="Aa CC Dd EE GG Pp Spsp rere"
|
placeholder="Aa CC Dd EE GG Pp Spsp rere"
|
||||||
onChange={(e) => {
|
onChange={(e) => set('genotype', e.target.value)}
|
||||||
const val = e.target.value
|
|
||||||
set('genotype', val)
|
|
||||||
if (val.trim() !== '' && isGenotypeValid(val)) {
|
|
||||||
try {
|
|
||||||
const name = genotypeToFarbschlag(fromDisplayString(val))
|
|
||||||
if (name === UNKNOWN_FARBSCHLAG) {
|
|
||||||
set('colorVarietyId', '')
|
|
||||||
} else {
|
|
||||||
const match = (colorVarieties.data ?? []).find((cv) => cv.name === name)
|
|
||||||
set('colorVarietyId', match?.id ?? '')
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// invalid while typing — leave colorVarietyId unchanged
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
aria-invalid={Boolean(errors.genotype)}
|
aria-invalid={Boolean(errors.genotype)}
|
||||||
/>
|
/>
|
||||||
<small className={errors.genotype ? 'error-text' : 'muted'}>
|
<small className={errors.genotype ? 'error-text' : 'muted'}>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { Link, useNavigate, useParams } from 'react-router-dom'
|
|||||||
import Tree from 'react-d3-tree'
|
import Tree from 'react-d3-tree'
|
||||||
import type { CustomNodeElementProps, Point, RawNodeDatum } from 'react-d3-tree'
|
import type { CustomNodeElementProps, Point, RawNodeDatum } from 'react-d3-tree'
|
||||||
import { de } from '../strings/de'
|
import { de } from '../strings/de'
|
||||||
import { ApiError } from '../api/client'
|
import { API_BASE_URL, ApiError } from '../api/client'
|
||||||
import { listLitters } from '../api/litters'
|
import { listLitters } from '../api/litters'
|
||||||
import { listColorVarieties } from '../api/lookups'
|
import { listColorVarieties } from '../api/lookups'
|
||||||
import { getInbreedingCoefficient } from '../api/pedigree'
|
import { getInbreedingCoefficient } from '../api/pedigree'
|
||||||
@@ -380,7 +380,15 @@ function PedigreeCard({
|
|||||||
const t = de.pages.stammbaum
|
const t = de.pages.stammbaum
|
||||||
const g = node.gerbil
|
const g = node.gerbil
|
||||||
const chip = farbschlag ? chipColorFor(farbschlag) : null
|
const chip = farbschlag ? chipColorFor(farbschlag) : null
|
||||||
const dob = g.dateOfBirth ? formatDate(g.dateOfBirth) : null
|
const year = g.dateOfBirth ? g.dateOfBirth.slice(0, 4) : null
|
||||||
|
const [imgError, setImgError] = useState(false)
|
||||||
|
useEffect(() => setImgError(false), [g.id])
|
||||||
|
const photoUrl =
|
||||||
|
!imgError && g.profilePhotoUrl
|
||||||
|
? /^(https?:|data:|\/\/)/.test(g.profilePhotoUrl)
|
||||||
|
? g.profilePhotoUrl
|
||||||
|
: `${API_BASE_URL}${g.profilePhotoUrl}`
|
||||||
|
: null
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={isRoot ? 'pedigree-card pedigree-card--root' : 'pedigree-card'}
|
className={isRoot ? 'pedigree-card pedigree-card--root' : 'pedigree-card'}
|
||||||
@@ -388,9 +396,17 @@ function PedigreeCard({
|
|||||||
role={isRoot ? undefined : 'button'}
|
role={isRoot ? undefined : 'button'}
|
||||||
title={isRoot ? undefined : t.tapHint}
|
title={isRoot ? undefined : t.tapHint}
|
||||||
>
|
>
|
||||||
{/* Foto-Platzhalter — echte Fotos kommen mit FEAT-6. */}
|
<div className="pedigree-card__photo" aria-hidden={!photoUrl || undefined}>
|
||||||
<div className="pedigree-card__photo" aria-hidden="true">
|
{photoUrl ? (
|
||||||
<GerbilIcon size="1.6rem" />
|
<img
|
||||||
|
src={photoUrl}
|
||||||
|
alt={g.name || ''}
|
||||||
|
className="pedigree-card__avatar"
|
||||||
|
onError={() => setImgError(true)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<GerbilIcon size="1.6rem" aria-hidden="true" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="pedigree-card__body">
|
<div className="pedigree-card__body">
|
||||||
<div className="pedigree-card__name">
|
<div className="pedigree-card__name">
|
||||||
@@ -407,12 +423,11 @@ function PedigreeCard({
|
|||||||
<span
|
<span
|
||||||
className="pedigree-chip"
|
className="pedigree-chip"
|
||||||
style={chip ? { background: chip.bg, color: chip.fg } : undefined}
|
style={chip ? { background: chip.bg, color: chip.fg } : undefined}
|
||||||
title={farbschlag}
|
|
||||||
>
|
>
|
||||||
{g.genotype || farbschlag}
|
{farbschlag}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{dob && <span className="pedigree-card__year">* {dob}</span>}
|
{year && <span className="pedigree-card__year">* {year}</span>}
|
||||||
</div>
|
</div>
|
||||||
{node.expandable && (
|
{node.expandable && (
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -92,12 +92,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>
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -236,6 +236,7 @@
|
|||||||
width: 42px;
|
width: 42px;
|
||||||
height: 42px;
|
height: 42px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
background: var(--color-accent-soft);
|
background: var(--color-accent-soft);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -243,6 +244,13 @@
|
|||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pedigree-card__avatar {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.pedigree-card__body {
|
.pedigree-card__body {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -285,15 +293,14 @@
|
|||||||
.pedigree-chip {
|
.pedigree-chip {
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
font-size: 0.62rem;
|
font-size: 0.68rem;
|
||||||
padding: 0.1rem 0.45rem;
|
padding: 0.1rem 0.45rem;
|
||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
background: var(--color-accent-soft);
|
background: var(--color-accent-soft);
|
||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
white-space: normal;
|
white-space: nowrap;
|
||||||
word-break: break-word;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
line-height: 1.3;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pedigree-card__year {
|
.pedigree-card__year {
|
||||||
|
|||||||
@@ -172,7 +172,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',
|
||||||
},
|
},
|
||||||
@@ -205,7 +204,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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user