@burdenoff/microfe-healthybowl 2026.714.2 → 2026.714.4
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/HealthyBowlRoutes.js +149 -109
- package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
- package/dist/healthybowl/hooks/useHealthyBowlContacts.js +149 -0
- package/dist/healthybowl/hooks/useHealthyBowlContacts.js.map +1 -0
- package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js +200 -0
- package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js.map +1 -0
- package/dist/healthybowl/hooks/useHealthyBowlStorage.js +162 -0
- package/dist/healthybowl/hooks/useHealthyBowlStorage.js.map +1 -0
- package/dist/healthybowl/pages/contacts/ContactDetailPage.js +224 -0
- package/dist/healthybowl/pages/contacts/ContactDetailPage.js.map +1 -0
- package/dist/healthybowl/pages/contacts/ContactFormModal.js +147 -0
- package/dist/healthybowl/pages/contacts/ContactFormModal.js.map +1 -0
- package/dist/healthybowl/pages/contacts/ContactsPage.js +241 -0
- package/dist/healthybowl/pages/contacts/ContactsPage.js.map +1 -0
- package/dist/healthybowl/pages/contacts/CsvImportModal.js +155 -0
- package/dist/healthybowl/pages/contacts/CsvImportModal.js.map +1 -0
- package/dist/healthybowl/pages/contacts/RecordOrderModal.js +131 -0
- package/dist/healthybowl/pages/contacts/RecordOrderModal.js.map +1 -0
- package/dist/healthybowl/pages/contacts/labels.js +46 -0
- package/dist/healthybowl/pages/contacts/labels.js.map +1 -0
- package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js +152 -0
- package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js.map +1 -0
- package/dist/healthybowl/pages/livestock/AnimalDepthPage.js +245 -0
- package/dist/healthybowl/pages/livestock/AnimalDepthPage.js.map +1 -0
- package/dist/healthybowl/pages/livestock/AnimalGroupModal.js +210 -0
- package/dist/healthybowl/pages/livestock/AnimalGroupModal.js.map +1 -0
- package/dist/healthybowl/pages/livestock/HerdDepthPage.js +189 -0
- package/dist/healthybowl/pages/livestock/HerdDepthPage.js.map +1 -0
- package/dist/healthybowl/pages/livestock/RecordWeightModal.js +100 -0
- package/dist/healthybowl/pages/livestock/RecordWeightModal.js.map +1 -0
- package/dist/healthybowl/pages/livestock/depthLabels.js +31 -0
- package/dist/healthybowl/pages/livestock/depthLabels.js.map +1 -0
- package/dist/healthybowl/pages/satellite/CropHealthAlertsPage.js +188 -0
- package/dist/healthybowl/pages/satellite/CropHealthAlertsPage.js.map +1 -0
- package/dist/healthybowl/pages/satellite/NdviComparePanel.js +196 -0
- package/dist/healthybowl/pages/satellite/NdviComparePanel.js.map +1 -0
- package/dist/healthybowl/pages/satellite/NdviGridThumbnail.js +44 -0
- package/dist/healthybowl/pages/satellite/NdviGridThumbnail.js.map +1 -0
- package/dist/healthybowl/pages/satellite/NdviHeatmapMap.js +144 -0
- package/dist/healthybowl/pages/satellite/NdviHeatmapMap.js.map +1 -0
- package/dist/healthybowl/pages/satellite/SatelliteCropHealthPage.js +278 -0
- package/dist/healthybowl/pages/satellite/SatelliteCropHealthPage.js.map +1 -0
- package/dist/healthybowl/pages/satellite/SatelliteFieldDetailPage.js +447 -0
- package/dist/healthybowl/pages/satellite/SatelliteFieldDetailPage.js.map +1 -0
- package/dist/healthybowl/pages/satellite/SatelliteSettingsPage.js +252 -0
- package/dist/healthybowl/pages/satellite/SatelliteSettingsPage.js.map +1 -0
- package/dist/healthybowl/pages/satellite/YieldReportPanel.js +236 -0
- package/dist/healthybowl/pages/satellite/YieldReportPanel.js.map +1 -0
- package/dist/healthybowl/pages/satellite/YieldSimulationPanel.js +363 -0
- package/dist/healthybowl/pages/satellite/YieldSimulationPanel.js.map +1 -0
- package/dist/healthybowl/pages/satellite/ndviColors.js +116 -0
- package/dist/healthybowl/pages/satellite/ndviColors.js.map +1 -0
- package/dist/healthybowl/pages/satellite/satelliteApi.js +191 -0
- package/dist/healthybowl/pages/satellite/satelliteApi.js.map +1 -0
- package/dist/healthybowl/pages/satellite/useSatelliteApi.js +15 -0
- package/dist/healthybowl/pages/satellite/useSatelliteApi.js.map +1 -0
- package/dist/healthybowl/pages/storage/PlaceLotModal.js +150 -0
- package/dist/healthybowl/pages/storage/PlaceLotModal.js.map +1 -0
- package/dist/healthybowl/pages/storage/RecordMovementModal.js +140 -0
- package/dist/healthybowl/pages/storage/RecordMovementModal.js.map +1 -0
- package/dist/healthybowl/pages/storage/StorageLocationFormModal.js +139 -0
- package/dist/healthybowl/pages/storage/StorageLocationFormModal.js.map +1 -0
- package/dist/healthybowl/pages/storage/StorageLotDetailPage.js +150 -0
- package/dist/healthybowl/pages/storage/StorageLotDetailPage.js.map +1 -0
- package/dist/healthybowl/pages/storage/StoragePage.js +251 -0
- package/dist/healthybowl/pages/storage/StoragePage.js.map +1 -0
- package/dist/healthybowl/pages/storage/labels.js +67 -0
- package/dist/healthybowl/pages/storage/labels.js.map +1 -0
- package/dist/node_modules/recharts/es6/cartesian/Scatter.js +368 -0
- package/dist/node_modules/recharts/es6/cartesian/Scatter.js.map +1 -0
- package/dist/node_modules/recharts/es6/cartesian/ZAxis.js +103 -0
- package/dist/node_modules/recharts/es6/cartesian/ZAxis.js.map +1 -0
- package/dist/node_modules/recharts/es6/chart/ComposedChart.js +38 -0
- package/dist/node_modules/recharts/es6/chart/ComposedChart.js.map +1 -0
- package/dist/node_modules/recharts/es6/util/DataUtils.js +12 -2
- package/dist/node_modules/recharts/es6/util/DataUtils.js.map +1 -1
- package/dist/node_modules/recharts/es6/util/ScatterUtils.js +48 -0
- package/dist/node_modules/recharts/es6/util/ScatterUtils.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { useBasePath as e } from "../../hooks/useBasePath.js";
|
|
2
|
+
import { PageLayout as t } from "../../components/PageLayout.js";
|
|
3
|
+
import { StatCard as n } from "../../components/StatCard.js";
|
|
4
|
+
import { DataTable as r } from "../../components/DataTable.js";
|
|
5
|
+
import { StatusBadge as i } from "../../components/StatusBadge.js";
|
|
6
|
+
import { EmptyState as a } from "../../components/EmptyState.js";
|
|
7
|
+
import { ErrorState as o } from "../../components/ErrorState.js";
|
|
8
|
+
import { PageLoader as s } from "../../components/PageLoader.js";
|
|
9
|
+
import "../../components/index.js";
|
|
10
|
+
import { useHealthyBowlLivestockDepth as c } from "../../hooks/useHealthyBowlLivestockDepth.js";
|
|
11
|
+
import { formatAdg as l, formatBcs as u, formatShortDate as d, withdrawalBadgeVariant as f } from "./depthLabels.js";
|
|
12
|
+
import { AnimalGroupModal as p } from "./AnimalGroupModal.js";
|
|
13
|
+
import { useState as m } from "react";
|
|
14
|
+
import { useI18n as h } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
15
|
+
import { AlertTriangle as g, Network as _, Settings2 as v, ShieldCheck as y, Users as b } from "lucide-react";
|
|
16
|
+
import { useNavigate as x } from "react-router-dom";
|
|
17
|
+
import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
18
|
+
import { Button as T, Input as E } from "@burdenoff/fe-libs/ui";
|
|
19
|
+
//#region src/healthybowl/pages/livestock/HerdDepthPage.tsx
|
|
20
|
+
var D = () => {
|
|
21
|
+
let { t: D } = h(), O = x(), { buildPath: k } = e(), [A, j] = m(null), [M, N] = m(""), [P, F] = m(!1), { herd: I, loading: L, errors: R, refetchHerd: z } = c({
|
|
22
|
+
herd: !0,
|
|
23
|
+
herdGroupId: A,
|
|
24
|
+
herdSearch: M.trim() || null
|
|
25
|
+
}), B = I?.rows ?? [], V = I?.summary, H = I?.groups ?? [], U = [
|
|
26
|
+
{
|
|
27
|
+
key: "tag",
|
|
28
|
+
header: D("healthybowl.livestock.depth.table.tag", "Tag / EID"),
|
|
29
|
+
render: (e) => /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("div", {
|
|
30
|
+
className: "font-medium text-text-primary",
|
|
31
|
+
children: e.tagNumber
|
|
32
|
+
}), e.eidTag ? /* @__PURE__ */ C("div", {
|
|
33
|
+
className: "text-xs text-text-secondary tabular-nums",
|
|
34
|
+
children: e.eidTag
|
|
35
|
+
}) : null] })
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: "animal",
|
|
39
|
+
header: D("healthybowl.livestock.depth.table.animal", "Animal"),
|
|
40
|
+
render: (e) => /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("div", {
|
|
41
|
+
className: "text-text-primary",
|
|
42
|
+
children: e.name
|
|
43
|
+
}), /* @__PURE__ */ C("div", {
|
|
44
|
+
className: "text-xs text-text-secondary",
|
|
45
|
+
children: e.type
|
|
46
|
+
})] })
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "group",
|
|
50
|
+
header: D("healthybowl.livestock.depth.table.group", "Group"),
|
|
51
|
+
render: (e) => /* @__PURE__ */ C("span", {
|
|
52
|
+
className: "text-text-primary",
|
|
53
|
+
children: e.groupName ?? "—"
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "bcs",
|
|
58
|
+
header: D("healthybowl.livestock.depth.table.bcs", "Body Condition"),
|
|
59
|
+
render: (e) => /* @__PURE__ */ C("span", {
|
|
60
|
+
className: "tabular-nums text-text-primary",
|
|
61
|
+
children: u(e.bodyConditionScore)
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "withdrawal",
|
|
66
|
+
header: D("healthybowl.livestock.depth.table.withdrawal", "Med. Withdrawal Ends"),
|
|
67
|
+
render: (e) => e.withdrawal.blocked ? /* @__PURE__ */ C(i, {
|
|
68
|
+
variant: f(e.withdrawal.status),
|
|
69
|
+
label: D("healthybowl.livestock.depth.table.withdrawalEnds", "Withdrawal ends {{date}}", { date: d(e.withdrawal.endDate) }),
|
|
70
|
+
dot: !0
|
|
71
|
+
}) : /* @__PURE__ */ C("span", {
|
|
72
|
+
className: "text-text-secondary",
|
|
73
|
+
children: D("healthybowl.livestock.depth.table.none", "none")
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "adg",
|
|
78
|
+
header: D("healthybowl.livestock.depth.table.adg", "ADG"),
|
|
79
|
+
render: (e) => /* @__PURE__ */ C("span", {
|
|
80
|
+
className: "tabular-nums text-text-primary",
|
|
81
|
+
children: l(e.adgKgPerDay)
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
return L.herd && !I ? /* @__PURE__ */ C(s, {}) : /* @__PURE__ */ w(t, {
|
|
86
|
+
title: D("healthybowl.livestock.depth.title", "Livestock Records"),
|
|
87
|
+
titleAccent: D("healthybowl.livestock.depth.titleAccent", "Records"),
|
|
88
|
+
description: D("healthybowl.livestock.depth.description", "Deep herd view — body condition, groups, ear-tag/EID, genealogy, ADG and medication-withdrawal compliance."),
|
|
89
|
+
actions: /* @__PURE__ */ w(T, {
|
|
90
|
+
variant: "outline",
|
|
91
|
+
onClick: () => F(!0),
|
|
92
|
+
children: [/* @__PURE__ */ C(v, { className: "h-4 w-4" }), D("healthybowl.livestock.depth.groups.manageAction", "Manage Groups")]
|
|
93
|
+
}),
|
|
94
|
+
children: [R.herd && !I ? /* @__PURE__ */ C(o, {
|
|
95
|
+
description: R.herd.message,
|
|
96
|
+
onRetry: () => void z()
|
|
97
|
+
}) : /* @__PURE__ */ w(S, { children: [
|
|
98
|
+
V && V.animalsInWithdrawal > 0 ? /* @__PURE__ */ w("div", {
|
|
99
|
+
role: "alert",
|
|
100
|
+
className: "mt-4 flex items-center gap-3 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-status-error-text",
|
|
101
|
+
children: [/* @__PURE__ */ C(g, { className: "h-5 w-5 shrink-0" }), /* @__PURE__ */ C("span", {
|
|
102
|
+
className: "text-sm font-semibold",
|
|
103
|
+
children: V.complianceMessage
|
|
104
|
+
})]
|
|
105
|
+
}) : null,
|
|
106
|
+
/* @__PURE__ */ w("div", {
|
|
107
|
+
className: "mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ C(n, {
|
|
110
|
+
label: D("healthybowl.livestock.depth.stats.total", "Animals"),
|
|
111
|
+
value: V?.totalAnimals ?? 0,
|
|
112
|
+
icon: /* @__PURE__ */ C(b, { className: "h-5 w-5" }),
|
|
113
|
+
hero: !0
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ C(n, {
|
|
116
|
+
label: D("healthybowl.livestock.depth.stats.withdrawal", "In withdrawal"),
|
|
117
|
+
value: V?.animalsInWithdrawal ?? 0,
|
|
118
|
+
icon: /* @__PURE__ */ C(g, { className: "h-5 w-5" })
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ C(n, {
|
|
121
|
+
label: D("healthybowl.livestock.depth.stats.clear", "Clear to sell"),
|
|
122
|
+
value: V?.animalsClear ?? 0,
|
|
123
|
+
icon: /* @__PURE__ */ C(y, { className: "h-5 w-5" })
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ w("div", {
|
|
128
|
+
className: "mt-4 flex flex-wrap items-center gap-2",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ C("button", {
|
|
131
|
+
type: "button",
|
|
132
|
+
onClick: () => j(null),
|
|
133
|
+
className: `rounded-full px-3 py-1 text-sm ${A === null ? "bg-accent-teal text-white" : "bg-bg-sunken text-text-secondary"}`,
|
|
134
|
+
children: D("healthybowl.livestock.depth.groups.all", "All groups")
|
|
135
|
+
}),
|
|
136
|
+
H.map((e) => /* @__PURE__ */ w("button", {
|
|
137
|
+
type: "button",
|
|
138
|
+
onClick: () => j(e.id),
|
|
139
|
+
className: `flex items-center gap-1 rounded-full px-3 py-1 text-sm ${A === e.id ? "bg-accent-teal text-white" : "bg-bg-sunken text-text-secondary"}`,
|
|
140
|
+
children: [
|
|
141
|
+
e.kind === "SMART" ? /* @__PURE__ */ C(_, { className: "h-3.5 w-3.5" }) : null,
|
|
142
|
+
e.name,
|
|
143
|
+
/* @__PURE__ */ w("span", {
|
|
144
|
+
className: "tabular-nums opacity-80",
|
|
145
|
+
children: [
|
|
146
|
+
"(",
|
|
147
|
+
e.animalCount,
|
|
148
|
+
")"
|
|
149
|
+
]
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
}, e.id)),
|
|
153
|
+
/* @__PURE__ */ C("div", {
|
|
154
|
+
className: "ml-auto w-full sm:w-64",
|
|
155
|
+
children: /* @__PURE__ */ C(E, {
|
|
156
|
+
value: M,
|
|
157
|
+
onChange: (e) => N(e.target.value),
|
|
158
|
+
placeholder: D("healthybowl.livestock.depth.searchPlaceholder", "Search tag, name or EID…")
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
B.length === 0 ? /* @__PURE__ */ C(a, {
|
|
164
|
+
icon: /* @__PURE__ */ C(b, { className: "h-8 w-8 text-text-secondary" }),
|
|
165
|
+
title: D("healthybowl.livestock.depth.empty.title", "No animals to show"),
|
|
166
|
+
description: D("healthybowl.livestock.depth.empty.description", "Register animals in the Livestock module, then their deep records appear here."),
|
|
167
|
+
action: /* @__PURE__ */ C(T, {
|
|
168
|
+
variant: "outline",
|
|
169
|
+
onClick: () => O(k("livestock/animals")),
|
|
170
|
+
children: D("healthybowl.livestock.depth.empty.action", "Go to Animal Registry")
|
|
171
|
+
})
|
|
172
|
+
}) : /* @__PURE__ */ C(r, {
|
|
173
|
+
columns: U,
|
|
174
|
+
data: B,
|
|
175
|
+
keyField: "animalId",
|
|
176
|
+
pageSize: 12,
|
|
177
|
+
onRowClick: (e) => O(k(`livestock/records/${e.animalId}`))
|
|
178
|
+
})
|
|
179
|
+
] }), /* @__PURE__ */ C(p, {
|
|
180
|
+
open: P,
|
|
181
|
+
onClose: () => F(!1),
|
|
182
|
+
onChanged: () => void z()
|
|
183
|
+
})]
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
//#endregion
|
|
187
|
+
export { D as HerdDepthPage };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=HerdDepthPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HerdDepthPage.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/HerdDepthPage.tsx"],"sourcesContent":["/**\n * Deep herd records view (BOFF-2890 · L-1).\n * One row per animal with group, body-condition score, medication-withdrawal end-date and ADG,\n * plus a red \"do not sell milk or meat\" compliance banner whenever any animal is inside its\n * withdrawal window. Every value is a real record from the backend — no fabricated data.\n */\nimport { useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { AlertTriangle, Network, Settings2, ShieldCheck, Users } from 'lucide-react';\nimport { Button, Input } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout, StatCard, DataTable, StatusBadge, EmptyState, ErrorState, PageLoader } from '../../components';\nimport type { Column } from '../../components';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlLivestockDepth, type HerdDepthRow } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { formatAdg, formatBcs, formatShortDate, withdrawalBadgeVariant } from './depthLabels';\nimport { AnimalGroupModal } from './AnimalGroupModal';\n\nexport const HerdDepthPage = () => {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n\n const [groupId, setGroupId] = useState<string | null>(null);\n const [search, setSearch] = useState('');\n const [groupsOpen, setGroupsOpen] = useState(false);\n\n const { herd, loading, errors, refetchHerd } = useHealthyBowlLivestockDepth({\n herd: true,\n herdGroupId: groupId,\n herdSearch: search.trim() || null,\n });\n\n const rows = herd?.rows ?? [];\n const summary = herd?.summary;\n const groups = herd?.groups ?? [];\n\n const columns: Column<HerdDepthRow>[] = [\n {\n key: 'tag',\n header: t('healthybowl.livestock.depth.table.tag', 'Tag / EID'),\n render: (a) => (\n <div>\n <div className=\"font-medium text-text-primary\">{a.tagNumber}</div>\n {a.eidTag ? <div className=\"text-xs text-text-secondary tabular-nums\">{a.eidTag}</div> : null}\n </div>\n ),\n },\n {\n key: 'animal',\n header: t('healthybowl.livestock.depth.table.animal', 'Animal'),\n render: (a) => (\n <div>\n <div className=\"text-text-primary\">{a.name}</div>\n <div className=\"text-xs text-text-secondary\">{a.type}</div>\n </div>\n ),\n },\n {\n key: 'group',\n header: t('healthybowl.livestock.depth.table.group', 'Group'),\n render: (a) => <span className=\"text-text-primary\">{a.groupName ?? '—'}</span>,\n },\n {\n key: 'bcs',\n header: t('healthybowl.livestock.depth.table.bcs', 'Body Condition'),\n render: (a) => <span className=\"tabular-nums text-text-primary\">{formatBcs(a.bodyConditionScore)}</span>,\n },\n {\n key: 'withdrawal',\n header: t('healthybowl.livestock.depth.table.withdrawal', 'Med. Withdrawal Ends'),\n render: (a) =>\n a.withdrawal.blocked ? (\n <StatusBadge\n variant={withdrawalBadgeVariant(a.withdrawal.status)}\n label={t('healthybowl.livestock.depth.table.withdrawalEnds', 'Withdrawal ends {{date}}', {\n date: formatShortDate(a.withdrawal.endDate),\n })}\n dot\n />\n ) : (\n <span className=\"text-text-secondary\">{t('healthybowl.livestock.depth.table.none', 'none')}</span>\n ),\n },\n {\n key: 'adg',\n header: t('healthybowl.livestock.depth.table.adg', 'ADG'),\n render: (a) => <span className=\"tabular-nums text-text-primary\">{formatAdg(a.adgKgPerDay)}</span>,\n },\n ];\n\n if (loading.herd && !herd) {\n return <PageLoader />;\n }\n\n return (\n <PageLayout\n title={t('healthybowl.livestock.depth.title', 'Livestock Records')}\n titleAccent={t('healthybowl.livestock.depth.titleAccent', 'Records')}\n description={t(\n 'healthybowl.livestock.depth.description',\n 'Deep herd view — body condition, groups, ear-tag/EID, genealogy, ADG and medication-withdrawal compliance.'\n )}\n actions={\n <Button variant=\"outline\" onClick={() => setGroupsOpen(true)}>\n <Settings2 className=\"h-4 w-4\" />\n {t('healthybowl.livestock.depth.groups.manageAction', 'Manage Groups')}\n </Button>\n }\n >\n {errors.herd && !herd ? (\n <ErrorState description={errors.herd.message} onRetry={() => void refetchHerd()} />\n ) : (\n <>\n {summary && summary.animalsInWithdrawal > 0 ? (\n <div\n role=\"alert\"\n className=\"mt-4 flex items-center gap-3 rounded-lg border border-status-error-border bg-status-error-bg px-4 py-3 text-status-error-text\"\n >\n <AlertTriangle className=\"h-5 w-5 shrink-0\" />\n <span className=\"text-sm font-semibold\">{summary.complianceMessage}</span>\n </div>\n ) : null}\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <StatCard\n label={t('healthybowl.livestock.depth.stats.total', 'Animals')}\n value={summary?.totalAnimals ?? 0}\n icon={<Users className=\"h-5 w-5\" />}\n hero\n />\n <StatCard\n label={t('healthybowl.livestock.depth.stats.withdrawal', 'In withdrawal')}\n value={summary?.animalsInWithdrawal ?? 0}\n icon={<AlertTriangle className=\"h-5 w-5\" />}\n />\n <StatCard\n label={t('healthybowl.livestock.depth.stats.clear', 'Clear to sell')}\n value={summary?.animalsClear ?? 0}\n icon={<ShieldCheck className=\"h-5 w-5\" />}\n />\n </div>\n\n <div className=\"mt-4 flex flex-wrap items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setGroupId(null)}\n className={`rounded-full px-3 py-1 text-sm ${groupId === null ? 'bg-accent-teal text-white' : 'bg-bg-sunken text-text-secondary'}`}\n >\n {t('healthybowl.livestock.depth.groups.all', 'All groups')}\n </button>\n {groups.map((g) => (\n <button\n key={g.id}\n type=\"button\"\n onClick={() => setGroupId(g.id)}\n className={`flex items-center gap-1 rounded-full px-3 py-1 text-sm ${groupId === g.id ? 'bg-accent-teal text-white' : 'bg-bg-sunken text-text-secondary'}`}\n >\n {g.kind === 'SMART' ? <Network className=\"h-3.5 w-3.5\" /> : null}\n {g.name}\n <span className=\"tabular-nums opacity-80\">({g.animalCount})</span>\n </button>\n ))}\n <div className=\"ml-auto w-full sm:w-64\">\n <Input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder={t('healthybowl.livestock.depth.searchPlaceholder', 'Search tag, name or EID…')}\n />\n </div>\n </div>\n\n {rows.length === 0 ? (\n <EmptyState\n icon={<Users className=\"h-8 w-8 text-text-secondary\" />}\n title={t('healthybowl.livestock.depth.empty.title', 'No animals to show')}\n description={t(\n 'healthybowl.livestock.depth.empty.description',\n 'Register animals in the Livestock module, then their deep records appear here.'\n )}\n action={\n <Button variant=\"outline\" onClick={() => navigate(buildPath('livestock/animals'))}>\n {t('healthybowl.livestock.depth.empty.action', 'Go to Animal Registry')}\n </Button>\n }\n />\n ) : (\n <DataTable\n columns={columns}\n data={rows}\n keyField=\"animalId\"\n pageSize={12}\n onRowClick={(a) => navigate(buildPath(`livestock/records/${a.animalId}`))}\n />\n )}\n </>\n )}\n\n <AnimalGroupModal open={groupsOpen} onClose={() => setGroupsOpen(false)} onChanged={() => void refetchHerd()} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,IAAa,UAAsB;CACjC,IAAM,EAAE,SAAM,GAAS,EACjB,IAAW,GAAa,EACxB,EAAE,iBAAc,GAAa,EAE7B,CAAC,GAAS,KAAc,EAAwB,KAAK,EACrD,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,CAAC,GAAY,KAAiB,EAAS,GAAM,EAE7C,EAAE,SAAM,YAAS,WAAQ,mBAAgB,EAA6B;EAC1E,MAAM;EACN,aAAa;EACb,YAAY,EAAO,MAAM,IAAI;EAC9B,CAAC,EAEI,IAAO,GAAM,QAAQ,EAAE,EACvB,IAAU,GAAM,SAChB,IAAS,GAAM,UAAU,EAAE,EAE3B,IAAkC;EACtC;GACE,KAAK;GACL,QAAQ,EAAE,yCAAyC,YAAY;GAC/D,SAAS,MACP,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;cAAiC,EAAE;IAAgB,CAAA,EACjE,EAAE,SAAS,kBAAC,OAAD;IAAK,WAAU;cAA4C,EAAE;I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,kBAAC,GAAD,EAAS,WAAU,eAAgB,CAAA,GAAG;OAC3D,EAAE;OACH,kBAAC,QAAD;QAAM,WAAU;kBAAhB;SAA0C;SAAE,EAAE;SAAY;SAAQ;;OAC3D;QARF,EAAE,GAQA,CACT;KACF,kBAAC,OAAD;MAAK,WAAU;gBACb,kBAAC,GAAD;OACE,OAAO;OACP,WAAW,MAAM,EAAU,EAAE,OAAO,MAAM;OAC1C,aAAa,EAAE,iDAAiD,2BAA2B;OAC3F,CAAA;MACE,CAAA;KACF;;GAEL,EAAK,WAAW,IACf,kBAAC,GAAD;IACE,MAAM,kBAAC,GAAD,EAAO,WAAU,+BAAgC,CAAA;IACvD,OAAO,EAAE,2CAA2C,qBAAqB;IACzE,aAAa,EACX,iDACA,iFACD;IACD,QACE,kBAAC,GAAD;KAAQ,SAAQ;KAAU,eAAe,EAAS,EAAU,oBAAoB,CAAC;eAC9E,EAAE,4CAA4C,wBAAwB;KAChE,CAAA;IAEX,CAAA,GAEF,kBAAC,GAAD;IACW;IACT,MAAM;IACN,UAAS;IACT,UAAU;IACV,aAAa,MAAM,EAAS,EAAU,qBAAqB,EAAE,WAAW,CAAC;IACzE,CAAA;GAEH,EAAA,CAAA,EAGL,kBAAC,GAAD;GAAkB,MAAM;GAAY,eAAe,EAAc,GAAM;GAAE,iBAAiB,KAAK,GAAa;GAAI,CAAA,CACrG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Modal as e } from "../../components/Modal.js";
|
|
2
|
+
import "../../components/index.js";
|
|
3
|
+
import { WEIGHT_METHODS as t } from "./depthLabels.js";
|
|
4
|
+
import { useEffect as n, useState as r } from "react";
|
|
5
|
+
import { useI18n as i } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
6
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { Button as c, Input as l, Select as u, SelectContent as d, SelectItem as f, SelectTrigger as p, SelectValue as m, Textarea as h } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
//#region src/healthybowl/pages/livestock/RecordWeightModal.tsx
|
|
9
|
+
var g = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), _ = "mb-1 block text-sm font-medium text-text-primary", v = "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", y = ({ open: y, onClose: b, animalName: x, onSubmit: S }) => {
|
|
10
|
+
let { t: C } = i(), [w, T] = r(""), [E, D] = r(g()), [O, k] = r("SCALE"), [A, j] = r(""), [M, N] = r(!1), [P, F] = r(null);
|
|
11
|
+
n(() => {
|
|
12
|
+
y && (T(""), D(g()), k("SCALE"), j(""), F(null));
|
|
13
|
+
}, [y]);
|
|
14
|
+
let I = Number(w) > 0 && !M, L = async () => {
|
|
15
|
+
if (I) {
|
|
16
|
+
N(!0), F(null);
|
|
17
|
+
try {
|
|
18
|
+
await S({
|
|
19
|
+
weightKg: Number(w),
|
|
20
|
+
measuredAt: E,
|
|
21
|
+
method: O,
|
|
22
|
+
notes: A.trim() || null
|
|
23
|
+
}), b();
|
|
24
|
+
} catch (e) {
|
|
25
|
+
F(e instanceof Error ? e.message : String(e));
|
|
26
|
+
} finally {
|
|
27
|
+
N(!1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ o(e, {
|
|
32
|
+
open: y,
|
|
33
|
+
onClose: b,
|
|
34
|
+
title: C("healthybowl.livestock.depth.weight.title", "Record weight"),
|
|
35
|
+
description: x,
|
|
36
|
+
footer: /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(c, {
|
|
37
|
+
variant: "outline",
|
|
38
|
+
onClick: b,
|
|
39
|
+
disabled: M,
|
|
40
|
+
children: C("common.cancel", "Cancel")
|
|
41
|
+
}), /* @__PURE__ */ o(c, {
|
|
42
|
+
onClick: () => void L(),
|
|
43
|
+
disabled: !I,
|
|
44
|
+
children: C("healthybowl.livestock.depth.weight.save", "Save weight")
|
|
45
|
+
})] }),
|
|
46
|
+
children: /* @__PURE__ */ s("div", {
|
|
47
|
+
className: "space-y-3",
|
|
48
|
+
children: [
|
|
49
|
+
P ? /* @__PURE__ */ o("div", {
|
|
50
|
+
className: "rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text",
|
|
51
|
+
children: P
|
|
52
|
+
}) : null,
|
|
53
|
+
/* @__PURE__ */ s("div", {
|
|
54
|
+
className: "grid grid-cols-2 gap-3",
|
|
55
|
+
children: [/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
56
|
+
className: _,
|
|
57
|
+
children: C("healthybowl.livestock.depth.weight.kg", "Weight (kg)")
|
|
58
|
+
}), /* @__PURE__ */ o(l, {
|
|
59
|
+
type: "number",
|
|
60
|
+
min: "0",
|
|
61
|
+
step: "0.1",
|
|
62
|
+
value: w,
|
|
63
|
+
onChange: (e) => T(e.target.value)
|
|
64
|
+
})] }), /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
65
|
+
className: _,
|
|
66
|
+
children: C("healthybowl.livestock.depth.weight.date", "Measured on")
|
|
67
|
+
}), /* @__PURE__ */ o("input", {
|
|
68
|
+
type: "date",
|
|
69
|
+
className: v,
|
|
70
|
+
value: E,
|
|
71
|
+
onChange: (e) => D(e.target.value)
|
|
72
|
+
})] })]
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
75
|
+
className: _,
|
|
76
|
+
children: C("healthybowl.livestock.depth.weight.method", "Method")
|
|
77
|
+
}), /* @__PURE__ */ s(u, {
|
|
78
|
+
value: O,
|
|
79
|
+
onValueChange: k,
|
|
80
|
+
children: [/* @__PURE__ */ o(p, { children: /* @__PURE__ */ o(m, {}) }), /* @__PURE__ */ o(d, { children: t.map((e) => /* @__PURE__ */ o(f, {
|
|
81
|
+
value: e,
|
|
82
|
+
children: e
|
|
83
|
+
}, e)) })]
|
|
84
|
+
})] }),
|
|
85
|
+
/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
86
|
+
className: _,
|
|
87
|
+
children: C("healthybowl.livestock.depth.weight.notes", "Notes")
|
|
88
|
+
}), /* @__PURE__ */ o(h, {
|
|
89
|
+
value: A,
|
|
90
|
+
onChange: (e) => j(e.target.value),
|
|
91
|
+
rows: 2
|
|
92
|
+
})] })
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { y as RecordWeightModal };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=RecordWeightModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordWeightModal.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/RecordWeightModal.tsx"],"sourcesContent":["/**\n * Record a weight measurement for an animal (BOFF-2890 · L-1).\n * Feeds the time-series that yields ADG; the newest measurement also updates the animal's\n * current weight. No fabricated data — every field is user-entered and persisted.\n */\nimport { useEffect, useState } from 'react';\nimport {\n Button,\n Input,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Modal } from '../../components';\nimport { WEIGHT_METHODS } from './depthLabels';\n\ninterface RecordWeightModalProps {\n open: boolean;\n onClose: () => void;\n animalName: string;\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst todayIso = (): string => new Date().toISOString().slice(0, 10);\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\nconst dateInput =\n 'w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport const RecordWeightModal = ({ open, onClose, animalName, onSubmit }: RecordWeightModalProps) => {\n const { t } = useI18n();\n const [weightKg, setWeightKg] = useState('');\n const [measuredAt, setMeasuredAt] = useState(todayIso());\n const [method, setMethod] = useState('SCALE');\n const [notes, setNotes] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!open) return;\n setWeightKg('');\n setMeasuredAt(todayIso());\n setMethod('SCALE');\n setNotes('');\n setError(null);\n }, [open]);\n\n const canSubmit = Number(weightKg) > 0 && !submitting;\n\n const handleSubmit = async () => {\n if (!canSubmit) return;\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({ weightKg: Number(weightKg), measuredAt, method, notes: notes.trim() || null });\n onClose();\n } catch (err) {\n setError(err instanceof Error ? err.message : String(err));\n } finally {\n setSubmitting(false);\n }\n };\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.livestock.depth.weight.title', 'Record weight')}\n description={animalName}\n footer={\n <>\n <Button variant=\"outline\" onClick={onClose} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={!canSubmit}>\n {t('healthybowl.livestock.depth.weight.save', 'Save weight')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-3\">\n {error ? (\n <div className=\"rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n ) : null}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.weight.kg', 'Weight (kg)')}</label>\n <Input type=\"number\" min=\"0\" step=\"0.1\" value={weightKg} onChange={(e) => setWeightKg(e.target.value)} />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.weight.date', 'Measured on')}</label>\n <input\n type=\"date\"\n className={dateInput}\n value={measuredAt}\n onChange={(e) => setMeasuredAt(e.target.value)}\n />\n </div>\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.weight.method', 'Method')}</label>\n <Select value={method} onValueChange={setMethod}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {WEIGHT_METHODS.map((m) => (\n <SelectItem key={m} value={m}>\n {m}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.weight.notes', 'Notes')}</label>\n <Textarea value={notes} onChange={(e) => setNotes(e.target.value)} rows={2} />\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;AA2BA,IAAM,2BAAyB,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,GAAG,GAAG,EAC9D,IAAa,oDACb,IACJ,wKAEW,KAAqB,EAAE,SAAM,YAAS,eAAY,kBAAuC;CACpG,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAY,KAAiB,EAAS,GAAU,CAAC,EAClD,CAAC,GAAQ,KAAa,EAAS,QAAQ,EACvC,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAO,KAAY,EAAwB,KAAK;AAEvD,SAAgB;AACT,QACL,EAAY,GAAG,EACf,EAAc,GAAU,CAAC,EACzB,EAAU,QAAQ,EAClB,EAAS,GAAG,EACZ,EAAS,KAAK;IACb,CAAC,EAAK,CAAC;CAEV,IAAM,IAAY,OAAO,EAAS,GAAG,KAAK,CAAC,GAErC,IAAe,YAAY;AAC1B,SAEL;GADA,EAAc,GAAK,EACnB,EAAS,KAAK;AACd,OAAI;AAEF,IADA,MAAM,EAAS;KAAE,UAAU,OAAO,EAAS;KAAE;KAAY;KAAQ,OAAO,EAAM,MAAM,IAAI;KAAM,CAAC,EAC/F,GAAS;YACF,GAAK;AACZ,MAAS,aAAe,QAAQ,EAAI,UAAU,OAAO,EAAI,CAAC;aAClD;AACR,MAAc,GAAM;;;;AAIxB,QACE,kBAAC,GAAD;EACQ;EACG;EACT,OAAO,EAAE,4CAA4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AC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;KAAO,WAAW;eAAa,EAAE,4CAA4C,QAAQ;KAAS,CAAA,EAC9F,kBAAC,GAAD;KAAU,OAAO;KAAO,WAAW,MAAM,EAAS,EAAE,OAAO,MAAM;KAAE,MAAM;KAAK,CAAA,CAC1E,EAAA,CAAA;IACF;;EACA,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/healthybowl/pages/livestock/depthLabels.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
switch (e) {
|
|
4
|
+
case "BLOCKED": return "error";
|
|
5
|
+
case "UNDER_WITHDRAWAL": return "warning";
|
|
6
|
+
case "CLEARED": return "success";
|
|
7
|
+
default: return "muted";
|
|
8
|
+
}
|
|
9
|
+
}, t = (e) => e === "SMART" ? "info" : "default", n = [
|
|
10
|
+
"CATTLE",
|
|
11
|
+
"BUFFALO",
|
|
12
|
+
"GOAT",
|
|
13
|
+
"SHEEP",
|
|
14
|
+
"PIG",
|
|
15
|
+
"POULTRY"
|
|
16
|
+
], r = [
|
|
17
|
+
"SCALE",
|
|
18
|
+
"TAPE",
|
|
19
|
+
"ESTIMATE"
|
|
20
|
+
], i = ["MANUAL", "SMART"], a = (e) => e == null ? "—" : `${Number.isInteger(e) ? e : e.toFixed(2).replace(/0$/, "")} / 5`, o = (e) => e == null ? "—" : `${e} kg/day`, s = (e) => {
|
|
21
|
+
if (!e) return "—";
|
|
22
|
+
let t = new Date(e);
|
|
23
|
+
return Number.isNaN(t.getTime()) ? "—" : t.toLocaleDateString("en-GB", {
|
|
24
|
+
day: "2-digit",
|
|
25
|
+
month: "short"
|
|
26
|
+
});
|
|
27
|
+
}, c = (e, t) => e == null ? "—" : `${e} kg${t ? ` (${s(t)})` : ""}`;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { n as ANIMAL_TYPES, i as GROUP_KINDS, r as WEIGHT_METHODS, o as formatAdg, a as formatBcs, s as formatShortDate, c as formatWeight, t as groupKindVariant, e as withdrawalBadgeVariant };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=depthLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depthLabels.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/depthLabels.ts"],"sourcesContent":["/**\n * Shared label + status-variant helpers for the deep livestock views (BOFF-2890 · L-1).\n * Keeps the enum→display vocabulary in one place so every page maps the backend's String-typed\n * fields onto the same `StatusBadge` variants.\n */\n\ntype BadgeVariant = 'success' | 'warning' | 'error' | 'info' | 'default' | 'muted';\n\n/** Medication-withdrawal roll-up status → badge colour. */\nexport const withdrawalBadgeVariant = (status: string): BadgeVariant => {\n switch (status) {\n case 'BLOCKED':\n return 'error';\n case 'UNDER_WITHDRAWAL':\n return 'warning';\n case 'CLEARED':\n return 'success';\n default:\n return 'muted';\n }\n};\n\nexport const groupKindVariant = (kind: string): BadgeVariant => (kind === 'SMART' ? 'info' : 'default');\n\nexport const ANIMAL_TYPES = ['CATTLE', 'BUFFALO', 'GOAT', 'SHEEP', 'PIG', 'POULTRY'] as const;\nexport const WEIGHT_METHODS = ['SCALE', 'TAPE', 'ESTIMATE'] as const;\nexport const GROUP_KINDS = ['MANUAL', 'SMART'] as const;\n\n/** \"3.5 / 5\" body-condition display; \"—\" when unset. */\nexport const formatBcs = (bcs: number | null | undefined): string =>\n bcs === null || bcs === undefined ? '—' : `${Number.isInteger(bcs) ? bcs : bcs.toFixed(2).replace(/0$/, '')} / 5`;\n\n/** \"0.62 kg/day\" ADG display; \"—\" when it cannot be computed (< 2 weights). */\nexport const formatAdg = (adg: number | null | undefined): string =>\n adg === null || adg === undefined ? '—' : `${adg} kg/day`;\n\n/** \"18 Jun\" short date; \"—\" when null. */\nexport const formatShortDate = (iso: string | null | undefined): string => {\n if (!iso) return '—';\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return '—';\n return d.toLocaleDateString('en-GB', { day: '2-digit', month: 'short' });\n};\n\n/** \"412 kg (17 Jun)\" weight + date; \"—\" when no weight. */\nexport const formatWeight = (kg: number | null | undefined, at: string | null | undefined): string => {\n if (kg === null || kg === undefined) return '—';\n const date = at ? ` (${formatShortDate(at)})` : '';\n return `${kg} kg${date}`;\n};\n"],"mappings":";AASA,IAAa,KAA0B,MAAiC;AACtE,SAAQ,GAAR;EACE,KAAK,UACH,QAAO;EACT,KAAK,mBACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,QACE,QAAO;;GAIA,KAAoB,MAAgC,MAAS,UAAU,SAAS,WAEhF,IAAe;CAAC;CAAU;CAAW;CAAQ;CAAS;CAAO;CAAU,EACvE,IAAiB;CAAC;CAAS;CAAQ;CAAW,EAC9C,IAAc,CAAC,UAAU,QAAQ,EAGjC,KAAa,MACxB,KAAQ,OAA4B,MAAM,GAAG,OAAO,UAAU,EAAI,GAAG,IAAM,EAAI,QAAQ,EAAE,CAAC,QAAQ,MAAM,GAAG,CAAC,OAGjG,KAAa,MACxB,KAAQ,OAA4B,MAAM,GAAG,EAAI,UAGtC,KAAmB,MAA2C;AACzE,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,IAAI,IAAI,KAAK,EAAI;AAEvB,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,MAC/B,EAAE,mBAAmB,SAAS;EAAE,KAAK;EAAW,OAAO;EAAS,CAAC;GAI7D,KAAgB,GAA+B,MACtD,KAAO,OAAiC,MAErC,GAAG,EAAG,KADA,IAAK,KAAK,EAAgB,EAAG,CAAC,KAAK"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { useBasePath as e } from "../../hooks/useBasePath.js";
|
|
2
|
+
import { PageLayout as t } from "../../components/PageLayout.js";
|
|
3
|
+
import { StatusBadge as n } from "../../components/StatusBadge.js";
|
|
4
|
+
import { EmptyState as r } from "../../components/EmptyState.js";
|
|
5
|
+
import { ErrorState as i } from "../../components/ErrorState.js";
|
|
6
|
+
import { PageLoader as a } from "../../components/PageLoader.js";
|
|
7
|
+
import { useToast as o } from "../../hooks/useToast.js";
|
|
8
|
+
import "../../components/index.js";
|
|
9
|
+
import { useSatelliteApi as s } from "./useSatelliteApi.js";
|
|
10
|
+
import { formatDate as c, formatNdvi as l, reasonLabel as u, severityVariant as d } from "./ndviColors.js";
|
|
11
|
+
import { useCallback as f, useEffect as p, useMemo as m, useState as h } from "react";
|
|
12
|
+
import { ArrowLeft as g, Bug as _, Check as v, CheckCheck as y, ClipboardList as b, Satellite as x } from "lucide-react";
|
|
13
|
+
import { useNavigate as S } from "react-router-dom";
|
|
14
|
+
import { jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
15
|
+
import { Button as T } from "@burdenoff/fe-libs/ui";
|
|
16
|
+
//#region src/healthybowl/pages/satellite/CropHealthAlertsPage.tsx
|
|
17
|
+
var E = () => {
|
|
18
|
+
let { api: E } = s(), D = S(), { buildPath: O } = e(), { toast: k } = o(), [A, j] = h([]), [M, N] = h(!0), [P, F] = h(null), [I, L] = h("open"), [R, z] = h(null), B = f(async () => {
|
|
19
|
+
F(null);
|
|
20
|
+
try {
|
|
21
|
+
j(await E.getStressedZones({ status: "ALL" }));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
F(e instanceof Error ? e.message : "Failed to load alerts.");
|
|
24
|
+
} finally {
|
|
25
|
+
N(!1);
|
|
26
|
+
}
|
|
27
|
+
}, [E]);
|
|
28
|
+
p(() => {
|
|
29
|
+
B();
|
|
30
|
+
}, [B]);
|
|
31
|
+
let V = f(async (e, t) => {
|
|
32
|
+
z(e.id);
|
|
33
|
+
try {
|
|
34
|
+
t === "ack" ? await E.acknowledgeZone(e.id) : t === "resolve" ? await E.resolveZone(e.id) : await E.escalateZone(e.id, t === "pest" ? "PEST" : "TASK"), k({
|
|
35
|
+
title: t === "pest" ? "Pest issue created" : t === "task" ? "Scouting task created" : t === "ack" ? "Marked as read" : "Resolved",
|
|
36
|
+
variant: "success"
|
|
37
|
+
}), await B();
|
|
38
|
+
} catch (e) {
|
|
39
|
+
k({
|
|
40
|
+
title: "Action failed",
|
|
41
|
+
description: e instanceof Error ? e.message : "Unknown error",
|
|
42
|
+
variant: "error"
|
|
43
|
+
});
|
|
44
|
+
} finally {
|
|
45
|
+
z(null);
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
E,
|
|
49
|
+
k,
|
|
50
|
+
B
|
|
51
|
+
]), H = m(() => I === "high" ? A.filter((e) => e.severity === "HIGH") : I === "open" ? A.filter((e) => e.status === "OPEN") : A, [A, I]), U = A.filter((e) => e.status === "OPEN").length;
|
|
52
|
+
return M ? /* @__PURE__ */ C(a, {}) : P ? /* @__PURE__ */ C(i, {
|
|
53
|
+
title: "Couldn't load alerts",
|
|
54
|
+
description: P,
|
|
55
|
+
onRetry: () => void B()
|
|
56
|
+
}) : /* @__PURE__ */ w(t, {
|
|
57
|
+
title: "Crop-Health Alerts",
|
|
58
|
+
description: "Auto-flagged stressed zones from the latest satellite passes.",
|
|
59
|
+
helpPrompt: "Explain the crop-health alerts and how to escalate a stressed zone to a pest issue or a task.",
|
|
60
|
+
actions: /* @__PURE__ */ w(T, {
|
|
61
|
+
variant: "ghost",
|
|
62
|
+
size: "sm",
|
|
63
|
+
onClick: () => D(O("satellite")),
|
|
64
|
+
children: [/* @__PURE__ */ C(g, { className: "mr-1.5 h-4 w-4" }), " Satellite Crop Health"]
|
|
65
|
+
}),
|
|
66
|
+
children: [/* @__PURE__ */ w("div", {
|
|
67
|
+
className: "mb-4 flex flex-wrap items-center gap-2",
|
|
68
|
+
children: [[
|
|
69
|
+
"open",
|
|
70
|
+
"all",
|
|
71
|
+
"high"
|
|
72
|
+
].map((e) => /* @__PURE__ */ C(T, {
|
|
73
|
+
variant: I === e ? "default" : "outline",
|
|
74
|
+
size: "sm",
|
|
75
|
+
onClick: () => L(e),
|
|
76
|
+
children: e === "open" ? "Unread" : e === "all" ? "All" : "High severity"
|
|
77
|
+
}, e)), U > 0 && /* @__PURE__ */ w("span", {
|
|
78
|
+
className: "rounded-full bg-destructive px-2 py-0.5 text-xs text-white",
|
|
79
|
+
children: [U, " new"]
|
|
80
|
+
})]
|
|
81
|
+
}), H.length === 0 ? /* @__PURE__ */ C(r, {
|
|
82
|
+
icon: /* @__PURE__ */ C(x, { className: "h-6 w-6" }),
|
|
83
|
+
title: "No alerts",
|
|
84
|
+
description: "No stressed zones match this filter. Refresh NDVI from a field to run detection."
|
|
85
|
+
}) : /* @__PURE__ */ C("ul", {
|
|
86
|
+
className: "space-y-3",
|
|
87
|
+
children: H.map((e) => /* @__PURE__ */ C("li", {
|
|
88
|
+
className: "rounded-xl border border-border-subtle bg-bg-surface p-4",
|
|
89
|
+
children: /* @__PURE__ */ w("div", {
|
|
90
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",
|
|
91
|
+
children: [/* @__PURE__ */ w("div", {
|
|
92
|
+
className: "min-w-0",
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ w("div", {
|
|
95
|
+
className: "flex items-center gap-2",
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ C("span", { className: `h-2.5 w-2.5 shrink-0 rounded-full ${e.severity === "HIGH" ? "bg-destructive" : e.severity === "MEDIUM" ? "bg-warning" : "bg-warning/60"}` }),
|
|
98
|
+
/* @__PURE__ */ w("button", {
|
|
99
|
+
className: "truncate text-left font-semibold text-text-primary hover:underline",
|
|
100
|
+
onClick: () => D(O(`satellite/${e.fieldId}`)),
|
|
101
|
+
children: [
|
|
102
|
+
u(e.reason),
|
|
103
|
+
" — ",
|
|
104
|
+
e.fieldName
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ C(n, {
|
|
108
|
+
label: e.status,
|
|
109
|
+
variant: e.status === "ESCALATED" ? "info" : e.status === "RESOLVED" ? "success" : d(e.severity)
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
}),
|
|
113
|
+
/* @__PURE__ */ w("p", {
|
|
114
|
+
className: "mt-1 text-sm text-text-secondary",
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ C("span", {
|
|
117
|
+
className: "font-medium text-text-primary",
|
|
118
|
+
children: "Reason:"
|
|
119
|
+
}),
|
|
120
|
+
" ",
|
|
121
|
+
e.reasonDetail ?? u(e.reason)
|
|
122
|
+
]
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ w("p", {
|
|
125
|
+
className: "mt-1 text-sm text-text-secondary",
|
|
126
|
+
children: [
|
|
127
|
+
"NDVI ",
|
|
128
|
+
l(e.fieldNdvi),
|
|
129
|
+
" →",
|
|
130
|
+
" ",
|
|
131
|
+
/* @__PURE__ */ C("span", {
|
|
132
|
+
className: "font-medium text-text-primary",
|
|
133
|
+
children: l(e.zoneNdvi)
|
|
134
|
+
}),
|
|
135
|
+
",",
|
|
136
|
+
" ",
|
|
137
|
+
/* @__PURE__ */ w("span", {
|
|
138
|
+
className: "text-destructive",
|
|
139
|
+
children: [e.deltaPct, "%"]
|
|
140
|
+
}),
|
|
141
|
+
" vs field average ·",
|
|
142
|
+
" ",
|
|
143
|
+
c(e.capturedDate)
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
}), /* @__PURE__ */ w("div", {
|
|
148
|
+
className: "flex shrink-0 flex-col gap-2",
|
|
149
|
+
children: [e.status !== "ESCALATED" && /* @__PURE__ */ w("div", {
|
|
150
|
+
className: "flex gap-2",
|
|
151
|
+
children: [/* @__PURE__ */ w(T, {
|
|
152
|
+
size: "sm",
|
|
153
|
+
onClick: () => void V(e, "pest"),
|
|
154
|
+
disabled: R === e.id,
|
|
155
|
+
children: [/* @__PURE__ */ C(_, { className: "mr-1 h-3.5 w-3.5" }), " Create Pest Issue"]
|
|
156
|
+
}), /* @__PURE__ */ w(T, {
|
|
157
|
+
variant: "outline",
|
|
158
|
+
size: "sm",
|
|
159
|
+
onClick: () => void V(e, "task"),
|
|
160
|
+
disabled: R === e.id,
|
|
161
|
+
children: [/* @__PURE__ */ C(b, { className: "mr-1 h-3.5 w-3.5" }), " Create Task"]
|
|
162
|
+
})]
|
|
163
|
+
}), e.status === "OPEN" && /* @__PURE__ */ w("div", {
|
|
164
|
+
className: "flex gap-2",
|
|
165
|
+
children: [/* @__PURE__ */ w(T, {
|
|
166
|
+
variant: "ghost",
|
|
167
|
+
size: "sm",
|
|
168
|
+
onClick: () => void V(e, "ack"),
|
|
169
|
+
disabled: R === e.id,
|
|
170
|
+
children: [/* @__PURE__ */ C(v, { className: "mr-1 h-3.5 w-3.5" }), " Mark read"]
|
|
171
|
+
}), /* @__PURE__ */ w(T, {
|
|
172
|
+
variant: "ghost",
|
|
173
|
+
size: "sm",
|
|
174
|
+
onClick: () => void V(e, "resolve"),
|
|
175
|
+
disabled: R === e.id,
|
|
176
|
+
children: [/* @__PURE__ */ C(y, { className: "mr-1 h-3.5 w-3.5" }), " Resolve"]
|
|
177
|
+
})]
|
|
178
|
+
})]
|
|
179
|
+
})]
|
|
180
|
+
})
|
|
181
|
+
}, e.id))
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
//#endregion
|
|
186
|
+
export { E as CropHealthAlertsPage };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=CropHealthAlertsPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CropHealthAlertsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/satellite/CropHealthAlertsPage.tsx"],"sourcesContent":["/**\n * Crop-Health Alerts (BOFF-2886).\n *\n * The workspace-wide list of auto-flagged stressed zones from the latest satellite\n * passes. Each can be acknowledged, resolved, or escalated into an existing\n * HealthyBowl Pest issue or a field scouting Task. Live gateway — no mocks.\n */\nimport { type FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { ArrowLeft, Bug, ClipboardList, Check, CheckCheck, Satellite } from 'lucide-react';\nimport { PageLayout, StatusBadge, EmptyState, ErrorState, PageLoader } from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useSatelliteApi } from './useSatelliteApi';\nimport type { StressedZone } from './satelliteApi';\nimport { formatDate, formatNdvi, reasonLabel, severityVariant } from './ndviColors';\n\ntype Filter = 'open' | 'all' | 'high';\n\nexport const CropHealthAlertsPage: FC = () => {\n const { api } = useSatelliteApi();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n\n const [zones, setZones] = useState<StressedZone[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [filter, setFilter] = useState<Filter>('open');\n const [busyId, setBusyId] = useState<string | null>(null);\n\n const load = useCallback(async () => {\n setError(null);\n try {\n setZones(await api.getStressedZones({ status: 'ALL' }));\n } catch (e) {\n setError(e instanceof Error ? e.message : 'Failed to load alerts.');\n } finally {\n setLoading(false);\n }\n }, [api]);\n\n useEffect(() => {\n void load();\n }, [load]);\n\n const act = useCallback(\n async (z: StressedZone, action: 'ack' | 'resolve' | 'pest' | 'task') => {\n setBusyId(z.id);\n try {\n if (action === 'ack') await api.acknowledgeZone(z.id);\n else if (action === 'resolve') await api.resolveZone(z.id);\n else await api.escalateZone(z.id, action === 'pest' ? 'PEST' : 'TASK');\n toast({\n title:\n action === 'pest'\n ? 'Pest issue created'\n : action === 'task'\n ? 'Scouting task created'\n : action === 'ack'\n ? 'Marked as read'\n : 'Resolved',\n variant: 'success',\n });\n await load();\n } catch (e) {\n toast({\n title: 'Action failed',\n description: e instanceof Error ? e.message : 'Unknown error',\n variant: 'error',\n });\n } finally {\n setBusyId(null);\n }\n },\n [api, toast, load]\n );\n\n const rows = useMemo(() => {\n if (filter === 'high') return zones.filter((z) => z.severity === 'HIGH');\n if (filter === 'open') return zones.filter((z) => z.status === 'OPEN');\n return zones;\n }, [zones, filter]);\n\n const newCount = zones.filter((z) => z.status === 'OPEN').length;\n\n if (loading) return <PageLoader />;\n if (error) return <ErrorState title=\"Couldn't load alerts\" description={error} onRetry={() => void load()} />;\n\n return (\n <PageLayout\n title=\"Crop-Health Alerts\"\n description=\"Auto-flagged stressed zones from the latest satellite passes.\"\n helpPrompt=\"Explain the crop-health alerts and how to escalate a stressed zone to a pest issue or a task.\"\n actions={\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate(buildPath('satellite'))}>\n <ArrowLeft className=\"mr-1.5 h-4 w-4\" /> Satellite Crop Health\n </Button>\n }\n >\n <div className=\"mb-4 flex flex-wrap items-center gap-2\">\n {(['open', 'all', 'high'] as Filter[]).map((k) => (\n <Button key={k} variant={filter === k ? 'default' : 'outline'} size=\"sm\" onClick={() => setFilter(k)}>\n {k === 'open' ? 'Unread' : k === 'all' ? 'All' : 'High severity'}\n </Button>\n ))}\n {newCount > 0 && (\n <span className=\"rounded-full bg-destructive px-2 py-0.5 text-xs text-white\">{newCount} new</span>\n )}\n </div>\n\n {rows.length === 0 ? (\n <EmptyState\n icon={<Satellite className=\"h-6 w-6\" />}\n title=\"No alerts\"\n description=\"No stressed zones match this filter. Refresh NDVI from a field to run detection.\"\n />\n ) : (\n <ul className=\"space-y-3\">\n {rows.map((z) => (\n <li key={z.id} className=\"rounded-xl border border-border-subtle bg-bg-surface p-4\">\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between\">\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2\">\n <span\n className={`h-2.5 w-2.5 shrink-0 rounded-full ${z.severity === 'HIGH' ? 'bg-destructive' : z.severity === 'MEDIUM' ? 'bg-warning' : 'bg-warning/60'}`}\n />\n <button\n className=\"truncate text-left font-semibold text-text-primary hover:underline\"\n onClick={() => navigate(buildPath(`satellite/${z.fieldId}`))}\n >\n {reasonLabel(z.reason)} — {z.fieldName}\n </button>\n <StatusBadge\n label={z.status}\n variant={\n z.status === 'ESCALATED'\n ? 'info'\n : z.status === 'RESOLVED'\n ? 'success'\n : severityVariant(z.severity)\n }\n />\n </div>\n <p className=\"mt-1 text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Reason:</span>{' '}\n {z.reasonDetail ?? reasonLabel(z.reason)}\n </p>\n <p className=\"mt-1 text-sm text-text-secondary\">\n NDVI {formatNdvi(z.fieldNdvi)} →{' '}\n <span className=\"font-medium text-text-primary\">{formatNdvi(z.zoneNdvi)}</span>,{' '}\n <span className=\"text-destructive\">{z.deltaPct}%</span> vs field average ·{' '}\n {formatDate(z.capturedDate)}\n </p>\n </div>\n <div className=\"flex shrink-0 flex-col gap-2\">\n {z.status !== 'ESCALATED' && (\n <div className=\"flex gap-2\">\n <Button size=\"sm\" onClick={() => void act(z, 'pest')} disabled={busyId === z.id}>\n <Bug className=\"mr-1 h-3.5 w-3.5\" /> Create Pest Issue\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void act(z, 'task')}\n disabled={busyId === z.id}\n >\n <ClipboardList className=\"mr-1 h-3.5 w-3.5\" /> Create Task\n </Button>\n </div>\n )}\n {z.status === 'OPEN' && (\n <div className=\"flex gap-2\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => void act(z, 'ack')} disabled={busyId === z.id}>\n <Check className=\"mr-1 h-3.5 w-3.5\" /> Mark read\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => void act(z, 'resolve')}\n disabled={busyId === z.id}\n >\n <CheckCheck className=\"mr-1 h-3.5 w-3.5\" /> Resolve\n </Button>\n </div>\n )}\n </div>\n </div>\n </li>\n ))}\n </ul>\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,IAAa,UAAiC;CAC5C,IAAM,EAAE,WAAQ,GAAiB,EAC3B,IAAW,GAAa,EACxB,EAAE,iBAAc,GAAa,EAC7B,EAAE,aAAU,GAAU,EAEtB,CAAC,GAAO,KAAY,EAAyB,EAAE,CAAC,EAChD,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAwB,KA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