@burdenoff/microfe-healthybowl 2026.804.2 → 2026.805.2
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/useHealthyBowlLivestockFeed.js +66 -0
- package/dist/healthybowl/hooks/useHealthyBowlLivestockFeed.js.map +1 -0
- package/dist/healthybowl/hooks/useHealthyBowlLivestockGrowth.js +2 -0
- package/dist/healthybowl/hooks/useHealthyBowlLivestockGrowth.js.map +1 -1
- package/dist/healthybowl/pages/livestock/LivestockDashboardPage.js +23 -21
- package/dist/healthybowl/pages/livestock/LivestockDashboardPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/LivestockFeedCard.js +165 -0
- package/dist/healthybowl/pages/livestock/LivestockFeedCard.js.map +1 -0
- package/dist/healthybowl/pages/livestock/LivestockGrowthCard.js +109 -102
- package/dist/healthybowl/pages/livestock/LivestockGrowthCard.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
import { gql as n } from "@apollo/client";
|
|
4
|
+
import { useQuery as r } from "@apollo/client/react";
|
|
5
|
+
//#region src/healthybowl/hooks/useHealthyBowlLivestockFeed.ts
|
|
6
|
+
var i = "00000000-0000-0000-0000-000000000001", a = n`
|
|
7
|
+
query HealthyBowlLivestockFeed(
|
|
8
|
+
$context: ContextInput!
|
|
9
|
+
$groupId: ID
|
|
10
|
+
$from: String
|
|
11
|
+
$to: String
|
|
12
|
+
$granularity: HealthyBowlGrowthGranularity
|
|
13
|
+
) {
|
|
14
|
+
healthyBowlLivestockFeed(context: $context, groupId: $groupId, from: $from, to: $to, granularity: $granularity) {
|
|
15
|
+
truncated
|
|
16
|
+
buckets {
|
|
17
|
+
at
|
|
18
|
+
totalCost
|
|
19
|
+
totalKg
|
|
20
|
+
byUnit {
|
|
21
|
+
unit
|
|
22
|
+
quantity
|
|
23
|
+
}
|
|
24
|
+
records
|
|
25
|
+
}
|
|
26
|
+
summary {
|
|
27
|
+
totalCost
|
|
28
|
+
totalKg
|
|
29
|
+
totalGainKg
|
|
30
|
+
animalsCounted
|
|
31
|
+
feedConversionRatio
|
|
32
|
+
costPerKgGain
|
|
33
|
+
unitsSeen
|
|
34
|
+
windowFrom
|
|
35
|
+
windowTo
|
|
36
|
+
granularity
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
function o(n = {}) {
|
|
42
|
+
let { workspaceId: o } = e(), s = o || i, { data: c, loading: l, error: u, refetch: d } = r(a, {
|
|
43
|
+
variables: {
|
|
44
|
+
context: t(() => ({ workspaceId: s }), [s]),
|
|
45
|
+
groupId: n.groupId ?? null,
|
|
46
|
+
from: n.from ?? null,
|
|
47
|
+
to: n.to ?? null,
|
|
48
|
+
granularity: n.granularity ?? "WEEK"
|
|
49
|
+
},
|
|
50
|
+
fetchPolicy: "cache-and-network",
|
|
51
|
+
skip: n.enabled === !1
|
|
52
|
+
}), f = c?.healthyBowlLivestockFeed ?? null;
|
|
53
|
+
return {
|
|
54
|
+
feed: f,
|
|
55
|
+
truncated: f?.truncated ?? !1,
|
|
56
|
+
buckets: f?.buckets ?? [],
|
|
57
|
+
summary: f?.summary ?? null,
|
|
58
|
+
loading: l,
|
|
59
|
+
error: u,
|
|
60
|
+
refetch: d
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { o as useHealthyBowlLivestockFeed };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=useHealthyBowlLivestockFeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHealthyBowlLivestockFeed.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockFeed.ts"],"sourcesContent":["/**\n * Livestock feed analytics — data hook (BOFF-5971, slice 2).\n *\n * Companion to `useHealthyBowlLivestockGrowth`: feed says what went in, growth says what came out.\n * The document is declared inline with `gql` for the same reason as its sibling — codegen validates\n * against the committed `graphql/wspace.graphql` snapshot, which does not yet carry this query.\n *\n * ⚠️ `totalKg` is null whenever the period mixes a non-mass unit (bags, litres). That is the\n * backend refusing to invent a total, not a loading state — render it as \"mixed units\", never as\n * zero.\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';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\nexport interface FeedUnitTotal {\n unit: string;\n quantity: number;\n}\n\nexport interface FeedBucket {\n at: string;\n totalCost: number;\n totalKg: number | null;\n byUnit: FeedUnitTotal[];\n records: number;\n}\n\nexport interface FeedSummary {\n totalCost: number;\n totalKg: number | null;\n totalGainKg: number | null;\n animalsCounted: number;\n feedConversionRatio: number | null;\n costPerKgGain: number | null;\n unitsSeen: string[];\n windowFrom: string | null;\n windowTo: string | null;\n granularity: GrowthGranularity;\n}\n\nexport interface LivestockFeed {\n /** True when the backend hit its row cap — results are incomplete (BOFF-6002). */\n truncated: boolean;\n buckets: FeedBucket[];\n summary: FeedSummary;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst GET_LIVESTOCK_FEED = gql`\n query HealthyBowlLivestockFeed(\n $context: ContextInput!\n $groupId: ID\n $from: String\n $to: String\n $granularity: HealthyBowlGrowthGranularity\n ) {\n healthyBowlLivestockFeed(context: $context, groupId: $groupId, from: $from, to: $to, granularity: $granularity) {\n truncated\n buckets {\n at\n totalCost\n totalKg\n byUnit {\n unit\n quantity\n }\n records\n }\n summary {\n totalCost\n totalKg\n totalGainKg\n animalsCounted\n feedConversionRatio\n costPerKgGain\n unitsSeen\n windowFrom\n windowTo\n granularity\n }\n }\n }\n`;\n\nexport interface UseLivestockFeedOptions {\n enabled?: boolean;\n groupId?: string | null;\n from?: string | null;\n to?: string | null;\n granularity?: GrowthGranularity;\n}\n\nexport function useHealthyBowlLivestockFeed(options: UseLivestockFeedOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const { data, loading, error, refetch } = useQuery<\n { healthyBowlLivestockFeed: LivestockFeed },\n {\n context: HbContext;\n groupId: string | null;\n from: string | null;\n to: string | null;\n granularity: GrowthGranularity;\n }\n >(GET_LIVESTOCK_FEED, {\n variables: {\n context: ctx,\n groupId: options.groupId ?? null,\n from: options.from ?? null,\n to: options.to ?? null,\n granularity: options.granularity ?? 'WEEK',\n },\n fetchPolicy: 'cache-and-network',\n skip: options.enabled === false,\n });\n\n const feed = data?.healthyBowlLivestockFeed ?? null;\n\n return {\n feed,\n truncated: feed?.truncated ?? false,\n buckets: feed?.buckets ?? [],\n summary: feed?.summary ?? null,\n loading,\n error,\n refetch,\n };\n}\n"],"mappings":";;;;;AAkBA,IAAM,IAAwB,wCAuCxB,IAAqB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C9B,SAAgB,EAA4B,IAAmC,EAAE,EAAE;CACjF,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAuB,KAAe,GAGtC,EAAE,SAAM,YAAS,UAAO,eAAY,EASxC,GAAoB;EACpB,WAAW;GACT,SAbQ,SAA0B,EAAE,aAAa,GAAsB,GAAG,CAAC,EAAqB,CAAC;GAcjG,SAAS,EAAQ,WAAW;GAC5B,MAAM,EAAQ,QAAQ;GACtB,IAAI,EAAQ,MAAM;GAClB,aAAa,EAAQ,eAAe;GACrC;EACD,aAAa;EACb,MAAM,EAAQ,YAAY;EAC3B,CAAC,EAEI,IAAO,GAAM,4BAA4B;AAE/C,QAAO;EACL;EACA,WAAW,GAAM,aAAa;EAC9B,SAAS,GAAM,WAAW,EAAE;EAC5B,SAAS,GAAM,WAAW;EAC1B;EACA;EACA;EACD"}
|
|
@@ -20,6 +20,7 @@ var i = "00000000-0000-0000-0000-000000000001", a = n`
|
|
|
20
20
|
to: $to
|
|
21
21
|
granularity: $granularity
|
|
22
22
|
) {
|
|
23
|
+
truncated
|
|
23
24
|
series {
|
|
24
25
|
animalId
|
|
25
26
|
tagNumber
|
|
@@ -79,6 +80,7 @@ function o(n = {}) {
|
|
|
79
80
|
}), f = c?.healthyBowlLivestockGrowth ?? null;
|
|
80
81
|
return {
|
|
81
82
|
growth: f,
|
|
83
|
+
truncated: f?.truncated ?? !1,
|
|
82
84
|
series: f?.series ?? [],
|
|
83
85
|
herdAverage: f?.herdAverage ?? [],
|
|
84
86
|
summary: f?.summary ?? null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHealthyBowlLivestockGrowth.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockGrowth.ts"],"sourcesContent":["/**\n * Livestock growth analytics — data hook (BOFF-5971).\n *\n * Feeds the growth chart: one weight curve per animal, a herd-average line, and the ADG leaders.\n * The document is declared inline with `gql` — the same escape hatch `useHealthyBowlLivestockDepth`\n * and `useHealthyBowlWithdrawal` use — because codegen validates against the committed\n * `graphql/wspace.graphql` snapshot, which does not yet carry this query.\n *\n * Types mirror `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n *\n * ⚠️ ADG here is computed over the requested window, so it can legitimately differ from the\n * lifetime ADG shown on the deep herd view — same formula, different span. Label it as such\n * wherever both appear on one screen.\n */\n\nimport { useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror livestock-depth.gql) ────────────────────────────────────────\n\nexport type GrowthGranularity = 'DAY' | 'WEEK' | 'MONTH';\n\nexport interface GrowthPoint {\n at: string;\n weightKg: number;\n}\n\nexport interface GrowthSeries {\n animalId: string;\n tagNumber: string;\n name: string;\n type: string;\n groupId: string | null;\n groupName: string | null;\n points: GrowthPoint[];\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n}\n\nexport interface GrowthAveragePoint {\n at: string;\n avgWeightKg: number;\n animalCount: number;\n sampleSize: number;\n}\n\nexport interface GrowthLeader {\n animalId: string;\n name: string;\n tagNumber: string;\n adgKgPerDay: number;\n}\n\nexport interface GrowthSummary {\n animalsWithWeights: number;\n animalsWithoutWeights: number;\n medianAdgKgPerDay: number | null;\n fastestGrowing: GrowthLeader | null;\n slowestGrowing: GrowthLeader | null;\n windowFrom: string | null;\n windowTo: string | null;\n granularity: GrowthGranularity;\n}\n\nexport interface LivestockGrowth {\n series: GrowthSeries[];\n herdAverage: GrowthAveragePoint[];\n summary: GrowthSummary;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst GET_LIVESTOCK_GROWTH = gql`\n query HealthyBowlLivestockGrowth(\n $context: ContextInput!\n $groupId: ID\n $animalIds: [ID!]\n $from: String\n $to: String\n $granularity: HealthyBowlGrowthGranularity\n ) {\n healthyBowlLivestockGrowth(\n context: $context\n groupId: $groupId\n animalIds: $animalIds\n from: $from\n to: $to\n granularity: $granularity\n ) {\n series {\n animalId\n tagNumber\n name\n type\n groupId\n groupName\n points {\n at\n weightKg\n }\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n }\n herdAverage {\n at\n avgWeightKg\n animalCount\n sampleSize\n }\n summary {\n animalsWithWeights\n animalsWithoutWeights\n medianAdgKgPerDay\n fastestGrowing {\n animalId\n name\n tagNumber\n adgKgPerDay\n }\n slowestGrowing {\n animalId\n name\n tagNumber\n adgKgPerDay\n }\n windowFrom\n windowTo\n granularity\n }\n }\n }\n`;\n\nexport interface UseLivestockGrowthOptions {\n enabled?: boolean;\n groupId?: string | null;\n animalIds?: string[] | null;\n from?: string | null;\n to?: string | null;\n granularity?: GrowthGranularity;\n}\n\nexport function useHealthyBowlLivestockGrowth(options: UseLivestockGrowthOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const { data, loading, error, refetch } = useQuery<\n { healthyBowlLivestockGrowth: LivestockGrowth },\n {\n context: HbContext;\n groupId: string | null;\n animalIds: string[] | null;\n from: string | null;\n to: string | null;\n granularity: GrowthGranularity;\n }\n >(GET_LIVESTOCK_GROWTH, {\n variables: {\n context: ctx,\n groupId: options.groupId ?? null,\n animalIds: options.animalIds ?? null,\n from: options.from ?? null,\n to: options.to ?? null,\n granularity: options.granularity ?? 'WEEK',\n },\n fetchPolicy: 'cache-and-network',\n skip: options.enabled === false,\n });\n\n const growth = data?.healthyBowlLivestockGrowth ?? null;\n\n return {\n growth,\n series: growth?.series ?? [],\n herdAverage: growth?.herdAverage ?? [],\n summary: growth?.summary ?? null,\n loading,\n error,\n refetch,\n };\n}\n"],"mappings":";;;;;AAoBA,IAAM,IAAwB,
|
|
1
|
+
{"version":3,"file":"useHealthyBowlLivestockGrowth.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockGrowth.ts"],"sourcesContent":["/**\n * Livestock growth analytics — data hook (BOFF-5971).\n *\n * Feeds the growth chart: one weight curve per animal, a herd-average line, and the ADG leaders.\n * The document is declared inline with `gql` — the same escape hatch `useHealthyBowlLivestockDepth`\n * and `useHealthyBowlWithdrawal` use — because codegen validates against the committed\n * `graphql/wspace.graphql` snapshot, which does not yet carry this query.\n *\n * Types mirror `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n *\n * ⚠️ ADG here is computed over the requested window, so it can legitimately differ from the\n * lifetime ADG shown on the deep herd view — same formula, different span. Label it as such\n * wherever both appear on one screen.\n */\n\nimport { useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror livestock-depth.gql) ────────────────────────────────────────\n\nexport type GrowthGranularity = 'DAY' | 'WEEK' | 'MONTH';\n\nexport interface GrowthPoint {\n at: string;\n weightKg: number;\n}\n\nexport interface GrowthSeries {\n animalId: string;\n tagNumber: string;\n name: string;\n type: string;\n groupId: string | null;\n groupName: string | null;\n points: GrowthPoint[];\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n}\n\nexport interface GrowthAveragePoint {\n at: string;\n avgWeightKg: number;\n animalCount: number;\n sampleSize: number;\n}\n\nexport interface GrowthLeader {\n animalId: string;\n name: string;\n tagNumber: string;\n adgKgPerDay: number;\n}\n\nexport interface GrowthSummary {\n animalsWithWeights: number;\n animalsWithoutWeights: number;\n medianAdgKgPerDay: number | null;\n fastestGrowing: GrowthLeader | null;\n slowestGrowing: GrowthLeader | null;\n windowFrom: string | null;\n windowTo: string | null;\n granularity: GrowthGranularity;\n}\n\nexport interface LivestockGrowth {\n /** True when the backend hit its row cap — results are incomplete (BOFF-6002). */\n truncated: boolean;\n series: GrowthSeries[];\n herdAverage: GrowthAveragePoint[];\n summary: GrowthSummary;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst GET_LIVESTOCK_GROWTH = gql`\n query HealthyBowlLivestockGrowth(\n $context: ContextInput!\n $groupId: ID\n $animalIds: [ID!]\n $from: String\n $to: String\n $granularity: HealthyBowlGrowthGranularity\n ) {\n healthyBowlLivestockGrowth(\n context: $context\n groupId: $groupId\n animalIds: $animalIds\n from: $from\n to: $to\n granularity: $granularity\n ) {\n truncated\n series {\n animalId\n tagNumber\n name\n type\n groupId\n groupName\n points {\n at\n weightKg\n }\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n }\n herdAverage {\n at\n avgWeightKg\n animalCount\n sampleSize\n }\n summary {\n animalsWithWeights\n animalsWithoutWeights\n medianAdgKgPerDay\n fastestGrowing {\n animalId\n name\n tagNumber\n adgKgPerDay\n }\n slowestGrowing {\n animalId\n name\n tagNumber\n adgKgPerDay\n }\n windowFrom\n windowTo\n granularity\n }\n }\n }\n`;\n\nexport interface UseLivestockGrowthOptions {\n enabled?: boolean;\n groupId?: string | null;\n animalIds?: string[] | null;\n from?: string | null;\n to?: string | null;\n granularity?: GrowthGranularity;\n}\n\nexport function useHealthyBowlLivestockGrowth(options: UseLivestockGrowthOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const { data, loading, error, refetch } = useQuery<\n { healthyBowlLivestockGrowth: LivestockGrowth },\n {\n context: HbContext;\n groupId: string | null;\n animalIds: string[] | null;\n from: string | null;\n to: string | null;\n granularity: GrowthGranularity;\n }\n >(GET_LIVESTOCK_GROWTH, {\n variables: {\n context: ctx,\n groupId: options.groupId ?? null,\n animalIds: options.animalIds ?? null,\n from: options.from ?? null,\n to: options.to ?? null,\n granularity: options.granularity ?? 'WEEK',\n },\n fetchPolicy: 'cache-and-network',\n skip: options.enabled === false,\n });\n\n const growth = data?.healthyBowlLivestockGrowth ?? null;\n\n return {\n growth,\n truncated: growth?.truncated ?? false,\n series: growth?.series ?? [],\n herdAverage: growth?.herdAverage ?? [],\n summary: growth?.summary ?? null,\n loading,\n error,\n refetch,\n };\n}\n"],"mappings":";;;;;AAoBA,IAAM,IAAwB,wCA6DxB,IAAuB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEhC,SAAgB,EAA8B,IAAqC,EAAE,EAAE;CACrF,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAuB,KAAe,GAGtC,EAAE,SAAM,YAAS,UAAO,eAAY,EAUxC,GAAsB;EACtB,WAAW;GACT,SAdQ,SAA0B,EAAE,aAAa,GAAsB,GAAG,CAAC,EAAqB,CAAC;GAejG,SAAS,EAAQ,WAAW;GAC5B,WAAW,EAAQ,aAAa;GAChC,MAAM,EAAQ,QAAQ;GACtB,IAAI,EAAQ,MAAM;GAClB,aAAa,EAAQ,eAAe;GACrC;EACD,aAAa;EACb,MAAM,EAAQ,YAAY;EAC3B,CAAC,EAEI,IAAS,GAAM,8BAA8B;AAEnD,QAAO;EACL;EACA,WAAW,GAAQ,aAAa;EAChC,QAAQ,GAAQ,UAAU,EAAE;EAC5B,aAAa,GAAQ,eAAe,EAAE;EACtC,SAAS,GAAQ,WAAW;EAC5B;EACA;EACA;EACD"}
|
|
@@ -6,12 +6,13 @@ import { StatusBadge as a } from "../../components/StatusBadge.js";
|
|
|
6
6
|
import { EmptyState as o } from "../../components/EmptyState.js";
|
|
7
7
|
import { ErrorState as s } from "../../components/ErrorState.js";
|
|
8
8
|
import { ChartCard as c } from "../../components/ChartCard.js";
|
|
9
|
-
import { LoadingSkeleton as
|
|
9
|
+
import { LoadingSkeleton as l } from "../../components/LoadingSkeleton.js";
|
|
10
10
|
import "../../components/index.js";
|
|
11
|
-
import { useHealthyBowlData as
|
|
12
|
-
import { LivestockGrowthCard as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { useHealthyBowlData as ee } from "../../hooks/useHealthyBowlData.js";
|
|
12
|
+
import { LivestockGrowthCard as u } from "./LivestockGrowthCard.js";
|
|
13
|
+
import { LivestockFeedCard as d } from "./LivestockFeedCard.js";
|
|
14
|
+
import { useI18n as f } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
15
|
+
import { AlertCircle as p, ArrowRight as te, Baby as ne, Calendar as m, ChevronRight as h, Clock as g, DollarSign as re, Egg as ie, Heart as _, Milk as v, Package as y, PawPrint as b, Plus as x, TrendingUp as S, Users as C } from "lucide-react";
|
|
15
16
|
import { useNavigate as w } from "react-router";
|
|
16
17
|
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
17
18
|
import { Button as O } from "@burdenoff/fe-libs/ui";
|
|
@@ -33,7 +34,7 @@ var k = (e) => {
|
|
|
33
34
|
meat: 350,
|
|
34
35
|
manure: 5
|
|
35
36
|
}, j = () => {
|
|
36
|
-
let { animals: j, healthRecords: M, vaccinations: N, productionRecords: P, feedRecords: F, loading: I, errors: L } =
|
|
37
|
+
let { animals: j, healthRecords: M, vaccinations: N, productionRecords: P, feedRecords: F, loading: I, errors: L } = ee(), R = w(), { buildPath: z } = n(), { t: B } = f(), V = j.length, H = j.filter((e) => e.healthStatus === "healthy").length, U = j.filter((e) => e.healthStatus === "sick").length, W = j.filter((e) => e.healthStatus === "under_treatment").length, G = j.filter((e) => e.healthStatus === "quarantine").length, K = j.filter((e) => e.healthStatus === "pregnant").length, q = j.reduce((e, t) => (e[t.type] = (e[t.type] || 0) + 1, e), {}), J = P.filter((e) => e.type === "milk").reduce((e, t) => e + t.quantity, 0), Y = P.filter((e) => e.type === "eggs").reduce((e, t) => e + t.quantity, 0), X = P.reduce((e, t) => e + t.quantity * (A[t.type] ?? 0), 0), Z = F.reduce((e, t) => e + t.cost, 0), ae = X > 0 ? ((X - Z) / X * 100).toFixed(1) : "0.0", Q = M.filter((e) => e.status === "active" || e.status === "monitoring").slice(0, 3), $ = N.filter((e) => e.status === "scheduled").slice(0, 3);
|
|
37
38
|
return /* @__PURE__ */ E(r, {
|
|
38
39
|
title: B("healthybowl.livestock.dashboard.title", "Livestock Management"),
|
|
39
40
|
description: B("healthybowl.livestock.dashboard.description", "Monitor and manage your livestock operations"),
|
|
@@ -65,7 +66,7 @@ var k = (e) => {
|
|
|
65
66
|
onClick: () => R(z("livestock/animals")),
|
|
66
67
|
children: [/* @__PURE__ */ E(x, { className: "h-4 w-4" }), B("healthybowl.livestock.dashboard.actions.addAnimal", "Add Animal")]
|
|
67
68
|
}),
|
|
68
|
-
children: I && j.length === 0 ? /* @__PURE__ */ E(
|
|
69
|
+
children: I && j.length === 0 ? /* @__PURE__ */ E(l, {
|
|
69
70
|
variant: "card",
|
|
70
71
|
count: 4
|
|
71
72
|
}) : /* @__PURE__ */ D(T, { children: [
|
|
@@ -76,21 +77,21 @@ var k = (e) => {
|
|
|
76
77
|
hero: !0,
|
|
77
78
|
label: B("healthybowl.livestock.dashboard.stats.totalAnimals.label", "Total Animals"),
|
|
78
79
|
value: V,
|
|
79
|
-
icon: /* @__PURE__ */ E(
|
|
80
|
+
icon: /* @__PURE__ */ E(b, { className: "h-4 w-4" })
|
|
80
81
|
}),
|
|
81
82
|
/* @__PURE__ */ E(i, {
|
|
82
83
|
label: B("healthybowl.livestock.dashboard.stats.healthIssues.label", "Health Issues"),
|
|
83
84
|
value: U + W,
|
|
84
|
-
icon: /* @__PURE__ */ E(
|
|
85
|
+
icon: /* @__PURE__ */ E(_, { className: "h-4 w-4" })
|
|
85
86
|
}),
|
|
86
87
|
/* @__PURE__ */ E(i, {
|
|
87
88
|
label: B("healthybowl.livestock.dashboard.stats.productionValue.label", "Est. Production Value"),
|
|
88
89
|
value: e(X),
|
|
89
|
-
icon: /* @__PURE__ */ E(
|
|
90
|
+
icon: /* @__PURE__ */ E(re, { className: "h-4 w-4" })
|
|
90
91
|
}),
|
|
91
92
|
/* @__PURE__ */ E(i, {
|
|
92
93
|
label: B("healthybowl.livestock.dashboard.stats.margin.label", "Est. Margin"),
|
|
93
|
-
value: parseFloat(
|
|
94
|
+
value: parseFloat(ae),
|
|
94
95
|
unit: "%",
|
|
95
96
|
icon: /* @__PURE__ */ E(S, { className: "h-4 w-4" })
|
|
96
97
|
})
|
|
@@ -149,7 +150,7 @@ var k = (e) => {
|
|
|
149
150
|
children: [
|
|
150
151
|
B("healthybowl.livestock.dashboard.distribution.viewAll", "View All Animals"),
|
|
151
152
|
" ",
|
|
152
|
-
/* @__PURE__ */ E(
|
|
153
|
+
/* @__PURE__ */ E(te, { className: "h-4 w-4" })
|
|
153
154
|
]
|
|
154
155
|
})
|
|
155
156
|
})]
|
|
@@ -165,7 +166,7 @@ var k = (e) => {
|
|
|
165
166
|
className: "flex items-center gap-3",
|
|
166
167
|
children: [/* @__PURE__ */ E("div", {
|
|
167
168
|
className: "rounded-full bg-bg-surface p-3",
|
|
168
|
-
children: /* @__PURE__ */ E(
|
|
169
|
+
children: /* @__PURE__ */ E(v, { className: "h-5 w-5 text-primary" })
|
|
169
170
|
}), /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
170
171
|
className: "text-sm font-medium text-text-primary",
|
|
171
172
|
children: B("healthybowl.livestock.dashboard.production.milk.label", "Milk Production")
|
|
@@ -190,7 +191,7 @@ var k = (e) => {
|
|
|
190
191
|
className: "flex items-center gap-3",
|
|
191
192
|
children: [/* @__PURE__ */ E("div", {
|
|
192
193
|
className: "rounded-full bg-bg-surface p-3",
|
|
193
|
-
children: /* @__PURE__ */ E(
|
|
194
|
+
children: /* @__PURE__ */ E(ie, { className: "h-5 w-5 text-primary" })
|
|
194
195
|
}), /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
195
196
|
className: "text-sm font-medium text-text-primary",
|
|
196
197
|
children: B("healthybowl.livestock.dashboard.production.eggs.label", "Egg Collection")
|
|
@@ -223,7 +224,8 @@ var k = (e) => {
|
|
|
223
224
|
})
|
|
224
225
|
})]
|
|
225
226
|
}),
|
|
226
|
-
/* @__PURE__ */ E(
|
|
227
|
+
/* @__PURE__ */ E(u, {}),
|
|
228
|
+
/* @__PURE__ */ E(d, {}),
|
|
227
229
|
/* @__PURE__ */ D("div", {
|
|
228
230
|
className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
|
|
229
231
|
children: [/* @__PURE__ */ D("div", {
|
|
@@ -253,14 +255,14 @@ var k = (e) => {
|
|
|
253
255
|
label: B("healthybowl.livestock.dashboard.healthStatus.healthy", "Healthy"),
|
|
254
256
|
value: H,
|
|
255
257
|
variant: "success",
|
|
256
|
-
icon:
|
|
258
|
+
icon: _
|
|
257
259
|
},
|
|
258
260
|
{
|
|
259
261
|
id: "sick",
|
|
260
262
|
label: B("healthybowl.livestock.dashboard.healthStatus.sick", "Sick"),
|
|
261
263
|
value: U,
|
|
262
264
|
variant: "error",
|
|
263
|
-
icon:
|
|
265
|
+
icon: p
|
|
264
266
|
},
|
|
265
267
|
{
|
|
266
268
|
id: "treatment",
|
|
@@ -274,14 +276,14 @@ var k = (e) => {
|
|
|
274
276
|
label: B("healthybowl.livestock.dashboard.healthStatus.quarantine", "Quarantine"),
|
|
275
277
|
value: G,
|
|
276
278
|
variant: "error",
|
|
277
|
-
icon:
|
|
279
|
+
icon: p
|
|
278
280
|
},
|
|
279
281
|
{
|
|
280
282
|
id: "pregnant",
|
|
281
283
|
label: B("healthybowl.livestock.dashboard.healthStatus.pregnant", "Pregnant"),
|
|
282
284
|
value: K,
|
|
283
285
|
variant: "info",
|
|
284
|
-
icon:
|
|
286
|
+
icon: ne
|
|
285
287
|
}
|
|
286
288
|
].map((e) => /* @__PURE__ */ D("div", {
|
|
287
289
|
className: "rounded-lg bg-bg-sunken/50 p-3 text-center",
|
|
@@ -342,7 +344,7 @@ var k = (e) => {
|
|
|
342
344
|
{
|
|
343
345
|
id: "healthCheck",
|
|
344
346
|
label: B("healthybowl.livestock.dashboard.quickActions.recordHealthCheck", "Record Health Check"),
|
|
345
|
-
icon:
|
|
347
|
+
icon: _,
|
|
346
348
|
path: z("livestock/health")
|
|
347
349
|
},
|
|
348
350
|
{
|
|
@@ -354,7 +356,7 @@ var k = (e) => {
|
|
|
354
356
|
{
|
|
355
357
|
id: "feed",
|
|
356
358
|
label: B("healthybowl.livestock.dashboard.quickActions.updateFeedRecords", "Update Feed Records"),
|
|
357
|
-
icon:
|
|
359
|
+
icon: y,
|
|
358
360
|
path: z("livestock/feed")
|
|
359
361
|
},
|
|
360
362
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivestockDashboardPage.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/LivestockDashboardPage.tsx"],"sourcesContent":["import { type FC } from 'react';\nimport { useNavigate } from 'react-router';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport {\n PawPrint,\n Heart,\n Baby,\n DollarSign,\n TrendingUp,\n Milk,\n Egg,\n Calendar,\n ArrowRight,\n AlertCircle,\n Clock,\n ChevronRight,\n Plus,\n Package,\n Users,\n} from 'lucide-react';\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n ChartCard,\n LoadingSkeleton,\n EmptyState,\n ErrorState,\n} from '../../components';\nimport { LivestockGrowthCard } from './LivestockGrowthCard';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { formatDate, formatCurrency } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\n\nconst getAnimalIcon = (type: string) => {\n switch (type) {\n case 'cattle':\n case 'buffalo':\n return '🐄';\n case 'goat':\n return '🐐';\n case 'sheep':\n return '🐑';\n case 'pig':\n return '🐷';\n case 'poultry':\n return '🐔';\n default:\n return '🐾';\n }\n};\n\n// Per-unit price estimates for production types (used to derive revenue)\nconst UNIT_PRICES: Record<string, number> = {\n milk: 55,\n eggs: 8,\n wool: 400,\n meat: 350,\n manure: 5,\n};\n\nexport const LivestockDashboardPage: FC = () => {\n const { animals, healthRecords, vaccinations, productionRecords, feedRecords, loading, errors } =\n useHealthyBowlData();\n\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { t } = useI18n();\n\n const totalAnimals = animals.length;\n const healthy = animals.filter((a) => a.healthStatus === 'healthy').length;\n const sick = animals.filter((a) => a.healthStatus === 'sick').length;\n const underTreatment = animals.filter((a) => a.healthStatus === 'under_treatment').length;\n const quarantine = animals.filter((a) => a.healthStatus === 'quarantine').length;\n const pregnant = animals.filter((a) => a.healthStatus === 'pregnant').length;\n\n const typeCounts = animals.reduce<Record<string, number>>((acc, a) => {\n acc[a.type] = (acc[a.type] || 0) + 1;\n return acc;\n }, {});\n\n // Total production from all records\n const milkProduction = productionRecords.filter((p) => p.type === 'milk').reduce((sum, p) => sum + p.quantity, 0);\n const eggProduction = productionRecords.filter((p) => p.type === 'eggs').reduce((sum, p) => sum + p.quantity, 0);\n\n // Derive financial figures from actual data\n const monthlyRevenue = productionRecords.reduce((sum, p) => sum + p.quantity * (UNIT_PRICES[p.type] ?? 0), 0);\n const monthlyExpenses = feedRecords.reduce((sum, r) => sum + r.cost, 0);\n const profitMargin =\n monthlyRevenue > 0 ? (((monthlyRevenue - monthlyExpenses) / monthlyRevenue) * 100).toFixed(1) : '0.0';\n\n const recentHealthIssues = healthRecords\n .filter((r) => r.status === 'active' || r.status === 'monitoring')\n .slice(0, 3);\n const upcomingVaccinations = vaccinations.filter((v) => v.status === 'scheduled').slice(0, 3);\n\n return (\n <PageLayout\n title={t('healthybowl.livestock.dashboard.title', 'Livestock Management')}\n description={t('healthybowl.livestock.dashboard.description', 'Monitor and manage your livestock operations')}\n purpose=\"The health of your animal operation at a glance — herd size, health flags and production. Start here each day, then dive into the registry, health, breeding or feed sections as needed.\"\n nextStepsKey=\"healthybowl-livestock-dashboard\"\n nextStepsTitle=\"Run your herd day to day\"\n nextSteps={[\n {\n id: 'registry',\n label: 'Register your animals',\n description: 'Build the herd registry so every record links to an animal.',\n onClick: () => navigate(buildPath('livestock/animals')),\n },\n {\n id: 'health',\n label: 'Log health & vaccinations',\n description: 'Keep treatment and vaccination history in one place.',\n onClick: () => navigate(buildPath('livestock/health')),\n },\n {\n id: 'production',\n label: 'Track production',\n description: 'Record milk, eggs or other yields to watch trends.',\n onClick: () => navigate(buildPath('livestock/production')),\n },\n ]}\n actions={\n <Button variant=\"default\" onClick={() => navigate(buildPath('livestock/animals'))}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.livestock.dashboard.actions.addAnimal', 'Add Animal')}\n </Button>\n }\n >\n {loading && animals.length === 0 ? (\n <LoadingSkeleton variant=\"card\" count={4} />\n ) : (\n <>\n {/* Key Metrics */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n hero\n label={t('healthybowl.livestock.dashboard.stats.totalAnimals.label', 'Total Animals')}\n value={totalAnimals}\n icon={<PawPrint className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.dashboard.stats.healthIssues.label', 'Health Issues')}\n value={sick + underTreatment}\n icon={<Heart className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.dashboard.stats.productionValue.label', 'Est. Production Value')}\n value={formatCurrency(monthlyRevenue)}\n icon={<DollarSign className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.dashboard.stats.margin.label', 'Est. Margin')}\n value={parseFloat(profitMargin)}\n unit=\"%\"\n icon={<TrendingUp className=\"h-4 w-4\" />}\n />\n </div>\n\n {/* Animal Distribution & Total Production */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-2\">\n {/* Animal Distribution */}\n <ChartCard\n title={t('healthybowl.livestock.dashboard.distribution.title', 'Animal Distribution')}\n description={t('healthybowl.livestock.dashboard.distribution.description', 'Breakdown by animal type')}\n >\n {totalAnimals === 0 ? (\n errors.livestock ? (\n <ErrorState />\n ) : (\n <EmptyState\n illustration=\"empty-generic\"\n title={t('healthybowl.livestock.dashboard.distribution.empty.title', 'No animals yet')}\n description={t(\n 'healthybowl.livestock.dashboard.distribution.empty.description',\n 'Add an animal to see your livestock distribution by type.'\n )}\n />\n )\n ) : (\n <div className=\"flex flex-col gap-3\">\n {Object.entries(typeCounts).map(([type, count]) => {\n const percentage = totalAnimals > 0 ? Math.round((count / totalAnimals) * 100) : 0;\n return (\n <div key={type} className=\"space-y-1.5\">\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-lg\">{getAnimalIcon(type)}</span>\n <span className=\"text-sm font-medium capitalize text-text-primary\">{type}</span>\n </div>\n <span className=\"text-xs text-text-secondary\">\n {count} ({percentage}%)\n </span>\n </div>\n <div className=\"h-2 w-full rounded-full bg-bg-sunken\">\n <div\n className=\"h-2 rounded-full bg-action-primary-bg transition-all\"\n style={{ width: `${percentage}%` }}\n />\n </div>\n </div>\n );\n })}\n </div>\n )}\n <div className=\"mt-4 border-t border-border-subtle pt-4\">\n <Button\n variant=\"outline\"\n onClick={() => navigate(buildPath('livestock/animals'))}\n className=\"w-full justify-center\"\n >\n {t('healthybowl.livestock.dashboard.distribution.viewAll', 'View All Animals')}{' '}\n <ArrowRight className=\"h-4 w-4\" />\n </Button>\n </div>\n </ChartCard>\n\n {/* Total Production */}\n <ChartCard\n title={t('healthybowl.livestock.dashboard.production.title', 'Total Production')}\n description={t(\n 'healthybowl.livestock.dashboard.production.description',\n 'Cumulative production tracking'\n )}\n >\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center justify-between rounded-lg bg-bg-sunken/50 p-4\">\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-full bg-bg-surface p-3\">\n <Milk className=\"h-5 w-5 text-primary\" />\n </div>\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.production.milk.label', 'Milk Production')}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.milk.source', 'From dairy animals')}\n </p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"text-xl font-bold text-text-primary\">{milkProduction}</p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.milk.unit', 'liters')}\n </p>\n </div>\n </div>\n\n <div className=\"flex items-center justify-between rounded-lg bg-bg-sunken/50 p-4\">\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-full bg-bg-surface p-3\">\n <Egg className=\"h-5 w-5 text-primary\" />\n </div>\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.production.eggs.label', 'Egg Collection')}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.eggs.source', 'From poultry')}\n </p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"text-xl font-bold text-text-primary\">{eggProduction}</p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.eggs.unit', 'eggs')}\n </p>\n </div>\n </div>\n\n <Button\n variant=\"default\"\n onClick={() => navigate(buildPath('livestock/production'))}\n className=\"w-full justify-center\"\n >\n {t('healthybowl.livestock.dashboard.production.record', 'Record Production')}{' '}\n <Plus className=\"h-4 w-4\" />\n </Button>\n </div>\n </ChartCard>\n </div>\n\n {/* Growth (BOFF-5971) — herd-average weight curve + ADG leaders */}\n <LivestockGrowthCard />\n\n {/* Health Status & Quick Actions */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Health Status Overview */}\n <div className=\"lg:col-span-2 rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h3 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.healthStatus.title', 'Health Status Overview')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.healthStatus.subtitle', 'Current health distribution')}\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('livestock/health'))}\n className=\"text-xs\"\n >\n {t('healthybowl.common.viewAll', 'View All')}\n </Button>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-5\">\n {[\n {\n id: 'healthy',\n label: t('healthybowl.livestock.dashboard.healthStatus.healthy', 'Healthy'),\n value: healthy,\n variant: 'success' as const,\n icon: Heart,\n },\n {\n id: 'sick',\n label: t('healthybowl.livestock.dashboard.healthStatus.sick', 'Sick'),\n value: sick,\n variant: 'error' as const,\n icon: AlertCircle,\n },\n {\n id: 'treatment',\n label: t('healthybowl.livestock.dashboard.healthStatus.treatment', 'Treatment'),\n value: underTreatment,\n variant: 'warning' as const,\n icon: Clock,\n },\n {\n id: 'quarantine',\n label: t('healthybowl.livestock.dashboard.healthStatus.quarantine', 'Quarantine'),\n value: quarantine,\n variant: 'error' as const,\n icon: AlertCircle,\n },\n {\n id: 'pregnant',\n label: t('healthybowl.livestock.dashboard.healthStatus.pregnant', 'Pregnant'),\n value: pregnant,\n variant: 'info' as const,\n icon: Baby,\n },\n ].map((item) => (\n <div key={item.id} className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <item.icon className=\"mx-auto mb-1 h-4 w-4 text-text-secondary\" />\n <p className=\"text-xl font-bold text-text-primary\">{item.value}</p>\n <p className=\"text-xs text-text-secondary\">{item.label}</p>\n </div>\n ))}\n </div>\n\n {/* Recent Health Issues */}\n {recentHealthIssues.length > 0 && (\n <div className=\"mt-4\">\n <h4 className=\"mb-2 text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.healthStatus.recentIssues', 'Recent Health Issues')}\n </h4>\n <div className=\"flex flex-col gap-2\">\n {recentHealthIssues.map((issue) => (\n <div\n key={issue.id}\n className=\"flex cursor-pointer items-center justify-between rounded-md border border-border-subtle p-3 hover:bg-bg-sunken/30\"\n onClick={() => navigate(buildPath('livestock/health'))}\n >\n <div className=\"flex items-center gap-3\">\n <StatusBadge label={issue.status} variant={issue.status === 'active' ? 'warning' : 'info'} />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">{issue.animalName}</p>\n <p className=\"text-xs text-text-secondary\">{issue.diagnosis}</p>\n </div>\n </div>\n <ChevronRight className=\"h-4 w-4 text-text-secondary\" />\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n\n {/* Quick Actions */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <h3 className=\"mb-1 text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.quickActions.title', 'Quick Actions')}\n </h3>\n <p className=\"mb-4 text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.quickActions.subtitle', 'Common livestock tasks')}\n </p>\n <div className=\"flex flex-col gap-2\">\n {[\n {\n id: 'healthCheck',\n label: t('healthybowl.livestock.dashboard.quickActions.recordHealthCheck', 'Record Health Check'),\n icon: Heart,\n path: buildPath('livestock/health'),\n },\n {\n id: 'vaccination',\n label: t(\n 'healthybowl.livestock.dashboard.quickActions.scheduleVaccination',\n 'Schedule Vaccination'\n ),\n icon: Calendar,\n path: buildPath('livestock/vaccinations'),\n },\n {\n id: 'feed',\n label: t('healthybowl.livestock.dashboard.quickActions.updateFeedRecords', 'Update Feed Records'),\n icon: Package,\n path: buildPath('livestock/feed'),\n },\n {\n id: 'breeding',\n label: t('healthybowl.livestock.dashboard.quickActions.breedingManagement', 'Breeding Management'),\n icon: Users,\n path: buildPath('livestock/breeding'),\n },\n {\n id: 'production',\n label: t('healthybowl.livestock.dashboard.quickActions.viewProduction', 'View Production'),\n icon: TrendingUp,\n path: buildPath('livestock/production'),\n },\n ].map((action) => (\n <Button\n key={action.id}\n variant=\"outline\"\n onClick={() => navigate(action.path)}\n className=\"justify-start\"\n >\n <action.icon className=\"h-4 w-4 text-text-secondary\" />\n {action.label}\n </Button>\n ))}\n </div>\n </div>\n </div>\n\n {/* Upcoming Vaccinations */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h3 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.vaccinations.title', 'Upcoming Vaccinations')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.vaccinations.subtitle', 'Next 7 days · {{count}} scheduled', {\n count: upcomingVaccinations.length,\n })}\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('livestock/vaccinations'))}\n className=\"text-xs\"\n >\n {t('healthybowl.common.viewAll', 'View All')}\n </Button>\n </div>\n <div className=\"flex flex-col gap-2\">\n {upcomingVaccinations.map((vac) => (\n <div\n key={vac.id}\n className=\"flex items-center justify-between rounded-md border border-border-subtle p-3 hover:bg-bg-sunken/30\"\n >\n <div className=\"flex items-center gap-3\">\n <Calendar className=\"h-4 w-4 text-text-secondary\" />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">{vac.animalName}</p>\n <p className=\"text-xs text-text-secondary\">{vac.vaccineName}</p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"text-xs font-medium text-text-primary\">{formatDate(vac.nextDueDate)}</p>\n <StatusBadge label={vac.status} variant=\"info\" />\n </div>\n </div>\n ))}\n {upcomingVaccinations.length === 0 && (\n <p className=\"py-4 text-center text-sm text-text-secondary\">\n {t('healthybowl.livestock.dashboard.vaccinations.empty', 'No upcoming vaccinations')}\n </p>\n )}\n </div>\n </div>\n\n {/* Financial Summary — production value is ESTIMATED (recorded quantities × standard unit\n prices, not booked sales); feed cost is real. Labelled as estimates to avoid implying\n real revenue. */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <h3 className=\"mb-1 text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.financials.title', 'Estimated Financials')}\n </h3>\n <p className=\"mb-3 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.dashboard.financials.description',\n 'Production value is estimated from recorded output at standard unit prices; feed cost is actual.'\n )}\n </p>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.financials.productionValue', 'Est. Production Value')}\n </p>\n <p className=\"text-lg font-bold text-text-primary\">{formatCurrency(monthlyRevenue)}</p>\n </div>\n <div className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.financials.feedCost', 'Feed Cost')}\n </p>\n <p className=\"text-lg font-bold text-text-primary\">{formatCurrency(monthlyExpenses)}</p>\n </div>\n <div className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.financials.net', 'Est. Net')}\n </p>\n <p className=\"text-lg font-bold text-text-primary\">\n {formatCurrency(monthlyRevenue - monthlyExpenses)}\n </p>\n </div>\n </div>\n </div>\n </>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,IAAM,KAAiB,MAAiB;AACtC,SAAQ,GAAR;EACE,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,QACE,QAAO;;GAKP,IAAsC;CAC1C,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,QAAQ;CACT,EAEY,UAAmC;CAC9C,IAAM,EAAE,YAAS,kBAAe,iBAAc,sBAAmB,gBAAa,YAAS,cACrF,IAAoB,EAEhB,IAAW,GAAa,EACxB,EAAE,iBAAc,GAAa,EAC7B,EAAE,SAAM,GAAS,EAEjB,IAAe,EAAQ,QACvB,IAAU,EAAQ,QAAQ,MAAM,EAAE,iBAAiB,UAAU,CAAC,QAC9D,IAAO,EAAQ,QAAQ,MAAM,EAAE,iBAAiB,OAAO,CAAC,QACxD,IAAiB,EAAQ,QAAQ,MAAM,EAAE,iBAAiB,kBAAkB,CAAC,QAC7E,IAAa,EAAQ,QAAQ,MAAM,EAAE,iBAAiB,aAAa,CAAC,QACpE,IAAW,EAAQ,QAAQ,MAAM,EAAE,iBAAiB,WAAW,CAAC,QAEhE,IAAa,EAAQ,QAAgC,GAAK,OAC9D,EAAI,EAAE,SAAS,EAAI,EAAE,SAAS,KAAK,GAC5B,IACN,EAAE,CAAC,EAGA,IAAiB,EAAkB,QAAQ,MAAM,EAAE,SAAS,OAAO,CAA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,EAAE,uDAAuD,YAAY;SACpE,CAAA,EACJ,kBAAC,KAAD;SAAG,WAAU;mBAAuC,EAAe,EAAgB;SAAK,CAAA,CACpF;;OACN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,KAAD;SAAG,WAAU;mBACV,EAAE,kDAAkD,WAAW;SAC9D,CAAA,EACJ,kBAAC,KAAD;SAAG,WAAU;mBACV,EAAe,IAAiB,EAAgB;SAC/C,CAAA,CACA;;OACF;;KACF;;GACL,EAAA,CAAA;EAEM,CAAA"}
|
|
1
|
+
{"version":3,"file":"LivestockDashboardPage.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/LivestockDashboardPage.tsx"],"sourcesContent":["import { type FC } from 'react';\nimport { useNavigate } from 'react-router';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport {\n PawPrint,\n Heart,\n Baby,\n DollarSign,\n TrendingUp,\n Milk,\n Egg,\n Calendar,\n ArrowRight,\n AlertCircle,\n Clock,\n ChevronRight,\n Plus,\n Package,\n Users,\n} from 'lucide-react';\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n ChartCard,\n LoadingSkeleton,\n EmptyState,\n ErrorState,\n} from '../../components';\nimport { LivestockGrowthCard } from './LivestockGrowthCard';\nimport { LivestockFeedCard } from './LivestockFeedCard';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { formatDate, formatCurrency } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\n\nconst getAnimalIcon = (type: string) => {\n switch (type) {\n case 'cattle':\n case 'buffalo':\n return '🐄';\n case 'goat':\n return '🐐';\n case 'sheep':\n return '🐑';\n case 'pig':\n return '🐷';\n case 'poultry':\n return '🐔';\n default:\n return '🐾';\n }\n};\n\n// Per-unit price estimates for production types (used to derive revenue)\nconst UNIT_PRICES: Record<string, number> = {\n milk: 55,\n eggs: 8,\n wool: 400,\n meat: 350,\n manure: 5,\n};\n\nexport const LivestockDashboardPage: FC = () => {\n const { animals, healthRecords, vaccinations, productionRecords, feedRecords, loading, errors } =\n useHealthyBowlData();\n\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { t } = useI18n();\n\n const totalAnimals = animals.length;\n const healthy = animals.filter((a) => a.healthStatus === 'healthy').length;\n const sick = animals.filter((a) => a.healthStatus === 'sick').length;\n const underTreatment = animals.filter((a) => a.healthStatus === 'under_treatment').length;\n const quarantine = animals.filter((a) => a.healthStatus === 'quarantine').length;\n const pregnant = animals.filter((a) => a.healthStatus === 'pregnant').length;\n\n const typeCounts = animals.reduce<Record<string, number>>((acc, a) => {\n acc[a.type] = (acc[a.type] || 0) + 1;\n return acc;\n }, {});\n\n // Total production from all records\n const milkProduction = productionRecords.filter((p) => p.type === 'milk').reduce((sum, p) => sum + p.quantity, 0);\n const eggProduction = productionRecords.filter((p) => p.type === 'eggs').reduce((sum, p) => sum + p.quantity, 0);\n\n // Derive financial figures from actual data\n const monthlyRevenue = productionRecords.reduce((sum, p) => sum + p.quantity * (UNIT_PRICES[p.type] ?? 0), 0);\n const monthlyExpenses = feedRecords.reduce((sum, r) => sum + r.cost, 0);\n const profitMargin =\n monthlyRevenue > 0 ? (((monthlyRevenue - monthlyExpenses) / monthlyRevenue) * 100).toFixed(1) : '0.0';\n\n const recentHealthIssues = healthRecords\n .filter((r) => r.status === 'active' || r.status === 'monitoring')\n .slice(0, 3);\n const upcomingVaccinations = vaccinations.filter((v) => v.status === 'scheduled').slice(0, 3);\n\n return (\n <PageLayout\n title={t('healthybowl.livestock.dashboard.title', 'Livestock Management')}\n description={t('healthybowl.livestock.dashboard.description', 'Monitor and manage your livestock operations')}\n purpose=\"The health of your animal operation at a glance — herd size, health flags and production. Start here each day, then dive into the registry, health, breeding or feed sections as needed.\"\n nextStepsKey=\"healthybowl-livestock-dashboard\"\n nextStepsTitle=\"Run your herd day to day\"\n nextSteps={[\n {\n id: 'registry',\n label: 'Register your animals',\n description: 'Build the herd registry so every record links to an animal.',\n onClick: () => navigate(buildPath('livestock/animals')),\n },\n {\n id: 'health',\n label: 'Log health & vaccinations',\n description: 'Keep treatment and vaccination history in one place.',\n onClick: () => navigate(buildPath('livestock/health')),\n },\n {\n id: 'production',\n label: 'Track production',\n description: 'Record milk, eggs or other yields to watch trends.',\n onClick: () => navigate(buildPath('livestock/production')),\n },\n ]}\n actions={\n <Button variant=\"default\" onClick={() => navigate(buildPath('livestock/animals'))}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.livestock.dashboard.actions.addAnimal', 'Add Animal')}\n </Button>\n }\n >\n {loading && animals.length === 0 ? (\n <LoadingSkeleton variant=\"card\" count={4} />\n ) : (\n <>\n {/* Key Metrics */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n hero\n label={t('healthybowl.livestock.dashboard.stats.totalAnimals.label', 'Total Animals')}\n value={totalAnimals}\n icon={<PawPrint className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.dashboard.stats.healthIssues.label', 'Health Issues')}\n value={sick + underTreatment}\n icon={<Heart className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.dashboard.stats.productionValue.label', 'Est. Production Value')}\n value={formatCurrency(monthlyRevenue)}\n icon={<DollarSign className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.dashboard.stats.margin.label', 'Est. Margin')}\n value={parseFloat(profitMargin)}\n unit=\"%\"\n icon={<TrendingUp className=\"h-4 w-4\" />}\n />\n </div>\n\n {/* Animal Distribution & Total Production */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-2\">\n {/* Animal Distribution */}\n <ChartCard\n title={t('healthybowl.livestock.dashboard.distribution.title', 'Animal Distribution')}\n description={t('healthybowl.livestock.dashboard.distribution.description', 'Breakdown by animal type')}\n >\n {totalAnimals === 0 ? (\n errors.livestock ? (\n <ErrorState />\n ) : (\n <EmptyState\n illustration=\"empty-generic\"\n title={t('healthybowl.livestock.dashboard.distribution.empty.title', 'No animals yet')}\n description={t(\n 'healthybowl.livestock.dashboard.distribution.empty.description',\n 'Add an animal to see your livestock distribution by type.'\n )}\n />\n )\n ) : (\n <div className=\"flex flex-col gap-3\">\n {Object.entries(typeCounts).map(([type, count]) => {\n const percentage = totalAnimals > 0 ? Math.round((count / totalAnimals) * 100) : 0;\n return (\n <div key={type} className=\"space-y-1.5\">\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-lg\">{getAnimalIcon(type)}</span>\n <span className=\"text-sm font-medium capitalize text-text-primary\">{type}</span>\n </div>\n <span className=\"text-xs text-text-secondary\">\n {count} ({percentage}%)\n </span>\n </div>\n <div className=\"h-2 w-full rounded-full bg-bg-sunken\">\n <div\n className=\"h-2 rounded-full bg-action-primary-bg transition-all\"\n style={{ width: `${percentage}%` }}\n />\n </div>\n </div>\n );\n })}\n </div>\n )}\n <div className=\"mt-4 border-t border-border-subtle pt-4\">\n <Button\n variant=\"outline\"\n onClick={() => navigate(buildPath('livestock/animals'))}\n className=\"w-full justify-center\"\n >\n {t('healthybowl.livestock.dashboard.distribution.viewAll', 'View All Animals')}{' '}\n <ArrowRight className=\"h-4 w-4\" />\n </Button>\n </div>\n </ChartCard>\n\n {/* Total Production */}\n <ChartCard\n title={t('healthybowl.livestock.dashboard.production.title', 'Total Production')}\n description={t(\n 'healthybowl.livestock.dashboard.production.description',\n 'Cumulative production tracking'\n )}\n >\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center justify-between rounded-lg bg-bg-sunken/50 p-4\">\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-full bg-bg-surface p-3\">\n <Milk className=\"h-5 w-5 text-primary\" />\n </div>\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.production.milk.label', 'Milk Production')}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.milk.source', 'From dairy animals')}\n </p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"text-xl font-bold text-text-primary\">{milkProduction}</p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.milk.unit', 'liters')}\n </p>\n </div>\n </div>\n\n <div className=\"flex items-center justify-between rounded-lg bg-bg-sunken/50 p-4\">\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-full bg-bg-surface p-3\">\n <Egg className=\"h-5 w-5 text-primary\" />\n </div>\n <div>\n <p className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.production.eggs.label', 'Egg Collection')}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.eggs.source', 'From poultry')}\n </p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"text-xl font-bold text-text-primary\">{eggProduction}</p>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.production.eggs.unit', 'eggs')}\n </p>\n </div>\n </div>\n\n <Button\n variant=\"default\"\n onClick={() => navigate(buildPath('livestock/production'))}\n className=\"w-full justify-center\"\n >\n {t('healthybowl.livestock.dashboard.production.record', 'Record Production')}{' '}\n <Plus className=\"h-4 w-4\" />\n </Button>\n </div>\n </ChartCard>\n </div>\n\n {/* Growth (BOFF-5971) — herd-average weight curve + ADG leaders */}\n <LivestockGrowthCard />\n\n {/* Feed (BOFF-5971) — spend over time + what a kilo of gain costs */}\n <LivestockFeedCard />\n\n {/* Health Status & Quick Actions */}\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Health Status Overview */}\n <div className=\"lg:col-span-2 rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h3 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.healthStatus.title', 'Health Status Overview')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.healthStatus.subtitle', 'Current health distribution')}\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('livestock/health'))}\n className=\"text-xs\"\n >\n {t('healthybowl.common.viewAll', 'View All')}\n </Button>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-5\">\n {[\n {\n id: 'healthy',\n label: t('healthybowl.livestock.dashboard.healthStatus.healthy', 'Healthy'),\n value: healthy,\n variant: 'success' as const,\n icon: Heart,\n },\n {\n id: 'sick',\n label: t('healthybowl.livestock.dashboard.healthStatus.sick', 'Sick'),\n value: sick,\n variant: 'error' as const,\n icon: AlertCircle,\n },\n {\n id: 'treatment',\n label: t('healthybowl.livestock.dashboard.healthStatus.treatment', 'Treatment'),\n value: underTreatment,\n variant: 'warning' as const,\n icon: Clock,\n },\n {\n id: 'quarantine',\n label: t('healthybowl.livestock.dashboard.healthStatus.quarantine', 'Quarantine'),\n value: quarantine,\n variant: 'error' as const,\n icon: AlertCircle,\n },\n {\n id: 'pregnant',\n label: t('healthybowl.livestock.dashboard.healthStatus.pregnant', 'Pregnant'),\n value: pregnant,\n variant: 'info' as const,\n icon: Baby,\n },\n ].map((item) => (\n <div key={item.id} className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <item.icon className=\"mx-auto mb-1 h-4 w-4 text-text-secondary\" />\n <p className=\"text-xl font-bold text-text-primary\">{item.value}</p>\n <p className=\"text-xs text-text-secondary\">{item.label}</p>\n </div>\n ))}\n </div>\n\n {/* Recent Health Issues */}\n {recentHealthIssues.length > 0 && (\n <div className=\"mt-4\">\n <h4 className=\"mb-2 text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.healthStatus.recentIssues', 'Recent Health Issues')}\n </h4>\n <div className=\"flex flex-col gap-2\">\n {recentHealthIssues.map((issue) => (\n <div\n key={issue.id}\n className=\"flex cursor-pointer items-center justify-between rounded-md border border-border-subtle p-3 hover:bg-bg-sunken/30\"\n onClick={() => navigate(buildPath('livestock/health'))}\n >\n <div className=\"flex items-center gap-3\">\n <StatusBadge label={issue.status} variant={issue.status === 'active' ? 'warning' : 'info'} />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">{issue.animalName}</p>\n <p className=\"text-xs text-text-secondary\">{issue.diagnosis}</p>\n </div>\n </div>\n <ChevronRight className=\"h-4 w-4 text-text-secondary\" />\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n\n {/* Quick Actions */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <h3 className=\"mb-1 text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.quickActions.title', 'Quick Actions')}\n </h3>\n <p className=\"mb-4 text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.quickActions.subtitle', 'Common livestock tasks')}\n </p>\n <div className=\"flex flex-col gap-2\">\n {[\n {\n id: 'healthCheck',\n label: t('healthybowl.livestock.dashboard.quickActions.recordHealthCheck', 'Record Health Check'),\n icon: Heart,\n path: buildPath('livestock/health'),\n },\n {\n id: 'vaccination',\n label: t(\n 'healthybowl.livestock.dashboard.quickActions.scheduleVaccination',\n 'Schedule Vaccination'\n ),\n icon: Calendar,\n path: buildPath('livestock/vaccinations'),\n },\n {\n id: 'feed',\n label: t('healthybowl.livestock.dashboard.quickActions.updateFeedRecords', 'Update Feed Records'),\n icon: Package,\n path: buildPath('livestock/feed'),\n },\n {\n id: 'breeding',\n label: t('healthybowl.livestock.dashboard.quickActions.breedingManagement', 'Breeding Management'),\n icon: Users,\n path: buildPath('livestock/breeding'),\n },\n {\n id: 'production',\n label: t('healthybowl.livestock.dashboard.quickActions.viewProduction', 'View Production'),\n icon: TrendingUp,\n path: buildPath('livestock/production'),\n },\n ].map((action) => (\n <Button\n key={action.id}\n variant=\"outline\"\n onClick={() => navigate(action.path)}\n className=\"justify-start\"\n >\n <action.icon className=\"h-4 w-4 text-text-secondary\" />\n {action.label}\n </Button>\n ))}\n </div>\n </div>\n </div>\n\n {/* Upcoming Vaccinations */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h3 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.vaccinations.title', 'Upcoming Vaccinations')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.vaccinations.subtitle', 'Next 7 days · {{count}} scheduled', {\n count: upcomingVaccinations.length,\n })}\n </p>\n </div>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(buildPath('livestock/vaccinations'))}\n className=\"text-xs\"\n >\n {t('healthybowl.common.viewAll', 'View All')}\n </Button>\n </div>\n <div className=\"flex flex-col gap-2\">\n {upcomingVaccinations.map((vac) => (\n <div\n key={vac.id}\n className=\"flex items-center justify-between rounded-md border border-border-subtle p-3 hover:bg-bg-sunken/30\"\n >\n <div className=\"flex items-center gap-3\">\n <Calendar className=\"h-4 w-4 text-text-secondary\" />\n <div>\n <p className=\"text-sm font-medium text-text-primary\">{vac.animalName}</p>\n <p className=\"text-xs text-text-secondary\">{vac.vaccineName}</p>\n </div>\n </div>\n <div className=\"text-right\">\n <p className=\"text-xs font-medium text-text-primary\">{formatDate(vac.nextDueDate)}</p>\n <StatusBadge label={vac.status} variant=\"info\" />\n </div>\n </div>\n ))}\n {upcomingVaccinations.length === 0 && (\n <p className=\"py-4 text-center text-sm text-text-secondary\">\n {t('healthybowl.livestock.dashboard.vaccinations.empty', 'No upcoming vaccinations')}\n </p>\n )}\n </div>\n </div>\n\n {/* Financial Summary — production value is ESTIMATED (recorded quantities × standard unit\n prices, not booked sales); feed cost is real. Labelled as estimates to avoid implying\n real revenue. */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <h3 className=\"mb-1 text-sm font-medium text-text-primary\">\n {t('healthybowl.livestock.dashboard.financials.title', 'Estimated Financials')}\n </h3>\n <p className=\"mb-3 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.dashboard.financials.description',\n 'Production value is estimated from recorded output at standard unit prices; feed cost is actual.'\n )}\n </p>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.financials.productionValue', 'Est. Production Value')}\n </p>\n <p className=\"text-lg font-bold text-text-primary\">{formatCurrency(monthlyRevenue)}</p>\n </div>\n <div className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.financials.feedCost', 'Feed Cost')}\n </p>\n <p className=\"text-lg font-bold text-text-primary\">{formatCurrency(monthlyExpenses)}</p>\n </div>\n <div className=\"rounded-lg bg-bg-sunken/50 p-3 text-center\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.dashboard.financials.net', 'Est. Net')}\n </p>\n <p className=\"text-lg font-bold text-text-primary\">\n {formatCurrency(monthlyRevenue - monthlyExpenses)}\n </p>\n </div>\n </div>\n </div>\n </>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,IAAM,KAAiB,MAAiB;AACtC,SAAQ,GAAR;EACE,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,QACE,QAAO;;GAKP,IAAsC;CAC1C,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,QAAQ;CACT,EAEY,UAAmC;CAC9C,IAAM,EAAE,YAAS,kBAAe,iBAAc,sBAAmB,gBAAa,YAAS,cACrF,IAAoB,EAEhB,IAAW,GAAa,EACxB,EAAE,iBAAc,GAAa,EAC7B,EAAE,SAAM,GAAS,EAEjB,IAAe,EAAQ,QACvB,IAAU,EAAQ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AAA,CAEF;OACF;;GAKN,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,MAAD;MAAI,WAAU;gBACX,EAAE,oDAAoD,uBAAuB;MAC3E,CAAA;KACL,kBAAC,KAAD;MAAG,WAAU;gBACV,EACC,0DACA,mGACD;MACC,CAAA;KACJ,kBAAC,OAAD;MAAK,WAAU;gBAAf;OACE,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,KAAD;SAAG,WAAU;mBACV,EAAE,8DAA8D,wBAAwB;SACvF,CAAA,EACJ,kBAAC,KAAD;SAAG,WAAU;mBAAuC,EAAe,EAAe;SAAK,CAAA,CACnF;;OACN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,KAAD;SAAG,WAAU;mBACV,EAAE,uDAAuD,YAAY;SACpE,CAAA,EACJ,kBAAC,KAAD;SAAG,WAAU;mBAAuC,EAAe,EAAgB;SAAK,CAAA,CACpF;;OACN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,KAAD;SAAG,WAAU;mBACV,EAAE,kDAAkD,WAAW;SAC9D,CAAA,EACJ,kBAAC,KAAD;SAAG,WAAU;mBACV,EAAe,IAAiB,EAAgB;SAC/C,CAAA,CACA;;OACF;;KACF;;GACL,EAAA,CAAA;EAEM,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { formatNumber as e } from "../../utils/helpers.js";
|
|
2
|
+
import { ChartCard as t } from "../../components/ChartCard.js";
|
|
3
|
+
import { Tooltip as n } from "../../../node_modules/recharts/es6/component/Tooltip.js";
|
|
4
|
+
import { ResponsiveContainer as r } from "../../../node_modules/recharts/es6/component/ResponsiveContainer.js";
|
|
5
|
+
import { Bar as i } from "../../../node_modules/recharts/es6/cartesian/Bar.js";
|
|
6
|
+
import { CartesianGrid as a } from "../../../node_modules/recharts/es6/cartesian/CartesianGrid.js";
|
|
7
|
+
import { XAxis as o } from "../../../node_modules/recharts/es6/cartesian/XAxis.js";
|
|
8
|
+
import { YAxis as s } from "../../../node_modules/recharts/es6/cartesian/YAxis.js";
|
|
9
|
+
import { BarChart as c } from "../../../node_modules/recharts/es6/chart/BarChart.js";
|
|
10
|
+
import { useHealthyBowlLivestockFeed as l } from "../../hooks/useHealthyBowlLivestockFeed.js";
|
|
11
|
+
import { useState as u } from "react";
|
|
12
|
+
import { useI18n as d } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
13
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
14
|
+
//#region src/healthybowl/pages/livestock/LivestockFeedCard.tsx
|
|
15
|
+
var h = [
|
|
16
|
+
"DAY",
|
|
17
|
+
"WEEK",
|
|
18
|
+
"MONTH"
|
|
19
|
+
], g = ({ groupId: g = null, className: _ }) => {
|
|
20
|
+
let { t: v } = d(), [y, b] = u("WEEK"), { buckets: x, summary: S, loading: C, error: w, truncated: T } = l({
|
|
21
|
+
groupId: g,
|
|
22
|
+
granularity: y
|
|
23
|
+
}), E = x.length > 0, D = /* @__PURE__ */ p("div", {
|
|
24
|
+
className: "flex items-center gap-1",
|
|
25
|
+
children: h.map((e) => /* @__PURE__ */ p("button", {
|
|
26
|
+
type: "button",
|
|
27
|
+
onClick: () => b(e),
|
|
28
|
+
"aria-pressed": y === e,
|
|
29
|
+
className: `min-h-[32px] rounded-md px-2 py-1 text-xs transition-colors ${y === e ? "bg-action-primary-bg text-action-primary-text" : "text-text-secondary hover:bg-bg-sunken/50"}`,
|
|
30
|
+
children: v(`healthybowl.livestock.feed.granularity.${e.toLowerCase()}`, e.charAt(0) + e.slice(1).toLowerCase())
|
|
31
|
+
}, e))
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ p(t, {
|
|
34
|
+
title: v("healthybowl.livestock.feed.title", "Feed"),
|
|
35
|
+
description: v("healthybowl.livestock.feed.description", "What the herd ate, what it cost, and how much weight it bought."),
|
|
36
|
+
actions: D,
|
|
37
|
+
className: _,
|
|
38
|
+
children: w ? /* @__PURE__ */ m("div", {
|
|
39
|
+
className: "py-8 text-center",
|
|
40
|
+
children: [/* @__PURE__ */ p("p", {
|
|
41
|
+
className: "text-sm text-text-primary",
|
|
42
|
+
children: v("healthybowl.livestock.feed.error.title", "Could not load feed data")
|
|
43
|
+
}), /* @__PURE__ */ p("p", {
|
|
44
|
+
className: "mt-1 text-xs text-text-secondary",
|
|
45
|
+
children: w.message
|
|
46
|
+
})]
|
|
47
|
+
}) : C && !E ? /* @__PURE__ */ p("p", {
|
|
48
|
+
className: "py-8 text-center text-xs text-text-secondary",
|
|
49
|
+
children: v("healthybowl.livestock.feed.loading", "Loading feed data…")
|
|
50
|
+
}) : E ? /* @__PURE__ */ m(f, { children: [
|
|
51
|
+
/* @__PURE__ */ p(r, {
|
|
52
|
+
width: "100%",
|
|
53
|
+
height: 240,
|
|
54
|
+
children: /* @__PURE__ */ m(c, {
|
|
55
|
+
data: x,
|
|
56
|
+
margin: {
|
|
57
|
+
top: 5,
|
|
58
|
+
right: 20,
|
|
59
|
+
left: 0,
|
|
60
|
+
bottom: 5
|
|
61
|
+
},
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ p(a, {
|
|
64
|
+
strokeDasharray: "3 3",
|
|
65
|
+
stroke: "var(--color-border)"
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ p(o, {
|
|
68
|
+
dataKey: "at",
|
|
69
|
+
tick: { fontSize: 11 },
|
|
70
|
+
stroke: "var(--color-muted-foreground)"
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ p(s, {
|
|
73
|
+
tick: { fontSize: 11 },
|
|
74
|
+
stroke: "var(--color-muted-foreground)"
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ p(n, {
|
|
77
|
+
cursor: {
|
|
78
|
+
fill: "var(--color-muted)",
|
|
79
|
+
opacity: .2
|
|
80
|
+
},
|
|
81
|
+
contentStyle: {
|
|
82
|
+
backgroundColor: "var(--color-card)",
|
|
83
|
+
border: "1px solid var(--color-border)",
|
|
84
|
+
borderRadius: 8,
|
|
85
|
+
fontSize: 12
|
|
86
|
+
},
|
|
87
|
+
labelStyle: { color: "var(--color-foreground)" },
|
|
88
|
+
formatter: (t, n, r) => {
|
|
89
|
+
let i = r?.payload, a = (i?.byUnit ?? []).map((t) => `${e(t.quantity)} ${t.unit}`).join(", ");
|
|
90
|
+
return [e(typeof t == "number" ? t : Number(t)), v("healthybowl.livestock.feed.tooltip.cost", "Spend — {{qty}} across {{n}} records", {
|
|
91
|
+
qty: a || "—",
|
|
92
|
+
n: String(i?.records ?? 0)
|
|
93
|
+
})];
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ p(i, {
|
|
97
|
+
dataKey: "totalCost",
|
|
98
|
+
fill: "var(--color-success)",
|
|
99
|
+
radius: [
|
|
100
|
+
3,
|
|
101
|
+
3,
|
|
102
|
+
0,
|
|
103
|
+
0
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
T && /* @__PURE__ */ p("p", {
|
|
110
|
+
className: "mt-2 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary",
|
|
111
|
+
children: v("healthybowl.livestock.feed.truncated", "This herd has more records than one view can load, so the totals below cover only part of the period. Narrow the date range or filter by group for an exact figure.")
|
|
112
|
+
}),
|
|
113
|
+
S && /* @__PURE__ */ m("dl", {
|
|
114
|
+
className: "mt-3 grid grid-cols-2 gap-3 border-t border-border-subtle pt-3 sm:grid-cols-4",
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", {
|
|
117
|
+
className: "text-xs text-text-secondary",
|
|
118
|
+
children: v("healthybowl.livestock.feed.summary.spend", "Total spend")
|
|
119
|
+
}), /* @__PURE__ */ p("dd", {
|
|
120
|
+
className: "text-sm font-medium text-text-primary",
|
|
121
|
+
children: e(S.totalCost)
|
|
122
|
+
})] }),
|
|
123
|
+
/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", {
|
|
124
|
+
className: "text-xs text-text-secondary",
|
|
125
|
+
children: v("healthybowl.livestock.feed.summary.intake", "Feed used")
|
|
126
|
+
}), /* @__PURE__ */ p("dd", {
|
|
127
|
+
className: "text-sm font-medium text-text-primary",
|
|
128
|
+
children: ((t) => t === null ? v("healthybowl.livestock.feed.mixedUnits", "mixed units") : `${e(t)} kg`)(S.totalKg)
|
|
129
|
+
})] }),
|
|
130
|
+
/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", {
|
|
131
|
+
className: "text-xs text-text-secondary",
|
|
132
|
+
children: v("healthybowl.livestock.feed.summary.fcr", "Feed per kg gained")
|
|
133
|
+
}), /* @__PURE__ */ p("dd", {
|
|
134
|
+
className: "text-sm font-medium text-text-primary",
|
|
135
|
+
children: S.feedConversionRatio === null ? "—" : `${S.feedConversionRatio} kg`
|
|
136
|
+
})] }),
|
|
137
|
+
/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", {
|
|
138
|
+
className: "text-xs text-text-secondary",
|
|
139
|
+
children: v("healthybowl.livestock.feed.summary.costPerKg", "Cost per kg gained")
|
|
140
|
+
}), /* @__PURE__ */ p("dd", {
|
|
141
|
+
className: "text-sm font-medium text-text-primary",
|
|
142
|
+
children: S.costPerKgGain === null ? "—" : e(S.costPerKgGain)
|
|
143
|
+
})] })
|
|
144
|
+
]
|
|
145
|
+
}),
|
|
146
|
+
S && S.totalKg === null && S.unitsSeen.length > 1 && /* @__PURE__ */ p("p", {
|
|
147
|
+
className: "mt-2 text-xs text-text-secondary",
|
|
148
|
+
children: v("healthybowl.livestock.feed.mixedUnitsHint", "Feed was recorded in {{units}}, so it cannot be totalled by weight — spend per kilo gained still is.", { units: S.unitsSeen.join(", ") })
|
|
149
|
+
})
|
|
150
|
+
] }) : /* @__PURE__ */ m("div", {
|
|
151
|
+
className: "py-8 text-center",
|
|
152
|
+
children: [/* @__PURE__ */ p("p", {
|
|
153
|
+
className: "text-sm text-text-primary",
|
|
154
|
+
children: v("healthybowl.livestock.feed.empty.title", "No feed recorded yet")
|
|
155
|
+
}), /* @__PURE__ */ p("p", {
|
|
156
|
+
className: "mt-1 text-xs text-text-secondary",
|
|
157
|
+
children: v("healthybowl.livestock.feed.empty.hint", "Log what you feed the herd to see spend over time — and, with weights, what it costs to add a kilo.")
|
|
158
|
+
})]
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
//#endregion
|
|
163
|
+
export { g as LivestockFeedCard };
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=LivestockFeedCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LivestockFeedCard.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/LivestockFeedCard.tsx"],"sourcesContent":["/**\n * Livestock feed chart (BOFF-5971, slice 2).\n *\n * Sits under the growth card: growth shows what came out, this shows what went in and what it cost.\n *\n * Deliberate choices:\n * - **Cost is the plotted series, not quantity.** `FeedRecord.unit` is free text, so a period can\n * mix kg with bags and litres; the backend refuses to total those into kilograms and returns\n * null. Currency always sums, so spend is the one series that is honest in every workspace.\n * Quantity appears in the tooltip, per unit.\n * - **\"Mixed units\" is rendered as a statement, never as 0 kg.** A null total means the backend\n * declined to invent a number, and showing zero would misreport intake as nothing.\n * - Feed conversion is shown beside cost-per-kg-gained, because a farm buying feed in bags can\n * still act on the second even when the first is uncomputable.\n */\n\nimport { useState, type FC } from 'react';\nimport { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChartCard } from '../../components/ChartCard';\nimport { formatNumber } from '../../utils/helpers';\nimport { useHealthyBowlLivestockFeed } from '../../hooks/useHealthyBowlLivestockFeed';\nimport type { GrowthGranularity } from '../../hooks/useHealthyBowlLivestockGrowth';\n\nconst GRANULARITIES: GrowthGranularity[] = ['DAY', 'WEEK', 'MONTH'];\n\ninterface LivestockFeedCardProps {\n groupId?: string | null;\n className?: string;\n}\n\nexport const LivestockFeedCard: FC<LivestockFeedCardProps> = ({ groupId = null, className }) => {\n const { t } = useI18n();\n const [granularity, setGranularity] = useState<GrowthGranularity>('WEEK');\n const { buckets, summary, loading, error, truncated } = useHealthyBowlLivestockFeed({ groupId, granularity });\n\n const hasData = buckets.length > 0;\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.feed.granularity.${g.toLowerCase()}`, g.charAt(0) + g.slice(1).toLowerCase())}\n </button>\n ))}\n </div>\n );\n\n /** Null kg means \"units cannot be totalled\", which must never render as 0. */\n const kgLabel = (kg: number | null): string =>\n kg === null ? t('healthybowl.livestock.feed.mixedUnits', 'mixed units') : `${formatNumber(kg)} kg`;\n\n return (\n <ChartCard\n title={t('healthybowl.livestock.feed.title', 'Feed')}\n description={t(\n 'healthybowl.livestock.feed.description',\n 'What the herd ate, what it cost, and how much weight it bought.'\n )}\n actions={granularityToggle}\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.feed.error.title', 'Could not load feed data')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">{error.message}</p>\n </div>\n ) : loading && !hasData ? (\n <p className=\"py-8 text-center text-xs text-text-secondary\">\n {t('healthybowl.livestock.feed.loading', 'Loading feed data…')}\n </p>\n ) : !hasData ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.feed.empty.title', 'No feed recorded yet')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.feed.empty.hint',\n 'Log what you feed the herd to see spend over time — and, with weights, what it costs to add a kilo.'\n )}\n </p>\n </div>\n ) : (\n <>\n <ResponsiveContainer width=\"100%\" height={240}>\n <BarChart data={buckets} margin={{ top: 5, right: 20, left: 0, bottom: 5 }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--color-border)\" />\n <XAxis dataKey=\"at\" tick={{ fontSize: 11 }} stroke=\"var(--color-muted-foreground)\" />\n <YAxis tick={{ fontSize: 11 }} stroke=\"var(--color-muted-foreground)\" />\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, item: { payload?: FeedTooltipPayload }) => {\n const p = item?.payload;\n const qty = (p?.byUnit ?? []).map((u) => `${formatNumber(u.quantity)} ${u.unit}`).join(', ');\n return [\n formatNumber(typeof value === 'number' ? value : Number(value)),\n t('healthybowl.livestock.feed.tooltip.cost', 'Spend — {{qty}} across {{n}} records', {\n qty: qty || '—',\n n: String(p?.records ?? 0),\n }),\n ];\n }}\n />\n <Bar dataKey=\"totalCost\" fill=\"var(--color-success)\" radius={[3, 3, 0, 0]} />\n </BarChart>\n </ResponsiveContainer>\n\n {truncated && (\n <p className=\"mt-2 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.feed.truncated',\n 'This herd has more records than one view can load, so the totals below cover only part of the period. Narrow the date range or filter by group for an exact figure.'\n )}\n </p>\n )}\n\n {summary && (\n <dl className=\"mt-3 grid grid-cols-2 gap-3 border-t border-border-subtle pt-3 sm:grid-cols-4\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.feed.summary.spend', 'Total spend')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">{formatNumber(summary.totalCost)}</dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.feed.summary.intake', 'Feed used')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">{kgLabel(summary.totalKg)}</dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.feed.summary.fcr', 'Feed per kg gained')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.feedConversionRatio === null ? '—' : `${summary.feedConversionRatio} kg`}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.feed.summary.costPerKg', 'Cost per kg gained')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.costPerKgGain === null ? '—' : formatNumber(summary.costPerKgGain)}\n </dd>\n </div>\n </dl>\n )}\n\n {summary && summary.totalKg === null && summary.unitsSeen.length > 1 && (\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.feed.mixedUnitsHint',\n 'Feed was recorded in {{units}}, so it cannot be totalled by weight — spend per kilo gained still is.',\n { units: summary.unitsSeen.join(', ') }\n )}\n </p>\n )}\n </>\n )}\n </ChartCard>\n );\n};\n\ninterface FeedTooltipPayload {\n byUnit?: { unit: string; quantity: number }[];\n records?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,IAAM,IAAqC;CAAC;CAAO;CAAQ;CAAQ,EAOtD,KAAiD,EAAE,aAAU,MAAM,mBAAgB;CAC9F,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAa,KAAkB,EAA4B,OAAO,EACnE,EAAE,YAAS,YAAS,YAAS,UAAO,iBAAc,EAA4B;EAAE;EAAS;EAAa,CAAC,EAEvG,IAAU,EAAQ,SAAS,GAE3B,IACJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EAAc,KAAK,MAClB,kBAAC,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WAAU;gBACX,EAAE,gDAAgD,qBAAqB;MACrE,CAAA,EACL,kBAAC,MAAD;MAAI,WAAU;gBACX,EAAQ,kBAAkB,OAAO,MAAM,EAAa,EAAQ,cAAc;MACxE,CAAA,CACD,EAAA,CAAA;KACH;;GAGN,KAAW,EAAQ,YAAY,QAAQ,EAAQ,UAAU,SAAS,KACjE,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,6CACA,wGACA,EAAE,OAAO,EAAQ,UAAU,KAAK,KAAK,EAAE,CACxC;IACC,CAAA;GAEL,EAAA,CAAA,GA9FH,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cACV,EAAE,0CAA0C,uBAAuB;IAClE,CAAA,EACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,yCACA,sGACD;IACC,CAAA,CACA;;EAsFE,CAAA"}
|
|
@@ -17,15 +17,15 @@ var g = [
|
|
|
17
17
|
"WEEK",
|
|
18
18
|
"MONTH"
|
|
19
19
|
], _ = ({ groupId: _ = null, className: v }) => {
|
|
20
|
-
let { t: y } = f(), [b, x] = d("WEEK"), { herdAverage: S, summary: C, loading: w, error: T } = l({
|
|
20
|
+
let { t: y } = f(), [b, x] = d("WEEK"), { herdAverage: S, summary: C, loading: w, error: T, truncated: E } = l({
|
|
21
21
|
groupId: _,
|
|
22
22
|
granularity: b
|
|
23
|
-
}),
|
|
23
|
+
}), D = u(() => [...S].sort((e, t) => e.at.localeCompare(t.at)).map((e) => ({
|
|
24
24
|
at: e.at,
|
|
25
25
|
herd: e.avgWeightKg,
|
|
26
26
|
animalCount: e.animalCount,
|
|
27
27
|
sampleSize: e.sampleSize
|
|
28
|
-
})), [S]),
|
|
28
|
+
})), [S]), O = D.length > 0, k = /* @__PURE__ */ m("div", {
|
|
29
29
|
className: "flex items-center gap-1",
|
|
30
30
|
children: g.map((e) => /* @__PURE__ */ m("button", {
|
|
31
31
|
type: "button",
|
|
@@ -38,7 +38,7 @@ var g = [
|
|
|
38
38
|
return /* @__PURE__ */ m(t, {
|
|
39
39
|
title: y("healthybowl.livestock.growth.title", "Growth"),
|
|
40
40
|
description: y("healthybowl.livestock.growth.description", "Average herd weight over time, and how fast each animal is gaining."),
|
|
41
|
-
actions:
|
|
41
|
+
actions: k,
|
|
42
42
|
className: v,
|
|
43
43
|
children: T ? /* @__PURE__ */ h("div", {
|
|
44
44
|
className: "py-8 text-center",
|
|
@@ -49,109 +49,116 @@ var g = [
|
|
|
49
49
|
className: "mt-1 text-xs text-text-secondary",
|
|
50
50
|
children: T.message
|
|
51
51
|
})]
|
|
52
|
-
}) : w && !
|
|
52
|
+
}) : w && !O ? /* @__PURE__ */ m("p", {
|
|
53
53
|
className: "py-8 text-center text-xs text-text-secondary",
|
|
54
54
|
children: y("healthybowl.livestock.growth.loading", "Loading growth data…")
|
|
55
|
-
}) :
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
}) : O ? /* @__PURE__ */ h(p, { children: [
|
|
56
|
+
/* @__PURE__ */ m(r, {
|
|
57
|
+
width: "100%",
|
|
58
|
+
height: 280,
|
|
59
|
+
children: /* @__PURE__ */ h(c, {
|
|
60
|
+
data: D,
|
|
61
|
+
margin: {
|
|
62
|
+
top: 5,
|
|
63
|
+
right: 20,
|
|
64
|
+
left: 0,
|
|
65
|
+
bottom: 5
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ m(i, {
|
|
69
|
+
strokeDasharray: "3 3",
|
|
70
|
+
stroke: "var(--color-border)"
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ m(o, {
|
|
73
|
+
dataKey: "at",
|
|
74
|
+
tick: { fontSize: 11 },
|
|
75
|
+
stroke: "var(--color-muted-foreground)"
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ m(s, {
|
|
78
|
+
tick: { fontSize: 11 },
|
|
79
|
+
stroke: "var(--color-muted-foreground)",
|
|
80
|
+
label: {
|
|
81
|
+
value: "kg",
|
|
82
|
+
angle: -90,
|
|
83
|
+
position: "insideLeft",
|
|
84
|
+
fontSize: 11
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ m(n, {
|
|
88
|
+
contentStyle: {
|
|
89
|
+
backgroundColor: "var(--color-card)",
|
|
90
|
+
border: "1px solid var(--color-border)",
|
|
91
|
+
borderRadius: 8,
|
|
92
|
+
fontSize: 12
|
|
93
|
+
},
|
|
94
|
+
labelStyle: { color: "var(--color-foreground)" },
|
|
95
|
+
formatter: (t, n, r) => {
|
|
96
|
+
let i = typeof t == "number" ? e(t) : t;
|
|
97
|
+
if (n !== "herd") return [`${i} kg`, n];
|
|
98
|
+
let a = r?.payload?.animalCount, o = r?.payload?.sampleSize;
|
|
99
|
+
return [`${i} kg`, y("healthybowl.livestock.growth.tooltip.herd", "Herd average ({{count}} animals, {{samples}} readings)", {
|
|
100
|
+
count: String(a ?? "—"),
|
|
101
|
+
samples: String(o ?? "—")
|
|
102
|
+
})];
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ m(a, {
|
|
106
|
+
type: "monotone",
|
|
107
|
+
dataKey: "herd",
|
|
108
|
+
name: "herd",
|
|
109
|
+
stroke: "var(--color-success)",
|
|
110
|
+
strokeWidth: 2.5,
|
|
111
|
+
dot: { r: 2 },
|
|
112
|
+
connectNulls: !0
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
}),
|
|
117
|
+
E && /* @__PURE__ */ m("p", {
|
|
118
|
+
className: "mt-2 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary",
|
|
119
|
+
children: y("healthybowl.livestock.growth.truncated", "This herd has more records than one view can load, so the average above covers only the most recent. Narrow the date range or filter by group for an exact figure.")
|
|
120
|
+
}),
|
|
121
|
+
C && /* @__PURE__ */ h("dl", {
|
|
122
|
+
className: "mt-3 grid grid-cols-2 gap-3 border-t border-border-subtle pt-3 sm:grid-cols-4",
|
|
66
123
|
children: [
|
|
67
|
-
/* @__PURE__ */ m(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
/* @__PURE__ */ m(a, {
|
|
105
|
-
type: "monotone",
|
|
106
|
-
dataKey: "herd",
|
|
107
|
-
name: "herd",
|
|
108
|
-
stroke: "var(--color-success)",
|
|
109
|
-
strokeWidth: 2.5,
|
|
110
|
-
dot: { r: 2 },
|
|
111
|
-
connectNulls: !0
|
|
112
|
-
})
|
|
124
|
+
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
125
|
+
className: "text-xs text-text-secondary",
|
|
126
|
+
children: y("healthybowl.livestock.growth.summary.medianAdg", "Median gain")
|
|
127
|
+
}), /* @__PURE__ */ m("dd", {
|
|
128
|
+
className: "text-sm font-medium text-text-primary",
|
|
129
|
+
children: C.medianAdgKgPerDay === null ? "—" : `${C.medianAdgKgPerDay} kg/day`
|
|
130
|
+
})] }),
|
|
131
|
+
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
132
|
+
className: "text-xs text-text-secondary",
|
|
133
|
+
children: y("healthybowl.livestock.growth.summary.fastest", "Fastest")
|
|
134
|
+
}), /* @__PURE__ */ m("dd", {
|
|
135
|
+
className: "text-sm font-medium text-text-primary",
|
|
136
|
+
children: C.fastestGrowing ? `${C.fastestGrowing.name} · ${C.fastestGrowing.adgKgPerDay} kg/day` : "—"
|
|
137
|
+
})] }),
|
|
138
|
+
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
139
|
+
className: "text-xs text-text-secondary",
|
|
140
|
+
children: y("healthybowl.livestock.growth.summary.slowest", "Slowest")
|
|
141
|
+
}), /* @__PURE__ */ m("dd", {
|
|
142
|
+
className: "text-sm font-medium text-text-primary",
|
|
143
|
+
children: C.slowestGrowing ? `${C.slowestGrowing.name} · ${C.slowestGrowing.adgKgPerDay} kg/day` : "—"
|
|
144
|
+
})] }),
|
|
145
|
+
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
146
|
+
className: "text-xs text-text-secondary",
|
|
147
|
+
children: y("healthybowl.livestock.growth.summary.unweighed", "Not weighed")
|
|
148
|
+
}), /* @__PURE__ */ h("dd", {
|
|
149
|
+
className: "text-sm font-medium text-text-primary",
|
|
150
|
+
children: [C.animalsWithoutWeights, /* @__PURE__ */ h("span", {
|
|
151
|
+
className: "text-xs text-text-secondary",
|
|
152
|
+
children: [
|
|
153
|
+
" ",
|
|
154
|
+
"/ ",
|
|
155
|
+
C.animalsWithWeights + C.animalsWithoutWeights
|
|
156
|
+
]
|
|
157
|
+
})]
|
|
158
|
+
})] })
|
|
113
159
|
]
|
|
114
160
|
})
|
|
115
|
-
})
|
|
116
|
-
className: "mt-3 grid grid-cols-2 gap-3 border-t border-border-subtle pt-3 sm:grid-cols-4",
|
|
117
|
-
children: [
|
|
118
|
-
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
119
|
-
className: "text-xs text-text-secondary",
|
|
120
|
-
children: y("healthybowl.livestock.growth.summary.medianAdg", "Median gain")
|
|
121
|
-
}), /* @__PURE__ */ m("dd", {
|
|
122
|
-
className: "text-sm font-medium text-text-primary",
|
|
123
|
-
children: C.medianAdgKgPerDay === null ? "—" : `${C.medianAdgKgPerDay} kg/day`
|
|
124
|
-
})] }),
|
|
125
|
-
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
126
|
-
className: "text-xs text-text-secondary",
|
|
127
|
-
children: y("healthybowl.livestock.growth.summary.fastest", "Fastest")
|
|
128
|
-
}), /* @__PURE__ */ m("dd", {
|
|
129
|
-
className: "text-sm font-medium text-text-primary",
|
|
130
|
-
children: C.fastestGrowing ? `${C.fastestGrowing.name} · ${C.fastestGrowing.adgKgPerDay} kg/day` : "—"
|
|
131
|
-
})] }),
|
|
132
|
-
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
133
|
-
className: "text-xs text-text-secondary",
|
|
134
|
-
children: y("healthybowl.livestock.growth.summary.slowest", "Slowest")
|
|
135
|
-
}), /* @__PURE__ */ m("dd", {
|
|
136
|
-
className: "text-sm font-medium text-text-primary",
|
|
137
|
-
children: C.slowestGrowing ? `${C.slowestGrowing.name} · ${C.slowestGrowing.adgKgPerDay} kg/day` : "—"
|
|
138
|
-
})] }),
|
|
139
|
-
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", {
|
|
140
|
-
className: "text-xs text-text-secondary",
|
|
141
|
-
children: y("healthybowl.livestock.growth.summary.unweighed", "Not weighed")
|
|
142
|
-
}), /* @__PURE__ */ h("dd", {
|
|
143
|
-
className: "text-sm font-medium text-text-primary",
|
|
144
|
-
children: [C.animalsWithoutWeights, /* @__PURE__ */ h("span", {
|
|
145
|
-
className: "text-xs text-text-secondary",
|
|
146
|
-
children: [
|
|
147
|
-
" ",
|
|
148
|
-
"/ ",
|
|
149
|
-
C.animalsWithWeights + C.animalsWithoutWeights
|
|
150
|
-
]
|
|
151
|
-
})]
|
|
152
|
-
})] })
|
|
153
|
-
]
|
|
154
|
-
})] }) : /* @__PURE__ */ h("div", {
|
|
161
|
+
] }) : /* @__PURE__ */ h("div", {
|
|
155
162
|
className: "py-8 text-center",
|
|
156
163
|
children: [/* @__PURE__ */ m("p", {
|
|
157
164
|
className: "text-sm text-text-primary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivestockGrowthCard.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/LivestockGrowthCard.tsx"],"sourcesContent":["/**\n * Livestock growth chart (BOFF-5971).\n *\n * Plots the herd-average weight line from `healthyBowlLivestockGrowth`, with the ADG leaders and\n * the coverage gap beside it.\n *\n * Deliberate choices:\n * - Only the herd-average line is plotted. Per-animal curves were tried and pulled: herd points\n * are keyed by BUCKET START (Monday, for WEEK) while a weight is keyed by its measurement date,\n * so the two only align at DAY granularity — everywhere else the curves land on separate rows.\n * Bucketing the animal points here would duplicate the Monday-start rule that deliberately\n * lives in exactly one place (`livestock-depth/growth.ts`). The overlay returns when the chart\n * moves to a numeric time axis, or when the API carries a bucket key per point.\n * - `animalCount` / `sampleSize` ride in the tooltip. The backend averages each animal to itself\n * before averaging the herd, so a bucket built from one animal is honest but thin — the user\n * should be able to see that rather than read it as a solid trend.\n * - A query error is surfaced as an error, never as the empty state: \"no weights recorded\" is a\n * statement about the farm, and it must not be shown when the truth is \"we could not load\".\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChartCard } from '../../components/ChartCard';\nimport { formatNumber } from '../../utils/helpers';\nimport { useHealthyBowlLivestockGrowth, type GrowthGranularity } from '../../hooks/useHealthyBowlLivestockGrowth';\n\nconst GRANULARITIES: GrowthGranularity[] = ['DAY', 'WEEK', 'MONTH'];\n\ninterface LivestockGrowthCardProps {\n groupId?: string | null;\n className?: string;\n}\n\nexport const LivestockGrowthCard: FC<LivestockGrowthCardProps> = ({ groupId = null, className }) => {\n const { t } = useI18n();\n const [granularity, setGranularity] = useState<GrowthGranularity>('WEEK');\n const { herdAverage, summary, loading, error } = useHealthyBowlLivestockGrowth({ groupId, granularity });\n\n const chartData = useMemo(\n () =>\n [...herdAverage]\n .sort((a, b) => a.at.localeCompare(b.at))\n .map((p) => ({\n at: p.at,\n herd: p.avgWeightKg,\n animalCount: p.animalCount,\n sampleSize: p.sampleSize,\n })),\n [herdAverage]\n );\n\n const hasData = chartData.length > 0;\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.growth.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.growth.title', 'Growth')}\n description={t(\n 'healthybowl.livestock.growth.description',\n 'Average herd weight over time, and how fast each animal is gaining.'\n )}\n actions={granularityToggle}\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.growth.error.title', 'Could not load growth data')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">{error.message}</p>\n </div>\n ) : loading && !hasData ? (\n <p className=\"py-8 text-center text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.loading', 'Loading growth data…')}\n </p>\n ) : !hasData ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.growth.empty.title', 'No weights recorded yet')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.growth.empty.hint',\n 'Record a weight against an animal — two measurements are enough to show a growth rate.'\n )}\n </p>\n </div>\n ) : (\n <>\n <ResponsiveContainer width=\"100%\" height={280}>\n <LineChart data={chartData} margin={{ top: 5, right: 20, left: 0, bottom: 5 }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--color-border)\" />\n <XAxis dataKey=\"at\" tick={{ fontSize: 11 }} stroke=\"var(--color-muted-foreground)\" />\n <YAxis\n tick={{ fontSize: 11 }}\n stroke=\"var(--color-muted-foreground)\"\n label={{ value: 'kg', angle: -90, position: 'insideLeft', fontSize: 11 }}\n />\n <Tooltip\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, item: { payload?: Record<string, unknown> }) => {\n const kg = typeof value === 'number' ? formatNumber(value) : value;\n if (name !== 'herd') return [`${kg} kg`, name];\n const count = item?.payload?.['animalCount'];\n const samples = item?.payload?.['sampleSize'];\n return [\n `${kg} kg`,\n t(\n 'healthybowl.livestock.growth.tooltip.herd',\n 'Herd average ({{count}} animals, {{samples}} readings)',\n {\n count: String(count ?? '—'),\n samples: String(samples ?? '—'),\n }\n ),\n ];\n }}\n />\n <Line\n type=\"monotone\"\n dataKey=\"herd\"\n name=\"herd\"\n stroke=\"var(--color-success)\"\n strokeWidth={2.5}\n dot={{ r: 2 }}\n connectNulls\n />\n </LineChart>\n </ResponsiveContainer>\n\n {summary && (\n <dl className=\"mt-3 grid grid-cols-2 gap-3 border-t border-border-subtle pt-3 sm:grid-cols-4\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.medianAdg', 'Median gain')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.medianAdgKgPerDay === null ? '—' : `${summary.medianAdgKgPerDay} kg/day`}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.fastest', 'Fastest')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.fastestGrowing\n ? `${summary.fastestGrowing.name} · ${summary.fastestGrowing.adgKgPerDay} kg/day`\n : '—'}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.slowest', 'Slowest')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.slowestGrowing\n ? `${summary.slowestGrowing.name} · ${summary.slowestGrowing.adgKgPerDay} kg/day`\n : '—'}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.unweighed', 'Not weighed')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.animalsWithoutWeights}\n <span className=\"text-xs text-text-secondary\">\n {' '}\n / {summary.animalsWithWeights + summary.animalsWithoutWeights}\n </span>\n </dd>\n </div>\n </dl>\n )}\n </>\n )}\n </ChartCard>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA2BA,IAAM,IAAqC;CAAC;CAAO;CAAQ;CAAQ,EAOtD,KAAqD,EAAE,aAAU,MAAM,mBAAgB;CAClG,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAa,KAAkB,EAA4B,OAAO,EACnE,EAAE,gBAAa,YAAS,YAAS,aAAU,EAA8B;EAAE;EAAS;EAAa,CAAC,EAElG,IAAY,QAEd,CAAC,GAAG,EAAY,CACb,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,EAAE,GAAG,CAAC,CACxC,KAAK,OAAO;EACX,IAAI,EAAE;EACN,MAAM,EAAE;EACR,aAAa,EAAE;EACf,YAAY,EAAE;EACf,EAAE,EACP,CAAC,EAAY,CACd,EAEK,IAAU,EAAU,SAAS,GAE7B,IACJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EAAc,KAAK,MAClB,kBAAC,UAAD;GAEE,MAAK;GACL,eAAe,EAAe,EAAE;GAChC,gBAAc,MAAgB;GAC9B,WAAW,+DACT,MAAgB,IACZ,kDACA;aAGL,EAAE,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AAI;OACF,EAAQ,qBAAqB,EAAQ;OACnC;QACJ;OACD,EAAA,CAAA;IACH;KAEN,EAAA,CAAA,GAxGH,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cACV,EAAE,4CAA4C,0BAA0B;IACvE,CAAA,EACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,2CACA,yFACD;IACC,CAAA,CACA;;EAgGE,CAAA"}
|
|
1
|
+
{"version":3,"file":"LivestockGrowthCard.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/LivestockGrowthCard.tsx"],"sourcesContent":["/**\n * Livestock growth chart (BOFF-5971).\n *\n * Plots the herd-average weight line from `healthyBowlLivestockGrowth`, with the ADG leaders and\n * the coverage gap beside it.\n *\n * Deliberate choices:\n * - Only the herd-average line is plotted. Per-animal curves were tried and pulled: herd points\n * are keyed by BUCKET START (Monday, for WEEK) while a weight is keyed by its measurement date,\n * so the two only align at DAY granularity — everywhere else the curves land on separate rows.\n * Bucketing the animal points here would duplicate the Monday-start rule that deliberately\n * lives in exactly one place (`livestock-depth/growth.ts`). The overlay returns when the chart\n * moves to a numeric time axis, or when the API carries a bucket key per point.\n * - `animalCount` / `sampleSize` ride in the tooltip. The backend averages each animal to itself\n * before averaging the herd, so a bucket built from one animal is honest but thin — the user\n * should be able to see that rather than read it as a solid trend.\n * - A query error is surfaced as an error, never as the empty state: \"no weights recorded\" is a\n * statement about the farm, and it must not be shown when the truth is \"we could not load\".\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChartCard } from '../../components/ChartCard';\nimport { formatNumber } from '../../utils/helpers';\nimport { useHealthyBowlLivestockGrowth, type GrowthGranularity } from '../../hooks/useHealthyBowlLivestockGrowth';\n\nconst GRANULARITIES: GrowthGranularity[] = ['DAY', 'WEEK', 'MONTH'];\n\ninterface LivestockGrowthCardProps {\n groupId?: string | null;\n className?: string;\n}\n\nexport const LivestockGrowthCard: FC<LivestockGrowthCardProps> = ({ groupId = null, className }) => {\n const { t } = useI18n();\n const [granularity, setGranularity] = useState<GrowthGranularity>('WEEK');\n const { herdAverage, summary, loading, error, truncated } = useHealthyBowlLivestockGrowth({ groupId, granularity });\n\n const chartData = useMemo(\n () =>\n [...herdAverage]\n .sort((a, b) => a.at.localeCompare(b.at))\n .map((p) => ({\n at: p.at,\n herd: p.avgWeightKg,\n animalCount: p.animalCount,\n sampleSize: p.sampleSize,\n })),\n [herdAverage]\n );\n\n const hasData = chartData.length > 0;\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.growth.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.growth.title', 'Growth')}\n description={t(\n 'healthybowl.livestock.growth.description',\n 'Average herd weight over time, and how fast each animal is gaining.'\n )}\n actions={granularityToggle}\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.growth.error.title', 'Could not load growth data')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">{error.message}</p>\n </div>\n ) : loading && !hasData ? (\n <p className=\"py-8 text-center text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.loading', 'Loading growth data…')}\n </p>\n ) : !hasData ? (\n <div className=\"py-8 text-center\">\n <p className=\"text-sm text-text-primary\">\n {t('healthybowl.livestock.growth.empty.title', 'No weights recorded yet')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.growth.empty.hint',\n 'Record a weight against an animal — two measurements are enough to show a growth rate.'\n )}\n </p>\n </div>\n ) : (\n <>\n <ResponsiveContainer width=\"100%\" height={280}>\n <LineChart data={chartData} margin={{ top: 5, right: 20, left: 0, bottom: 5 }}>\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"var(--color-border)\" />\n <XAxis dataKey=\"at\" tick={{ fontSize: 11 }} stroke=\"var(--color-muted-foreground)\" />\n <YAxis\n tick={{ fontSize: 11 }}\n stroke=\"var(--color-muted-foreground)\"\n label={{ value: 'kg', angle: -90, position: 'insideLeft', fontSize: 11 }}\n />\n <Tooltip\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, item: { payload?: Record<string, unknown> }) => {\n const kg = typeof value === 'number' ? formatNumber(value) : value;\n if (name !== 'herd') return [`${kg} kg`, name];\n const count = item?.payload?.['animalCount'];\n const samples = item?.payload?.['sampleSize'];\n return [\n `${kg} kg`,\n t(\n 'healthybowl.livestock.growth.tooltip.herd',\n 'Herd average ({{count}} animals, {{samples}} readings)',\n {\n count: String(count ?? '—'),\n samples: String(samples ?? '—'),\n }\n ),\n ];\n }}\n />\n <Line\n type=\"monotone\"\n dataKey=\"herd\"\n name=\"herd\"\n stroke=\"var(--color-success)\"\n strokeWidth={2.5}\n dot={{ r: 2 }}\n connectNulls\n />\n </LineChart>\n </ResponsiveContainer>\n\n {truncated && (\n <p className=\"mt-2 rounded-md bg-bg-sunken/60 px-3 py-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.growth.truncated',\n 'This herd has more records than one view can load, so the average above covers only the most recent. Narrow the date range or filter by group for an exact figure.'\n )}\n </p>\n )}\n\n {summary && (\n <dl className=\"mt-3 grid grid-cols-2 gap-3 border-t border-border-subtle pt-3 sm:grid-cols-4\">\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.medianAdg', 'Median gain')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.medianAdgKgPerDay === null ? '—' : `${summary.medianAdgKgPerDay} kg/day`}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.fastest', 'Fastest')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.fastestGrowing\n ? `${summary.fastestGrowing.name} · ${summary.fastestGrowing.adgKgPerDay} kg/day`\n : '—'}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.slowest', 'Slowest')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.slowestGrowing\n ? `${summary.slowestGrowing.name} · ${summary.slowestGrowing.adgKgPerDay} kg/day`\n : '—'}\n </dd>\n </div>\n <div>\n <dt className=\"text-xs text-text-secondary\">\n {t('healthybowl.livestock.growth.summary.unweighed', 'Not weighed')}\n </dt>\n <dd className=\"text-sm font-medium text-text-primary\">\n {summary.animalsWithoutWeights}\n <span className=\"text-xs text-text-secondary\">\n {' '}\n / {summary.animalsWithWeights + summary.animalsWithoutWeights}\n </span>\n </dd>\n </div>\n </dl>\n )}\n </>\n )}\n </ChartCard>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA2BA,IAAM,IAAqC;CAAC;CAAO;CAAQ;CAAQ,EAOtD,KAAqD,EAAE,aAAU,MAAM,mBAAgB;CAClG,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAa,KAAkB,EAA4B,OAAO,EACnE,EAAE,gBAAa,YAAS,YAAS,UAAO,iBAAc,EAA8B;EAAE;EAAS;EAAa,CAAC,EAE7G,IAAY,QAEd,CAAC,GAAG,EAAY,CACb,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc,EAAE,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AAD,EAAA,UAAA,CACE,kBAAC,MAAD;MAAI,WAAU;gBACX,EAAE,gDAAgD,UAAU;MAC1D,CAAA,EACL,kBAAC,MAAD;MAAI,WAAU;gBACX,EAAQ,iBACL,GAAG,EAAQ,eAAe,KAAK,KAAK,EAAQ,eAAe,YAAY,WACvE;MACD,CAAA,CACD,EAAA,CAAA;KACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;MAAI,WAAU;gBACX,EAAE,kDAAkD,cAAc;MAChE,CAAA,EACL,kBAAC,MAAD;MAAI,WAAU;gBAAd,CACG,EAAQ,uBACT,kBAAC,QAAD;OAAM,WAAU;iBAAhB;QACG;QAAI;QACF,EAAQ,qBAAqB,EAAQ;QACnC;SACJ;QACD,EAAA,CAAA;KACH;;GAEN,EAAA,CAAA,GAjHH,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cACV,EAAE,4CAA4C,0BAA0B;IACvE,CAAA,EACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,2CACA,yFACD;IACC,CAAA,CACA;;EAyGE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-healthybowl",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.805.2",
|
|
4
4
|
"description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"zustand": "^5.0.0"
|
|
111
111
|
},
|
|
112
112
|
"publishConfig": {
|
|
113
|
-
"access": "
|
|
113
|
+
"access": "public"
|
|
114
114
|
},
|
|
115
115
|
"overrides": {
|
|
116
116
|
"lodash": ">=4.17.21",
|