@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,140 @@
1
+ import { cn as e } from "../../utils/helpers.js";
2
+ import { Modal as t } from "../../components/Modal.js";
3
+ import "../../components/index.js";
4
+ import { MOVEMENT_REASONS as n } from "./labels.js";
5
+ import { useEffect as r, useState as i } from "react";
6
+ import { useI18n as a } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ 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";
9
+ //#region src/healthybowl/pages/storage/RecordMovementModal.tsx
10
+ var g = "mb-1 block text-sm font-medium text-text-primary", _ = "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)]", v = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), y = ({ open: y, onClose: b, lot: x, onSubmit: S }) => {
11
+ let { t: C } = a(), [w, T] = i("OUT"), [E, D] = i(""), [O, k] = i("SALE"), [A, j] = i(""), [M, N] = i(v()), [P, F] = i(""), [I, L] = i(!1), [R, z] = i(null);
12
+ r(() => {
13
+ y && (z(null), T("OUT"), D(""), k("SALE"), j(""), N(v()), F(""));
14
+ }, [y]);
15
+ let B = !!x && Number(E) > 0 && !I, V = async () => {
16
+ if (!(!B || !x)) {
17
+ L(!0), z(null);
18
+ try {
19
+ await S({
20
+ lotId: x.id,
21
+ direction: w,
22
+ quantity: Number(E),
23
+ unit: x.unit,
24
+ reason: O,
25
+ reference: A.trim() || null,
26
+ occurredAt: M || null,
27
+ notes: P.trim() || null
28
+ }), b();
29
+ } catch (e) {
30
+ z(e instanceof Error ? e.message : String(e));
31
+ } finally {
32
+ L(!1);
33
+ }
34
+ }
35
+ };
36
+ return /* @__PURE__ */ o(t, {
37
+ open: y,
38
+ onClose: b,
39
+ title: C("healthybowl.storage.movement.title", "Record Movement"),
40
+ description: x ? `${x.produce} · ${x.lotCode} · ${x.quantity} ${x.unit} ${C("healthybowl.storage.movement.onHand", "on hand")}` : void 0,
41
+ size: "md",
42
+ footer: /* @__PURE__ */ s("div", {
43
+ className: "flex items-center justify-end gap-2",
44
+ children: [/* @__PURE__ */ o(c, {
45
+ variant: "ghost",
46
+ onClick: b,
47
+ disabled: I,
48
+ children: C("common.cancel", "Cancel")
49
+ }), /* @__PURE__ */ o(c, {
50
+ onClick: () => void V(),
51
+ disabled: !B,
52
+ children: C("healthybowl.storage.movement.record", "Record")
53
+ })]
54
+ }),
55
+ children: /* @__PURE__ */ s("div", {
56
+ className: "space-y-4",
57
+ children: [
58
+ R ? /* @__PURE__ */ o("div", {
59
+ className: "rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text",
60
+ children: R
61
+ }) : null,
62
+ /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
63
+ className: g,
64
+ children: C("healthybowl.storage.movement.direction", "Direction")
65
+ }), /* @__PURE__ */ s("div", {
66
+ className: "flex gap-2",
67
+ children: [/* @__PURE__ */ o("button", {
68
+ type: "button",
69
+ onClick: () => T("IN"),
70
+ className: e("flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors", w === "IN" ? "bg-status-success-bg text-status-success-text ring-1 ring-status-success-border" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
71
+ children: C("healthybowl.storage.movement.in", "IN (add stock)")
72
+ }), /* @__PURE__ */ o("button", {
73
+ type: "button",
74
+ onClick: () => T("OUT"),
75
+ className: e("flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors", w === "OUT" ? "bg-status-error-bg text-status-error-text ring-1 ring-status-error-border" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
76
+ children: C("healthybowl.storage.movement.out", "OUT (remove stock)")
77
+ })]
78
+ })] }),
79
+ /* @__PURE__ */ s("div", {
80
+ className: "grid grid-cols-2 gap-4",
81
+ children: [/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ s("label", {
82
+ className: g,
83
+ children: [
84
+ C("healthybowl.storage.movement.quantity", "Quantity"),
85
+ " (",
86
+ x?.unit ?? "kg",
87
+ ")"
88
+ ]
89
+ }), /* @__PURE__ */ o(l, {
90
+ type: "number",
91
+ value: E,
92
+ onChange: (e) => D(e.target.value),
93
+ placeholder: "200"
94
+ })] }), /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
95
+ className: g,
96
+ children: C("healthybowl.storage.movement.reason", "Reason")
97
+ }), /* @__PURE__ */ s(u, {
98
+ value: O,
99
+ onValueChange: k,
100
+ children: [/* @__PURE__ */ o(p, { children: /* @__PURE__ */ o(m, {}) }), /* @__PURE__ */ o(d, { children: n.map((e) => /* @__PURE__ */ o(f, {
101
+ value: e.value,
102
+ children: e.label
103
+ }, e.value)) })]
104
+ })] })]
105
+ }),
106
+ /* @__PURE__ */ s("div", {
107
+ className: "grid grid-cols-2 gap-4",
108
+ children: [/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
109
+ className: g,
110
+ children: C("healthybowl.storage.movement.reference", "Reference")
111
+ }), /* @__PURE__ */ o(l, {
112
+ value: A,
113
+ onChange: (e) => j(e.target.value),
114
+ placeholder: "Order #BB-118"
115
+ })] }), /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
116
+ className: g,
117
+ children: C("healthybowl.storage.movement.date", "Date")
118
+ }), /* @__PURE__ */ o("input", {
119
+ type: "date",
120
+ value: M,
121
+ onChange: (e) => N(e.target.value),
122
+ className: _
123
+ })] })]
124
+ }),
125
+ /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
126
+ className: g,
127
+ children: C("healthybowl.storage.movement.notes", "Notes")
128
+ }), /* @__PURE__ */ o(h, {
129
+ value: P,
130
+ onChange: (e) => F(e.target.value),
131
+ rows: 2
132
+ })] })
133
+ ]
134
+ })
135
+ });
136
+ };
137
+ //#endregion
138
+ export { y as RecordMovementModal };
139
+
140
+ //# sourceMappingURL=RecordMovementModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecordMovementModal.js","names":[],"sources":["../../../../src/healthybowl/pages/storage/RecordMovementModal.tsx"],"sourcesContent":["/**\n * Record an IN/OUT stock movement on a lot (BOFF-2890 · K-1).\n * Adjusts the lot's on-hand quantity; every movement is a real ledger entry.\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 { cn } from '../../utils/helpers';\nimport type { StorageLot } from '../../hooks/useHealthyBowlStorage';\nimport { MOVEMENT_REASONS } from './labels';\n\ninterface RecordMovementModalProps {\n open: boolean;\n onClose: () => void;\n lot: StorageLot | 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 RecordMovementModal = ({ open, onClose, lot, onSubmit }: RecordMovementModalProps) => {\n const { t } = useI18n();\n\n const [direction, setDirection] = useState<'IN' | 'OUT'>('OUT');\n const [quantity, setQuantity] = useState('');\n const [reason, setReason] = useState('SALE');\n const [reference, setReference] = useState('');\n const [occurredAt, setOccurredAt] = useState(todayIso());\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 setDirection('OUT');\n setQuantity('');\n setReason('SALE');\n setReference('');\n setOccurredAt(todayIso());\n setNotes('');\n }, [open]);\n\n const canSubmit = Boolean(lot) && Number(quantity) > 0 && !submitting;\n\n const handleSubmit = async () => {\n if (!canSubmit || !lot) return;\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n lotId: lot.id,\n direction,\n quantity: Number(quantity),\n unit: lot.unit,\n reason,\n reference: reference.trim() || null,\n occurredAt: occurredAt || 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.movement.title', 'Record Movement')}\n description={\n lot\n ? `${lot.produce} · ${lot.lotCode} · ${lot.quantity} ${lot.unit} ${t('healthybowl.storage.movement.onHand', 'on hand')}`\n : undefined\n }\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.movement.record', 'Record')}\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.movement.direction', 'Direction')}</label>\n <div className=\"flex gap-2\">\n <button\n type=\"button\"\n onClick={() => setDirection('IN')}\n className={cn(\n 'flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors',\n direction === 'IN'\n ? 'bg-status-success-bg text-status-success-text ring-1 ring-status-success-border'\n : 'bg-bg-sunken text-text-secondary hover:text-text-primary'\n )}\n >\n {t('healthybowl.storage.movement.in', 'IN (add stock)')}\n </button>\n <button\n type=\"button\"\n onClick={() => setDirection('OUT')}\n className={cn(\n 'flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors',\n direction === 'OUT'\n ? 'bg-status-error-bg text-status-error-text ring-1 ring-status-error-border'\n : 'bg-bg-sunken text-text-secondary hover:text-text-primary'\n )}\n >\n {t('healthybowl.storage.movement.out', 'OUT (remove stock)')}\n </button>\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.storage.movement.quantity', 'Quantity')} ({lot?.unit ?? 'kg'})\n </label>\n <Input type=\"number\" value={quantity} onChange={(e) => setQuantity(e.target.value)} placeholder=\"200\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.movement.reason', 'Reason')}</label>\n <Select value={reason} onValueChange={setReason}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {MOVEMENT_REASONS.map((r) => (\n <SelectItem key={r.value} value={r.value}>\n {r.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.movement.reference', 'Reference')}</label>\n <Input value={reference} onChange={(e) => setReference(e.target.value)} placeholder=\"Order #BB-118\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.movement.date', 'Date')}</label>\n <input\n type=\"date\"\n value={occurredAt}\n onChange={(e) => setOccurredAt(e.target.value)}\n className={dateInput}\n />\n </div>\n </div>\n\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.movement.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,KAAuB,EAAE,SAAM,YAAS,QAAK,kBAAyC;CACjG,IAAM,EAAE,SAAM,GAAS,EAEjB,CAAC,GAAW,KAAgB,EAAuB,MAAM,EACzD,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAQ,KAAa,EAAS,OAAO,EACtC,CAAC,GAAW,KAAgB,EAAS,GAAG,EACxC,CAAC,GAAY,KAAiB,EAAS,GAAU,CAAC,EAClD,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAO,KAAY,EAAwB,KAAK;AAEvD,SAAgB;AACT,QACL,EAAS,KAAK,EACd,EAAa,MAAM,EACnB,EAAY,GAAG,EACf,EAAU,OAAO,EACjB,EAAa,GAAG,EAChB,EAAc,GAAU,CAAC,EACzB,EAAS,GAAG;IACX,CAAC,EAAK,CAAC;CAEV,IAAM,IAAY,EAAQ,KAAQ,O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MACL,OAAO;MACP,WAAW,MAAM,EAAc,EAAE,OAAO,MAAM;MAC9C,WAAW;MACX,CAAA,CACE,EAAA,CAAA,CACF;;IAEN,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;KAAO,WAAW;eAAa,EAAE,sCAAsC,QAAQ;KAAS,CAAA,EACxF,kBAAC,GAAD;KAAU,OAAO;KAAO,WAAW,MAAM,EAAS,EAAE,OAAO,MAAM;KAAE,MAAM;KAAK,CAAA,CAC1E,EAAA,CAAA;IACF;;EACA,CAAA"}
@@ -0,0 +1,139 @@
1
+ import { cn as e } from "../../utils/helpers.js";
2
+ import { Modal as t } from "../../components/Modal.js";
3
+ import "../../components/index.js";
4
+ import { STORAGE_TYPES as n } from "./labels.js";
5
+ import { useEffect as r, useState as i } from "react";
6
+ import { useI18n as a } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ 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";
9
+ //#region src/healthybowl/pages/storage/StorageLocationFormModal.tsx
10
+ var g = "mb-1 block text-sm font-medium text-text-primary", _ = ({ open: _, onClose: v, location: y, warehouses: b, defaultKind: x = "WAREHOUSE", onSubmit: S }) => {
11
+ let { t: C } = a(), w = !!y, [T, E] = i(""), [D, O] = i(x), [k, A] = i("COLD_STORE"), [j, M] = i(""), [N, P] = i(""), [F, I] = i("kg"), [L, R] = i(""), [z, B] = i(!1), [V, H] = i(null);
12
+ r(() => {
13
+ _ && (H(null), y ? (E(y.name), O(y.kind === "BIN" ? "BIN" : "WAREHOUSE"), A(y.storageType ?? "COLD_STORE"), M(y.parentId ?? ""), P(y.capacity === null ? "" : String(y.capacity)), I(y.capacityUnit ?? "kg"), R(y.notes ?? "")) : (E(""), O(x), A("COLD_STORE"), M(b[0]?.id ?? ""), P(""), I("kg"), R("")));
14
+ }, [
15
+ _,
16
+ y,
17
+ x,
18
+ b
19
+ ]);
20
+ let U = T.trim().length > 0 && !(D === "BIN" && !j) && !z, W = async () => {
21
+ if (U) {
22
+ B(!0), H(null);
23
+ try {
24
+ let e = {
25
+ name: T.trim(),
26
+ capacity: N.trim() ? Number(N) : null,
27
+ capacityUnit: F.trim() || "kg",
28
+ notes: L.trim() || null
29
+ };
30
+ w ? (e.id = y.id, D === "WAREHOUSE" && (e.storageType = k)) : (e.kind = D, D === "WAREHOUSE" && (e.storageType = k), D === "BIN" && (e.parentId = j)), await S(e), v();
31
+ } catch (e) {
32
+ H(e instanceof Error ? e.message : String(e));
33
+ } finally {
34
+ B(!1);
35
+ }
36
+ }
37
+ };
38
+ return /* @__PURE__ */ o(t, {
39
+ open: _,
40
+ onClose: v,
41
+ title: w ? C("healthybowl.storage.location.editTitle", "Edit Location") : C("healthybowl.storage.location.newTitle", "Add Storage Location"),
42
+ size: "md",
43
+ footer: /* @__PURE__ */ s("div", {
44
+ className: "flex items-center justify-end gap-2",
45
+ children: [/* @__PURE__ */ o(c, {
46
+ variant: "ghost",
47
+ onClick: v,
48
+ disabled: z,
49
+ children: C("common.cancel", "Cancel")
50
+ }), /* @__PURE__ */ o(c, {
51
+ onClick: () => void W(),
52
+ disabled: !U,
53
+ children: C("healthybowl.storage.location.save", "Save")
54
+ })]
55
+ }),
56
+ children: /* @__PURE__ */ s("div", {
57
+ className: "space-y-4",
58
+ children: [
59
+ V ? /* @__PURE__ */ o("div", {
60
+ className: "rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text",
61
+ children: V
62
+ }) : null,
63
+ /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
64
+ className: g,
65
+ children: C("healthybowl.storage.location.name", "Name")
66
+ }), /* @__PURE__ */ o(l, {
67
+ value: T,
68
+ onChange: (e) => E(e.target.value),
69
+ placeholder: "Cold Store A / Bin A-3"
70
+ })] }),
71
+ w ? null : /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
72
+ className: g,
73
+ children: C("healthybowl.storage.location.kind", "Type")
74
+ }), /* @__PURE__ */ o("div", {
75
+ className: "flex gap-2",
76
+ children: ["WAREHOUSE", "BIN"].map((t) => /* @__PURE__ */ o("button", {
77
+ type: "button",
78
+ onClick: () => O(t),
79
+ className: e("flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors", D === t ? "bg-accent-teal text-white" : "bg-bg-sunken text-text-secondary hover:text-text-primary"),
80
+ children: t === "WAREHOUSE" ? C("healthybowl.storage.location.warehouse", "Warehouse") : C("healthybowl.storage.location.bin", "Bin")
81
+ }, t))
82
+ })] }),
83
+ D === "WAREHOUSE" ? /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
84
+ className: g,
85
+ children: C("healthybowl.storage.location.storageType", "Storage Type")
86
+ }), /* @__PURE__ */ s(u, {
87
+ value: k,
88
+ onValueChange: A,
89
+ children: [/* @__PURE__ */ o(p, { children: /* @__PURE__ */ o(m, {}) }), /* @__PURE__ */ o(d, { children: n.map((e) => /* @__PURE__ */ o(f, {
90
+ value: e.value,
91
+ children: e.label
92
+ }, e.value)) })]
93
+ })] }) : null,
94
+ D === "BIN" && !w ? /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
95
+ className: g,
96
+ children: C("healthybowl.storage.location.parent", "Parent Warehouse")
97
+ }), /* @__PURE__ */ s(u, {
98
+ value: j,
99
+ onValueChange: M,
100
+ children: [/* @__PURE__ */ o(p, { children: /* @__PURE__ */ o(m, { placeholder: C("healthybowl.storage.location.selectWarehouse", "Select a warehouse") }) }), /* @__PURE__ */ o(d, { children: b.map((e) => /* @__PURE__ */ o(f, {
101
+ value: e.id,
102
+ children: e.name
103
+ }, e.id)) })]
104
+ })] }) : null,
105
+ /* @__PURE__ */ s("div", {
106
+ className: "grid grid-cols-2 gap-4",
107
+ children: [/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
108
+ className: g,
109
+ children: C("healthybowl.storage.location.capacity", "Capacity")
110
+ }), /* @__PURE__ */ o(l, {
111
+ type: "number",
112
+ value: N,
113
+ onChange: (e) => P(e.target.value),
114
+ placeholder: "4000"
115
+ })] }), /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
116
+ className: g,
117
+ children: C("healthybowl.storage.location.unit", "Unit")
118
+ }), /* @__PURE__ */ o(l, {
119
+ value: F,
120
+ onChange: (e) => I(e.target.value),
121
+ placeholder: "kg"
122
+ })] })]
123
+ }),
124
+ /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
125
+ className: g,
126
+ children: C("healthybowl.storage.location.notes", "Notes")
127
+ }), /* @__PURE__ */ o(h, {
128
+ value: L,
129
+ onChange: (e) => R(e.target.value),
130
+ rows: 2
131
+ })] })
132
+ ]
133
+ })
134
+ });
135
+ };
136
+ //#endregion
137
+ export { _ as StorageLocationFormModal };
138
+
139
+ //# sourceMappingURL=StorageLocationFormModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageLocationFormModal.js","names":[],"sources":["../../../../src/healthybowl/pages/storage/StorageLocationFormModal.tsx"],"sourcesContent":["/**\n * Create / edit a storage location — a warehouse or a bin within one (BOFF-2890 · K-1).\n * Bins require a parent warehouse. All fields are user-entered and persisted via the real\n * mutation — no fabricated data.\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 { cn } from '../../utils/helpers';\nimport type { StorageLocation } from '../../hooks/useHealthyBowlStorage';\nimport { STORAGE_TYPES } from './labels';\n\ninterface StorageLocationFormModalProps {\n open: boolean;\n onClose: () => void;\n location?: StorageLocation | null;\n /** Warehouses available as bin parents (for the parent Select). */\n warehouses: StorageLocation[];\n /** Default kind when creating (e.g. opening \"Add Bin\" preselects BIN). */\n defaultKind?: 'WAREHOUSE' | 'BIN';\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\n\nexport const StorageLocationFormModal = ({\n open,\n onClose,\n location,\n warehouses,\n defaultKind = 'WAREHOUSE',\n onSubmit,\n}: StorageLocationFormModalProps) => {\n const { t } = useI18n();\n const isEdit = Boolean(location);\n\n const [name, setName] = useState('');\n const [kind, setKind] = useState<'WAREHOUSE' | 'BIN'>(defaultKind);\n const [storageType, setStorageType] = useState('COLD_STORE');\n const [parentId, setParentId] = useState('');\n const [capacity, setCapacity] = useState('');\n const [capacityUnit, setCapacityUnit] = useState('kg');\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 if (location) {\n setName(location.name);\n setKind(location.kind === 'BIN' ? 'BIN' : 'WAREHOUSE');\n setStorageType(location.storageType ?? 'COLD_STORE');\n setParentId(location.parentId ?? '');\n setCapacity(location.capacity === null ? '' : String(location.capacity));\n setCapacityUnit(location.capacityUnit ?? 'kg');\n setNotes(location.notes ?? '');\n } else {\n setName('');\n setKind(defaultKind);\n setStorageType('COLD_STORE');\n setParentId(warehouses[0]?.id ?? '');\n setCapacity('');\n setCapacityUnit('kg');\n setNotes('');\n }\n }, [open, location, defaultKind, warehouses]);\n\n const canSubmit = name.trim().length > 0 && !(kind === 'BIN' && !parentId) && !submitting;\n\n const handleSubmit = async () => {\n if (!canSubmit) return;\n setSubmitting(true);\n setError(null);\n try {\n const input: Record<string, unknown> = {\n name: name.trim(),\n capacity: capacity.trim() ? Number(capacity) : null,\n capacityUnit: capacityUnit.trim() || 'kg',\n notes: notes.trim() || null,\n };\n if (isEdit) {\n input.id = location!.id;\n if (kind === 'WAREHOUSE') input.storageType = storageType;\n } else {\n input.kind = kind;\n if (kind === 'WAREHOUSE') input.storageType = storageType;\n if (kind === 'BIN') input.parentId = parentId;\n }\n await onSubmit(input);\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={\n isEdit\n ? t('healthybowl.storage.location.editTitle', 'Edit Location')\n : t('healthybowl.storage.location.newTitle', 'Add Storage Location')\n }\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.location.save', 'Save')}\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.location.name', 'Name')}</label>\n <Input value={name} onChange={(e) => setName(e.target.value)} placeholder=\"Cold Store A / Bin A-3\" />\n </div>\n\n {!isEdit ? (\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.location.kind', 'Type')}</label>\n <div className=\"flex gap-2\">\n {(['WAREHOUSE', 'BIN'] as const).map((k) => (\n <button\n key={k}\n type=\"button\"\n onClick={() => setKind(k)}\n className={cn(\n 'flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors',\n kind === k\n ? 'bg-accent-teal text-white'\n : 'bg-bg-sunken text-text-secondary hover:text-text-primary'\n )}\n >\n {k === 'WAREHOUSE'\n ? t('healthybowl.storage.location.warehouse', 'Warehouse')\n : t('healthybowl.storage.location.bin', 'Bin')}\n </button>\n ))}\n </div>\n </div>\n ) : null}\n\n {kind === 'WAREHOUSE' ? (\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.location.storageType', 'Storage Type')}</label>\n <Select value={storageType} onValueChange={setStorageType}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {STORAGE_TYPES.map((s) => (\n <SelectItem key={s.value} value={s.value}>\n {s.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ) : null}\n\n {kind === 'BIN' && !isEdit ? (\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.location.parent', 'Parent Warehouse')}</label>\n <Select value={parentId} onValueChange={setParentId}>\n <SelectTrigger>\n <SelectValue placeholder={t('healthybowl.storage.location.selectWarehouse', 'Select a warehouse')} />\n </SelectTrigger>\n <SelectContent>\n {warehouses.map((w) => (\n <SelectItem key={w.id} value={w.id}>\n {w.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ) : null}\n\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.location.capacity', 'Capacity')}</label>\n <Input type=\"number\" value={capacity} onChange={(e) => setCapacity(e.target.value)} placeholder=\"4000\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.location.unit', 'Unit')}</label>\n <Input value={capacityUnit} onChange={(e) => setCapacityUnit(e.target.value)} placeholder=\"kg\" />\n </div>\n </div>\n\n <div>\n <label className={fieldLabel}>{t('healthybowl.storage.location.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":";;;;;;;;;AAiCA,IAAM,IAAa,oDAEN,KAA4B,EACvC,SACA,YACA,aACA,eACA,iBAAc,aACd,kBACmC;CACnC,IAAM,EAAE,SAAM,GAAS,EACjB,IAAS,EAAQ,GAEjB,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAM,KAAW,EAA8B,EAAY,EAC5D,CAAC,GAAa,KAAkB,EAAS,aAAa,EACtD,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAU,KAAe,EAAS,GAAG,EACtC,CAAC,GAAc,KAAmB,EAAS,KAAK,EAChD,CAAC,GAAO,KAAY,EAAS,GA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,MAAM,EAAS,EAAE,OAAO,MAAM;KAAE,MAAM;KAAK,CAAA,CAC1E,EAAA,CAAA;IACF;;EACA,CAAA"}
@@ -0,0 +1,150 @@
1
+ import { cn as e } from "../../utils/helpers.js";
2
+ import { useBasePath as t } from "../../hooks/useBasePath.js";
3
+ import { PageLayout as n } from "../../components/PageLayout.js";
4
+ import { StatCard as r } from "../../components/StatCard.js";
5
+ import { StatusBadge as i } from "../../components/StatusBadge.js";
6
+ import { ErrorState as a } from "../../components/ErrorState.js";
7
+ import { PageLoader as o } from "../../components/PageLoader.js";
8
+ import { useToast as s } from "../../hooks/useToast.js";
9
+ import "../../components/index.js";
10
+ import { useHealthyBowlStorage as c } from "../../hooks/useHealthyBowlStorage.js";
11
+ import { lotStatusVariant as l, reasonLabel as u } from "./labels.js";
12
+ import { RecordMovementModal as d } from "./RecordMovementModal.js";
13
+ import { useState as f } from "react";
14
+ import { useI18n as p } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
15
+ import { ArrowDown as m, ArrowLeft as h, ArrowUp as g, Plus as _ } from "lucide-react";
16
+ import { useNavigate as v, useParams as y } from "react-router-dom";
17
+ import { jsx as b, jsxs as x } from "react/jsx-runtime";
18
+ import { Button as S } from "@burdenoff/fe-libs/ui";
19
+ //#region src/healthybowl/pages/storage/StorageLotDetailPage.tsx
20
+ var C = () => {
21
+ let { t: C } = p(), w = v(), { buildPath: T } = t(), { toast: E } = s(), { lotId: D } = y(), { lotDetail: O, loading: k, errors: A, refetchLot: j, recordMovement: M } = c({ lotId: D ?? null }), [N, P] = f(!1), F = async (e) => {
22
+ await M(e), E({
23
+ title: C("healthybowl.storage.toast.movementRecorded", "Movement recorded"),
24
+ variant: "success"
25
+ });
26
+ };
27
+ if (k.lot && !O) return /* @__PURE__ */ b(o, {});
28
+ if (A.lot && !O || !O) return /* @__PURE__ */ b("div", {
29
+ className: "p-4",
30
+ children: /* @__PURE__ */ b(a, {
31
+ description: A.lot?.message ?? C("healthybowl.storage.lot.notFound", "Lot not found."),
32
+ onRetry: () => void j()
33
+ })
34
+ });
35
+ let { lot: I, movements: L } = O;
36
+ return /* @__PURE__ */ x(n, {
37
+ title: `${I.produce} · ${I.lotCode}`,
38
+ description: `${I.warehouseName} · ${I.locationName}`,
39
+ hideHelp: !0,
40
+ children: [
41
+ /* @__PURE__ */ x("button", {
42
+ type: "button",
43
+ onClick: () => w(T("storage")),
44
+ className: "mb-3 inline-flex items-center gap-1 text-sm text-text-secondary hover:text-text-primary",
45
+ children: [/* @__PURE__ */ b(h, { className: "h-4 w-4" }), C("healthybowl.storage.lot.backToStorage", "Storage")]
46
+ }),
47
+ /* @__PURE__ */ x("div", {
48
+ className: "flex flex-wrap items-center justify-between gap-3",
49
+ children: [/* @__PURE__ */ x("div", {
50
+ className: "flex items-center gap-2",
51
+ children: [/* @__PURE__ */ b(i, {
52
+ variant: l(I.status),
53
+ label: I.status.toLowerCase(),
54
+ dot: !0
55
+ }), I.expiryDate ? /* @__PURE__ */ b("span", {
56
+ className: "text-xs text-text-tertiary",
57
+ children: C("healthybowl.storage.lot.expires", "Expires {{date}}", { date: I.expiryDate.slice(0, 10) })
58
+ }) : null]
59
+ }), /* @__PURE__ */ x(S, {
60
+ onClick: () => P(!0),
61
+ children: [/* @__PURE__ */ b(_, { className: "h-4 w-4" }), C("healthybowl.storage.movement.record", "Record Movement")]
62
+ })]
63
+ }),
64
+ /* @__PURE__ */ x("div", {
65
+ className: "mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",
66
+ children: [
67
+ /* @__PURE__ */ b(r, {
68
+ label: C("healthybowl.storage.lot.onHand", "On hand"),
69
+ value: `${I.quantity} ${I.unit}`,
70
+ hero: !0
71
+ }),
72
+ /* @__PURE__ */ b(r, {
73
+ label: C("healthybowl.storage.lot.location", "Location"),
74
+ value: I.locationName
75
+ }),
76
+ /* @__PURE__ */ b(r, {
77
+ label: C("healthybowl.storage.lot.received", "Received"),
78
+ value: I.receivedAt ? I.receivedAt.slice(0, 10) : "—"
79
+ })
80
+ ]
81
+ }),
82
+ /* @__PURE__ */ x("div", {
83
+ className: "mt-4 rounded-xl border border-border-subtle bg-bg-surface p-4",
84
+ children: [/* @__PURE__ */ b("h3", {
85
+ className: "mb-3 text-sm font-semibold text-text-primary",
86
+ children: C("healthybowl.storage.movementHistory", "Movement History")
87
+ }), L.length === 0 ? /* @__PURE__ */ b("div", {
88
+ className: "py-6 text-center text-sm text-text-secondary",
89
+ children: C("healthybowl.storage.noMovements", "No stock movements yet.")
90
+ }) : /* @__PURE__ */ b("ol", {
91
+ className: "space-y-3",
92
+ children: L.map((t) => {
93
+ let n = t.direction === "IN";
94
+ return /* @__PURE__ */ x("li", {
95
+ className: "flex items-start gap-3",
96
+ children: [/* @__PURE__ */ b("span", {
97
+ className: e("mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full", n ? "bg-status-success-bg text-status-success-text" : "bg-status-error-bg text-status-error-text"),
98
+ children: b(n ? g : m, { className: "h-3.5 w-3.5" })
99
+ }), /* @__PURE__ */ x("div", {
100
+ className: "min-w-0 flex-1",
101
+ children: [
102
+ /* @__PURE__ */ x("div", {
103
+ className: "text-sm",
104
+ children: [
105
+ /* @__PURE__ */ x("span", {
106
+ className: e("font-semibold", n ? "text-status-success-text" : "text-status-error-text"),
107
+ children: [
108
+ n ? "IN +" : "OUT −",
109
+ t.quantity,
110
+ " ",
111
+ t.unit
112
+ ]
113
+ }),
114
+ t.reason ? /* @__PURE__ */ b("span", {
115
+ className: "ml-2 text-xs text-text-tertiary",
116
+ children: u(t.reason)
117
+ }) : null,
118
+ t.reference ? /* @__PURE__ */ b("span", {
119
+ className: "ml-2 text-xs text-text-secondary",
120
+ children: t.reference
121
+ }) : null
122
+ ]
123
+ }),
124
+ /* @__PURE__ */ b("div", {
125
+ className: "text-xs tabular-nums text-text-tertiary",
126
+ children: t.occurredAt.slice(0, 10)
127
+ }),
128
+ t.notes ? /* @__PURE__ */ b("div", {
129
+ className: "mt-0.5 text-xs text-text-secondary",
130
+ children: t.notes
131
+ }) : null
132
+ ]
133
+ })]
134
+ }, t.id);
135
+ })
136
+ })]
137
+ }),
138
+ /* @__PURE__ */ b(d, {
139
+ open: N,
140
+ onClose: () => P(!1),
141
+ lot: I,
142
+ onSubmit: F
143
+ })
144
+ ]
145
+ });
146
+ };
147
+ //#endregion
148
+ export { C as StorageLotDetailPage };
149
+
150
+ //# sourceMappingURL=StorageLotDetailPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageLotDetailPage.js","names":[],"sources":["../../../../src/healthybowl/pages/storage/StorageLotDetailPage.tsx"],"sourcesContent":["/**\n * Storage lot detail (BOFF-2890 · K-1).\n * A lot's on-hand quantity + location + its full IN/OUT movement history, with a \"Record\n * Movement\" action. All from the backend ledger — no fabricated data.\n */\nimport { useState } from 'react';\nimport { useNavigate, useParams } from 'react-router-dom';\nimport { ArrowDown, ArrowLeft, ArrowUp, Plus } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout, StatCard, StatusBadge, ErrorState, PageLoader } from '../../components';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { cn } from '../../utils/helpers';\nimport { useHealthyBowlStorage } from '../../hooks/useHealthyBowlStorage';\nimport { RecordMovementModal } from './RecordMovementModal';\nimport { lotStatusVariant, reasonLabel } from './labels';\n\nexport const StorageLotDetailPage = () => {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast } = useToast();\n const { lotId } = useParams<{ lotId: string }>();\n\n const { lotDetail, loading, errors, refetchLot, recordMovement } = useHealthyBowlStorage({ lotId: lotId ?? null });\n const [moveOpen, setMoveOpen] = useState(false);\n\n const handleRecord = async (input: Record<string, unknown>) => {\n await recordMovement(input);\n toast({ title: t('healthybowl.storage.toast.movementRecorded', 'Movement recorded'), variant: 'success' });\n };\n\n if (loading.lot && !lotDetail) {\n return <PageLoader />;\n }\n if ((errors.lot && !lotDetail) || !lotDetail) {\n return (\n <div className=\"p-4\">\n <ErrorState\n description={errors.lot?.message ?? t('healthybowl.storage.lot.notFound', 'Lot not found.')}\n onRetry={() => void refetchLot()}\n />\n </div>\n );\n }\n\n const { lot, movements } = lotDetail;\n\n return (\n <PageLayout\n title={`${lot.produce} · ${lot.lotCode}`}\n description={`${lot.warehouseName} · ${lot.locationName}`}\n hideHelp\n >\n <button\n type=\"button\"\n onClick={() => navigate(buildPath('storage'))}\n className=\"mb-3 inline-flex items-center gap-1 text-sm text-text-secondary hover:text-text-primary\"\n >\n <ArrowLeft className=\"h-4 w-4\" />\n {t('healthybowl.storage.lot.backToStorage', 'Storage')}\n </button>\n\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div className=\"flex items-center gap-2\">\n <StatusBadge variant={lotStatusVariant(lot.status)} label={lot.status.toLowerCase()} dot />\n {lot.expiryDate ? (\n <span className=\"text-xs text-text-tertiary\">\n {t('healthybowl.storage.lot.expires', 'Expires {{date}}', { date: lot.expiryDate.slice(0, 10) })}\n </span>\n ) : null}\n </div>\n <Button onClick={() => setMoveOpen(true)}>\n <Plus className=\"h-4 w-4\" />\n {t('healthybowl.storage.movement.record', 'Record Movement')}\n </Button>\n </div>\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <StatCard label={t('healthybowl.storage.lot.onHand', 'On hand')} value={`${lot.quantity} ${lot.unit}`} hero />\n <StatCard label={t('healthybowl.storage.lot.location', 'Location')} value={lot.locationName} />\n <StatCard\n label={t('healthybowl.storage.lot.received', 'Received')}\n value={lot.receivedAt ? lot.receivedAt.slice(0, 10) : '—'}\n />\n </div>\n\n <div className=\"mt-4 rounded-xl border border-border-subtle bg-bg-surface p-4\">\n <h3 className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.storage.movementHistory', 'Movement History')}\n </h3>\n {movements.length === 0 ? (\n <div className=\"py-6 text-center text-sm text-text-secondary\">\n {t('healthybowl.storage.noMovements', 'No stock movements yet.')}\n </div>\n ) : (\n <ol className=\"space-y-3\">\n {movements.map((m) => {\n const isIn = m.direction === 'IN';\n return (\n <li key={m.id} className=\"flex items-start gap-3\">\n <span\n className={cn(\n 'mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full',\n isIn\n ? 'bg-status-success-bg text-status-success-text'\n : 'bg-status-error-bg text-status-error-text'\n )}\n >\n {isIn ? <ArrowUp className=\"h-3.5 w-3.5\" /> : <ArrowDown className=\"h-3.5 w-3.5\" />}\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-sm\">\n <span\n className={cn('font-semibold', isIn ? 'text-status-success-text' : 'text-status-error-text')}\n >\n {isIn ? 'IN +' : 'OUT −'}\n {m.quantity} {m.unit}\n </span>\n {m.reason ? (\n <span className=\"ml-2 text-xs text-text-tertiary\">{reasonLabel(m.reason)}</span>\n ) : null}\n {m.reference ? <span className=\"ml-2 text-xs text-text-secondary\">{m.reference}</span> : null}\n </div>\n <div className=\"text-xs tabular-nums text-text-tertiary\">{m.occurredAt.slice(0, 10)}</div>\n {m.notes ? <div className=\"mt-0.5 text-xs text-text-secondary\">{m.notes}</div> : null}\n </div>\n </li>\n );\n })}\n </ol>\n )}\n </div>\n\n <RecordMovementModal open={moveOpen} onClose={() => setMoveOpen(false)} lot={lot} onSubmit={handleRecord} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,IAAa,UAA6B;CACxC,IAAM,EAAE,SAAM,GAAS,EACjB,IAAW,GAAa,EACxB,EAAE,iBAAc,GAAa,EAC7B,EAAE,aAAU,GAAU,EACtB,EAAE,aAAU,GAA8B,EAE1C,EAAE,cAAW,YAAS,WAAQ,eAAY,sBAAmB,EAAsB,EAAE,OAAO,KAAS,MAAM,CAAC,EAC5G,CAAC,GAAU,KAAe,EAAS,GAAM,EAEzC,IAAe,OAAO,MAAmC;AAE7D,EADA,MA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