@burdenoff/microfe-healthybowl 2026.812.2 → 2026.812.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/healthybowl/hooks/useHealthyBowlFertility.js +1 -0
- package/dist/healthybowl/hooks/useHealthyBowlFertility.js.map +1 -1
- package/dist/healthybowl/pages/livestock/FertilityCard.js +175 -171
- package/dist/healthybowl/pages/livestock/FertilityCard.js.map +1 -1
- package/dist/healthybowl/utils/fertility.js +22 -7
- package/dist/healthybowl/utils/fertility.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHealthyBowlFertility.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlFertility.ts"],"sourcesContent":["/**\n * Fertility analytics — data hook (BOFF-6008).\n *\n * The fourth livestock analytics slice. Growth says how fast animals gain, feed says what that gain\n * cost, herd statistics says what the herd is made of — and this says whether it is actually\n * breeding. It shares the window and granularity contract with all three, so every livestock chart\n * describes the same period.\n *\n * The backend shipped on 2026-08-11 and had no UI at all until this hook, so nothing in the product\n * could reach it: a farmer could not see a single fertility number.\n *\n * The document is declared inline with `gql` for the same reason as its three siblings — codegen\n * validates against the committed `graphql/wspace.graphql` snapshot, which does not carry this\n * query. Types mirror `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n *\n * ⚠️ Two payload contracts the UI must not flatten:\n * - `calvingIntervalUnavailableReason` non-null means the interval is WRONG, not merely missing.\n * An undated delivery merges two births into one gap and overstates it. Render the reason, never\n * a number — `calvingIntervalDisplay` in `utils/fertility` enforces it.\n * - A null rate means unmeasured; `0` means measured and zero. Four services and nothing in calf\n * is `0`, and it is the most urgent thing this card can say. Never collapse the two.\n *\n * ★ Unlike its three siblings this hook does NOT fall back to a placeholder workspace id. Querying\n * a workspace that is not the user's returns an empty result, which this card would render as\n * \"No breeding records yet\" — a confident false statement about someone's farm. The query is\n * skipped until the workspace is known and `workspaceReady` says so, matching the fix made to\n * `useSharedMarket` for the same reason.\n */\n\nimport { useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport type { GrowthGranularity } from './useHealthyBowlLivestockGrowth';\nimport type { DueSoonRow, FertilityBucket } from '../utils/fertility';\n\nexport type { DueSoonRow, FertilityBucket };\n\nexport interface LivestockFertility {\n /** True when the backend hit its row cap — every figure below covers only part of the herd. */\n truncated: boolean;\n periodLabel: string;\n granularity: GrowthGranularity;\n\n services: number;\n conceived: number;\n /** Null = nothing was served. `0` = served and nothing conceived. Never conflate them. */\n conceptionRatePct: number | null;\n servicesPerConception: number | null;\n /** Share of CONFIRMED pregnancies that later failed — not of all services. */\n pregnancyLossPct: number | null;\n\n meanCalvingIntervalDays: number | null;\n medianCalvingIntervalDays: number | null;\n damsWithInterval: number;\n /** Non-null means the interval could not be computed honestly, and says why. */\n calvingIntervalUnavailableReason: string | null;\n\n deliveries: number;\n deliveriesWithCounts: number;\n meanOffspringBorn: number | null;\n meanOffspringLive: number | null;\n /** Null where live counts were never recorded — an unrecorded count is not a total loss. */\n perinatalMortalityPct: number | null;\n\n damsWithFirstCalving: number;\n meanAgeAtFirstCalvingDays: number | null;\n medianAgeAtFirstCalvingDays: number | null;\n\n dueSoon: DueSoonRow[];\n trend: FertilityBucket[];\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst GET_FERTILITY = gql`\n query HealthyBowlLivestockFertility(\n $context: ContextInput!\n $groupId: ID\n $from: String\n $to: String\n $granularity: HealthyBowlGrowthGranularity\n ) {\n healthyBowlLivestockFertility(\n context: $context\n groupId: $groupId\n from: $from\n to: $to\n granularity: $granularity\n ) {\n truncated\n periodLabel\n granularity\n services\n conceived\n conceptionRatePct\n servicesPerConception\n pregnancyLossPct\n meanCalvingIntervalDays\n medianCalvingIntervalDays\n damsWithInterval\n calvingIntervalUnavailableReason\n deliveries\n deliveriesWithCounts\n meanOffspringBorn\n meanOffspringLive\n perinatalMortalityPct\n damsWithFirstCalving\n meanAgeAtFirstCalvingDays\n medianAgeAtFirstCalvingDays\n dueSoon {\n animalId\n expectedDeliveryDate\n daysUntilDue\n }\n trend {\n bucket\n services\n conceived\n conceptionRatePct\n deliveries\n }\n }\n }\n`;\n\nexport interface UseFertilityOptions {\n enabled?: boolean;\n groupId?: string | null;\n from?: string | null;\n to?: string | null;\n granularity?: GrowthGranularity;\n}\n\nexport function useHealthyBowlFertility(options: UseFertilityOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n // No placeholder id — see the module docstring. An empty result from someone else's workspace\n // would be rendered as a statement about this farm.\n const workspaceReady = Boolean(workspaceId);\n const ctx = useMemo<HbContext>(() => ({ workspaceId: workspaceId || '' }), [workspaceId]);\n\n const { data, loading, error, refetch } = useQuery<\n { healthyBowlLivestockFertility: LivestockFertility },\n {\n context: HbContext;\n groupId: string | null;\n from: string | null;\n to: string | null;\n granularity: GrowthGranularity;\n }\n >(GET_FERTILITY, {\n variables: {\n context: ctx,\n groupId: options.groupId ?? null,\n from: options.from ?? null,\n to: options.to ?? null,\n granularity: options.granularity ?? 'MONTH',\n },\n fetchPolicy: 'cache-and-network',\n skip: options.enabled === false || !workspaceReady,\n });\n\n const fertility = data?.healthyBowlLivestockFertility ?? null;\n\n return {\n fertility,\n truncated: fertility?.truncated ?? false,\n dueSoon: fertility?.dueSoon ?? [],\n trend: fertility?.trend ?? [],\n /** False until the workspace is known — the caller must not claim \"no records\" before then. */\n workspaceReady,\n loading,\n error,\n refetch,\n };\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"useHealthyBowlFertility.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlFertility.ts"],"sourcesContent":["/**\n * Fertility analytics — data hook (BOFF-6008).\n *\n * The fourth livestock analytics slice. Growth says how fast animals gain, feed says what that gain\n * cost, herd statistics says what the herd is made of — and this says whether it is actually\n * breeding. It shares the window and granularity contract with all three, so every livestock chart\n * describes the same period.\n *\n * The backend shipped on 2026-08-11 and had no UI at all until this hook, so nothing in the product\n * could reach it: a farmer could not see a single fertility number.\n *\n * The document is declared inline with `gql` for the same reason as its three siblings — codegen\n * validates against the committed `graphql/wspace.graphql` snapshot, which does not carry this\n * query. Types mirror `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n *\n * ⚠️ Two payload contracts the UI must not flatten:\n * - `calvingIntervalUnavailableReason` non-null means the interval is WRONG, not merely missing.\n * An undated delivery merges two births into one gap and overstates it. Render the reason, never\n * a number — `calvingIntervalDisplay` in `utils/fertility` enforces it.\n * - A null rate means unmeasured; `0` means measured and zero. Four services and nothing in calf\n * is `0`, and it is the most urgent thing this card can say. Never collapse the two.\n *\n * ★ Unlike its three siblings this hook does NOT fall back to a placeholder workspace id. Querying\n * a workspace that is not the user's returns an empty result, which this card would render as\n * \"No breeding records yet\" — a confident false statement about someone's farm. The query is\n * skipped until the workspace is known and `workspaceReady` says so, matching the fix made to\n * `useSharedMarket` for the same reason.\n */\n\nimport { useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport type { GrowthGranularity } from './useHealthyBowlLivestockGrowth';\nimport type { DueSoonRow, FertilityBucket } from '../utils/fertility';\n\nexport type { DueSoonRow, FertilityBucket };\n\nexport interface LivestockFertility {\n /** True when the backend hit its row cap — every figure below covers only part of the herd. */\n truncated: boolean;\n periodLabel: string;\n granularity: GrowthGranularity;\n\n services: number;\n conceived: number;\n /** Null = nothing was served. `0` = served and nothing conceived. Never conflate them. */\n conceptionRatePct: number | null;\n servicesPerConception: number | null;\n /** Share of CONFIRMED pregnancies that later failed — not of all services. */\n pregnancyLossPct: number | null;\n /** Non-null means loss could not be computed honestly, and says why. Always set today. */\n pregnancyLossUnavailableReason: string | null;\n\n meanCalvingIntervalDays: number | null;\n medianCalvingIntervalDays: number | null;\n damsWithInterval: number;\n /** Non-null means the interval could not be computed honestly, and says why. */\n calvingIntervalUnavailableReason: string | null;\n\n deliveries: number;\n deliveriesWithCounts: number;\n meanOffspringBorn: number | null;\n meanOffspringLive: number | null;\n /** Null where live counts were never recorded — an unrecorded count is not a total loss. */\n perinatalMortalityPct: number | null;\n\n damsWithFirstCalving: number;\n meanAgeAtFirstCalvingDays: number | null;\n medianAgeAtFirstCalvingDays: number | null;\n\n dueSoon: DueSoonRow[];\n trend: FertilityBucket[];\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst GET_FERTILITY = gql`\n query HealthyBowlLivestockFertility(\n $context: ContextInput!\n $groupId: ID\n $from: String\n $to: String\n $granularity: HealthyBowlGrowthGranularity\n ) {\n healthyBowlLivestockFertility(\n context: $context\n groupId: $groupId\n from: $from\n to: $to\n granularity: $granularity\n ) {\n truncated\n periodLabel\n granularity\n services\n conceived\n conceptionRatePct\n servicesPerConception\n pregnancyLossPct\n pregnancyLossUnavailableReason\n meanCalvingIntervalDays\n medianCalvingIntervalDays\n damsWithInterval\n calvingIntervalUnavailableReason\n deliveries\n deliveriesWithCounts\n meanOffspringBorn\n meanOffspringLive\n perinatalMortalityPct\n damsWithFirstCalving\n meanAgeAtFirstCalvingDays\n medianAgeAtFirstCalvingDays\n dueSoon {\n animalId\n expectedDeliveryDate\n daysUntilDue\n }\n trend {\n bucket\n services\n conceived\n conceptionRatePct\n deliveries\n }\n }\n }\n`;\n\nexport interface UseFertilityOptions {\n enabled?: boolean;\n groupId?: string | null;\n from?: string | null;\n to?: string | null;\n granularity?: GrowthGranularity;\n}\n\nexport function useHealthyBowlFertility(options: UseFertilityOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n // No placeholder id — see the module docstring. An empty result from someone else's workspace\n // would be rendered as a statement about this farm.\n const workspaceReady = Boolean(workspaceId);\n const ctx = useMemo<HbContext>(() => ({ workspaceId: workspaceId || '' }), [workspaceId]);\n\n const { data, loading, error, refetch } = useQuery<\n { healthyBowlLivestockFertility: LivestockFertility },\n {\n context: HbContext;\n groupId: string | null;\n from: string | null;\n to: string | null;\n granularity: GrowthGranularity;\n }\n >(GET_FERTILITY, {\n variables: {\n context: ctx,\n groupId: options.groupId ?? null,\n from: options.from ?? null,\n to: options.to ?? null,\n granularity: options.granularity ?? 'MONTH',\n },\n fetchPolicy: 'cache-and-network',\n skip: options.enabled === false || !workspaceReady,\n });\n\n const fertility = data?.healthyBowlLivestockFertility ?? null;\n\n return {\n fertility,\n truncated: fertility?.truncated ?? false,\n dueSoon: fertility?.dueSoon ?? [],\n trend: fertility?.trend ?? [],\n /** False until the workspace is known — the caller must not claim \"no records\" before then. */\n workspaceReady,\n loading,\n error,\n refetch,\n };\n}\n"],"mappings":";;;;;AA+EA,IAAM,IAAgB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DzB,SAAgB,EAAwB,IAA+B,EAAE,EAAE;CACzE,IAAM,EAAE,mBAAgB,GAAgB,EAGlC,IAAiB,EAAQ,GAGzB,EAAE,SAAM,YAAS,UAAO,eAAY,EASxC,GAAe;EACf,WAAW;GACT,SAbQ,SAA0B,EAAE,aAAa,KAAe,IAAI,GAAG,CAAC,EAAY,CAAC;GAcrF,SAAS,EAAQ,WAAW;GAC5B,MAAM,EAAQ,QAAQ;GACtB,IAAI,EAAQ,MAAM;GAClB,aAAa,EAAQ,eAAe;GACrC;EACD,aAAa;EACb,MAAM,EAAQ,YAAY,MAAS,CAAC;EACrC,CAAC,EAEI,IAAY,GAAM,iCAAiC;AAEzD,QAAO;EACL;EACA,WAAW,GAAW,aAAa;EACnC,SAAS,GAAW,WAAW,EAAE;EACjC,OAAO,GAAW,SAAS,EAAE;EAE7B;EACA;EACA;EACA;EACD"}
|
|
@@ -12,161 +12,165 @@ import { YAxis as u } from "../../../node_modules/recharts/es6/cartesian/YAxis.j
|
|
|
12
12
|
import { ComposedChart as d } from "../../../node_modules/recharts/es6/chart/ComposedChart.js";
|
|
13
13
|
import { downloadCsv as f } from "../../utils/download.js";
|
|
14
14
|
import { optionalMetric as p } from "../../utils/optionalMetric.js";
|
|
15
|
-
import { FERTILITY_CSV_HEADERS as m, calvingIntervalDisplay as h, dueSoonUrgency as g, dueSoonUrgencyText as _, fertilityCsvRows as v, hasFertilityData as y, orderedDueSoon as b, orderedFertilityBuckets as x } from "../../utils/fertility.js";
|
|
16
|
-
import { useHealthyBowlFertility as
|
|
17
|
-
import { useMemo as
|
|
18
|
-
import { useI18n as
|
|
19
|
-
import { Fragment as
|
|
15
|
+
import { FERTILITY_CSV_HEADERS as m, calvingIntervalDisplay as h, dueSoonUrgency as g, dueSoonUrgencyText as _, fertilityCsvRows as v, hasFertilityData as y, orderedDueSoon as b, orderedFertilityBuckets as x, pregnancyLossDisplay as S } from "../../utils/fertility.js";
|
|
16
|
+
import { useHealthyBowlFertility as C } from "../../hooks/useHealthyBowlFertility.js";
|
|
17
|
+
import { useMemo as w, useState as T } from "react";
|
|
18
|
+
import { useI18n as E } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
19
|
+
import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
20
20
|
//#region src/healthybowl/pages/livestock/FertilityCard.tsx
|
|
21
|
-
var
|
|
21
|
+
var A = [
|
|
22
22
|
"DAY",
|
|
23
23
|
"WEEK",
|
|
24
24
|
"MONTH"
|
|
25
|
-
],
|
|
25
|
+
], j = {
|
|
26
26
|
OVERDUE: "text-status-error-text",
|
|
27
27
|
IMMINENT: "text-status-warning-text",
|
|
28
28
|
SOON: "text-text-primary",
|
|
29
29
|
LATER: "text-text-secondary"
|
|
30
|
-
},
|
|
31
|
-
let { t:
|
|
32
|
-
groupId:
|
|
33
|
-
granularity:
|
|
34
|
-
from:
|
|
35
|
-
to:
|
|
36
|
-
}),
|
|
37
|
-
services:
|
|
38
|
-
deliveries:
|
|
39
|
-
damsWithInterval:
|
|
40
|
-
dueSoonCount:
|
|
41
|
-
trendCount:
|
|
42
|
-
}),
|
|
43
|
-
|
|
44
|
-
services:
|
|
45
|
-
conceived:
|
|
46
|
-
conceptionRatePct:
|
|
47
|
-
deliveries:
|
|
48
|
-
trend:
|
|
30
|
+
}, M = ({ groupId: M = null, className: N }) => {
|
|
31
|
+
let { t: P } = E(), [F, I] = T("MONTH"), [L, R] = T(""), [z, B] = T(""), { fertility: V, dueSoon: H, trend: U, truncated: W, workspaceReady: G, loading: K, error: q } = C({
|
|
32
|
+
groupId: M,
|
|
33
|
+
granularity: F,
|
|
34
|
+
from: L || null,
|
|
35
|
+
to: z || null
|
|
36
|
+
}), J = w(() => x(U), [U]), Y = w(() => b(H), [H]), X = y({
|
|
37
|
+
services: V?.services,
|
|
38
|
+
deliveries: V?.deliveries,
|
|
39
|
+
damsWithInterval: V?.damsWithInterval,
|
|
40
|
+
dueSoonCount: Y.length,
|
|
41
|
+
trendCount: J.length
|
|
42
|
+
}), Z = V ? h(V) : null, Q = V ? S(V) : null, $ = () => {
|
|
43
|
+
V && f(`livestock-fertility-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`, [...m], v({
|
|
44
|
+
services: V.services,
|
|
45
|
+
conceived: V.conceived,
|
|
46
|
+
conceptionRatePct: V.conceptionRatePct,
|
|
47
|
+
deliveries: V.deliveries,
|
|
48
|
+
trend: J
|
|
49
49
|
}));
|
|
50
|
-
},
|
|
50
|
+
}, ee = /* @__PURE__ */ O("div", {
|
|
51
51
|
className: "flex items-center gap-1",
|
|
52
|
-
children:
|
|
52
|
+
children: A.map((e) => /* @__PURE__ */ O("button", {
|
|
53
53
|
type: "button",
|
|
54
|
-
onClick: () =>
|
|
55
|
-
"aria-pressed":
|
|
56
|
-
className: `min-h-[32px] rounded-md px-2 py-1 text-xs transition-colors ${
|
|
57
|
-
children:
|
|
54
|
+
onClick: () => I(e),
|
|
55
|
+
"aria-pressed": F === e,
|
|
56
|
+
className: `min-h-[32px] rounded-md px-2 py-1 text-xs transition-colors ${F === e ? "bg-action-primary-bg text-action-primary-text" : "text-text-secondary hover:bg-bg-sunken/50"}`,
|
|
57
|
+
children: P(`healthybowl.livestock.fertility.granularity.${e.toLowerCase()}`, e.charAt(0) + e.slice(1).toLowerCase())
|
|
58
58
|
}, e))
|
|
59
59
|
});
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
title:
|
|
62
|
-
description:
|
|
63
|
-
actions: /* @__PURE__ */
|
|
64
|
-
from:
|
|
65
|
-
to:
|
|
66
|
-
onFromChange:
|
|
67
|
-
onToChange:
|
|
68
|
-
onExportCsv:
|
|
69
|
-
exportDisabled: !
|
|
70
|
-
children:
|
|
60
|
+
return /* @__PURE__ */ O(t, {
|
|
61
|
+
title: P("healthybowl.livestock.fertility.title", "Fertility"),
|
|
62
|
+
description: P("healthybowl.livestock.fertility.description", "Whether the herd is actually breeding — conception, calving interval, litter size and who is due."),
|
|
63
|
+
actions: /* @__PURE__ */ O(n, {
|
|
64
|
+
from: L,
|
|
65
|
+
to: z,
|
|
66
|
+
onFromChange: R,
|
|
67
|
+
onToChange: B,
|
|
68
|
+
onExportCsv: $,
|
|
69
|
+
exportDisabled: !V || !X,
|
|
70
|
+
children: ee
|
|
71
71
|
}),
|
|
72
|
-
className:
|
|
73
|
-
children:
|
|
72
|
+
className: N,
|
|
73
|
+
children: q ? /* @__PURE__ */ k("div", {
|
|
74
74
|
className: "py-8 text-center",
|
|
75
|
-
children: [/* @__PURE__ */
|
|
75
|
+
children: [/* @__PURE__ */ O("p", {
|
|
76
76
|
className: "text-sm text-text-primary",
|
|
77
|
-
children:
|
|
78
|
-
}), /* @__PURE__ */
|
|
77
|
+
children: P("healthybowl.livestock.fertility.error.title", "Could not load fertility analytics")
|
|
78
|
+
}), /* @__PURE__ */ O("p", {
|
|
79
79
|
className: "mt-1 text-xs text-text-secondary",
|
|
80
|
-
children:
|
|
80
|
+
children: q.message
|
|
81
81
|
})]
|
|
82
|
-
}) : !
|
|
82
|
+
}) : !G || K && !X ? /* @__PURE__ */ O("p", {
|
|
83
83
|
className: "py-8 text-center text-xs text-text-secondary",
|
|
84
|
-
children:
|
|
85
|
-
}) :
|
|
86
|
-
|
|
84
|
+
children: P("healthybowl.livestock.fertility.loading", "Loading fertility analytics…")
|
|
85
|
+
}) : X ? /* @__PURE__ */ k(D, { children: [
|
|
86
|
+
W && /* @__PURE__ */ O("p", {
|
|
87
87
|
className: "mb-3 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary",
|
|
88
|
-
children:
|
|
88
|
+
children: P("healthybowl.livestock.fertility.truncated", "This herd has more breeding records than one view can load, so every figure below covers only part of it. Narrow the date range or filter by group for an exact figure.")
|
|
89
89
|
}),
|
|
90
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ k("dl", {
|
|
91
91
|
className: "mb-4 grid grid-cols-2 gap-3 sm:grid-cols-4",
|
|
92
92
|
children: [
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ k("div", { children: [
|
|
94
|
+
/* @__PURE__ */ O("dt", {
|
|
95
95
|
className: "text-xs text-text-secondary",
|
|
96
|
-
children:
|
|
96
|
+
children: P("healthybowl.livestock.fertility.summary.conceptionRate", "Conception rate")
|
|
97
97
|
}),
|
|
98
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ O("dd", {
|
|
99
99
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
100
|
-
children: p(
|
|
100
|
+
children: p(V?.conceptionRatePct, {
|
|
101
101
|
decimals: 1,
|
|
102
102
|
unit: "%"
|
|
103
103
|
})
|
|
104
104
|
}),
|
|
105
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ O("dd", {
|
|
106
106
|
className: "text-xs text-text-secondary",
|
|
107
|
-
children:
|
|
108
|
-
c: String(
|
|
109
|
-
s: String(
|
|
107
|
+
children: P("healthybowl.livestock.fertility.summary.ofServices", "{{c}} of {{s}} services", {
|
|
108
|
+
c: String(V?.conceived ?? 0),
|
|
109
|
+
s: String(V?.services ?? 0)
|
|
110
110
|
})
|
|
111
111
|
})
|
|
112
112
|
] }),
|
|
113
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
114
114
|
className: "text-xs text-text-secondary",
|
|
115
|
-
children:
|
|
116
|
-
}), /* @__PURE__ */
|
|
115
|
+
children: P("healthybowl.livestock.fertility.summary.servicesPerConception", "Services per conception")
|
|
116
|
+
}), /* @__PURE__ */ O("dd", {
|
|
117
117
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
118
|
-
children: p(
|
|
118
|
+
children: p(V?.servicesPerConception, { decimals: 1 })
|
|
119
119
|
})] }),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ k("div", { children: [
|
|
121
|
+
/* @__PURE__ */ O("dt", {
|
|
122
122
|
className: "text-xs text-text-secondary",
|
|
123
|
-
children:
|
|
123
|
+
children: P("healthybowl.livestock.fertility.summary.calvingInterval", "Mean calving interval")
|
|
124
124
|
}),
|
|
125
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ O("dd", {
|
|
126
126
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
127
|
-
children:
|
|
127
|
+
children: Z?.available ? P("healthybowl.livestock.fertility.summary.days", "{{n}} days", { n: e(Z.meanDays) }) : "—"
|
|
128
128
|
}),
|
|
129
|
-
|
|
129
|
+
Z?.available && Z.medianDays !== null && /* @__PURE__ */ O("dd", {
|
|
130
130
|
className: "text-xs text-text-secondary",
|
|
131
|
-
children:
|
|
131
|
+
children: P("healthybowl.livestock.fertility.summary.median", "median {{n}}", { n: p(Z.medianDays, { decimals: 0 }) })
|
|
132
132
|
})
|
|
133
133
|
] }),
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ k("div", { children: [
|
|
135
|
+
/* @__PURE__ */ O("dt", {
|
|
136
136
|
className: "text-xs text-text-secondary",
|
|
137
|
-
children:
|
|
137
|
+
children: P("healthybowl.livestock.fertility.summary.pregnancyLoss", "Pregnancy loss")
|
|
138
138
|
}),
|
|
139
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ O("dd", {
|
|
140
140
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
141
|
-
children: p(
|
|
141
|
+
children: Q?.available ? p(Q.ratePct, {
|
|
142
142
|
decimals: 1,
|
|
143
143
|
unit: "%"
|
|
144
|
-
})
|
|
144
|
+
}) : "—"
|
|
145
145
|
}),
|
|
146
|
-
/* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ O("dd", {
|
|
147
147
|
className: "text-xs text-text-secondary",
|
|
148
|
-
children:
|
|
148
|
+
children: P("healthybowl.livestock.fertility.summary.ofConfirmed", "of confirmed pregnancies")
|
|
149
149
|
})
|
|
150
150
|
] })
|
|
151
151
|
]
|
|
152
152
|
}),
|
|
153
|
-
|
|
153
|
+
Z && !Z.available && Z.reason && /* @__PURE__ */ O("p", {
|
|
154
|
+
className: "mb-4 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary",
|
|
155
|
+
children: Z.reason
|
|
156
|
+
}),
|
|
157
|
+
Q && !Q.available && Q.reason && /* @__PURE__ */ O("p", {
|
|
154
158
|
className: "mb-4 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary",
|
|
155
|
-
children:
|
|
159
|
+
children: Q.reason
|
|
156
160
|
}),
|
|
157
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ k("div", {
|
|
158
162
|
className: "border-t border-border-subtle pt-4",
|
|
159
|
-
children: [/* @__PURE__ */
|
|
163
|
+
children: [/* @__PURE__ */ O("h4", {
|
|
160
164
|
className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary",
|
|
161
|
-
children:
|
|
162
|
-
}),
|
|
165
|
+
children: P("healthybowl.livestock.fertility.trend.title", "Services and conceptions")
|
|
166
|
+
}), J.length === 0 ? /* @__PURE__ */ O("p", {
|
|
163
167
|
className: "py-4 text-center text-xs text-text-secondary",
|
|
164
|
-
children:
|
|
165
|
-
}) : /* @__PURE__ */
|
|
168
|
+
children: P("healthybowl.livestock.fertility.trend.empty", "No service in this period carries a mating date, so there is nothing to plot over time.")
|
|
169
|
+
}) : /* @__PURE__ */ O(a, {
|
|
166
170
|
width: "100%",
|
|
167
171
|
height: 220,
|
|
168
|
-
children: /* @__PURE__ */
|
|
169
|
-
data:
|
|
172
|
+
children: /* @__PURE__ */ k(d, {
|
|
173
|
+
data: J,
|
|
170
174
|
margin: {
|
|
171
175
|
top: 5,
|
|
172
176
|
right: 20,
|
|
@@ -174,22 +178,22 @@ var k = [
|
|
|
174
178
|
bottom: 5
|
|
175
179
|
},
|
|
176
180
|
children: [
|
|
177
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ O(s, {
|
|
178
182
|
strokeDasharray: "3 3",
|
|
179
183
|
stroke: "var(--color-border)"
|
|
180
184
|
}),
|
|
181
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ O(l, {
|
|
182
186
|
dataKey: "bucket",
|
|
183
187
|
tick: { fontSize: 11 },
|
|
184
188
|
stroke: "var(--color-muted-foreground)"
|
|
185
189
|
}),
|
|
186
|
-
/* @__PURE__ */
|
|
190
|
+
/* @__PURE__ */ O(u, {
|
|
187
191
|
yAxisId: "count",
|
|
188
192
|
allowDecimals: !1,
|
|
189
193
|
tick: { fontSize: 11 },
|
|
190
194
|
stroke: "var(--color-muted-foreground)"
|
|
191
195
|
}),
|
|
192
|
-
/* @__PURE__ */
|
|
196
|
+
/* @__PURE__ */ O(u, {
|
|
193
197
|
yAxisId: "rate",
|
|
194
198
|
orientation: "right",
|
|
195
199
|
domain: [0, 100],
|
|
@@ -197,7 +201,7 @@ var k = [
|
|
|
197
201
|
tick: { fontSize: 11 },
|
|
198
202
|
stroke: "var(--color-muted-foreground)"
|
|
199
203
|
}),
|
|
200
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ O(i, {
|
|
201
205
|
cursor: {
|
|
202
206
|
fill: "var(--color-muted)",
|
|
203
207
|
opacity: .2
|
|
@@ -211,11 +215,11 @@ var k = [
|
|
|
211
215
|
labelStyle: { color: "var(--color-foreground)" },
|
|
212
216
|
formatter: (t, n) => [typeof t == "number" ? e(t) : String(t ?? "—"), n]
|
|
213
217
|
}),
|
|
214
|
-
/* @__PURE__ */
|
|
215
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ O(r, { wrapperStyle: { fontSize: 11 } }),
|
|
219
|
+
/* @__PURE__ */ O(o, {
|
|
216
220
|
yAxisId: "count",
|
|
217
221
|
dataKey: "services",
|
|
218
|
-
name:
|
|
222
|
+
name: P("healthybowl.livestock.fertility.trend.services", "Services"),
|
|
219
223
|
fill: "var(--color-chart-1)",
|
|
220
224
|
radius: [
|
|
221
225
|
4,
|
|
@@ -224,10 +228,10 @@ var k = [
|
|
|
224
228
|
0
|
|
225
229
|
]
|
|
226
230
|
}),
|
|
227
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ O(o, {
|
|
228
232
|
yAxisId: "count",
|
|
229
233
|
dataKey: "conceived",
|
|
230
|
-
name:
|
|
234
|
+
name: P("healthybowl.livestock.fertility.trend.conceived", "Conceived"),
|
|
231
235
|
fill: "var(--color-chart-2)",
|
|
232
236
|
radius: [
|
|
233
237
|
4,
|
|
@@ -236,11 +240,11 @@ var k = [
|
|
|
236
240
|
0
|
|
237
241
|
]
|
|
238
242
|
}),
|
|
239
|
-
/* @__PURE__ */
|
|
243
|
+
/* @__PURE__ */ O(c, {
|
|
240
244
|
yAxisId: "rate",
|
|
241
245
|
type: "monotone",
|
|
242
246
|
dataKey: "conceptionRatePct",
|
|
243
|
-
name:
|
|
247
|
+
name: P("healthybowl.livestock.fertility.trend.rate", "Conception rate %"),
|
|
244
248
|
stroke: "var(--color-chart-3)",
|
|
245
249
|
strokeWidth: 2,
|
|
246
250
|
dot: !1,
|
|
@@ -250,126 +254,126 @@ var k = [
|
|
|
250
254
|
})
|
|
251
255
|
})]
|
|
252
256
|
}),
|
|
253
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ k("div", {
|
|
254
258
|
className: "mt-4 grid grid-cols-1 gap-4 border-t border-border-subtle pt-4 sm:grid-cols-2",
|
|
255
|
-
children: [/* @__PURE__ */
|
|
256
|
-
/* @__PURE__ */
|
|
259
|
+
children: [/* @__PURE__ */ k("div", { children: [
|
|
260
|
+
/* @__PURE__ */ O("h4", {
|
|
257
261
|
className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary",
|
|
258
|
-
children:
|
|
262
|
+
children: P("healthybowl.livestock.fertility.litter.title", "Litter size")
|
|
259
263
|
}),
|
|
260
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ k("dl", {
|
|
261
265
|
className: "grid grid-cols-2 gap-3",
|
|
262
266
|
children: [
|
|
263
|
-
/* @__PURE__ */
|
|
267
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
264
268
|
className: "text-xs text-text-secondary",
|
|
265
|
-
children:
|
|
266
|
-
}), /* @__PURE__ */
|
|
269
|
+
children: P("healthybowl.livestock.fertility.litter.born", "Mean born")
|
|
270
|
+
}), /* @__PURE__ */ O("dd", {
|
|
267
271
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
268
|
-
children: p(
|
|
272
|
+
children: p(V?.meanOffspringBorn, { decimals: 1 })
|
|
269
273
|
})] }),
|
|
270
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
271
275
|
className: "text-xs text-text-secondary",
|
|
272
|
-
children:
|
|
273
|
-
}), /* @__PURE__ */
|
|
276
|
+
children: P("healthybowl.livestock.fertility.litter.live", "Mean born alive")
|
|
277
|
+
}), /* @__PURE__ */ O("dd", {
|
|
274
278
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
275
|
-
children: p(
|
|
279
|
+
children: p(V?.meanOffspringLive, { decimals: 1 })
|
|
276
280
|
})] }),
|
|
277
|
-
/* @__PURE__ */
|
|
281
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
278
282
|
className: "text-xs text-text-secondary",
|
|
279
|
-
children:
|
|
280
|
-
}), /* @__PURE__ */
|
|
283
|
+
children: P("healthybowl.livestock.fertility.litter.perinatal", "Perinatal mortality")
|
|
284
|
+
}), /* @__PURE__ */ O("dd", {
|
|
281
285
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
282
|
-
children: p(
|
|
286
|
+
children: p(V?.perinatalMortalityPct, {
|
|
283
287
|
decimals: 1,
|
|
284
288
|
unit: "%"
|
|
285
289
|
})
|
|
286
290
|
})] }),
|
|
287
|
-
/* @__PURE__ */
|
|
291
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
288
292
|
className: "text-xs text-text-secondary",
|
|
289
|
-
children:
|
|
290
|
-
}), /* @__PURE__ */
|
|
293
|
+
children: P("healthybowl.livestock.fertility.litter.deliveries", "Deliveries")
|
|
294
|
+
}), /* @__PURE__ */ O("dd", {
|
|
291
295
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
292
|
-
children: e(
|
|
296
|
+
children: e(V?.deliveries ?? 0)
|
|
293
297
|
})] })
|
|
294
298
|
]
|
|
295
299
|
}),
|
|
296
|
-
/* @__PURE__ */
|
|
300
|
+
/* @__PURE__ */ O("p", {
|
|
297
301
|
className: "mt-2 text-xs text-text-secondary",
|
|
298
|
-
children:
|
|
299
|
-
counted: String(
|
|
300
|
-
total: String(
|
|
302
|
+
children: P("healthybowl.livestock.fertility.litter.coverage", "{{counted}} of {{total}} deliveries recorded how many were born — the averages are of those.", {
|
|
303
|
+
counted: String(V?.deliveriesWithCounts ?? 0),
|
|
304
|
+
total: String(V?.deliveries ?? 0)
|
|
301
305
|
})
|
|
302
306
|
})
|
|
303
|
-
] }), /* @__PURE__ */
|
|
304
|
-
/* @__PURE__ */
|
|
307
|
+
] }), /* @__PURE__ */ k("div", { children: [
|
|
308
|
+
/* @__PURE__ */ O("h4", {
|
|
305
309
|
className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary",
|
|
306
|
-
children:
|
|
310
|
+
children: P("healthybowl.livestock.fertility.firstCalving.title", "Age at first calving")
|
|
307
311
|
}),
|
|
308
|
-
/* @__PURE__ */
|
|
312
|
+
/* @__PURE__ */ k("dl", {
|
|
309
313
|
className: "grid grid-cols-2 gap-3",
|
|
310
314
|
children: [
|
|
311
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
312
316
|
className: "text-xs text-text-secondary",
|
|
313
|
-
children:
|
|
314
|
-
}), /* @__PURE__ */
|
|
317
|
+
children: P("healthybowl.livestock.fertility.firstCalving.mean", "Mean")
|
|
318
|
+
}), /* @__PURE__ */ O("dd", {
|
|
315
319
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
316
|
-
children:
|
|
320
|
+
children: V?.meanAgeAtFirstCalvingDays !== null && V?.meanAgeAtFirstCalvingDays !== void 0 ? P("healthybowl.livestock.fertility.summary.days", "{{n}} days", { n: e(V.meanAgeAtFirstCalvingDays) }) : "—"
|
|
317
321
|
})] }),
|
|
318
|
-
/* @__PURE__ */
|
|
322
|
+
/* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("dt", {
|
|
319
323
|
className: "text-xs text-text-secondary",
|
|
320
|
-
children:
|
|
321
|
-
}), /* @__PURE__ */
|
|
324
|
+
children: P("healthybowl.livestock.fertility.firstCalving.median", "Median")
|
|
325
|
+
}), /* @__PURE__ */ O("dd", {
|
|
322
326
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
323
|
-
children: p(
|
|
327
|
+
children: p(V?.medianAgeAtFirstCalvingDays, { decimals: 0 })
|
|
324
328
|
})] }),
|
|
325
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ k("div", {
|
|
326
330
|
className: "col-span-2",
|
|
327
|
-
children: [/* @__PURE__ */
|
|
331
|
+
children: [/* @__PURE__ */ O("dt", {
|
|
328
332
|
className: "text-xs text-text-secondary",
|
|
329
|
-
children:
|
|
330
|
-
}), /* @__PURE__ */
|
|
333
|
+
children: P("healthybowl.livestock.fertility.firstCalving.dams", "Dams with a first calving")
|
|
334
|
+
}), /* @__PURE__ */ k("dd", {
|
|
331
335
|
className: "text-sm font-medium tabular-nums text-text-primary",
|
|
332
|
-
children: [e(
|
|
336
|
+
children: [e(V?.damsWithFirstCalving ?? 0), /* @__PURE__ */ O("span", {
|
|
333
337
|
className: "ms-2 text-xs font-normal text-text-secondary",
|
|
334
|
-
children:
|
|
338
|
+
children: P("healthybowl.livestock.fertility.firstCalving.intervalDams", "· {{n}} with an interval", { n: String(V?.damsWithInterval ?? 0) })
|
|
335
339
|
})]
|
|
336
340
|
})]
|
|
337
341
|
})
|
|
338
342
|
]
|
|
339
343
|
}),
|
|
340
|
-
/* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ O("p", {
|
|
341
345
|
className: "mt-2 text-xs text-text-secondary",
|
|
342
|
-
children:
|
|
346
|
+
children: P("healthybowl.livestock.fertility.firstCalving.coverage", "Only dams whose own date of birth is recorded can contribute — an unknown birth date makes the age unknowable.")
|
|
343
347
|
})
|
|
344
348
|
] })]
|
|
345
349
|
}),
|
|
346
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ k("div", {
|
|
347
351
|
className: "mt-4 border-t border-border-subtle pt-4",
|
|
348
|
-
children: [/* @__PURE__ */
|
|
352
|
+
children: [/* @__PURE__ */ O("h4", {
|
|
349
353
|
className: "mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary",
|
|
350
|
-
children:
|
|
351
|
-
}),
|
|
354
|
+
children: P("healthybowl.livestock.fertility.due.title", "Due in the next 30 days")
|
|
355
|
+
}), Y.length === 0 ? /* @__PURE__ */ O("p", {
|
|
352
356
|
className: "text-xs text-text-secondary",
|
|
353
|
-
children:
|
|
354
|
-
}) : /* @__PURE__ */
|
|
357
|
+
children: P("healthybowl.livestock.fertility.due.empty", "No confirmed or mated pregnancy is due in the next 30 days.")
|
|
358
|
+
}) : /* @__PURE__ */ O("ul", {
|
|
355
359
|
className: "flex flex-col gap-1.5",
|
|
356
|
-
children:
|
|
360
|
+
children: Y.map((e) => {
|
|
357
361
|
let t = g(e.daysUntilDue), n = _(t);
|
|
358
|
-
return /* @__PURE__ */
|
|
362
|
+
return /* @__PURE__ */ k("li", {
|
|
359
363
|
className: "flex flex-wrap items-baseline justify-between gap-2 text-xs",
|
|
360
|
-
children: [/* @__PURE__ */
|
|
364
|
+
children: [/* @__PURE__ */ O("span", {
|
|
361
365
|
className: "font-medium text-text-primary",
|
|
362
366
|
children: e.animalId
|
|
363
|
-
}), /* @__PURE__ */
|
|
367
|
+
}), /* @__PURE__ */ k("span", {
|
|
364
368
|
className: "flex items-baseline gap-2",
|
|
365
|
-
children: [/* @__PURE__ */
|
|
369
|
+
children: [/* @__PURE__ */ O("span", {
|
|
366
370
|
className: "tabular-nums text-text-secondary",
|
|
367
371
|
children: e.expectedDeliveryDate
|
|
368
|
-
}), /* @__PURE__ */
|
|
369
|
-
className: `tabular-nums ${
|
|
370
|
-
children: [
|
|
372
|
+
}), /* @__PURE__ */ k("span", {
|
|
373
|
+
className: `tabular-nums ${j[t]}`,
|
|
374
|
+
children: [P(n.key, n.defaultValue), t !== "OVERDUE" && /* @__PURE__ */ k("span", {
|
|
371
375
|
className: "text-text-secondary",
|
|
372
|
-
children: [" ",
|
|
376
|
+
children: [" ", P("healthybowl.livestock.fertility.due.inDays", "({{n}}d)", { n: String(e.daysUntilDue) })]
|
|
373
377
|
})]
|
|
374
378
|
})]
|
|
375
379
|
})]
|
|
@@ -377,19 +381,19 @@ var k = [
|
|
|
377
381
|
})
|
|
378
382
|
})]
|
|
379
383
|
})
|
|
380
|
-
] }) : /* @__PURE__ */
|
|
384
|
+
] }) : /* @__PURE__ */ k("div", {
|
|
381
385
|
className: "py-8 text-center",
|
|
382
|
-
children: [/* @__PURE__ */
|
|
386
|
+
children: [/* @__PURE__ */ O("p", {
|
|
383
387
|
className: "text-sm text-text-primary",
|
|
384
|
-
children:
|
|
385
|
-
}), /* @__PURE__ */
|
|
388
|
+
children: P("healthybowl.livestock.fertility.empty.title", "No breeding records yet")
|
|
389
|
+
}), /* @__PURE__ */ O("p", {
|
|
386
390
|
className: "mt-1 text-xs text-text-secondary",
|
|
387
|
-
children:
|
|
391
|
+
children: P("healthybowl.livestock.fertility.empty.hint", "Record a mating on the Breeding page, then set its outcome — delivery date and offspring — to see conception, calving interval and litter size here.")
|
|
388
392
|
})]
|
|
389
393
|
})
|
|
390
394
|
});
|
|
391
395
|
};
|
|
392
396
|
//#endregion
|
|
393
|
-
export {
|
|
397
|
+
export { M as FertilityCard };
|
|
394
398
|
|
|
395
399
|
//# sourceMappingURL=FertilityCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FertilityCard.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/FertilityCard.tsx"],"sourcesContent":["/**\n * Fertility card (BOFF-6008).\n *\n * The fourth card beside growth, feed and herd statistics. Growth says how fast animals gain, feed\n * says what that gain cost, herd statistics says what the herd is made of — this says whether it is\n * actually breeding, which is the number a farmer culls on.\n *\n * The backend for this shipped without any UI, so until now no user of HealthyBowl could see a\n * single fertility figure.\n *\n * Deliberate choices:\n * - **The calving interval prints its reason, never a number, whenever the backend supplies one.**\n * A DELIVERED record with no delivery date merges two births into one gap and OVERSTATES the\n * interval — the direction that hides a fertility problem behind a figure reading as merely\n * mediocre. `calvingIntervalDisplay` owns that predicate and is unit-tested; the card cannot\n * reach the number when a reason exists. Same treatment as herd statistics gives mortality.\n * - **An unmeasured rate renders as an em dash; a measured zero renders as `0%`.** Four services\n * and nothing in calf is the most urgent thing this card can say, and it must not be flattened\n * into the same appearance as \"we have no breeding data\".\n * - **The empty state is decided by breeding ACTIVITY, not by a falsy rate** (`hasFertilityData`).\n * Deciding it on `conceptionRatePct` would print \"No breeding records yet\" over a barren herd.\n * - **Two y-axes on the trend, unlike the herd-turnover chart's one.** There, entries and exits\n * were both counts of animals and shared a scale honestly. Here counts and a percentage have no\n * common scale, so the rate rides its own right-hand axis, fixed to 0–100 so a good month and a\n * bad month are comparable across reloads rather than rescaled to whatever happened.\n * - **Due-soon is a worklist, not a chart.** It answers \"who do I check on this week\", so it is\n * ordered soonest-first and banded by urgency, with a passed due date called out rather than\n * folded into \"later\".\n * - A query error is surfaced as an error, never as the empty state — \"no breeding records\" is a\n * statement about the farm and must not be shown when the truth is \"we could not load\".\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { Bar, CartesianGrid, ComposedChart, Legend, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChartCard } from '../../components/ChartCard';\nimport { AnalyticsControls } from '../../components/AnalyticsControls';\nimport { formatNumber } from '../../utils/helpers';\nimport { downloadCsv } from '../../utils/download';\nimport { NOT_MEASURED, optionalMetric } from '../../utils/optionalMetric';\nimport {\n calvingIntervalDisplay,\n dueSoonUrgency,\n dueSoonUrgencyText,\n fertilityCsvRows,\n FERTILITY_CSV_HEADERS,\n hasFertilityData,\n orderedDueSoon,\n orderedFertilityBuckets,\n type DueSoonUrgency,\n} from '../../utils/fertility';\nimport { useHealthyBowlFertility } from '../../hooks/useHealthyBowlFertility';\nimport type { GrowthGranularity } from '../../hooks/useHealthyBowlLivestockGrowth';\n\nconst GRANULARITIES: GrowthGranularity[] = ['DAY', 'WEEK', 'MONTH'];\n\n/**\n * Urgency → text colour. Only OVERDUE and IMMINENT earn a status colour; the rest stay neutral.\n *\n * Keyed on the union rather than `string` so adding a band to `DueSoonUrgency` fails the build here\n * instead of silently rendering an unstyled row.\n */\nconst URGENCY_CLASS: Record<DueSoonUrgency, string> = {\n OVERDUE: 'text-status-error-text',\n IMMINENT: 'text-status-warning-text',\n SOON: 'text-text-primary',\n LATER: 'text-text-secondary',\n};\n\ninterface FertilityCardProps {\n groupId?: string | null;\n className?: string;\n}\n\nexport const FertilityCard: FC<FertilityCardProps> = ({ groupId = null, className }) => {\n const { t } = useI18n();\n const [granularity, setGranularity] = useState<GrowthGranularity>('MONTH');\n const [from, setFrom] = useState('');\n const [to, setTo] = useState('');\n const { fertility, dueSoon, trend, truncated, workspaceReady, loading, error } = useHealthyBowlFertility({\n groupId,\n granularity,\n from: from || null,\n to: to || null,\n });\n\n const trendData = useMemo(() => orderedFertilityBuckets(trend), [trend]);\n const dueSoonRows = useMemo(() => orderedDueSoon(dueSoon), [dueSoon]);\n\n const hasData = hasFertilityData({\n services: fertility?.services,\n deliveries: fertility?.deliveries,\n damsWithInterval: fertility?.damsWithInterval,\n dueSoonCount: dueSoonRows.length,\n trendCount: trendData.length,\n });\n\n const interval = fertility ? calvingIntervalDisplay(fertility) : null;\n\n const handleExportCsv = () => {\n if (!fertility) return;\n downloadCsv(\n `livestock-fertility-${new Date().toISOString().slice(0, 10)}.csv`,\n [...FERTILITY_CSV_HEADERS],\n fertilityCsvRows({\n services: fertility.services,\n conceived: fertility.conceived,\n conceptionRatePct: fertility.conceptionRatePct,\n deliveries: fertility.deliveries,\n trend: trendData,\n })\n );\n };\n\n const granularityToggle = (\n <div className=\"flex items-center gap-1\">\n {GRANULARITIES.map((g) => (\n <button\n key={g}\n type=\"button\"\n onClick={() => setGranularity(g)}\n aria-pressed={granularity === g}\n className={`min-h-[32px] rounded-md px-2 py-1 text-xs transition-colors ${\n granularity === g\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'text-text-secondary hover:bg-bg-sunken/50'\n }`}\n >\n {t(`healthybowl.livestock.fertility.granularity.${g.toLowerCase()}`, g.charAt(0) + g.slice(1).toLowerCase())}\n </button>\n ))}\n </div>\n );\n\n return (\n <ChartCard\n title={t('healthybowl.livestock.fertility.title', 'Fertility')}\n description={t(\n 'healthybowl.livestock.fertility.description',\n 'Whether the herd is actually breeding — conception, calving interval, litter size and who is due.'\n )}\n actions={\n <AnalyticsControls\n from={from}\n to={to}\n onFromChange={setFrom}\n onToChange={setTo}\n onExportCsv={handleExportCsv}\n exportDisabled={!fertility || !hasData}\n >\n {granularityToggle}\n </AnalyticsControls>\n }\n className={className}\n >\n {error ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.fertility.error.title', 'Could not load fertility analytics')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">{error.message}</p>\n </div>\n ) : !workspaceReady || (loading && !hasData) ? (\n <p className=\"py-8 text-center text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.loading', 'Loading fertility analytics…')}\n </p>\n ) : !hasData ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.fertility.empty.title', 'No breeding records yet')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.empty.hint',\n 'Record a mating on the Breeding page, then set its outcome — delivery date and offspring — to see conception, calving interval and litter size here.'\n )}\n </p>\n </div>\n ) : (\n <>\n {truncated && (\n <p className=\"mb-3 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.truncated',\n 'This herd has more breeding records than one view can load, so every figure below covers only part of it. Narrow the date range or filter by group for an exact figure.'\n )}\n </p>\n )}\n\n {/* Headline — conception is what a farmer checks first. */}\n <dl className=\"mb-4 grid grid-cols-2 gap-3 sm:grid-cols-4\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.conceptionRate', 'Conception rate')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.conceptionRatePct, { decimals: 1, unit: '%' })}\n </dd>\n <dd className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.ofServices', '{{c}} of {{s}} services', {\n c: String(fertility?.conceived ?? 0),\n s: String(fertility?.services ?? 0),\n })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.servicesPerConception', 'Services per conception')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.servicesPerConception, { decimals: 1 })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.calvingInterval', 'Mean calving interval')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {/* Never reachable when a reason exists — see calvingIntervalDisplay. */}\n {interval?.available\n ? t('healthybowl.livestock.fertility.summary.days', '{{n}} days', {\n n: formatNumber(interval.meanDays),\n })\n : NOT_MEASURED}\n </dd>\n {interval?.available && interval.medianDays !== null && (\n <dd className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.median', 'median {{n}}', {\n n: optionalMetric(interval.medianDays, { decimals: 0 }),\n })}\n </dd>\n )}\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.pregnancyLoss', 'Pregnancy loss')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.pregnancyLossPct, { decimals: 1, unit: '%' })}\n </dd>\n <dd className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.ofConfirmed', 'of confirmed pregnancies')}\n </dd>\n </div>\n </dl>\n\n {/* The reason IS the value here — never a blank, and never a number. */}\n {interval && !interval.available && interval.reason && (\n <p className=\"mb-4 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">{interval.reason}</p>\n )}\n\n {/* Trend — counts as bars, rate as its own axis. */}\n <div className=\"border-t border-border-subtle pt-4\">\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.trend.title', 'Services and conceptions')}\n </h4>\n {trendData.length === 0 ? (\n <p className=\"py-4 text-center text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.trend.empty',\n 'No service in this period carries a mating date, so there is nothing to plot over time.'\n )}\n </p>\n ) : (\n <ResponsiveContainer width=\"100%\" height={220}>\n <ComposedChart data={trendData} margin={{ top: 5, right: 20, left: 0, bottom: 5 }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--color-border)\" />\n <XAxis dataKey=\"bucket\" tick={{ fontSize: 11 }} stroke=\"var(--color-muted-foreground)\" />\n <YAxis\n yAxisId=\"count\"\n allowDecimals={false}\n tick={{ fontSize: 11 }}\n stroke=\"var(--color-muted-foreground)\"\n />\n {/* Fixed 0–100 so two periods are comparable, not rescaled to whatever happened. */}\n <YAxis\n yAxisId=\"rate\"\n orientation=\"right\"\n domain={[0, 100]}\n unit=\"%\"\n tick={{ fontSize: 11 }}\n stroke=\"var(--color-muted-foreground)\"\n />\n <Tooltip\n cursor={{ fill: 'var(--color-muted)', opacity: 0.2 }}\n contentStyle={{\n backgroundColor: 'var(--color-card)',\n border: '1px solid var(--color-border)',\n borderRadius: 8,\n fontSize: 12,\n }}\n labelStyle={{ color: 'var(--color-foreground)' }}\n formatter={(value: number | string, name: string) => [\n typeof value === 'number' ? formatNumber(value) : String(value ?? NOT_MEASURED),\n name,\n ]}\n />\n <Legend wrapperStyle={{ fontSize: 11 }} />\n <Bar\n yAxisId=\"count\"\n dataKey=\"services\"\n name={t('healthybowl.livestock.fertility.trend.services', 'Services')}\n fill=\"var(--color-chart-1)\"\n radius={[4, 4, 0, 0]}\n />\n <Bar\n yAxisId=\"count\"\n dataKey=\"conceived\"\n name={t('healthybowl.livestock.fertility.trend.conceived', 'Conceived')}\n fill=\"var(--color-chart-2)\"\n radius={[4, 4, 0, 0]}\n />\n <Line\n yAxisId=\"rate\"\n type=\"monotone\"\n dataKey=\"conceptionRatePct\"\n name={t('healthybowl.livestock.fertility.trend.rate', 'Conception rate %')}\n stroke=\"var(--color-chart-3)\"\n strokeWidth={2}\n dot={false}\n connectNulls={false}\n />\n </ComposedChart>\n </ResponsiveContainer>\n )}\n </div>\n\n {/* Litter and first calving. */}\n <div className=\"mt-4 grid grid-cols-1 gap-4 border-t border-border-subtle pt-4 sm:grid-cols-2\">\n <div>\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.title', 'Litter size')}\n </h4>\n <dl className=\"grid grid-cols-2 gap-3\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.born', 'Mean born')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.meanOffspringBorn, { decimals: 1 })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.live', 'Mean born alive')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.meanOffspringLive, { decimals: 1 })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.perinatal', 'Perinatal mortality')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.perinatalMortalityPct, { decimals: 1, unit: '%' })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.deliveries', 'Deliveries')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {formatNumber(fertility?.deliveries ?? 0)}\n </dd>\n </div>\n </dl>\n {/* The denominator caveat, as animalsWithoutAge is for the age chart. */}\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.litter.coverage',\n '{{counted}} of {{total}} deliveries recorded how many were born — the averages are of those.',\n {\n counted: String(fertility?.deliveriesWithCounts ?? 0),\n total: String(fertility?.deliveries ?? 0),\n }\n )}\n </p>\n </div>\n\n <div>\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.title', 'Age at first calving')}\n </h4>\n <dl className=\"grid grid-cols-2 gap-3\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.mean', 'Mean')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {fertility?.meanAgeAtFirstCalvingDays !== null && fertility?.meanAgeAtFirstCalvingDays !== undefined\n ? t('healthybowl.livestock.fertility.summary.days', '{{n}} days', {\n n: formatNumber(fertility.meanAgeAtFirstCalvingDays),\n })\n : NOT_MEASURED}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.median', 'Median')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.medianAgeAtFirstCalvingDays, { decimals: 0 })}\n </dd>\n </div>\n <div className=\"col-span-2\">\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.dams', 'Dams with a first calving')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {formatNumber(fertility?.damsWithFirstCalving ?? 0)}\n <span className=\"ms-2 text-xs font-normal text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.intervalDams', '· {{n}} with an interval', {\n n: String(fertility?.damsWithInterval ?? 0),\n })}\n </span>\n </dd>\n </div>\n </dl>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.firstCalving.coverage',\n 'Only dams whose own date of birth is recorded can contribute — an unknown birth date makes the age unknowable.'\n )}\n </p>\n </div>\n </div>\n\n {/* Due soon — a worklist, soonest first. */}\n <div className=\"mt-4 border-t border-border-subtle pt-4\">\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.due.title', 'Due in the next 30 days')}\n </h4>\n {dueSoonRows.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.due.empty',\n 'No confirmed or mated pregnancy is due in the next 30 days.'\n )}\n </p>\n ) : (\n <ul className=\"flex flex-col gap-1.5\">\n {dueSoonRows.map((row) => {\n const urgency = dueSoonUrgency(row.daysUntilDue);\n const label = dueSoonUrgencyText(urgency);\n return (\n <li\n key={`${row.animalId}:${row.expectedDeliveryDate}`}\n className=\"flex flex-wrap items-baseline justify-between gap-2 text-xs\"\n >\n <span className=\"font-medium text-text-primary\">{row.animalId}</span>\n <span className=\"flex items-baseline gap-2\">\n <span className=\"tabular-nums text-text-secondary\">{row.expectedDeliveryDate}</span>\n <span className={`tabular-nums ${URGENCY_CLASS[urgency]}`}>\n {t(label.key, label.defaultValue)}\n {urgency !== 'OVERDUE' && (\n <span className=\"text-text-secondary\">\n {' '}\n {t('healthybowl.livestock.fertility.due.inDays', '({{n}}d)', {\n n: String(row.daysUntilDue),\n })}\n </span>\n )}\n </span>\n </span>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </>\n )}\n </ChartCard>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsDA,IAAM,IAAqC;CAAC;CAAO;CAAQ;CAAQ,EAQ7D,IAAgD;CACpD,SAAS;CACT,UAAU;CACV,MAAM;CACN,OAAO;CACR,EAOY,KAAyC,EAAE,aAAU,MAAM,mBAAgB;CACtF,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAa,KAAkB,EAA4B,QAAQ,EACpE,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAI,KAAS,EAAS,GAAG,EAC1B,EAAE,cAAW,YAAS,UAAO,cAAW,mBAAgB,YAAS,aAA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lBE,GAAG,EAAI,SAAS,GAAG,EAAI,uBAkBzB;OAEP;KACC,CAAA,CAEH;;GACL,EAAA,CAAA,GAhTH,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cACV,EAAE,+CAA+C,0BAA0B;IAC1E,CAAA,EACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,8CACA,uJACD;IACC,CAAA,CACA;;EAwSE,CAAA"}
|
|
1
|
+
{"version":3,"file":"FertilityCard.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/FertilityCard.tsx"],"sourcesContent":["/**\n * Fertility card (BOFF-6008).\n *\n * The fourth card beside growth, feed and herd statistics. Growth says how fast animals gain, feed\n * says what that gain cost, herd statistics says what the herd is made of — this says whether it is\n * actually breeding, which is the number a farmer culls on.\n *\n * The backend for this shipped without any UI, so until now no user of HealthyBowl could see a\n * single fertility figure.\n *\n * Deliberate choices:\n * - **The calving interval prints its reason, never a number, whenever the backend supplies one.**\n * A DELIVERED record with no delivery date merges two births into one gap and OVERSTATES the\n * interval — the direction that hides a fertility problem behind a figure reading as merely\n * mediocre. `calvingIntervalDisplay` owns that predicate and is unit-tested; the card cannot\n * reach the number when a reason exists. Same treatment as herd statistics gives mortality.\n * - **An unmeasured rate renders as an em dash; a measured zero renders as `0%`.** Four services\n * and nothing in calf is the most urgent thing this card can say, and it must not be flattened\n * into the same appearance as \"we have no breeding data\".\n * - **The empty state is decided by breeding ACTIVITY, not by a falsy rate** (`hasFertilityData`).\n * Deciding it on `conceptionRatePct` would print \"No breeding records yet\" over a barren herd.\n * - **Two y-axes on the trend, unlike the herd-turnover chart's one.** There, entries and exits\n * were both counts of animals and shared a scale honestly. Here counts and a percentage have no\n * common scale, so the rate rides its own right-hand axis, fixed to 0–100 so a good month and a\n * bad month are comparable across reloads rather than rescaled to whatever happened.\n * - **Due-soon is a worklist, not a chart.** It answers \"who do I check on this week\", so it is\n * ordered soonest-first and banded by urgency, with a passed due date called out rather than\n * folded into \"later\".\n * - A query error is surfaced as an error, never as the empty state — \"no breeding records\" is a\n * statement about the farm and must not be shown when the truth is \"we could not load\".\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { Bar, CartesianGrid, ComposedChart, Legend, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChartCard } from '../../components/ChartCard';\nimport { AnalyticsControls } from '../../components/AnalyticsControls';\nimport { formatNumber } from '../../utils/helpers';\nimport { downloadCsv } from '../../utils/download';\nimport { NOT_MEASURED, optionalMetric } from '../../utils/optionalMetric';\nimport {\n calvingIntervalDisplay,\n dueSoonUrgency,\n dueSoonUrgencyText,\n fertilityCsvRows,\n FERTILITY_CSV_HEADERS,\n hasFertilityData,\n orderedDueSoon,\n orderedFertilityBuckets,\n pregnancyLossDisplay,\n type DueSoonUrgency,\n} from '../../utils/fertility';\nimport { useHealthyBowlFertility } from '../../hooks/useHealthyBowlFertility';\nimport type { GrowthGranularity } from '../../hooks/useHealthyBowlLivestockGrowth';\n\nconst GRANULARITIES: GrowthGranularity[] = ['DAY', 'WEEK', 'MONTH'];\n\n/**\n * Urgency → text colour. Only OVERDUE and IMMINENT earn a status colour; the rest stay neutral.\n *\n * Keyed on the union rather than `string` so adding a band to `DueSoonUrgency` fails the build here\n * instead of silently rendering an unstyled row.\n */\nconst URGENCY_CLASS: Record<DueSoonUrgency, string> = {\n OVERDUE: 'text-status-error-text',\n IMMINENT: 'text-status-warning-text',\n SOON: 'text-text-primary',\n LATER: 'text-text-secondary',\n};\n\ninterface FertilityCardProps {\n groupId?: string | null;\n className?: string;\n}\n\nexport const FertilityCard: FC<FertilityCardProps> = ({ groupId = null, className }) => {\n const { t } = useI18n();\n const [granularity, setGranularity] = useState<GrowthGranularity>('MONTH');\n const [from, setFrom] = useState('');\n const [to, setTo] = useState('');\n const { fertility, dueSoon, trend, truncated, workspaceReady, loading, error } = useHealthyBowlFertility({\n groupId,\n granularity,\n from: from || null,\n to: to || null,\n });\n\n const trendData = useMemo(() => orderedFertilityBuckets(trend), [trend]);\n const dueSoonRows = useMemo(() => orderedDueSoon(dueSoon), [dueSoon]);\n\n const hasData = hasFertilityData({\n services: fertility?.services,\n deliveries: fertility?.deliveries,\n damsWithInterval: fertility?.damsWithInterval,\n dueSoonCount: dueSoonRows.length,\n trendCount: trendData.length,\n });\n\n const interval = fertility ? calvingIntervalDisplay(fertility) : null;\n const loss = fertility ? pregnancyLossDisplay(fertility) : null;\n\n const handleExportCsv = () => {\n if (!fertility) return;\n downloadCsv(\n `livestock-fertility-${new Date().toISOString().slice(0, 10)}.csv`,\n [...FERTILITY_CSV_HEADERS],\n fertilityCsvRows({\n services: fertility.services,\n conceived: fertility.conceived,\n conceptionRatePct: fertility.conceptionRatePct,\n deliveries: fertility.deliveries,\n trend: trendData,\n })\n );\n };\n\n const granularityToggle = (\n <div className=\"flex items-center gap-1\">\n {GRANULARITIES.map((g) => (\n <button\n key={g}\n type=\"button\"\n onClick={() => setGranularity(g)}\n aria-pressed={granularity === g}\n className={`min-h-[32px] rounded-md px-2 py-1 text-xs transition-colors ${\n granularity === g\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'text-text-secondary hover:bg-bg-sunken/50'\n }`}\n >\n {t(`healthybowl.livestock.fertility.granularity.${g.toLowerCase()}`, g.charAt(0) + g.slice(1).toLowerCase())}\n </button>\n ))}\n </div>\n );\n\n return (\n <ChartCard\n title={t('healthybowl.livestock.fertility.title', 'Fertility')}\n description={t(\n 'healthybowl.livestock.fertility.description',\n 'Whether the herd is actually breeding — conception, calving interval, litter size and who is due.'\n )}\n actions={\n <AnalyticsControls\n from={from}\n to={to}\n onFromChange={setFrom}\n onToChange={setTo}\n onExportCsv={handleExportCsv}\n exportDisabled={!fertility || !hasData}\n >\n {granularityToggle}\n </AnalyticsControls>\n }\n className={className}\n >\n {error ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.fertility.error.title', 'Could not load fertility analytics')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">{error.message}</p>\n </div>\n ) : !workspaceReady || (loading && !hasData) ? (\n <p className=\"py-8 text-center text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.loading', 'Loading fertility analytics…')}\n </p>\n ) : !hasData ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.fertility.empty.title', 'No breeding records yet')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.empty.hint',\n 'Record a mating on the Breeding page, then set its outcome — delivery date and offspring — to see conception, calving interval and litter size here.'\n )}\n </p>\n </div>\n ) : (\n <>\n {truncated && (\n <p className=\"mb-3 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.truncated',\n 'This herd has more breeding records than one view can load, so every figure below covers only part of it. Narrow the date range or filter by group for an exact figure.'\n )}\n </p>\n )}\n\n {/* Headline — conception is what a farmer checks first. */}\n <dl className=\"mb-4 grid grid-cols-2 gap-3 sm:grid-cols-4\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.conceptionRate', 'Conception rate')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.conceptionRatePct, { decimals: 1, unit: '%' })}\n </dd>\n <dd className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.ofServices', '{{c}} of {{s}} services', {\n c: String(fertility?.conceived ?? 0),\n s: String(fertility?.services ?? 0),\n })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.servicesPerConception', 'Services per conception')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.servicesPerConception, { decimals: 1 })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.calvingInterval', 'Mean calving interval')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {/* Never reachable when a reason exists — see calvingIntervalDisplay. */}\n {interval?.available\n ? t('healthybowl.livestock.fertility.summary.days', '{{n}} days', {\n n: formatNumber(interval.meanDays),\n })\n : NOT_MEASURED}\n </dd>\n {interval?.available && interval.medianDays !== null && (\n <dd className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.median', 'median {{n}}', {\n n: optionalMetric(interval.medianDays, { decimals: 0 }),\n })}\n </dd>\n )}\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.pregnancyLoss', 'Pregnancy loss')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {/* Unreachable while a reason exists — the raw figure is a structural 0, not a\n measurement, and printing it would read as a herd that lost nothing. */}\n {loss?.available ? optionalMetric(loss.ratePct, { decimals: 1, unit: '%' }) : NOT_MEASURED}\n </dd>\n <dd className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.summary.ofConfirmed', 'of confirmed pregnancies')}\n </dd>\n </div>\n </dl>\n\n {/* The reason IS the value in both of these — never a blank, and never a number. */}\n {interval && !interval.available && interval.reason && (\n <p className=\"mb-4 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">{interval.reason}</p>\n )}\n {loss && !loss.available && loss.reason && (\n <p className=\"mb-4 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">{loss.reason}</p>\n )}\n\n {/* Trend — counts as bars, rate as its own axis. */}\n <div className=\"border-t border-border-subtle pt-4\">\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.trend.title', 'Services and conceptions')}\n </h4>\n {trendData.length === 0 ? (\n <p className=\"py-4 text-center text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.trend.empty',\n 'No service in this period carries a mating date, so there is nothing to plot over time.'\n )}\n </p>\n ) : (\n <ResponsiveContainer width=\"100%\" height={220}>\n <ComposedChart data={trendData} margin={{ top: 5, right: 20, left: 0, bottom: 5 }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--color-border)\" />\n <XAxis dataKey=\"bucket\" tick={{ fontSize: 11 }} stroke=\"var(--color-muted-foreground)\" />\n <YAxis\n yAxisId=\"count\"\n allowDecimals={false}\n tick={{ fontSize: 11 }}\n stroke=\"var(--color-muted-foreground)\"\n />\n {/* Fixed 0–100 so two periods are comparable, not rescaled to whatever happened. */}\n <YAxis\n yAxisId=\"rate\"\n orientation=\"right\"\n domain={[0, 100]}\n unit=\"%\"\n tick={{ fontSize: 11 }}\n stroke=\"var(--color-muted-foreground)\"\n />\n <Tooltip\n cursor={{ fill: 'var(--color-muted)', opacity: 0.2 }}\n contentStyle={{\n backgroundColor: 'var(--color-card)',\n border: '1px solid var(--color-border)',\n borderRadius: 8,\n fontSize: 12,\n }}\n labelStyle={{ color: 'var(--color-foreground)' }}\n formatter={(value: number | string, name: string) => [\n typeof value === 'number' ? formatNumber(value) : String(value ?? NOT_MEASURED),\n name,\n ]}\n />\n <Legend wrapperStyle={{ fontSize: 11 }} />\n <Bar\n yAxisId=\"count\"\n dataKey=\"services\"\n name={t('healthybowl.livestock.fertility.trend.services', 'Services')}\n fill=\"var(--color-chart-1)\"\n radius={[4, 4, 0, 0]}\n />\n <Bar\n yAxisId=\"count\"\n dataKey=\"conceived\"\n name={t('healthybowl.livestock.fertility.trend.conceived', 'Conceived')}\n fill=\"var(--color-chart-2)\"\n radius={[4, 4, 0, 0]}\n />\n <Line\n yAxisId=\"rate\"\n type=\"monotone\"\n dataKey=\"conceptionRatePct\"\n name={t('healthybowl.livestock.fertility.trend.rate', 'Conception rate %')}\n stroke=\"var(--color-chart-3)\"\n strokeWidth={2}\n dot={false}\n connectNulls={false}\n />\n </ComposedChart>\n </ResponsiveContainer>\n )}\n </div>\n\n {/* Litter and first calving. */}\n <div className=\"mt-4 grid grid-cols-1 gap-4 border-t border-border-subtle pt-4 sm:grid-cols-2\">\n <div>\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.title', 'Litter size')}\n </h4>\n <dl className=\"grid grid-cols-2 gap-3\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.born', 'Mean born')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.meanOffspringBorn, { decimals: 1 })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.live', 'Mean born alive')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.meanOffspringLive, { decimals: 1 })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.perinatal', 'Perinatal mortality')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.perinatalMortalityPct, { decimals: 1, unit: '%' })}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.litter.deliveries', 'Deliveries')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {formatNumber(fertility?.deliveries ?? 0)}\n </dd>\n </div>\n </dl>\n {/* The denominator caveat, as animalsWithoutAge is for the age chart. */}\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.litter.coverage',\n '{{counted}} of {{total}} deliveries recorded how many were born — the averages are of those.',\n {\n counted: String(fertility?.deliveriesWithCounts ?? 0),\n total: String(fertility?.deliveries ?? 0),\n }\n )}\n </p>\n </div>\n\n <div>\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.title', 'Age at first calving')}\n </h4>\n <dl className=\"grid grid-cols-2 gap-3\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.mean', 'Mean')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {fertility?.meanAgeAtFirstCalvingDays !== null && fertility?.meanAgeAtFirstCalvingDays !== undefined\n ? t('healthybowl.livestock.fertility.summary.days', '{{n}} days', {\n n: formatNumber(fertility.meanAgeAtFirstCalvingDays),\n })\n : NOT_MEASURED}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.median', 'Median')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {optionalMetric(fertility?.medianAgeAtFirstCalvingDays, { decimals: 0 })}\n </dd>\n </div>\n <div className=\"col-span-2\">\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.dams', 'Dams with a first calving')}\n </dt>\n <dd className=\"text-sm font-medium tabular-nums text-text-primary\">\n {formatNumber(fertility?.damsWithFirstCalving ?? 0)}\n <span className=\"ms-2 text-xs font-normal text-text-secondary\">\n {t('healthybowl.livestock.fertility.firstCalving.intervalDams', '· {{n}} with an interval', {\n n: String(fertility?.damsWithInterval ?? 0),\n })}\n </span>\n </dd>\n </div>\n </dl>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.firstCalving.coverage',\n 'Only dams whose own date of birth is recorded can contribute — an unknown birth date makes the age unknowable.'\n )}\n </p>\n </div>\n </div>\n\n {/* Due soon — a worklist, soonest first. */}\n <div className=\"mt-4 border-t border-border-subtle pt-4\">\n <h4 className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.livestock.fertility.due.title', 'Due in the next 30 days')}\n </h4>\n {dueSoonRows.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.fertility.due.empty',\n 'No confirmed or mated pregnancy is due in the next 30 days.'\n )}\n </p>\n ) : (\n <ul className=\"flex flex-col gap-1.5\">\n {dueSoonRows.map((row) => {\n const urgency = dueSoonUrgency(row.daysUntilDue);\n const label = dueSoonUrgencyText(urgency);\n return (\n <li\n key={`${row.animalId}:${row.expectedDeliveryDate}`}\n className=\"flex flex-wrap items-baseline justify-between gap-2 text-xs\"\n >\n <span className=\"font-medium text-text-primary\">{row.animalId}</span>\n <span className=\"flex items-baseline gap-2\">\n <span className=\"tabular-nums text-text-secondary\">{row.expectedDeliveryDate}</span>\n <span className={`tabular-nums ${URGENCY_CLASS[urgency]}`}>\n {t(label.key, label.defaultValue)}\n {urgency !== 'OVERDUE' && (\n <span className=\"text-text-secondary\">\n {' '}\n {t('healthybowl.livestock.fertility.due.inDays', '({{n}}d)', {\n n: String(row.daysUntilDue),\n })}\n </span>\n )}\n </span>\n </span>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </>\n )}\n </ChartCard>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuDA,IAAM,IAAqC;CAAC;CAAO;CAAQ;CAAQ,EAQ7D,IAAgD;CACpD,SAAS;CACT,UAAU;CACV,MAAM;CACN,OAAO;CACR,EAOY,KAAyC,EAAE,aAAU,MAAM,mBAAgB;CACtF,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAa,KAAkB,EAA4B,QAAQ,EACpE,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAI,KAAS,EAAS,GAAG,EAC1B,EAAE,cAAW,YAAS,UAAO,cAAW,mBAAgB,YAAS,aAAU,EAAwB;EACvG;EACA;EACA,MAAM,KAAQ;EACd,IAAI,KAAM;EACX,CAAC,EAEI,IAAY,QAAc,EAAwB,EAAM,EAAE,CAAC,EAAM,CAAC,EAClE,IAAc,QAAc,EAAe,EAAQ,EAAE,CAAC,EAAQ,CAAC,EA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AAI,uBAkBzB;OAEP;KACC,CAAA,CAEH;;GACL,EAAA,CAAA,GArTH,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cACV,EAAE,+CAA+C,0BAA0B;IAC1E,CAAA,EACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,8CACA,uJACD;IACC,CAAA,CACA;;EA6SE,CAAA"}
|
|
@@ -22,16 +22,31 @@ function t(e) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
function n(e) {
|
|
25
|
+
let t = e.pregnancyLossUnavailableReason?.trim();
|
|
26
|
+
if (t && t.length > 0) return {
|
|
27
|
+
available: !1,
|
|
28
|
+
reason: t
|
|
29
|
+
};
|
|
30
|
+
let n = e.pregnancyLossPct;
|
|
31
|
+
return typeof n != "number" || !Number.isFinite(n) ? {
|
|
32
|
+
available: !1,
|
|
33
|
+
reason: null
|
|
34
|
+
} : {
|
|
35
|
+
available: !0,
|
|
36
|
+
ratePct: n
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function r(e) {
|
|
25
40
|
return [...e].sort((e, t) => e.bucket.localeCompare(t.bucket));
|
|
26
41
|
}
|
|
27
|
-
var
|
|
42
|
+
var i = [
|
|
28
43
|
"Period",
|
|
29
44
|
"Services",
|
|
30
45
|
"Conceived",
|
|
31
46
|
"Conception rate %",
|
|
32
47
|
"Deliveries"
|
|
33
48
|
];
|
|
34
|
-
function
|
|
49
|
+
function a(e) {
|
|
35
50
|
let t = (e) => typeof e == "number" && Number.isFinite(e) ? e : "";
|
|
36
51
|
return [[
|
|
37
52
|
"Total (all services in window)",
|
|
@@ -39,7 +54,7 @@ function i(e) {
|
|
|
39
54
|
e.conceived,
|
|
40
55
|
t(e.conceptionRatePct),
|
|
41
56
|
e.deliveries
|
|
42
|
-
], ...
|
|
57
|
+
], ...r(e.trend).map((e) => [
|
|
43
58
|
e.bucket,
|
|
44
59
|
e.services,
|
|
45
60
|
e.conceived,
|
|
@@ -47,10 +62,10 @@ function i(e) {
|
|
|
47
62
|
e.deliveries
|
|
48
63
|
])];
|
|
49
64
|
}
|
|
50
|
-
function
|
|
65
|
+
function o(e) {
|
|
51
66
|
return !Number.isFinite(e) || e < 0 ? "OVERDUE" : e <= 7 ? "IMMINENT" : e <= 14 ? "SOON" : "LATER";
|
|
52
67
|
}
|
|
53
|
-
function
|
|
68
|
+
function s(e) {
|
|
54
69
|
switch (e) {
|
|
55
70
|
case "OVERDUE": return {
|
|
56
71
|
key: "healthybowl.livestock.fertility.due.overdue",
|
|
@@ -70,11 +85,11 @@ function o(e) {
|
|
|
70
85
|
};
|
|
71
86
|
}
|
|
72
87
|
}
|
|
73
|
-
function
|
|
88
|
+
function c(e) {
|
|
74
89
|
let t = (e) => Number.isFinite(e) ? e : -Infinity;
|
|
75
90
|
return [...e].sort((e, n) => t(e.daysUntilDue) - t(n.daysUntilDue));
|
|
76
91
|
}
|
|
77
92
|
//#endregion
|
|
78
|
-
export {
|
|
93
|
+
export { i as FERTILITY_CSV_HEADERS, t as calvingIntervalDisplay, o as dueSoonUrgency, s as dueSoonUrgencyText, a as fertilityCsvRows, e as hasFertilityData, c as orderedDueSoon, r as orderedFertilityBuckets, n as pregnancyLossDisplay };
|
|
79
94
|
|
|
80
95
|
//# sourceMappingURL=fertility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fertility.js","names":[],"sources":["../../../src/healthybowl/utils/fertility.ts"],"sourcesContent":["/**\n * Fertility vocabulary and the caveats that travel with it (BOFF-6008).\n *\n * `healthyBowlLivestockFertility` is the fourth livestock analytics slice, beside growth, feed and\n * herd statistics. Its payload carries three contracts that are easy to break in JSX, so they live\n * here as pure functions and are unit-tested rather than left to the component:\n *\n * 1. **An unmeasured rate is not a zero, but a measured zero IS a zero.** The backend returns\n * `conceptionRatePct: null` when nothing was served, and `0` when services were served and\n * none conceived. Those are opposite facts about a herd — \"we have no breeding data\" versus\n * \"nothing is getting pregnant\" — and the second is the alarming one a farmer must see. So the\n * empty state is decided by whether any breeding activity exists at all\n * ({@link hasFertilityData}), never by whether a rate happens to be falsy.\n * 2. **The calving interval is withheld, with a reason, rather than guessed.** A DELIVERED record\n * with no delivery date merges two births into one gap and OVERSTATES the interval — the\n * direction that hides a fertility problem behind a number reading as merely mediocre. A farmer\n * culls animals on these figures. {@link calvingIntervalDisplay} forces the caller to render\n * the backend's sentence instead of a number, exactly as `mortalityDisplay` does for mortality.\n * 3. **The CSV must carry what the card shows.** The trend series is keyed on the MATING date and\n * therefore skips services with no mating date, so its buckets can legitimately under-sum the\n * window totals. {@link fertilityCsvRows} emits the window total as its own labelled row so the\n * headline figure is in the export, and so the difference is visible rather than hidden.\n *\n * Strings are `{ key, defaultValue }` pairs, not finished text — this module is pure and tested in\n * the repo's `node` vitest environment, so callers pass them to their own `t()`.\n *\n * @module healthybowl\n */\n\nimport type { TranslatableText } from './grazing';\n\nexport type { TranslatableText };\n\n/** One bucket of the fertility trend, mirroring `HealthyBowlFertilityBucket`. */\nexport interface FertilityBucket {\n /** Bucket start, YYYY-MM-DD, keyed on the MATING date. */\n bucket: string;\n services: number;\n conceived: number;\n conceptionRatePct: number | null;\n deliveries: number;\n}\n\n/** A pregnancy due within the horizon, mirroring `HealthyBowlDueSoon`. */\nexport interface DueSoonRow {\n animalId: string;\n expectedDeliveryDate: string;\n daysUntilDue: number;\n}\n\n// ── 1. the empty state ────────────────────────────────────────────────────────\n\n/** The fields {@link hasFertilityData} needs. Deliberately not the whole payload. */\nexport interface FertilityPresence {\n services: number | null | undefined;\n deliveries: number | null | undefined;\n damsWithInterval: number | null | undefined;\n dueSoonCount: number;\n trendCount: number;\n}\n\n/**\n * Whether this workspace has any breeding activity to describe.\n *\n * ★ Decided on ACTIVITY, never on a rate. `conceptionRatePct === 0` is a real and serious\n * measurement — four services and nothing in calf — and showing \"No breeding records yet\" over the\n * top of it would tell a farmer their herd is fine when it is barren. Conversely a workspace that\n * has genuinely recorded nothing must not be shown `0%`, which reads as the same disaster.\n *\n * Deliveries are counted separately from services because a delivery whose mating fell outside the\n * window is still evidence the herd breeds; so are dams with a computable interval, and so is a\n * pregnancy due next week.\n */\nexport function hasFertilityData(input: FertilityPresence): boolean {\n const positive = (n: number | null | undefined): boolean => typeof n === 'number' && n > 0;\n return (\n positive(input.services) ||\n positive(input.deliveries) ||\n positive(input.damsWithInterval) ||\n input.dueSoonCount > 0 ||\n input.trendCount > 0\n );\n}\n\n// ── 2. the calving-interval disclosure ────────────────────────────────────────\n\nexport type CalvingIntervalDisplay =\n { available: true; meanDays: number; medianDays: number | null } | { available: false; reason: string | null };\n\n/**\n * Whether a calving interval can honestly be shown, and if not, why.\n *\n * Mirrors `mortalityDisplay`. The backend supplies the sentence precisely so the UI does not have\n * to invent one or, far worse, print the inflated figure. `reason` non-null is authoritative even\n * if a mean somehow arrived alongside it: the guard exists because the number is WRONG, not merely\n * absent, and a caller that preferred the number would defeat the whole guard.\n */\nexport function calvingIntervalDisplay(summary: {\n meanCalvingIntervalDays: number | null;\n medianCalvingIntervalDays: number | null;\n calvingIntervalUnavailableReason: string | null;\n}): CalvingIntervalDisplay {\n const reason = summary.calvingIntervalUnavailableReason?.trim();\n if (reason && reason.length > 0) return { available: false, reason };\n const mean = summary.meanCalvingIntervalDays;\n if (typeof mean !== 'number' || !Number.isFinite(mean)) return { available: false, reason: null };\n const median = summary.medianCalvingIntervalDays;\n return {\n available: true,\n meanDays: mean,\n medianDays: typeof median === 'number' && Number.isFinite(median) ? median : null,\n };\n}\n\n// ── 3. trend + export ─────────────────────────────────────────────────────────\n\n/** Buckets in chronological order. The backend already sorts; this makes the chart independent. */\nexport function orderedFertilityBuckets(buckets: readonly FertilityBucket[]): FertilityBucket[] {\n return [...buckets].sort((a, b) => a.bucket.localeCompare(b.bucket));\n}\n\nexport interface FertilityCsvInput {\n services: number;\n conceived: number;\n conceptionRatePct: number | null;\n deliveries: number;\n trend: readonly FertilityBucket[];\n}\n\n/** Column order for {@link fertilityCsvRows}. Exported so the card and the test cannot drift. */\nexport const FERTILITY_CSV_HEADERS = ['Period', 'Services', 'Conceived', 'Conception rate %', 'Deliveries'] as const;\n\n/**\n * CSV rows for the fertility card: the window total first, then each bucket.\n *\n * The total leads because it is the figure the card headlines and the one a reader checks first.\n *\n * ★ The total is NOT the sum of the rows beneath it, and that is correct rather than a bug: buckets\n * are keyed on the mating date, so a service recorded without one contributes to the window total\n * and to no bucket. Labelling the total row explicitly is what keeps that visible — silently\n * dropping it would make the export disagree with the card, and silently summing the buckets\n * instead would under-report the herd's real service count.\n *\n * An unmeasured rate exports as an empty cell, never as `0` — a spreadsheet will average a zero.\n */\nexport function fertilityCsvRows(input: FertilityCsvInput): (string | number)[][] {\n const pct = (v: number | null): string | number => (typeof v === 'number' && Number.isFinite(v) ? v : '');\n return [\n ['Total (all services in window)', input.services, input.conceived, pct(input.conceptionRatePct), input.deliveries],\n ...orderedFertilityBuckets(input.trend).map((b) => [\n b.bucket,\n b.services,\n b.conceived,\n pct(b.conceptionRatePct),\n b.deliveries,\n ]),\n ];\n}\n\n// ── due-soon ──────────────────────────────────────────────────────────────────\n\n/**\n * How urgently a pregnancy needs attention.\n *\n * Purely a presentation band; the backend already excludes DELIVERED and FAILED records, so every\n * row here is a birth that has not happened yet. `OVERDUE` cannot occur from the current backend\n * (it drops negative `daysUntilDue`) but is handled rather than trusted — a due date that has\n * passed is precisely the row a farmer most needs to see, and silently dropping it into the\n * \"later\" bucket would bury it.\n */\nexport type DueSoonUrgency = 'OVERDUE' | 'IMMINENT' | 'SOON' | 'LATER';\n\nexport function dueSoonUrgency(daysUntilDue: number): DueSoonUrgency {\n if (!Number.isFinite(daysUntilDue) || daysUntilDue < 0) return 'OVERDUE';\n if (daysUntilDue <= 7) return 'IMMINENT';\n if (daysUntilDue <= 14) return 'SOON';\n return 'LATER';\n}\n\n/** Label for a due-soon row's urgency, for the caller's `t()`. */\nexport function dueSoonUrgencyText(urgency: DueSoonUrgency): TranslatableText {\n switch (urgency) {\n case 'OVERDUE':\n return { key: 'healthybowl.livestock.fertility.due.overdue', defaultValue: 'Overdue' };\n case 'IMMINENT':\n return { key: 'healthybowl.livestock.fertility.due.imminent', defaultValue: 'Within a week' };\n case 'SOON':\n return { key: 'healthybowl.livestock.fertility.due.soon', defaultValue: 'Within a fortnight' };\n default:\n return { key: 'healthybowl.livestock.fertility.due.later', defaultValue: 'Later this month' };\n }\n}\n\n/**\n * Soonest first — the ordering a farmer plans around.\n *\n * A non-finite `daysUntilDue` sorts to the TOP, not to wherever the comparator happens to leave it.\n * {@link dueSoonUrgency} already labels such a row `OVERDUE`, so leaving the sort to return `NaN`\n * would print \"Overdue\" against a row sitting arbitrarily in the middle of the list — the one row\n * that most needs to be first, placed by chance.\n */\nexport function orderedDueSoon(rows: readonly DueSoonRow[]): DueSoonRow[] {\n const rank = (n: number): number => (Number.isFinite(n) ? n : Number.NEGATIVE_INFINITY);\n return [...rows].sort((a, b) => rank(a.daysUntilDue) - rank(b.daysUntilDue));\n}\n"],"mappings":";AAyEA,SAAgB,EAAiB,GAAmC;CAClE,IAAM,KAAY,MAA0C,OAAO,KAAM,YAAY,IAAI;AACzF,QACE,EAAS,EAAM,SAAS,IACxB,EAAS,EAAM,WAAW,IAC1B,EAAS,EAAM,iBAAiB,IAChC,EAAM,eAAe,KACrB,EAAM,aAAa;;AAiBvB,SAAgB,EAAuB,GAIZ;CACzB,IAAM,IAAS,EAAQ,kCAAkC,MAAM;AAC/D,KAAI,KAAU,EAAO,SAAS,EAAG,QAAO;EAAE,WAAW;EAAO;EAAQ;CACpE,IAAM,IAAO,EAAQ;AACrB,KAAI,OAAO,KAAS,YAAY,CAAC,OAAO,SAAS,EAAK,CAAE,QAAO;EAAE,WAAW;EAAO,QAAQ;EAAM;CACjG,IAAM,IAAS,EAAQ;AACvB,QAAO;EACL,WAAW;EACX,UAAU;EACV,YAAY,OAAO,KAAW,YAAY,OAAO,SAAS,EAAO,GAAG,IAAS;EAC9E;;AAMH,SAAgB,EAAwB,GAAwD;AAC9F,QAAO,CAAC,GAAG,EAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,cAAc,EAAE,OAAO,CAAC;;AAYtE,IAAa,IAAwB;CAAC;CAAU;CAAY;CAAa;CAAqB;CAAa;AAe3G,SAAgB,EAAiB,GAAiD;CAChF,IAAM,KAAO,MAAuC,OAAO,KAAM,YAAY,OAAO,SAAS,EAAE,GAAG,IAAI;AACtG,QAAO,CACL;EAAC;EAAkC,EAAM;EAAU,EAAM;EAAW,EAAI,EAAM,kBAAkB;EAAE,EAAM;EAAW,EACnH,GAAG,EAAwB,EAAM,MAAM,CAAC,KAAK,MAAM;EACjD,EAAE;EACF,EAAE;EACF,EAAE;EACF,EAAI,EAAE,kBAAkB;EACxB,EAAE;EACH,CAAC,CACH;;AAgBH,SAAgB,EAAe,GAAsC;AAInE,QAHI,CAAC,OAAO,SAAS,EAAa,IAAI,IAAe,IAAU,YAC3D,KAAgB,IAAU,aAC1B,KAAgB,KAAW,SACxB;;AAIT,SAAgB,EAAmB,GAA2C;AAC5E,SAAQ,GAAR;EACE,KAAK,UACH,QAAO;GAAE,KAAK;GAA+C,cAAc;GAAW;EACxF,KAAK,WACH,QAAO;GAAE,KAAK;GAAgD,cAAc;GAAiB;EAC/F,KAAK,OACH,QAAO;GAAE,KAAK;GAA4C,cAAc;GAAsB;EAChG,QACE,QAAO;GAAE,KAAK;GAA6C,cAAc;GAAoB;;;AAYnG,SAAgB,EAAe,GAA2C;CACxE,IAAM,KAAQ,MAAuB,OAAO,SAAS,EAAE,GAAG,IAAI;AAC9D,QAAO,CAAC,GAAG,EAAK,CAAC,MAAM,GAAG,MAAM,EAAK,EAAE,aAAa,GAAG,EAAK,EAAE,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"fertility.js","names":[],"sources":["../../../src/healthybowl/utils/fertility.ts"],"sourcesContent":["/**\n * Fertility vocabulary and the caveats that travel with it (BOFF-6008).\n *\n * `healthyBowlLivestockFertility` is the fourth livestock analytics slice, beside growth, feed and\n * herd statistics. Its payload carries three contracts that are easy to break in JSX, so they live\n * here as pure functions and are unit-tested rather than left to the component:\n *\n * 1. **An unmeasured rate is not a zero, but a measured zero IS a zero.** The backend returns\n * `conceptionRatePct: null` when nothing was served, and `0` when services were served and\n * none conceived. Those are opposite facts about a herd — \"we have no breeding data\" versus\n * \"nothing is getting pregnant\" — and the second is the alarming one a farmer must see. So the\n * empty state is decided by whether any breeding activity exists at all\n * ({@link hasFertilityData}), never by whether a rate happens to be falsy.\n * 2. **The calving interval is withheld, with a reason, rather than guessed.** A DELIVERED record\n * with no delivery date merges two births into one gap and OVERSTATES the interval — the\n * direction that hides a fertility problem behind a number reading as merely mediocre. A farmer\n * culls animals on these figures. {@link calvingIntervalDisplay} forces the caller to render\n * the backend's sentence instead of a number, exactly as `mortalityDisplay` does for mortality.\n * 3. **The CSV must carry what the card shows.** The trend series is keyed on the MATING date and\n * therefore skips services with no mating date, so its buckets can legitimately under-sum the\n * window totals. {@link fertilityCsvRows} emits the window total as its own labelled row so the\n * headline figure is in the export, and so the difference is visible rather than hidden.\n *\n * Strings are `{ key, defaultValue }` pairs, not finished text — this module is pure and tested in\n * the repo's `node` vitest environment, so callers pass them to their own `t()`.\n *\n * @module healthybowl\n */\n\nimport type { TranslatableText } from './grazing';\n\nexport type { TranslatableText };\n\n/** One bucket of the fertility trend, mirroring `HealthyBowlFertilityBucket`. */\nexport interface FertilityBucket {\n /** Bucket start, YYYY-MM-DD, keyed on the MATING date. */\n bucket: string;\n services: number;\n conceived: number;\n conceptionRatePct: number | null;\n deliveries: number;\n}\n\n/** A pregnancy due within the horizon, mirroring `HealthyBowlDueSoon`. */\nexport interface DueSoonRow {\n animalId: string;\n expectedDeliveryDate: string;\n daysUntilDue: number;\n}\n\n// ── 1. the empty state ────────────────────────────────────────────────────────\n\n/** The fields {@link hasFertilityData} needs. Deliberately not the whole payload. */\nexport interface FertilityPresence {\n services: number | null | undefined;\n deliveries: number | null | undefined;\n damsWithInterval: number | null | undefined;\n dueSoonCount: number;\n trendCount: number;\n}\n\n/**\n * Whether this workspace has any breeding activity to describe.\n *\n * ★ Decided on ACTIVITY, never on a rate. `conceptionRatePct === 0` is a real and serious\n * measurement — four services and nothing in calf — and showing \"No breeding records yet\" over the\n * top of it would tell a farmer their herd is fine when it is barren. Conversely a workspace that\n * has genuinely recorded nothing must not be shown `0%`, which reads as the same disaster.\n *\n * Deliveries are counted separately from services because a delivery whose mating fell outside the\n * window is still evidence the herd breeds; so are dams with a computable interval, and so is a\n * pregnancy due next week.\n */\nexport function hasFertilityData(input: FertilityPresence): boolean {\n const positive = (n: number | null | undefined): boolean => typeof n === 'number' && n > 0;\n return (\n positive(input.services) ||\n positive(input.deliveries) ||\n positive(input.damsWithInterval) ||\n input.dueSoonCount > 0 ||\n input.trendCount > 0\n );\n}\n\n// ── 2. the calving-interval disclosure ────────────────────────────────────────\n\nexport type CalvingIntervalDisplay =\n { available: true; meanDays: number; medianDays: number | null } | { available: false; reason: string | null };\n\n/**\n * Whether a calving interval can honestly be shown, and if not, why.\n *\n * Mirrors `mortalityDisplay`. The backend supplies the sentence precisely so the UI does not have\n * to invent one or, far worse, print the inflated figure. `reason` non-null is authoritative even\n * if a mean somehow arrived alongside it: the guard exists because the number is WRONG, not merely\n * absent, and a caller that preferred the number would defeat the whole guard.\n */\nexport function calvingIntervalDisplay(summary: {\n meanCalvingIntervalDays: number | null;\n medianCalvingIntervalDays: number | null;\n calvingIntervalUnavailableReason: string | null;\n}): CalvingIntervalDisplay {\n const reason = summary.calvingIntervalUnavailableReason?.trim();\n if (reason && reason.length > 0) return { available: false, reason };\n const mean = summary.meanCalvingIntervalDays;\n if (typeof mean !== 'number' || !Number.isFinite(mean)) return { available: false, reason: null };\n const median = summary.medianCalvingIntervalDays;\n return {\n available: true,\n meanDays: mean,\n medianDays: typeof median === 'number' && Number.isFinite(median) ? median : null,\n };\n}\n\n// ── 2b. the pregnancy-loss disclosure ─────────────────────────────────────────\n\nexport type PregnancyLossDisplay = { available: true; ratePct: number } | { available: false; reason: string | null };\n\n/**\n * Whether a pregnancy-loss rate can honestly be shown, and if not, why.\n *\n * Same shape and same reasoning as {@link calvingIntervalDisplay}. Today the backend ALWAYS\n * withholds this: telling a lost pregnancy apart from a service that never took requires knowing it\n * was confirmed first, and `pregnancyConfirmed` has no write path in the product — so the raw ratio\n * is structurally 0 on every herd, including one losing every calf it confirmed. `optionalMetric`\n * would have printed that 0 as a measurement, indistinguishable from a genuinely perfect record.\n */\nexport function pregnancyLossDisplay(summary: {\n pregnancyLossPct: number | null;\n pregnancyLossUnavailableReason: string | null;\n}): PregnancyLossDisplay {\n const reason = summary.pregnancyLossUnavailableReason?.trim();\n if (reason && reason.length > 0) return { available: false, reason };\n const rate = summary.pregnancyLossPct;\n if (typeof rate !== 'number' || !Number.isFinite(rate)) return { available: false, reason: null };\n return { available: true, ratePct: rate };\n}\n\n// ── 3. trend + export ─────────────────────────────────────────────────────────\n\n/** Buckets in chronological order. The backend already sorts; this makes the chart independent. */\nexport function orderedFertilityBuckets(buckets: readonly FertilityBucket[]): FertilityBucket[] {\n return [...buckets].sort((a, b) => a.bucket.localeCompare(b.bucket));\n}\n\nexport interface FertilityCsvInput {\n services: number;\n conceived: number;\n conceptionRatePct: number | null;\n deliveries: number;\n trend: readonly FertilityBucket[];\n}\n\n/** Column order for {@link fertilityCsvRows}. Exported so the card and the test cannot drift. */\nexport const FERTILITY_CSV_HEADERS = ['Period', 'Services', 'Conceived', 'Conception rate %', 'Deliveries'] as const;\n\n/**\n * CSV rows for the fertility card: the window total first, then each bucket.\n *\n * The total leads because it is the figure the card headlines and the one a reader checks first.\n *\n * ★ The total is NOT the sum of the rows beneath it, and that is correct rather than a bug: buckets\n * are keyed on the mating date, so a service recorded without one contributes to the window total\n * and to no bucket. Labelling the total row explicitly is what keeps that visible — silently\n * dropping it would make the export disagree with the card, and silently summing the buckets\n * instead would under-report the herd's real service count.\n *\n * An unmeasured rate exports as an empty cell, never as `0` — a spreadsheet will average a zero.\n */\nexport function fertilityCsvRows(input: FertilityCsvInput): (string | number)[][] {\n const pct = (v: number | null): string | number => (typeof v === 'number' && Number.isFinite(v) ? v : '');\n return [\n ['Total (all services in window)', input.services, input.conceived, pct(input.conceptionRatePct), input.deliveries],\n ...orderedFertilityBuckets(input.trend).map((b) => [\n b.bucket,\n b.services,\n b.conceived,\n pct(b.conceptionRatePct),\n b.deliveries,\n ]),\n ];\n}\n\n// ── due-soon ──────────────────────────────────────────────────────────────────\n\n/**\n * How urgently a pregnancy needs attention.\n *\n * Purely a presentation band; the backend already excludes DELIVERED and FAILED records, so every\n * row here is a birth that has not happened yet. `OVERDUE` cannot occur from the current backend\n * (it drops negative `daysUntilDue`) but is handled rather than trusted — a due date that has\n * passed is precisely the row a farmer most needs to see, and silently dropping it into the\n * \"later\" bucket would bury it.\n */\nexport type DueSoonUrgency = 'OVERDUE' | 'IMMINENT' | 'SOON' | 'LATER';\n\nexport function dueSoonUrgency(daysUntilDue: number): DueSoonUrgency {\n if (!Number.isFinite(daysUntilDue) || daysUntilDue < 0) return 'OVERDUE';\n if (daysUntilDue <= 7) return 'IMMINENT';\n if (daysUntilDue <= 14) return 'SOON';\n return 'LATER';\n}\n\n/** Label for a due-soon row's urgency, for the caller's `t()`. */\nexport function dueSoonUrgencyText(urgency: DueSoonUrgency): TranslatableText {\n switch (urgency) {\n case 'OVERDUE':\n return { key: 'healthybowl.livestock.fertility.due.overdue', defaultValue: 'Overdue' };\n case 'IMMINENT':\n return { key: 'healthybowl.livestock.fertility.due.imminent', defaultValue: 'Within a week' };\n case 'SOON':\n return { key: 'healthybowl.livestock.fertility.due.soon', defaultValue: 'Within a fortnight' };\n default:\n return { key: 'healthybowl.livestock.fertility.due.later', defaultValue: 'Later this month' };\n }\n}\n\n/**\n * Soonest first — the ordering a farmer plans around.\n *\n * A non-finite `daysUntilDue` sorts to the TOP, not to wherever the comparator happens to leave it.\n * {@link dueSoonUrgency} already labels such a row `OVERDUE`, so leaving the sort to return `NaN`\n * would print \"Overdue\" against a row sitting arbitrarily in the middle of the list — the one row\n * that most needs to be first, placed by chance.\n */\nexport function orderedDueSoon(rows: readonly DueSoonRow[]): DueSoonRow[] {\n const rank = (n: number): number => (Number.isFinite(n) ? n : Number.NEGATIVE_INFINITY);\n return [...rows].sort((a, b) => rank(a.daysUntilDue) - rank(b.daysUntilDue));\n}\n"],"mappings":";AAyEA,SAAgB,EAAiB,GAAmC;CAClE,IAAM,KAAY,MAA0C,OAAO,KAAM,YAAY,IAAI;AACzF,QACE,EAAS,EAAM,SAAS,IACxB,EAAS,EAAM,WAAW,IAC1B,EAAS,EAAM,iBAAiB,IAChC,EAAM,eAAe,KACrB,EAAM,aAAa;;AAiBvB,SAAgB,EAAuB,GAIZ;CACzB,IAAM,IAAS,EAAQ,kCAAkC,MAAM;AAC/D,KAAI,KAAU,EAAO,SAAS,EAAG,QAAO;EAAE,WAAW;EAAO;EAAQ;CACpE,IAAM,IAAO,EAAQ;AACrB,KAAI,OAAO,KAAS,YAAY,CAAC,OAAO,SAAS,EAAK,CAAE,QAAO;EAAE,WAAW;EAAO,QAAQ;EAAM;CACjG,IAAM,IAAS,EAAQ;AACvB,QAAO;EACL,WAAW;EACX,UAAU;EACV,YAAY,OAAO,KAAW,YAAY,OAAO,SAAS,EAAO,GAAG,IAAS;EAC9E;;AAgBH,SAAgB,EAAqB,GAGZ;CACvB,IAAM,IAAS,EAAQ,gCAAgC,MAAM;AAC7D,KAAI,KAAU,EAAO,SAAS,EAAG,QAAO;EAAE,WAAW;EAAO;EAAQ;CACpE,IAAM,IAAO,EAAQ;AAErB,QADI,OAAO,KAAS,YAAY,CAAC,OAAO,SAAS,EAAK,GAAS;EAAE,WAAW;EAAO,QAAQ;EAAM,GAC1F;EAAE,WAAW;EAAM,SAAS;EAAM;;AAM3C,SAAgB,EAAwB,GAAwD;AAC9F,QAAO,CAAC,GAAG,EAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,cAAc,E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