@burdenoff/microfe-healthybowl 2026.714.3 → 2026.714.5
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/HealthyBowlRoot.js +114 -106
- package/dist/healthybowl/HealthyBowlRoot.js.map +1 -1
- package/dist/healthybowl/HealthyBowlRoutes.js +141 -113
- 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/hooks/usePlantScans.js +131 -0
- package/dist/healthybowl/hooks/usePlantScans.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/pest-management/AiPestDetectionPage.js +726 -0
- package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js.map +1 -0
- package/dist/healthybowl/pages/pest-management/PestOverviewPage.js +98 -88
- package/dist/healthybowl/pages/pest-management/PestOverviewPage.js.map +1 -1
- 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/healthybowl/utils/imageDownscale.js +76 -0
- package/dist/healthybowl/utils/imageDownscale.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { StatusBadge as e } from "../../components/StatusBadge.js";
|
|
2
|
+
import { useConfirm as t } from "../../components/ConfirmDialog.js";
|
|
3
|
+
import { Modal as n } from "../../components/Modal.js";
|
|
4
|
+
import { useToast as r } from "../../hooks/useToast.js";
|
|
5
|
+
import "../../components/index.js";
|
|
6
|
+
import { useHealthyBowlLivestockDepth as i } from "../../hooks/useHealthyBowlLivestockDepth.js";
|
|
7
|
+
import { ANIMAL_TYPES as a, GROUP_KINDS as o, groupKindVariant as s } from "./depthLabels.js";
|
|
8
|
+
import { useEffect as c, useState as l } from "react";
|
|
9
|
+
import { useI18n as u } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
10
|
+
import { Network as d, Plus as f, Trash2 as p } from "lucide-react";
|
|
11
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
12
|
+
import { Button as g, Input as _, Select as v, SelectContent as y, SelectItem as b, SelectTrigger as x, SelectValue as S, Textarea as C } from "@burdenoff/fe-libs/ui";
|
|
13
|
+
//#region src/healthybowl/pages/livestock/AnimalGroupModal.tsx
|
|
14
|
+
var w = "mb-1 block text-sm font-medium text-text-primary", T = ({ open: T, onClose: E, onChanged: D }) => {
|
|
15
|
+
let { t: O } = u(), { toast: k } = r(), A = t(), { groups: j, createGroup: M, updateGroup: N, deleteGroup: P, refetchGroups: F } = i({ groups: !0 }), [I, L] = l(null), [R, z] = l(""), [B, V] = l(""), [H, U] = l("MANUAL"), [W, G] = l(""), [K, q] = l(""), [J, Y] = l(!1), X = () => {
|
|
16
|
+
L(null), z(""), V(""), U("MANUAL"), G(""), q("");
|
|
17
|
+
};
|
|
18
|
+
c(() => {
|
|
19
|
+
T || X();
|
|
20
|
+
}, [T]);
|
|
21
|
+
let Z = (e) => {
|
|
22
|
+
L(e), z(e.name), V(e.description ?? ""), U(e.kind), G(typeof e.smartRule?.animalType == "string" ? e.smartRule.animalType : ""), q(typeof e.smartRule?.productionType == "string" ? e.smartRule.productionType : "");
|
|
23
|
+
}, Q = () => {
|
|
24
|
+
if (H !== "SMART") return;
|
|
25
|
+
let e = {};
|
|
26
|
+
return W && (e.animalType = W), K.trim() && (e.productionType = K.trim()), e;
|
|
27
|
+
}, $ = async () => {
|
|
28
|
+
if (R.trim()) {
|
|
29
|
+
Y(!0);
|
|
30
|
+
try {
|
|
31
|
+
let e = {
|
|
32
|
+
name: R.trim(),
|
|
33
|
+
description: B.trim() || null,
|
|
34
|
+
kind: H,
|
|
35
|
+
smartRule: Q()
|
|
36
|
+
};
|
|
37
|
+
I ? (await N({
|
|
38
|
+
id: I.id,
|
|
39
|
+
...e
|
|
40
|
+
}), k({
|
|
41
|
+
title: O("healthybowl.livestock.depth.groups.toast.updated", "Group updated"),
|
|
42
|
+
variant: "success"
|
|
43
|
+
})) : (await M(e), k({
|
|
44
|
+
title: O("healthybowl.livestock.depth.groups.toast.created", "Group created"),
|
|
45
|
+
variant: "success"
|
|
46
|
+
})), X(), await F(), D?.();
|
|
47
|
+
} catch (e) {
|
|
48
|
+
k({
|
|
49
|
+
title: O("healthybowl.livestock.depth.groups.toast.failed", "Could not save group"),
|
|
50
|
+
description: e instanceof Error ? e.message : String(e),
|
|
51
|
+
variant: "error"
|
|
52
|
+
});
|
|
53
|
+
} finally {
|
|
54
|
+
Y(!1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, ee = async (e) => {
|
|
58
|
+
if (await A({
|
|
59
|
+
title: O("healthybowl.livestock.depth.groups.confirm.title", "Delete group?"),
|
|
60
|
+
message: O("healthybowl.livestock.depth.groups.confirm.message", "Delete \"{{name}}\"? Its animals are detached (not deleted).", { name: e.name })
|
|
61
|
+
})) {
|
|
62
|
+
Y(!0);
|
|
63
|
+
try {
|
|
64
|
+
await P(e.id), k({
|
|
65
|
+
title: O("healthybowl.livestock.depth.groups.toast.deleted", "Group deleted"),
|
|
66
|
+
variant: "success"
|
|
67
|
+
}), I?.id === e.id && X(), await F(), D?.();
|
|
68
|
+
} catch (e) {
|
|
69
|
+
k({
|
|
70
|
+
title: O("healthybowl.livestock.depth.groups.toast.deleteFailed", "Could not delete group"),
|
|
71
|
+
description: e instanceof Error ? e.message : String(e),
|
|
72
|
+
variant: "error"
|
|
73
|
+
});
|
|
74
|
+
} finally {
|
|
75
|
+
Y(!1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return /* @__PURE__ */ m(n, {
|
|
80
|
+
open: T,
|
|
81
|
+
onClose: E,
|
|
82
|
+
title: O("healthybowl.livestock.depth.groups.manage", "Manage animal groups"),
|
|
83
|
+
size: "lg",
|
|
84
|
+
children: /* @__PURE__ */ h("div", {
|
|
85
|
+
className: "space-y-4",
|
|
86
|
+
children: [/* @__PURE__ */ m("div", {
|
|
87
|
+
className: "space-y-2",
|
|
88
|
+
children: j.length === 0 ? /* @__PURE__ */ m("p", {
|
|
89
|
+
className: "text-sm text-text-secondary",
|
|
90
|
+
children: O("healthybowl.livestock.depth.groups.none", "No groups yet. Create one below.")
|
|
91
|
+
}) : j.map((t) => /* @__PURE__ */ h("div", {
|
|
92
|
+
className: "flex items-center justify-between rounded-md border border-border-subtle bg-bg-surface px-3 py-2",
|
|
93
|
+
children: [/* @__PURE__ */ h("div", {
|
|
94
|
+
className: "flex items-center gap-2",
|
|
95
|
+
children: [
|
|
96
|
+
t.kind === "SMART" ? /* @__PURE__ */ m(d, { className: "h-4 w-4 text-text-secondary" }) : null,
|
|
97
|
+
/* @__PURE__ */ m("span", {
|
|
98
|
+
className: "font-medium text-text-primary",
|
|
99
|
+
children: t.name
|
|
100
|
+
}),
|
|
101
|
+
/* @__PURE__ */ m(e, {
|
|
102
|
+
variant: s(t.kind),
|
|
103
|
+
label: t.kind
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ m("span", {
|
|
106
|
+
className: "text-xs tabular-nums text-text-secondary",
|
|
107
|
+
children: O("healthybowl.livestock.depth.groups.count", "{{n}} animals", { n: t.animalCount })
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
}), /* @__PURE__ */ h("div", {
|
|
111
|
+
className: "flex items-center gap-1",
|
|
112
|
+
children: [/* @__PURE__ */ m(g, {
|
|
113
|
+
variant: "ghost",
|
|
114
|
+
size: "sm",
|
|
115
|
+
onClick: () => Z(t),
|
|
116
|
+
disabled: J,
|
|
117
|
+
children: O("healthybowl.livestock.depth.groups.edit", "Edit")
|
|
118
|
+
}), /* @__PURE__ */ m(g, {
|
|
119
|
+
variant: "ghost",
|
|
120
|
+
size: "icon-sm",
|
|
121
|
+
onClick: () => void ee(t),
|
|
122
|
+
disabled: J,
|
|
123
|
+
"aria-label": O("healthybowl.livestock.depth.groups.delete", "Delete group"),
|
|
124
|
+
className: "text-text-secondary hover:text-status-error-text",
|
|
125
|
+
children: /* @__PURE__ */ m(p, { className: "h-4 w-4" })
|
|
126
|
+
})]
|
|
127
|
+
})]
|
|
128
|
+
}, t.id))
|
|
129
|
+
}), /* @__PURE__ */ h("div", {
|
|
130
|
+
className: "rounded-lg border border-border-subtle p-3",
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ m("h4", {
|
|
133
|
+
className: "mb-2 text-sm font-semibold text-text-primary",
|
|
134
|
+
children: I ? O("healthybowl.livestock.depth.groups.editHeading", "Edit group") : O("healthybowl.livestock.depth.groups.newHeading", "New group")
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ h("div", {
|
|
137
|
+
className: "grid grid-cols-1 gap-3 sm:grid-cols-2",
|
|
138
|
+
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
|
|
139
|
+
className: w,
|
|
140
|
+
children: O("healthybowl.livestock.depth.groups.name", "Name")
|
|
141
|
+
}), /* @__PURE__ */ m(_, {
|
|
142
|
+
value: R,
|
|
143
|
+
onChange: (e) => z(e.target.value),
|
|
144
|
+
placeholder: "Milking Herd"
|
|
145
|
+
})] }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
|
|
146
|
+
className: w,
|
|
147
|
+
children: O("healthybowl.livestock.depth.groups.kind", "Type")
|
|
148
|
+
}), /* @__PURE__ */ h(v, {
|
|
149
|
+
value: H,
|
|
150
|
+
onValueChange: U,
|
|
151
|
+
children: [/* @__PURE__ */ m(x, { children: /* @__PURE__ */ m(S, {}) }), /* @__PURE__ */ m(y, { children: o.map((e) => /* @__PURE__ */ m(b, {
|
|
152
|
+
value: e,
|
|
153
|
+
children: e
|
|
154
|
+
}, e)) })]
|
|
155
|
+
})] })]
|
|
156
|
+
}),
|
|
157
|
+
/* @__PURE__ */ h("div", {
|
|
158
|
+
className: "mt-3",
|
|
159
|
+
children: [/* @__PURE__ */ m("label", {
|
|
160
|
+
className: w,
|
|
161
|
+
children: O("healthybowl.livestock.depth.groups.description", "Description")
|
|
162
|
+
}), /* @__PURE__ */ m(C, {
|
|
163
|
+
value: B,
|
|
164
|
+
onChange: (e) => V(e.target.value),
|
|
165
|
+
rows: 2
|
|
166
|
+
})]
|
|
167
|
+
}),
|
|
168
|
+
H === "SMART" ? /* @__PURE__ */ h("div", {
|
|
169
|
+
className: "mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2",
|
|
170
|
+
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
|
|
171
|
+
className: w,
|
|
172
|
+
children: O("healthybowl.livestock.depth.groups.ruleType", "Rule: species")
|
|
173
|
+
}), /* @__PURE__ */ h(v, {
|
|
174
|
+
value: W,
|
|
175
|
+
onValueChange: G,
|
|
176
|
+
children: [/* @__PURE__ */ m(x, { children: /* @__PURE__ */ m(S, { placeholder: O("healthybowl.livestock.depth.groups.anySpecies", "Any species") }) }), /* @__PURE__ */ m(y, { children: a.map((e) => /* @__PURE__ */ m(b, {
|
|
177
|
+
value: e,
|
|
178
|
+
children: e
|
|
179
|
+
}, e)) })]
|
|
180
|
+
})] }), /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
|
|
181
|
+
className: w,
|
|
182
|
+
children: O("healthybowl.livestock.depth.groups.ruleProduction", "Rule: production type")
|
|
183
|
+
}), /* @__PURE__ */ m(_, {
|
|
184
|
+
value: K,
|
|
185
|
+
onChange: (e) => q(e.target.value),
|
|
186
|
+
placeholder: "DAIRY"
|
|
187
|
+
})] })]
|
|
188
|
+
}) : null,
|
|
189
|
+
/* @__PURE__ */ h("div", {
|
|
190
|
+
className: "mt-4 flex items-center gap-2",
|
|
191
|
+
children: [/* @__PURE__ */ h(g, {
|
|
192
|
+
onClick: () => void $(),
|
|
193
|
+
disabled: J || !R.trim(),
|
|
194
|
+
children: [/* @__PURE__ */ m(f, { className: "h-4 w-4" }), I ? O("healthybowl.livestock.depth.groups.save", "Save group") : O("healthybowl.livestock.depth.groups.create", "Create group")]
|
|
195
|
+
}), I ? /* @__PURE__ */ m(g, {
|
|
196
|
+
variant: "ghost",
|
|
197
|
+
onClick: X,
|
|
198
|
+
disabled: J,
|
|
199
|
+
children: O("healthybowl.livestock.depth.groups.cancel", "Cancel")
|
|
200
|
+
}) : null]
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
})]
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
export { T as AnimalGroupModal };
|
|
209
|
+
|
|
210
|
+
//# sourceMappingURL=AnimalGroupModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimalGroupModal.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalGroupModal.tsx"],"sourcesContent":["/**\n * Manage animal groups (BOFF-2890 · L-1).\n * List existing manual/smart groups with their live member counts, delete them, and\n * create/edit a group. A SMART group carries a rule (species + production type) evaluated\n * server-side; a MANUAL group is an explicit membership set assigned from an animal's record.\n * Every value is a real record — no fabricated data.\n */\nimport { useEffect, useState } from 'react';\nimport { Network, Plus, Trash2 } from 'lucide-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, StatusBadge, useConfirm } from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowlLivestockDepth, type AnimalGroup } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { ANIMAL_TYPES, GROUP_KINDS, groupKindVariant } from './depthLabels';\n\ninterface AnimalGroupModalProps {\n open: boolean;\n onClose: () => void;\n /** Called after any group mutation so the caller can refetch the herd view. */\n onChanged?: () => void;\n}\n\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\n\nexport const AnimalGroupModal = ({ open, onClose, onChanged }: AnimalGroupModalProps) => {\n const { t } = useI18n();\n const { toast } = useToast();\n const confirm = useConfirm();\n const { groups, createGroup, updateGroup, deleteGroup, refetchGroups } = useHealthyBowlLivestockDepth({\n groups: true,\n });\n\n const [editing, setEditing] = useState<AnimalGroup | null>(null);\n const [name, setName] = useState('');\n const [description, setDescription] = useState('');\n const [kind, setKind] = useState('MANUAL');\n const [ruleType, setRuleType] = useState('');\n const [ruleProduction, setRuleProduction] = useState('');\n const [busy, setBusy] = useState(false);\n\n const resetForm = () => {\n setEditing(null);\n setName('');\n setDescription('');\n setKind('MANUAL');\n setRuleType('');\n setRuleProduction('');\n };\n\n useEffect(() => {\n if (!open) resetForm();\n }, [open]);\n\n const startEdit = (g: AnimalGroup) => {\n setEditing(g);\n setName(g.name);\n setDescription(g.description ?? '');\n setKind(g.kind);\n setRuleType(typeof g.smartRule?.animalType === 'string' ? (g.smartRule.animalType as string) : '');\n setRuleProduction(typeof g.smartRule?.productionType === 'string' ? (g.smartRule.productionType as string) : '');\n };\n\n const buildSmartRule = (): Record<string, unknown> | undefined => {\n if (kind !== 'SMART') return undefined;\n const rule: Record<string, unknown> = {};\n if (ruleType) rule.animalType = ruleType;\n if (ruleProduction.trim()) rule.productionType = ruleProduction.trim();\n return rule;\n };\n\n const handleSubmit = async () => {\n if (!name.trim()) return;\n setBusy(true);\n try {\n const base = { name: name.trim(), description: description.trim() || null, kind, smartRule: buildSmartRule() };\n if (editing) {\n await updateGroup({ id: editing.id, ...base });\n toast({ title: t('healthybowl.livestock.depth.groups.toast.updated', 'Group updated'), variant: 'success' });\n } else {\n await createGroup(base);\n toast({ title: t('healthybowl.livestock.depth.groups.toast.created', 'Group created'), variant: 'success' });\n }\n resetForm();\n await refetchGroups();\n onChanged?.();\n } catch (err) {\n toast({\n title: t('healthybowl.livestock.depth.groups.toast.failed', 'Could not save group'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusy(false);\n }\n };\n\n const handleDelete = async (g: AnimalGroup) => {\n if (\n !(await confirm({\n title: t('healthybowl.livestock.depth.groups.confirm.title', 'Delete group?'),\n message: t(\n 'healthybowl.livestock.depth.groups.confirm.message',\n 'Delete \"{{name}}\"? Its animals are detached (not deleted).',\n { name: g.name }\n ),\n }))\n )\n return;\n setBusy(true);\n try {\n await deleteGroup(g.id);\n toast({ title: t('healthybowl.livestock.depth.groups.toast.deleted', 'Group deleted'), variant: 'success' });\n if (editing?.id === g.id) resetForm();\n await refetchGroups();\n onChanged?.();\n } catch (err) {\n toast({\n title: t('healthybowl.livestock.depth.groups.toast.deleteFailed', 'Could not delete group'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setBusy(false);\n }\n };\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.livestock.depth.groups.manage', 'Manage animal groups')}\n size=\"lg\"\n >\n <div className=\"space-y-4\">\n <div className=\"space-y-2\">\n {groups.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.livestock.depth.groups.none', 'No groups yet. Create one below.')}\n </p>\n ) : (\n groups.map((g) => (\n <div\n key={g.id}\n className=\"flex items-center justify-between rounded-md border border-border-subtle bg-bg-surface px-3 py-2\"\n >\n <div className=\"flex items-center gap-2\">\n {g.kind === 'SMART' ? <Network className=\"h-4 w-4 text-text-secondary\" /> : null}\n <span className=\"font-medium text-text-primary\">{g.name}</span>\n <StatusBadge variant={groupKindVariant(g.kind)} label={g.kind} />\n <span className=\"text-xs tabular-nums text-text-secondary\">\n {t('healthybowl.livestock.depth.groups.count', '{{n}} animals', { n: g.animalCount })}\n </span>\n </div>\n <div className=\"flex items-center gap-1\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => startEdit(g)} disabled={busy}>\n {t('healthybowl.livestock.depth.groups.edit', 'Edit')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n onClick={() => void handleDelete(g)}\n disabled={busy}\n aria-label={t('healthybowl.livestock.depth.groups.delete', 'Delete group')}\n className=\"text-text-secondary hover:text-status-error-text\"\n >\n <Trash2 className=\"h-4 w-4\" />\n </Button>\n </div>\n </div>\n ))\n )}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle p-3\">\n <h4 className=\"mb-2 text-sm font-semibold text-text-primary\">\n {editing\n ? t('healthybowl.livestock.depth.groups.editHeading', 'Edit group')\n : t('healthybowl.livestock.depth.groups.newHeading', 'New group')}\n </h4>\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.groups.name', 'Name')}</label>\n <Input value={name} onChange={(e) => setName(e.target.value)} placeholder=\"Milking Herd\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.groups.kind', 'Type')}</label>\n <Select value={kind} onValueChange={setKind}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {GROUP_KINDS.map((k) => (\n <SelectItem key={k} value={k}>\n {k}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n <div className=\"mt-3\">\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.groups.description', 'Description')}</label>\n <Textarea value={description} onChange={(e) => setDescription(e.target.value)} rows={2} />\n </div>\n {kind === 'SMART' ? (\n <div className=\"mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2\">\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.groups.ruleType', 'Rule: species')}\n </label>\n <Select value={ruleType} onValueChange={setRuleType}>\n <SelectTrigger>\n <SelectValue placeholder={t('healthybowl.livestock.depth.groups.anySpecies', 'Any species')} />\n </SelectTrigger>\n <SelectContent>\n {ANIMAL_TYPES.map((a) => (\n <SelectItem key={a} value={a}>\n {a}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.groups.ruleProduction', 'Rule: production type')}\n </label>\n <Input value={ruleProduction} onChange={(e) => setRuleProduction(e.target.value)} placeholder=\"DAIRY\" />\n </div>\n </div>\n ) : null}\n <div className=\"mt-4 flex items-center gap-2\">\n <Button onClick={() => void handleSubmit()} disabled={busy || !name.trim()}>\n <Plus className=\"h-4 w-4\" />\n {editing\n ? t('healthybowl.livestock.depth.groups.save', 'Save group')\n : t('healthybowl.livestock.depth.groups.create', 'Create group')}\n </Button>\n {editing ? (\n <Button variant=\"ghost\" onClick={resetForm} disabled={busy}>\n {t('healthybowl.livestock.depth.groups.cancel', 'Cancel')}\n </Button>\n ) : null}\n </div>\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAgCA,IAAM,IAAa,oDAEN,KAAoB,EAAE,SAAM,YAAS,mBAAuC;CACvF,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,aAAU,GAAU,EACtB,IAAU,GAAY,EACtB,EAAE,WAAQ,gBAAa,gBAAa,gBAAa,qBAAkB,EAA6B,EACpG,QAAQ,IACT,CAAC,EAEI,CAAC,GAAS,KAAc,EAA6B,KAAK,EAC1D,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAM,KAAW,EAAS,SAAS,EACpC,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAgB,KAAqB,EAAS,GAAG,EAClD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AU,OAAO;OAAa,WAAW,MAAM,EAAe,EAAE,OAAO,MAAM;OAAE,MAAM;OAAK,CAAA,CACtF;;KACL,MAAS,UACR,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;OAAO,WAAW;iBACf,EAAE,+CAA+C,gBAAgB;OAC5D,CAAA,EACR,kBAAC,GAAD;OAAQ,OAAO;OAAU,eAAe;iBAAxC,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAa,aAAa,EAAE,iDAAiD,cAAc,EAAI,CAAA,EACjF,CAAA,EAChB,kBAAC,GAAD,EAAA,UACG,EAAa,KAAK,MACjB,kBAAC,GAAD;QAAoB,OAAO;kBACxB;QACU,EAFI,EAEJ,CACb,EACY,CAAA,CACT;SACL,EAAA,CAAA,EACN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;OAAO,WAAW;iBACf,EAAE,qDAAqD,wBAAwB;OAC1E,CAAA,EACR,kBAAC,GAAD;OAAO,OAAO;OAAgB,WAAW,MAAM,EAAkB,EAAE,OAAO,MAAM;OAAE,aAAY;OAAU,CAAA,CACpG,EAAA,CAAA,CACF;UACJ;KACJ,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,GAAD;OAAQ,eAAe,KAAK,GAAc;OAAE,UAAU,KAAQ,CAAC,EAAK,MAAM;iBAA1E,CACE,kBAAC,GAAD,EAAM,WAAU,WAAY,CAAA,EAC3B,IACG,EAAE,2CAA2C,aAAa,GAC1D,EAAE,6CAA6C,eAAe,CAC3D;UACR,IACC,kBAAC,GAAD;OAAQ,SAAQ;OAAQ,SAAS;OAAW,UAAU;iBACnD,EAAE,6CAA6C,SAAS;OAClD,CAAA,GACP,KACA;;KACF;MACF;;EACA,CAAA"}
|
|
@@ -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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GAAG;MAC/B,WAAW,0DAA0D,MAAY,EAAE,KAAK,8BAA8B;gBAJxH;OAMG,EAAE,SAAS,UAAU,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;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;MAAoB,OAAO;gBACxB;MACU,EAFI,EAEJ,CACb,EACY,CAAA,CACT;OACL,EAAA,CAAA;IACN,kBAAC,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"}
|