@burdenoff/microfe-healthybowl 2026.714.3 → 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.
Files changed (45) hide show
  1. package/dist/healthybowl/HealthyBowlRoutes.js +137 -113
  2. package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
  3. package/dist/healthybowl/hooks/useHealthyBowlContacts.js +149 -0
  4. package/dist/healthybowl/hooks/useHealthyBowlContacts.js.map +1 -0
  5. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js +200 -0
  6. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js.map +1 -0
  7. package/dist/healthybowl/hooks/useHealthyBowlStorage.js +162 -0
  8. package/dist/healthybowl/hooks/useHealthyBowlStorage.js.map +1 -0
  9. package/dist/healthybowl/pages/contacts/ContactDetailPage.js +224 -0
  10. package/dist/healthybowl/pages/contacts/ContactDetailPage.js.map +1 -0
  11. package/dist/healthybowl/pages/contacts/ContactFormModal.js +147 -0
  12. package/dist/healthybowl/pages/contacts/ContactFormModal.js.map +1 -0
  13. package/dist/healthybowl/pages/contacts/ContactsPage.js +241 -0
  14. package/dist/healthybowl/pages/contacts/ContactsPage.js.map +1 -0
  15. package/dist/healthybowl/pages/contacts/CsvImportModal.js +155 -0
  16. package/dist/healthybowl/pages/contacts/CsvImportModal.js.map +1 -0
  17. package/dist/healthybowl/pages/contacts/RecordOrderModal.js +131 -0
  18. package/dist/healthybowl/pages/contacts/RecordOrderModal.js.map +1 -0
  19. package/dist/healthybowl/pages/contacts/labels.js +46 -0
  20. package/dist/healthybowl/pages/contacts/labels.js.map +1 -0
  21. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js +152 -0
  22. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js.map +1 -0
  23. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js +245 -0
  24. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js.map +1 -0
  25. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js +210 -0
  26. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js.map +1 -0
  27. package/dist/healthybowl/pages/livestock/HerdDepthPage.js +189 -0
  28. package/dist/healthybowl/pages/livestock/HerdDepthPage.js.map +1 -0
  29. package/dist/healthybowl/pages/livestock/RecordWeightModal.js +100 -0
  30. package/dist/healthybowl/pages/livestock/RecordWeightModal.js.map +1 -0
  31. package/dist/healthybowl/pages/livestock/depthLabels.js +31 -0
  32. package/dist/healthybowl/pages/livestock/depthLabels.js.map +1 -0
  33. package/dist/healthybowl/pages/storage/PlaceLotModal.js +150 -0
  34. package/dist/healthybowl/pages/storage/PlaceLotModal.js.map +1 -0
  35. package/dist/healthybowl/pages/storage/RecordMovementModal.js +140 -0
  36. package/dist/healthybowl/pages/storage/RecordMovementModal.js.map +1 -0
  37. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js +139 -0
  38. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js.map +1 -0
  39. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js +150 -0
  40. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js.map +1 -0
  41. package/dist/healthybowl/pages/storage/StoragePage.js +251 -0
  42. package/dist/healthybowl/pages/storage/StoragePage.js.map +1 -0
  43. package/dist/healthybowl/pages/storage/labels.js +67 -0
  44. package/dist/healthybowl/pages/storage/labels.js.map +1 -0
  45. 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;IAAa,CAAA,GAAG,KACrF,EAAA,CAAA;GAET;EACD;GACE,KAAK;GACL,QAAQ,EAAE,4CAA4C,SAAS;GAC/D,SAAS,MACP,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,OAAD;IAAK,WAAU;cAAqB,EAAE;IAAW,CAAA,EACjD,kBAAC,OAAD;IAAK,WAAU;cAA+B,EAAE;IAAW,CAAA,CACvD,EAAA,CAAA;GAET;EACD;GACE,KAAK;GACL,QAAQ,EAAE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AC3F,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,EAA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AAA,UACE,kBAAC,GAAD,EAAe,CAAA,EACD,CAAA,EAChB,kBAAC,GAAD,EAAA,UACG,EAAe,KAAK,MACnB,kBAAC,GAAD;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"}
@@ -0,0 +1,150 @@
1
+ import { Modal as e } from "../../components/Modal.js";
2
+ import "../../components/index.js";
3
+ import { useEffect as t, useState as n } from "react";
4
+ import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { Button as o, Input as s, Select as c, SelectContent as l, SelectItem as u, SelectTrigger as d, SelectValue as f, Textarea as p } from "@burdenoff/fe-libs/ui";
7
+ //#region src/healthybowl/pages/storage/PlaceLotModal.tsx
8
+ var m = "mb-1 block text-sm font-medium text-text-primary", h = "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)]", g = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), _ = ({ open: _, onClose: v, bins: y, defaultLocationId: b, onSubmit: x }) => {
9
+ let { t: S } = r(), [C, w] = n(""), [T, E] = n(""), [D, O] = n(""), [k, A] = n(""), [j, M] = n("kg"), [N, P] = n(g()), [F, I] = n(""), [L, R] = n(""), [z, B] = n(!1), [V, H] = n(null);
10
+ t(() => {
11
+ _ && (H(null), w(b ?? y[0]?.id ?? ""), E(""), O(""), A(""), M("kg"), P(g()), I(""), R(""));
12
+ }, [
13
+ _,
14
+ b,
15
+ y
16
+ ]);
17
+ let U = !!C && T.trim() && D.trim() && Number(k) > 0 && !z, W = async () => {
18
+ if (U) {
19
+ B(!0), H(null);
20
+ try {
21
+ await x({
22
+ locationId: C,
23
+ lotCode: T.trim(),
24
+ produce: D.trim(),
25
+ quantity: Number(k),
26
+ unit: j.trim() || "kg",
27
+ receivedAt: N || null,
28
+ expiryDate: F || null,
29
+ notes: L.trim() || null
30
+ }), v();
31
+ } catch (e) {
32
+ H(e instanceof Error ? e.message : String(e));
33
+ } finally {
34
+ B(!1);
35
+ }
36
+ }
37
+ };
38
+ return /* @__PURE__ */ i(e, {
39
+ open: _,
40
+ onClose: v,
41
+ title: S("healthybowl.storage.lot.placeTitle", "Place Lot"),
42
+ description: S("healthybowl.storage.lot.placeSubtitle", "Store a lot of produce or milk in a bin."),
43
+ size: "md",
44
+ footer: /* @__PURE__ */ a("div", {
45
+ className: "flex items-center justify-end gap-2",
46
+ children: [/* @__PURE__ */ i(o, {
47
+ variant: "ghost",
48
+ onClick: v,
49
+ disabled: z,
50
+ children: S("common.cancel", "Cancel")
51
+ }), /* @__PURE__ */ i(o, {
52
+ onClick: () => void W(),
53
+ disabled: !U,
54
+ children: S("healthybowl.storage.lot.place", "Place Lot")
55
+ })]
56
+ }),
57
+ children: /* @__PURE__ */ a("div", {
58
+ className: "space-y-4",
59
+ children: [
60
+ V ? /* @__PURE__ */ i("div", {
61
+ className: "rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text",
62
+ children: V
63
+ }) : null,
64
+ /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
65
+ className: m,
66
+ children: S("healthybowl.storage.lot.bin", "Bin")
67
+ }), y.length === 0 ? /* @__PURE__ */ i("p", {
68
+ className: "text-sm text-status-warning-text",
69
+ children: S("healthybowl.storage.lot.noBins", "Create a bin first (Add Location → Bin).")
70
+ }) : /* @__PURE__ */ a(c, {
71
+ value: C,
72
+ onValueChange: w,
73
+ children: [/* @__PURE__ */ i(d, { children: /* @__PURE__ */ i(f, { placeholder: S("healthybowl.storage.lot.selectBin", "Select a bin") }) }), /* @__PURE__ */ i(l, { children: y.map((e) => /* @__PURE__ */ i(u, {
74
+ value: e.id,
75
+ children: e.name
76
+ }, e.id)) })]
77
+ })] }),
78
+ /* @__PURE__ */ a("div", {
79
+ className: "grid grid-cols-2 gap-4",
80
+ children: [/* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
81
+ className: m,
82
+ children: S("healthybowl.storage.lot.code", "Lot Code")
83
+ }), /* @__PURE__ */ i(s, {
84
+ value: T,
85
+ onChange: (e) => E(e.target.value),
86
+ placeholder: "TR-204"
87
+ })] }), /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
88
+ className: m,
89
+ children: S("healthybowl.storage.lot.produce", "Produce")
90
+ }), /* @__PURE__ */ i(s, {
91
+ value: D,
92
+ onChange: (e) => O(e.target.value),
93
+ placeholder: "Tomatoes"
94
+ })] })]
95
+ }),
96
+ /* @__PURE__ */ a("div", {
97
+ className: "grid grid-cols-2 gap-4",
98
+ children: [/* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
99
+ className: m,
100
+ children: S("healthybowl.storage.lot.quantity", "Quantity")
101
+ }), /* @__PURE__ */ i(s, {
102
+ type: "number",
103
+ value: k,
104
+ onChange: (e) => A(e.target.value),
105
+ placeholder: "480"
106
+ })] }), /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
107
+ className: m,
108
+ children: S("healthybowl.storage.lot.unit", "Unit")
109
+ }), /* @__PURE__ */ i(s, {
110
+ value: j,
111
+ onChange: (e) => M(e.target.value),
112
+ placeholder: "kg"
113
+ })] })]
114
+ }),
115
+ /* @__PURE__ */ a("div", {
116
+ className: "grid grid-cols-2 gap-4",
117
+ children: [/* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
118
+ className: m,
119
+ children: S("healthybowl.storage.lot.received", "Received")
120
+ }), /* @__PURE__ */ i("input", {
121
+ type: "date",
122
+ value: N,
123
+ onChange: (e) => P(e.target.value),
124
+ className: h
125
+ })] }), /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
126
+ className: m,
127
+ children: S("healthybowl.storage.lot.expiry", "Expiry")
128
+ }), /* @__PURE__ */ i("input", {
129
+ type: "date",
130
+ value: F,
131
+ onChange: (e) => I(e.target.value),
132
+ className: h
133
+ })] })]
134
+ }),
135
+ /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ i("label", {
136
+ className: m,
137
+ children: S("healthybowl.storage.lot.notes", "Notes")
138
+ }), /* @__PURE__ */ i(p, {
139
+ value: L,
140
+ onChange: (e) => R(e.target.value),
141
+ rows: 2
142
+ })] })
143
+ ]
144
+ })
145
+ });
146
+ };
147
+ //#endregion
148
+ export { _ as PlaceLotModal };
149
+
150
+ //# sourceMappingURL=PlaceLotModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaceLotModal.js","names":[],"sources":["../../../../src/healthybowl/pages/storage/PlaceLotModal.tsx"],"sourcesContent":["/**\n * Place a lot of produce/milk into a bin (BOFF-2890 · K-1).\n * Records an opening IN movement of the initial quantity. All fields user-entered.\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 type { StorageLocation } from '../../hooks/useHealthyBowlStorage';\n\ninterface PlaceLotModalProps {\n open: boolean;\n onClose: () => void;\n /** Bins the lot can be placed into. */\n bins: StorageLocation[];\n defaultLocationId?: string | null;\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\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)]';\nconst todayIso = () => new Date().toISOString().slice(0, 10);\n\nexport const PlaceLotModal = ({ open, onClose, bins, defaultLocationId, onSubmit }: PlaceLotModalProps) => {\n const { t } = useI18n();\n\n const [locationId, setLocationId] = useState('');\n const [lotCode, setLotCode] = useState('');\n const [produce, setProduce] = useState('');\n const [quantity, setQuantity] = useState('');\n const [unit, setUnit] = useState('kg');\n const [receivedAt, setReceivedAt] = useState(todayIso());\n const [expiryDate, setExpiryDate] = useState('');\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 setError(null);\n setLocationId(defaultLocationId ?? bins[0]?.id ?? '');\n setLotCode('');\n setProduce('');\n setQuantity('');\n setUnit('kg');\n setReceivedAt(todayIso());\n setExpiryDate('');\n setNotes('');\n }, [open, defaultLocationId, bins]);\n\n const canSubmit = Boolean(locationId) && lotCode.trim() && produce.trim() && Number(quantity) > 0 && !submitting;\n\n const handleSubmit = async () => {\n if (!canSubmit) return;\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n locationId,\n lotCode: lotCode.trim(),\n produce: produce.trim(),\n quantity: Number(quantity),\n unit: unit.trim() || 'kg',\n receivedAt: receivedAt || null,\n expiryDate: expiryDate || null,\n notes: notes.trim() || null,\n });\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.storage.lot.placeTitle', 'Place Lot')}\n description={t('healthybowl.storage.lot.placeSubtitle', 'Store a lot of produce or milk in a bin.')}\n size=\"md\"\n footer={\n <div className=\"flex items-center justify-end gap-2\">\n <Button variant=\"ghost\" onClick={onClose} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={!canSubmit}>\n {t('healthybowl.storage.lot.place', 'Place Lot')}\n </Button>\n </div>\n }\n >\n <div className=\"space-y-4\">\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\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.bin', 'Bin')}</label>\n {bins.length === 0 ? (\n <p className=\"text-sm text-status-warning-text\">\n {t('healthybowl.storage.lot.noBins', 'Create a bin first (Add Location → Bin).')}\n </p>\n ) : (\n <Select value={locationId} onValueChange={setLocationId}>\n <SelectTrigger>\n <SelectValue placeholder={t('healthybowl.storage.lot.selectBin', 'Select a bin')} />\n </SelectTrigger>\n <SelectContent>\n {bins.map((b) => (\n <SelectItem key={b.id} value={b.id}>\n {b.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n </div>\n\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.code', 'Lot Code')}</label>\n <Input value={lotCode} onChange={(e) => setLotCode(e.target.value)} placeholder=\"TR-204\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.produce', 'Produce')}</label>\n <Input value={produce} onChange={(e) => setProduce(e.target.value)} placeholder=\"Tomatoes\" />\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.quantity', 'Quantity')}</label>\n <Input type=\"number\" value={quantity} onChange={(e) => setQuantity(e.target.value)} placeholder=\"480\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.unit', 'Unit')}</label>\n <Input value={unit} onChange={(e) => setUnit(e.target.value)} placeholder=\"kg\" />\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.received', 'Received')}</label>\n <input\n type=\"date\"\n value={receivedAt}\n onChange={(e) => setReceivedAt(e.target.value)}\n className={dateInput}\n />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.expiry', 'Expiry')}</label>\n <input\n type=\"date\"\n value={expiryDate}\n onChange={(e) => setExpiryDate(e.target.value)}\n className={dateInput}\n />\n </div>\n </div>\n\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.lot.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":";;;;;;;AA4BA,IAAM,IAAa,oDACb,IACJ,wKACI,2BAAiB,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,GAAG,GAAG,EAE/C,KAAiB,EAAE,SAAM,YAAS,SAAM,sBAAmB,kBAAmC;CACzG,IAAM,EAAE,SAAM,GAAS,EAEjB,CAAC,GAAY,KAAiB,EAAS,GAAG,EAC1C,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAM,KAAW,EAAS,KAAK,EAChC,CAAC,GAAY,KAAiB,EAAS,GAAU,CAAC,EAClD,CAAC,GAAY,KAAiB,EAAS,GAAG,EAC1C,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAY,KAAiB,EAAS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