@burdenoff/microfe-healthybowl 2026.819.4 → 2026.819.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/components/ProductionBatchCreateModal.js +189 -0
- package/dist/healthybowl/components/ProductionBatchCreateModal.js.map +1 -0
- package/dist/healthybowl/hooks/usePlantCatalog.js +31 -31
- package/dist/healthybowl/hooks/usePlantCatalog.js.map +1 -1
- package/dist/healthybowl/pages/production/ProductionBatchesPage.js +60 -40
- package/dist/healthybowl/pages/production/ProductionBatchesPage.js.map +1 -1
- package/dist/healthybowl/pages/products/BatchesPage.js +271 -459
- package/dist/healthybowl/pages/products/BatchesPage.js.map +1 -1
- package/dist/healthybowl/pages/terrace/PlantingFormModal.js +144 -108
- package/dist/healthybowl/pages/terrace/PlantingFormModal.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { formatCurrency as e } from "../utils/helpers.js";
|
|
2
|
+
import { Modal as t } from "./Modal.js";
|
|
3
|
+
import { useHealthyBowlData as n } from "../hooks/useHealthyBowlData.js";
|
|
4
|
+
import { 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, Select as l, SelectContent as u, SelectItem as d, SelectTrigger as f, SelectValue as p } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
//#region src/healthybowl/components/ProductionBatchCreateModal.tsx
|
|
9
|
+
var m = {
|
|
10
|
+
batchNumber: "",
|
|
11
|
+
recipe: "",
|
|
12
|
+
quantity: 0,
|
|
13
|
+
unit: "units",
|
|
14
|
+
startDate: ""
|
|
15
|
+
}, h = "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]", g = "text-sm font-medium text-text-primary", _ = ({ open: _, onClose: v, onNotify: y }) => {
|
|
16
|
+
let { t: b } = i(), { recipes: x, createProductionBatch: S } = n(), [C, w] = r(m), [T, E] = r(!1), D = (e, t) => w((n) => ({
|
|
17
|
+
...n,
|
|
18
|
+
[e]: t
|
|
19
|
+
})), O = () => {
|
|
20
|
+
w(m), v();
|
|
21
|
+
}, k = () => C.batchNumber.trim() ? C.recipe ? C.quantity <= 0 ? {
|
|
22
|
+
title: b("healthybowl.products.batches.toast.invalidQuantity.title", "Invalid quantity"),
|
|
23
|
+
description: b("healthybowl.products.batches.toast.invalidQuantity.description", "Quantity must be greater than zero."),
|
|
24
|
+
variant: "warning"
|
|
25
|
+
} : C.unit.trim() ? C.startDate ? null : {
|
|
26
|
+
title: b("healthybowl.products.batches.toast.selectStartDate.title", "Select start date"),
|
|
27
|
+
description: b("healthybowl.products.batches.toast.selectStartDate.description", "Please select a start date for the batch."),
|
|
28
|
+
variant: "warning"
|
|
29
|
+
} : {
|
|
30
|
+
title: b("healthybowl.products.batches.toast.unitRequired.title", "Unit required"),
|
|
31
|
+
description: b("healthybowl.products.batches.toast.unitRequired.description", "Please enter a unit for the quantity."),
|
|
32
|
+
variant: "warning"
|
|
33
|
+
} : {
|
|
34
|
+
title: b("healthybowl.products.batches.toast.selectRecipe.title", "Select a recipe"),
|
|
35
|
+
description: b("healthybowl.products.batches.toast.selectRecipe.description", "Please select a recipe for the batch."),
|
|
36
|
+
variant: "warning"
|
|
37
|
+
} : {
|
|
38
|
+
title: b("healthybowl.products.batches.toast.batchNumberRequired.title", "Batch number required"),
|
|
39
|
+
description: b("healthybowl.products.batches.toast.batchNumberRequired.description", "Please enter a batch number."),
|
|
40
|
+
variant: "warning"
|
|
41
|
+
}, A = async () => {
|
|
42
|
+
let e = k();
|
|
43
|
+
if (e) {
|
|
44
|
+
y(e);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
E(!0);
|
|
48
|
+
try {
|
|
49
|
+
await S({
|
|
50
|
+
batchNumber: C.batchNumber.trim(),
|
|
51
|
+
recipeId: C.recipe,
|
|
52
|
+
status: "planned",
|
|
53
|
+
quantity: C.quantity,
|
|
54
|
+
unit: C.unit.trim(),
|
|
55
|
+
startDate: C.startDate
|
|
56
|
+
}), y({
|
|
57
|
+
title: b("healthybowl.products.batches.toast.created.title", "Batch created"),
|
|
58
|
+
description: b("healthybowl.products.batches.toast.created.description", "Batch {{batchNumber}} has been created.", { batchNumber: C.batchNumber.trim() }),
|
|
59
|
+
variant: "success"
|
|
60
|
+
}), O();
|
|
61
|
+
} catch (e) {
|
|
62
|
+
y({
|
|
63
|
+
title: b("healthybowl.products.batches.toast.createFailed.title", "Could not create batch"),
|
|
64
|
+
description: e instanceof Error ? e.message : b("healthybowl.products.batches.toast.createFailed.description", "Failed to create batch"),
|
|
65
|
+
variant: "error"
|
|
66
|
+
});
|
|
67
|
+
} finally {
|
|
68
|
+
E(!1);
|
|
69
|
+
}
|
|
70
|
+
}, j = C.recipe ? x.find((e) => e.id === C.recipe) : void 0;
|
|
71
|
+
return /* @__PURE__ */ o(t, {
|
|
72
|
+
open: _,
|
|
73
|
+
onClose: O,
|
|
74
|
+
title: b("healthybowl.products.batches.createModal.title", "Create Production Batch"),
|
|
75
|
+
description: b("healthybowl.products.batches.createModal.description", "Select a recipe and configure the batch details."),
|
|
76
|
+
size: "md",
|
|
77
|
+
footer: /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(c, {
|
|
78
|
+
variant: "outline",
|
|
79
|
+
onClick: O,
|
|
80
|
+
className: "text-text-secondary hover:text-text-primary",
|
|
81
|
+
children: b("healthybowl.common.cancel", "Cancel")
|
|
82
|
+
}), /* @__PURE__ */ o(c, {
|
|
83
|
+
onClick: () => void A(),
|
|
84
|
+
disabled: T,
|
|
85
|
+
children: T ? b("healthybowl.products.batches.createModal.creating", "Creating...") : b("healthybowl.products.batches.actions.createBatch", "Create Batch")
|
|
86
|
+
})] }),
|
|
87
|
+
children: /* @__PURE__ */ s("div", {
|
|
88
|
+
className: "space-y-4",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
91
|
+
className: g,
|
|
92
|
+
children: b("healthybowl.products.batches.form.fields.batchNumber.label", "Batch Number *")
|
|
93
|
+
}), /* @__PURE__ */ o("input", {
|
|
94
|
+
type: "text",
|
|
95
|
+
value: C.batchNumber,
|
|
96
|
+
onChange: (e) => D("batchNumber", e.target.value),
|
|
97
|
+
placeholder: b("healthybowl.products.batches.form.fields.batchNumber.placeholder", "e.g., BATCH-2026-001"),
|
|
98
|
+
className: h
|
|
99
|
+
})] }),
|
|
100
|
+
/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
101
|
+
className: g,
|
|
102
|
+
children: b("healthybowl.products.batches.form.fields.recipe.label", "Recipe *")
|
|
103
|
+
}), /* @__PURE__ */ s(l, {
|
|
104
|
+
value: C.recipe,
|
|
105
|
+
onValueChange: (e) => D("recipe", e),
|
|
106
|
+
children: [/* @__PURE__ */ o(f, {
|
|
107
|
+
className: "mt-1 w-full",
|
|
108
|
+
children: /* @__PURE__ */ o(p, { placeholder: b("healthybowl.products.batches.form.fields.recipe.placeholder", "Select a recipe") })
|
|
109
|
+
}), /* @__PURE__ */ o(u, { children: x.map((e) => /* @__PURE__ */ s(d, {
|
|
110
|
+
value: e.id,
|
|
111
|
+
children: [
|
|
112
|
+
e.name,
|
|
113
|
+
" (",
|
|
114
|
+
e.product,
|
|
115
|
+
")"
|
|
116
|
+
]
|
|
117
|
+
}, e.id)) })]
|
|
118
|
+
})] }),
|
|
119
|
+
j ? /* @__PURE__ */ s("div", {
|
|
120
|
+
className: "rounded-md border border-border-subtle bg-bg-sunken/50 p-3",
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ o("p", {
|
|
123
|
+
className: "text-xs font-medium text-text-secondary",
|
|
124
|
+
children: b("healthybowl.products.batches.form.recipePreview.title", "Recipe Details")
|
|
125
|
+
}),
|
|
126
|
+
/* @__PURE__ */ s("p", {
|
|
127
|
+
className: "mt-1 text-sm text-text-primary",
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ o("span", {
|
|
130
|
+
className: "font-medium",
|
|
131
|
+
children: j.name
|
|
132
|
+
}),
|
|
133
|
+
" ",
|
|
134
|
+
b("healthybowl.products.batches.form.recipePreview.yields", "— yields {{yieldQuantity}} {{yieldUnit}} in ~{{processingTime}} min", {
|
|
135
|
+
yieldQuantity: j.yieldQuantity,
|
|
136
|
+
yieldUnit: j.yieldUnit,
|
|
137
|
+
processingTime: j.processingTime
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ o("p", {
|
|
142
|
+
className: "mt-0.5 text-xs text-text-secondary",
|
|
143
|
+
children: b("healthybowl.products.batches.form.recipePreview.costAndIngredients", "Cost per unit: {{costPerUnit}} | Ingredients: {{ingredientCount}}", {
|
|
144
|
+
costPerUnit: e(j.costPerUnit, "INR"),
|
|
145
|
+
ingredientCount: (j.ingredients ?? []).length
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
}) : null,
|
|
150
|
+
/* @__PURE__ */ s("div", {
|
|
151
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
|
|
152
|
+
children: [/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
153
|
+
className: g,
|
|
154
|
+
children: b("healthybowl.products.batches.form.fields.quantity.label", "Quantity *")
|
|
155
|
+
}), /* @__PURE__ */ o("input", {
|
|
156
|
+
type: "number",
|
|
157
|
+
min: 1,
|
|
158
|
+
value: C.quantity || "",
|
|
159
|
+
onChange: (e) => D("quantity", Number(e.target.value)),
|
|
160
|
+
placeholder: b("healthybowl.products.batches.form.fields.quantity.placeholder", "e.g., 200"),
|
|
161
|
+
className: h
|
|
162
|
+
})] }), /* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
163
|
+
className: g,
|
|
164
|
+
children: b("healthybowl.products.batches.form.fields.unit.label", "Unit *")
|
|
165
|
+
}), /* @__PURE__ */ o("input", {
|
|
166
|
+
type: "text",
|
|
167
|
+
value: C.unit,
|
|
168
|
+
onChange: (e) => D("unit", e.target.value),
|
|
169
|
+
placeholder: b("healthybowl.products.batches.form.fields.unit.placeholder", "e.g., units, kg, L"),
|
|
170
|
+
className: h
|
|
171
|
+
})] })]
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ s("div", { children: [/* @__PURE__ */ o("label", {
|
|
174
|
+
className: g,
|
|
175
|
+
children: b("healthybowl.products.batches.form.fields.startDate.label", "Start Date *")
|
|
176
|
+
}), /* @__PURE__ */ o("input", {
|
|
177
|
+
type: "date",
|
|
178
|
+
value: C.startDate,
|
|
179
|
+
onChange: (e) => D("startDate", e.target.value),
|
|
180
|
+
className: h
|
|
181
|
+
})] })
|
|
182
|
+
]
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
//#endregion
|
|
187
|
+
export { _ as ProductionBatchCreateModal };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=ProductionBatchCreateModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductionBatchCreateModal.js","names":[],"sources":["../../../src/healthybowl/components/ProductionBatchCreateModal.tsx"],"sourcesContent":["/**\n * Create a production batch (BOFF-6370).\n *\n * Lifted out of `pages/products/BatchesPage.tsx`, where it was the only way to create\n * a batch anywhere in the product. The published `production-products-quality` journey\n * tells the reader to \"Open Batches and create a production batch\", and a user who\n * follows the app's own navigation lands on `/healthybowl/production/batches` — a\n * read-only table with no create affordance at all. Both pages now drive this one\n * component, so neither can drift into offering a different form.\n *\n * It owns its form state and validation but reports every outcome through `onNotify`,\n * rather than rendering its own `ToastContainer`: `BatchesPage` already renders one,\n * and a second stack would overlap it. It does not refetch — `createProductionBatch`\n * already awaits a production refresh before it resolves.\n */\nimport { useState, type FC } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@burdenoff/fe-libs/ui';\nimport { Modal } from './Modal';\nimport { useHealthyBowlData } from '../hooks/useHealthyBowlData';\nimport { formatCurrency, HB_DEFAULT_CURRENCY } from '../utils/helpers';\n\nexport interface ProductionBatchNotice {\n title: string;\n description: string;\n variant: 'success' | 'warning' | 'error';\n}\n\ninterface ProductionBatchCreateModalProps {\n open: boolean;\n onClose: () => void;\n /** Surface a validation warning, a success or a failure on the host page. */\n onNotify: (notice: ProductionBatchNotice) => void;\n}\n\ninterface BatchFormData {\n batchNumber: string;\n recipe: string;\n quantity: number;\n unit: string;\n startDate: string;\n}\n\nconst defaultBatchForm: BatchFormData = {\n batchNumber: '',\n recipe: '',\n quantity: 0,\n unit: 'units',\n startDate: '',\n};\n\nconst inputClass =\n 'mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst labelClass = 'text-sm font-medium text-text-primary';\n\nexport const ProductionBatchCreateModal: FC<ProductionBatchCreateModalProps> = ({ open, onClose, onNotify }) => {\n const { t } = useI18n();\n const { recipes, createProductionBatch } = useHealthyBowlData();\n const [form, setForm] = useState<BatchFormData>(defaultBatchForm);\n const [submitting, setSubmitting] = useState(false);\n\n const update = <K extends keyof BatchFormData>(key: K, value: BatchFormData[K]) =>\n setForm((prev) => ({ ...prev, [key]: value }));\n\n const close = () => {\n setForm(defaultBatchForm);\n onClose();\n };\n\n /** Returns the first problem with the form, or null when it is ready to submit. */\n const firstProblem = (): ProductionBatchNotice | null => {\n if (!form.batchNumber.trim()) {\n return {\n title: t('healthybowl.products.batches.toast.batchNumberRequired.title', 'Batch number required'),\n description: t(\n 'healthybowl.products.batches.toast.batchNumberRequired.description',\n 'Please enter a batch number.'\n ),\n variant: 'warning',\n };\n }\n if (!form.recipe) {\n return {\n title: t('healthybowl.products.batches.toast.selectRecipe.title', 'Select a recipe'),\n description: t(\n 'healthybowl.products.batches.toast.selectRecipe.description',\n 'Please select a recipe for the batch.'\n ),\n variant: 'warning',\n };\n }\n if (form.quantity <= 0) {\n return {\n title: t('healthybowl.products.batches.toast.invalidQuantity.title', 'Invalid quantity'),\n description: t(\n 'healthybowl.products.batches.toast.invalidQuantity.description',\n 'Quantity must be greater than zero.'\n ),\n variant: 'warning',\n };\n }\n if (!form.unit.trim()) {\n return {\n title: t('healthybowl.products.batches.toast.unitRequired.title', 'Unit required'),\n description: t(\n 'healthybowl.products.batches.toast.unitRequired.description',\n 'Please enter a unit for the quantity.'\n ),\n variant: 'warning',\n };\n }\n if (!form.startDate) {\n return {\n title: t('healthybowl.products.batches.toast.selectStartDate.title', 'Select start date'),\n description: t(\n 'healthybowl.products.batches.toast.selectStartDate.description',\n 'Please select a start date for the batch.'\n ),\n variant: 'warning',\n };\n }\n return null;\n };\n\n const handleCreate = async () => {\n const problem = firstProblem();\n if (problem) {\n onNotify(problem);\n return;\n }\n setSubmitting(true);\n try {\n await createProductionBatch({\n batchNumber: form.batchNumber.trim(),\n recipeId: form.recipe,\n status: 'planned',\n quantity: form.quantity,\n unit: form.unit.trim(),\n startDate: form.startDate,\n });\n onNotify({\n title: t('healthybowl.products.batches.toast.created.title', 'Batch created'),\n description: t(\n 'healthybowl.products.batches.toast.created.description',\n 'Batch {{batchNumber}} has been created.',\n { batchNumber: form.batchNumber.trim() }\n ),\n variant: 'success',\n });\n close();\n } catch (err) {\n onNotify({\n title: t('healthybowl.products.batches.toast.createFailed.title', 'Could not create batch'),\n description:\n err instanceof Error\n ? err.message\n : t('healthybowl.products.batches.toast.createFailed.description', 'Failed to create batch'),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n const selectedRecipe = form.recipe ? recipes.find((r) => r.id === form.recipe) : undefined;\n\n return (\n <Modal\n open={open}\n onClose={close}\n title={t('healthybowl.products.batches.createModal.title', 'Create Production Batch')}\n description={t(\n 'healthybowl.products.batches.createModal.description',\n 'Select a recipe and configure the batch details.'\n )}\n size=\"md\"\n footer={\n <>\n <Button variant=\"outline\" onClick={close} className=\"text-text-secondary hover:text-text-primary\">\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleCreate()} disabled={submitting}>\n {submitting\n ? t('healthybowl.products.batches.createModal.creating', 'Creating...')\n : t('healthybowl.products.batches.actions.createBatch', 'Create Batch')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <div>\n <label className={labelClass}>\n {t('healthybowl.products.batches.form.fields.batchNumber.label', 'Batch Number *')}\n </label>\n <input\n type=\"text\"\n value={form.batchNumber}\n onChange={(e) => update('batchNumber', e.target.value)}\n placeholder={t('healthybowl.products.batches.form.fields.batchNumber.placeholder', 'e.g., BATCH-2026-001')}\n className={inputClass}\n />\n </div>\n <div>\n <label className={labelClass}>{t('healthybowl.products.batches.form.fields.recipe.label', 'Recipe *')}</label>\n <Select value={form.recipe} onValueChange={(value) => update('recipe', value)}>\n <SelectTrigger className=\"mt-1 w-full\">\n <SelectValue\n placeholder={t('healthybowl.products.batches.form.fields.recipe.placeholder', 'Select a recipe')}\n />\n </SelectTrigger>\n <SelectContent>\n {recipes.map((r) => (\n <SelectItem key={r.id} value={r.id}>\n {r.name} ({r.product})\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n {selectedRecipe ? (\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/50 p-3\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {t('healthybowl.products.batches.form.recipePreview.title', 'Recipe Details')}\n </p>\n <p className=\"mt-1 text-sm text-text-primary\">\n <span className=\"font-medium\">{selectedRecipe.name}</span>{' '}\n {t(\n 'healthybowl.products.batches.form.recipePreview.yields',\n '— yields {{yieldQuantity}} {{yieldUnit}} in ~{{processingTime}} min',\n {\n yieldQuantity: selectedRecipe.yieldQuantity,\n yieldUnit: selectedRecipe.yieldUnit,\n processingTime: selectedRecipe.processingTime,\n }\n )}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {t(\n 'healthybowl.products.batches.form.recipePreview.costAndIngredients',\n 'Cost per unit: {{costPerUnit}} | Ingredients: {{ingredientCount}}',\n {\n costPerUnit: formatCurrency(selectedRecipe.costPerUnit, HB_DEFAULT_CURRENCY),\n ingredientCount: (selectedRecipe.ingredients ?? []).length,\n }\n )}\n </p>\n </div>\n ) : null}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label className={labelClass}>\n {t('healthybowl.products.batches.form.fields.quantity.label', 'Quantity *')}\n </label>\n <input\n type=\"number\"\n min={1}\n value={form.quantity || ''}\n onChange={(e) => update('quantity', Number(e.target.value))}\n placeholder={t('healthybowl.products.batches.form.fields.quantity.placeholder', 'e.g., 200')}\n className={inputClass}\n />\n </div>\n <div>\n <label className={labelClass}>{t('healthybowl.products.batches.form.fields.unit.label', 'Unit *')}</label>\n <input\n type=\"text\"\n value={form.unit}\n onChange={(e) => update('unit', e.target.value)}\n placeholder={t('healthybowl.products.batches.form.fields.unit.placeholder', 'e.g., units, kg, L')}\n className={inputClass}\n />\n </div>\n </div>\n <div>\n <label className={labelClass}>\n {t('healthybowl.products.batches.form.fields.startDate.label', 'Start Date *')}\n </label>\n <input\n type=\"date\"\n value={form.startDate}\n onChange={(e) => update('startDate', e.target.value)}\n className={inputClass}\n />\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;AA2CA,IAAM,IAAkC;CACtC,aAAa;CACb,QAAQ;CACR,UAAU;CACV,MAAM;CACN,WAAW;CACZ,EAEK,IACJ,6MACI,IAAa,yCAEN,KAAmE,EAAE,SAAM,YAAS,kBAAe;CAC9G,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,YAAS,6BAA0B,GAAoB,EACzD,CAAC,GAAM,KAAW,EAAwB,EAAiB,E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,4DAA4D,eAAe;KACxE,CAAA,EACR,kBAAC,SAAD;KACE,MAAK;KACL,OAAO,EAAK;KACZ,WAAW,MAAM,EAAO,aAAa,EAAE,OAAO,MAAM;KACpD,WAAW;KACX,CAAA,CACE,EAAA,CAAA;IACF;;EACA,CAAA"}
|
|
@@ -26,49 +26,49 @@ var a = "\n id\n name\n category\n variety\n plantSpacingCm\n rowSpacingCm
|
|
|
26
26
|
deleteHealthyBowlPlantCatalogEntry(id: $id, context: $context)
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
|
-
function u() {
|
|
30
|
-
let { workspaceId:
|
|
31
|
-
variables: { context:
|
|
32
|
-
skip: !n,
|
|
29
|
+
function u(n) {
|
|
30
|
+
let { workspaceId: a } = e(), u = { workspaceId: a }, { data: d, loading: f, error: p, refetch: m } = i(o, {
|
|
31
|
+
variables: { context: u },
|
|
32
|
+
skip: !a || n?.skip === !0,
|
|
33
33
|
fetchPolicy: "cache-and-network",
|
|
34
34
|
notifyOnNetworkStatusChange: !0
|
|
35
|
-
}), [
|
|
36
|
-
await
|
|
35
|
+
}), [h] = r(s), [g] = r(c), [_] = r(l), v = t(async (e) => {
|
|
36
|
+
await h({ variables: { input: {
|
|
37
37
|
...e,
|
|
38
|
-
context:
|
|
39
|
-
} } }), await
|
|
38
|
+
context: u
|
|
39
|
+
} } }), await m();
|
|
40
40
|
}, [
|
|
41
|
+
h,
|
|
41
42
|
m,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await h({ variables: { input: {
|
|
43
|
+
a
|
|
44
|
+
]), y = t(async (e, t) => {
|
|
45
|
+
await g({ variables: { input: {
|
|
46
46
|
id: e,
|
|
47
47
|
...t,
|
|
48
|
-
context:
|
|
49
|
-
} } }), await
|
|
48
|
+
context: u
|
|
49
|
+
} } }), await m();
|
|
50
50
|
}, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]),
|
|
55
|
-
await
|
|
51
|
+
g,
|
|
52
|
+
m,
|
|
53
|
+
a
|
|
54
|
+
]), b = t(async (e) => {
|
|
55
|
+
await _({ variables: {
|
|
56
56
|
id: e,
|
|
57
|
-
context:
|
|
58
|
-
} }), await
|
|
57
|
+
context: u
|
|
58
|
+
} }), await m();
|
|
59
59
|
}, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
_,
|
|
61
|
+
m,
|
|
62
|
+
a
|
|
63
63
|
]);
|
|
64
64
|
return {
|
|
65
|
-
entries:
|
|
66
|
-
loading:
|
|
67
|
-
error:
|
|
68
|
-
refetch:
|
|
69
|
-
createEntry:
|
|
70
|
-
updateEntry:
|
|
71
|
-
deleteEntry:
|
|
65
|
+
entries: d?.healthyBowlPlantCatalog ?? [],
|
|
66
|
+
loading: f,
|
|
67
|
+
error: p,
|
|
68
|
+
refetch: m,
|
|
69
|
+
createEntry: v,
|
|
70
|
+
updateEntry: y,
|
|
71
|
+
deleteEntry: b
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePlantCatalog.js","names":[],"sources":["../../../src/healthybowl/hooks/usePlantCatalog.ts"],"sourcesContent":["/**\n * Master Plant List (variety catalog) data hook.\n *\n * The offline codegen doesn't type the PlantCatalog operations, so — mirroring\n * the raw-gql pattern used for `updateHealthyBowlField` in `FieldMap.tsx` — these\n * are hand-written `gql` documents executed directly against the live gateway.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A single entry in the Master Plant List (editable variety catalog with spacing). */\nexport interface PlantCatalogEntry {\n id: string;\n name: string;\n category?: string | null;\n variety?: string | null;\n plantSpacingCm?: number | null;\n rowSpacingCm?: number | null;\n daysToMaturity?: number | null;\n /** Approximate seed count per gram (seed-rate input). */\n seedsPerGram?: number | null;\n /** Germination rate as a fraction in [0, 1] (e.g. 0.85 = 85%). */\n germinationRate?: number | null;\n /** Seeds sown per nursery cell/plug when raising transplants. */\n seedsPerCell?: number | null;\n /** Whether the variety is suitable for organic production. */\n organicSuitable?: boolean | null;\n notes?: string | null;\n}\n\n/** Editable fields for create/update (context is attached from the hook). */\nexport interface PlantCatalogInput {\n name: string;\n category?: string | null;\n variety?: string | null;\n plantSpacingCm?: number | null;\n rowSpacingCm?: number | null;\n daysToMaturity?: number | null;\n seedsPerGram?: number | null;\n germinationRate?: number | null;\n seedsPerCell?: number | null;\n organicSuitable?: boolean | null;\n notes?: string | null;\n}\n\nconst CATALOG_FIELDS = `\n id\n name\n category\n variety\n plantSpacingCm\n rowSpacingCm\n daysToMaturity\n seedsPerGram\n germinationRate\n seedsPerCell\n organicSuitable\n notes\n`;\n\nconst PLANT_CATALOG_QUERY = gql`\n query HealthyBowlPlantCatalog($context: ContextInput!) {\n healthyBowlPlantCatalog(context: $context) {\n ${CATALOG_FIELDS}\n }\n }\n`;\n\nconst CREATE_PLANT_CATALOG = gql`\n mutation CreateHealthyBowlPlantCatalogEntry($input: CreateHealthyBowlPlantCatalogInput!) {\n createHealthyBowlPlantCatalogEntry(input: $input) {\n ${CATALOG_FIELDS}\n }\n }\n`;\n\nconst UPDATE_PLANT_CATALOG = gql`\n mutation UpdateHealthyBowlPlantCatalogEntry($input: UpdateHealthyBowlPlantCatalogInput!) {\n updateHealthyBowlPlantCatalogEntry(input: $input) {\n ${CATALOG_FIELDS}\n }\n }\n`;\n\nconst DELETE_PLANT_CATALOG = gql`\n mutation DeleteHealthyBowlPlantCatalogEntry($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPlantCatalogEntry(id: $id, context: $context)\n }\n`;\n\ninterface CatalogQueryData {\n healthyBowlPlantCatalog: PlantCatalogEntry[];\n}\n\n/**\n * Loads the Master Plant List for the active workspace and exposes create /\n * update / delete helpers. Mutations refetch the list so the caller's view stays\n * in sync without hand-managing the cache.\n */\nexport function usePlantCatalog() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<CatalogQueryData>(PLANT_CATALOG_QUERY, {\n variables: { context },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createMutation] = useMutation(CREATE_PLANT_CATALOG);\n const [updateMutation] = useMutation(UPDATE_PLANT_CATALOG);\n const [deleteMutation] = useMutation(DELETE_PLANT_CATALOG);\n\n const createEntry = useCallback(\n async (input: PlantCatalogInput) => {\n await createMutation({ variables: { input: { ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createMutation, refetch, workspaceId]\n );\n\n const updateEntry = useCallback(\n async (id: string, input: PlantCatalogInput) => {\n await updateMutation({ variables: { input: { id, ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [updateMutation, refetch, workspaceId]\n );\n\n const deleteEntry = useCallback(\n async (id: string) => {\n await deleteMutation({ variables: { id, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [deleteMutation, refetch, workspaceId]\n );\n\n return {\n entries: data?.healthyBowlPlantCatalog ?? [],\n loading,\n error,\n refetch,\n createEntry,\n updateEntry,\n deleteEntry,\n };\n}\n"],"mappings":";;;;;AAgDA,IAAM,IAAiB,8KAejB,IAAsB,CAAG;;;QAGvB,EAAe;;;GAKjB,IAAuB,CAAG;;;QAGxB,EAAe;;;GAKjB,IAAuB,CAAG;;;QAGxB,EAAe;;;GAKjB,IAAuB,CAAG;;;;;
|
|
1
|
+
{"version":3,"file":"usePlantCatalog.js","names":[],"sources":["../../../src/healthybowl/hooks/usePlantCatalog.ts"],"sourcesContent":["/**\n * Master Plant List (variety catalog) data hook.\n *\n * The offline codegen doesn't type the PlantCatalog operations, so — mirroring\n * the raw-gql pattern used for `updateHealthyBowlField` in `FieldMap.tsx` — these\n * are hand-written `gql` documents executed directly against the live gateway.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A single entry in the Master Plant List (editable variety catalog with spacing). */\nexport interface PlantCatalogEntry {\n id: string;\n name: string;\n category?: string | null;\n variety?: string | null;\n plantSpacingCm?: number | null;\n rowSpacingCm?: number | null;\n daysToMaturity?: number | null;\n /** Approximate seed count per gram (seed-rate input). */\n seedsPerGram?: number | null;\n /** Germination rate as a fraction in [0, 1] (e.g. 0.85 = 85%). */\n germinationRate?: number | null;\n /** Seeds sown per nursery cell/plug when raising transplants. */\n seedsPerCell?: number | null;\n /** Whether the variety is suitable for organic production. */\n organicSuitable?: boolean | null;\n notes?: string | null;\n}\n\n/** Editable fields for create/update (context is attached from the hook). */\nexport interface PlantCatalogInput {\n name: string;\n category?: string | null;\n variety?: string | null;\n plantSpacingCm?: number | null;\n rowSpacingCm?: number | null;\n daysToMaturity?: number | null;\n seedsPerGram?: number | null;\n germinationRate?: number | null;\n seedsPerCell?: number | null;\n organicSuitable?: boolean | null;\n notes?: string | null;\n}\n\nconst CATALOG_FIELDS = `\n id\n name\n category\n variety\n plantSpacingCm\n rowSpacingCm\n daysToMaturity\n seedsPerGram\n germinationRate\n seedsPerCell\n organicSuitable\n notes\n`;\n\nconst PLANT_CATALOG_QUERY = gql`\n query HealthyBowlPlantCatalog($context: ContextInput!) {\n healthyBowlPlantCatalog(context: $context) {\n ${CATALOG_FIELDS}\n }\n }\n`;\n\nconst CREATE_PLANT_CATALOG = gql`\n mutation CreateHealthyBowlPlantCatalogEntry($input: CreateHealthyBowlPlantCatalogInput!) {\n createHealthyBowlPlantCatalogEntry(input: $input) {\n ${CATALOG_FIELDS}\n }\n }\n`;\n\nconst UPDATE_PLANT_CATALOG = gql`\n mutation UpdateHealthyBowlPlantCatalogEntry($input: UpdateHealthyBowlPlantCatalogInput!) {\n updateHealthyBowlPlantCatalogEntry(input: $input) {\n ${CATALOG_FIELDS}\n }\n }\n`;\n\nconst DELETE_PLANT_CATALOG = gql`\n mutation DeleteHealthyBowlPlantCatalogEntry($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPlantCatalogEntry(id: $id, context: $context)\n }\n`;\n\ninterface CatalogQueryData {\n healthyBowlPlantCatalog: PlantCatalogEntry[];\n}\n\n/**\n * Loads the Master Plant List for the active workspace and exposes create /\n * update / delete helpers. Mutations refetch the list so the caller's view stays\n * in sync without hand-managing the cache.\n *\n * @param options.skip suppress the query entirely (e.g. a closed modal).\n */\nexport function usePlantCatalog(options?: { skip?: boolean }) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<CatalogQueryData>(PLANT_CATALOG_QUERY, {\n variables: { context },\n // `skip` lets a caller that only needs the catalogue sometimes — the planting\n // form, which needs it when its modal is open — avoid the query the rest of\n // the time (BOFF-6362).\n skip: !workspaceId || options?.skip === true,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createMutation] = useMutation(CREATE_PLANT_CATALOG);\n const [updateMutation] = useMutation(UPDATE_PLANT_CATALOG);\n const [deleteMutation] = useMutation(DELETE_PLANT_CATALOG);\n\n const createEntry = useCallback(\n async (input: PlantCatalogInput) => {\n await createMutation({ variables: { input: { ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createMutation, refetch, workspaceId]\n );\n\n const updateEntry = useCallback(\n async (id: string, input: PlantCatalogInput) => {\n await updateMutation({ variables: { input: { id, ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [updateMutation, refetch, workspaceId]\n );\n\n const deleteEntry = useCallback(\n async (id: string) => {\n await deleteMutation({ variables: { id, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [deleteMutation, refetch, workspaceId]\n );\n\n return {\n entries: data?.healthyBowlPlantCatalog ?? [],\n loading,\n error,\n refetch,\n createEntry,\n updateEntry,\n deleteEntry,\n };\n}\n"],"mappings":";;;;;AAgDA,IAAM,IAAiB,8KAejB,IAAsB,CAAG;;;QAGvB,EAAe;;;GAKjB,IAAuB,CAAG;;;QAGxB,EAAe;;;GAKjB,IAAuB,CAAG;;;QAGxB,EAAe;;;GAKjB,IAAuB,CAAG;;;;;AAiBhC,SAAgB,EAAgB,GAA8B;CAC5D,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAA2B,GAAqB;EACxF,WAAW,EAAE,YAAS;EAItB,MAAM,CAAC,KAAe,GAAS,SAAS;EACxC,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,KAAkB,EAAY,EAAqB,EACpD,CAAC,KAAkB,EAAY,EAAqB,EACpD,CAAC,KAAkB,EAAY,EAAqB,EAEpD,IAAc,EAClB,OAAO,MAA6B;AAElC,EADA,MAAM,EAAe,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EACrE,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC,EAEK,IAAc,EAClB,OAAO,GAAY,MAA6B;AAE9C,EADA,MAAM,EAAe,EAAE,WAAW,EAAE,OAAO;GAAE;GAAI,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EACzE,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC,EAEK,IAAc,EAClB,OAAO,MAAe;AAEpB,EADA,MAAM,EAAe,EAAE,WAAW;GAAE;GAAI;GAAS,EAAE,CAAC,EACpD,MAAM,GAAS;IAGjB;EAAC;EAAgB;EAAS;EAAY,CACvC;AAED,QAAO;EACL,SAAS,GAAM,2BAA2B,EAAE;EAC5C;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -4,28 +4,32 @@ import { DataTable as i } from "../../components/DataTable.js";
|
|
|
4
4
|
import { StatusBadge as a } from "../../components/StatusBadge.js";
|
|
5
5
|
import { ErrorState as o } from "../../components/ErrorState.js";
|
|
6
6
|
import { FilterBar as s } from "../../components/FilterBar.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ToastContainer as c } from "../../components/Toast.js";
|
|
8
|
+
import { PageLoader as l } from "../../components/PageLoader.js";
|
|
9
|
+
import { useToast as u } from "../../hooks/useToast.js";
|
|
8
10
|
import "../../components/index.js";
|
|
9
|
-
import { useHealthyBowlData as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { useHealthyBowlData as d } from "../../hooks/useHealthyBowlData.js";
|
|
12
|
+
import { ProductionBatchCreateModal as f } from "../../components/ProductionBatchCreateModal.js";
|
|
13
|
+
import { useState as p } from "react";
|
|
14
|
+
import { useI18n as m } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
15
|
+
import { Package as h, Plus as g } from "lucide-react";
|
|
16
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
17
|
+
import { Button as y } from "@burdenoff/fe-libs/ui";
|
|
14
18
|
//#region src/healthybowl/pages/production/ProductionBatchesPage.tsx
|
|
15
|
-
var
|
|
19
|
+
var b = {
|
|
16
20
|
completed: "success",
|
|
17
21
|
in_progress: "warning",
|
|
18
22
|
planned: "info",
|
|
19
23
|
quality_check: "muted"
|
|
20
24
|
};
|
|
21
|
-
function
|
|
22
|
-
let { t:
|
|
25
|
+
function x() {
|
|
26
|
+
let { t: x } = m(), { productionBatches: S, loadings: C, errors: w, refetch: T } = d(), [E, D] = p(""), [O, k] = p(!1), { toasts: A, toast: j, dismiss: M } = u(), N = S.filter((e) => (e.batchNumber ?? "").toLowerCase().includes(E.toLowerCase()) || (e.product ?? "").toLowerCase().includes(E.toLowerCase())), P = [
|
|
23
27
|
{
|
|
24
28
|
key: "batchNumber",
|
|
25
|
-
header:
|
|
26
|
-
render: (e) => /* @__PURE__ */
|
|
29
|
+
header: x("healthybowl.production.batches.table.headers.batchNumber", "Batch #"),
|
|
30
|
+
render: (e) => /* @__PURE__ */ v("div", {
|
|
27
31
|
className: "flex items-center gap-2",
|
|
28
|
-
children: [/* @__PURE__ */
|
|
32
|
+
children: [/* @__PURE__ */ _(h, { className: "h-4 w-4 text-text-secondary" }), /* @__PURE__ */ _("span", {
|
|
29
33
|
className: "font-medium text-text-primary",
|
|
30
34
|
children: e.batchNumber
|
|
31
35
|
})]
|
|
@@ -33,28 +37,28 @@ function g() {
|
|
|
33
37
|
},
|
|
34
38
|
{
|
|
35
39
|
key: "product",
|
|
36
|
-
header:
|
|
40
|
+
header: x("healthybowl.production.batches.table.headers.product", "Product")
|
|
37
41
|
},
|
|
38
42
|
{
|
|
39
43
|
key: "startDate",
|
|
40
|
-
header:
|
|
41
|
-
render: (e) => /* @__PURE__ */
|
|
44
|
+
header: x("healthybowl.production.batches.table.headers.startDate", "Start Date"),
|
|
45
|
+
render: (e) => /* @__PURE__ */ _("span", {
|
|
42
46
|
className: "text-text-secondary",
|
|
43
47
|
children: t(e.startDate)
|
|
44
48
|
})
|
|
45
49
|
},
|
|
46
50
|
{
|
|
47
51
|
key: "endDate",
|
|
48
|
-
header:
|
|
49
|
-
render: (e) => /* @__PURE__ */
|
|
52
|
+
header: x("healthybowl.production.batches.table.headers.endDate", "End Date"),
|
|
53
|
+
render: (e) => /* @__PURE__ */ _("span", {
|
|
50
54
|
className: "text-text-secondary",
|
|
51
55
|
children: e.endDate ? t(e.endDate) : "—"
|
|
52
56
|
})
|
|
53
57
|
},
|
|
54
58
|
{
|
|
55
59
|
key: "quantity",
|
|
56
|
-
header:
|
|
57
|
-
render: (e) => /* @__PURE__ */
|
|
60
|
+
header: x("healthybowl.production.batches.table.headers.quantity", "Quantity"),
|
|
61
|
+
render: (e) => /* @__PURE__ */ v("span", { children: [
|
|
58
62
|
n(e.quantity),
|
|
59
63
|
" ",
|
|
60
64
|
e.unit
|
|
@@ -62,49 +66,65 @@ function g() {
|
|
|
62
66
|
},
|
|
63
67
|
{
|
|
64
68
|
key: "status",
|
|
65
|
-
header:
|
|
66
|
-
render: (e) => /* @__PURE__ */
|
|
69
|
+
header: x("healthybowl.production.batches.table.headers.status", "Status"),
|
|
70
|
+
render: (e) => /* @__PURE__ */ _(a, {
|
|
67
71
|
label: (e.status ?? "unknown").replace("_", " "),
|
|
68
|
-
variant:
|
|
72
|
+
variant: b[e.status ?? "unknown"] ?? "muted",
|
|
69
73
|
dot: !0
|
|
70
74
|
})
|
|
71
75
|
},
|
|
72
76
|
{
|
|
73
77
|
key: "qualityScore",
|
|
74
|
-
header:
|
|
75
|
-
render: (e) => e.qualityScore ? /* @__PURE__ */
|
|
78
|
+
header: x("healthybowl.production.batches.table.headers.quality", "Quality"),
|
|
79
|
+
render: (e) => e.qualityScore ? /* @__PURE__ */ _(a, {
|
|
76
80
|
label: `${e.qualityScore}%`,
|
|
77
81
|
variant: e.qualityScore >= 90 ? "success" : "warning"
|
|
78
|
-
}) : /* @__PURE__ */
|
|
82
|
+
}) : /* @__PURE__ */ _("span", {
|
|
79
83
|
className: "text-text-secondary",
|
|
80
84
|
children: "—"
|
|
81
85
|
})
|
|
82
86
|
},
|
|
83
87
|
{
|
|
84
88
|
key: "cost",
|
|
85
|
-
header:
|
|
86
|
-
render: (t) => /* @__PURE__ */
|
|
89
|
+
header: x("healthybowl.production.batches.table.headers.cost", "Cost"),
|
|
90
|
+
render: (t) => /* @__PURE__ */ _("span", {
|
|
87
91
|
className: "text-text-primary",
|
|
88
92
|
children: e(t.cost, "INR")
|
|
89
93
|
})
|
|
90
94
|
}
|
|
91
95
|
];
|
|
92
|
-
return /* @__PURE__ */
|
|
93
|
-
title:
|
|
94
|
-
description:
|
|
96
|
+
return /* @__PURE__ */ v(r, {
|
|
97
|
+
title: x("healthybowl.production.batches.title", "Production Batches"),
|
|
98
|
+
description: x("healthybowl.production.batches.description", "Track all production batches and their status"),
|
|
95
99
|
purpose: "Every batch of value-added product you make — jams, oils, packaged goods — and where each one is in production. Use it to track work in progress, spot bottlenecks, and know what's ready to sell.",
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
actions: /* @__PURE__ */ v(y, {
|
|
101
|
+
onClick: () => k(!0),
|
|
102
|
+
children: [/* @__PURE__ */ _(g, { className: "mr-2 h-4 w-4" }), x("healthybowl.products.batches.actions.createBatch", "Create Batch")]
|
|
103
|
+
}),
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ _(s, {
|
|
106
|
+
searchValue: E,
|
|
107
|
+
onSearchChange: D,
|
|
108
|
+
searchPlaceholder: x("healthybowl.production.batches.searchPlaceholder", "Search batches...")
|
|
109
|
+
}),
|
|
110
|
+
C.production ? /* @__PURE__ */ _(l, {}) : w.production ? /* @__PURE__ */ _(o, { onRetry: T }) : /* @__PURE__ */ _(i, {
|
|
111
|
+
columns: P,
|
|
112
|
+
data: N,
|
|
113
|
+
keyField: "id"
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ _(f, {
|
|
116
|
+
open: O,
|
|
117
|
+
onClose: () => k(!1),
|
|
118
|
+
onNotify: j
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ _(c, {
|
|
121
|
+
toasts: A,
|
|
122
|
+
onDismiss: M
|
|
123
|
+
})
|
|
124
|
+
]
|
|
105
125
|
});
|
|
106
126
|
}
|
|
107
127
|
//#endregion
|
|
108
|
-
export {
|
|
128
|
+
export { x as ProductionBatchesPage };
|
|
109
129
|
|
|
110
130
|
//# sourceMappingURL=ProductionBatchesPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductionBatchesPage.js","names":[],"sources":["../../../../src/healthybowl/pages/production/ProductionBatchesPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Package } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PageLayout
|
|
1
|
+
{"version":3,"file":"ProductionBatchesPage.js","names":[],"sources":["../../../../src/healthybowl/pages/production/ProductionBatchesPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Package, Plus } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n DataTable,\n StatusBadge,\n FilterBar,\n ErrorState,\n PageLoader,\n ToastContainer,\n} from '../../components';\nimport { ProductionBatchCreateModal } from '../../components/ProductionBatchCreateModal';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { formatDate, formatCurrency, HB_DEFAULT_CURRENCY, formatNumber } from '../../utils/helpers';\n\nconst statusVariant: Record<string, 'success' | 'warning' | 'info' | 'muted'> = {\n completed: 'success',\n in_progress: 'warning',\n planned: 'info',\n quality_check: 'muted',\n};\n\nexport function ProductionBatchesPage() {\n const { t } = useI18n();\n const { productionBatches, loadings, errors, refetch } = useHealthyBowlData();\n\n const [search, setSearch] = useState('');\n // Drives the same create modal as /products/batches.\n const [showCreateModal, setShowCreateModal] = useState(false);\n const { toasts, toast, dismiss } = useToast();\n\n const filtered = productionBatches.filter(\n (b) =>\n (b.batchNumber ?? '').toLowerCase().includes(search.toLowerCase()) ||\n (b.product ?? '').toLowerCase().includes(search.toLowerCase())\n );\n\n const columns = [\n {\n key: 'batchNumber',\n header: t('healthybowl.production.batches.table.headers.batchNumber', 'Batch #'),\n render: (r: (typeof productionBatches)[0]) => (\n <div className=\"flex items-center gap-2\">\n <Package className=\"h-4 w-4 text-text-secondary\" />\n <span className=\"font-medium text-text-primary\">{r.batchNumber}</span>\n </div>\n ),\n },\n { key: 'product', header: t('healthybowl.production.batches.table.headers.product', 'Product') },\n {\n key: 'startDate',\n header: t('healthybowl.production.batches.table.headers.startDate', 'Start Date'),\n render: (r: (typeof productionBatches)[0]) => (\n <span className=\"text-text-secondary\">{formatDate(r.startDate)}</span>\n ),\n },\n {\n key: 'endDate',\n header: t('healthybowl.production.batches.table.headers.endDate', 'End Date'),\n render: (r: (typeof productionBatches)[0]) => (\n <span className=\"text-text-secondary\">{r.endDate ? formatDate(r.endDate) : '—'}</span>\n ),\n },\n {\n key: 'quantity',\n header: t('healthybowl.production.batches.table.headers.quantity', 'Quantity'),\n render: (r: (typeof productionBatches)[0]) => (\n <span>\n {formatNumber(r.quantity)} {r.unit}\n </span>\n ),\n },\n {\n key: 'status',\n header: t('healthybowl.production.batches.table.headers.status', 'Status'),\n render: (r: (typeof productionBatches)[0]) => (\n <StatusBadge\n label={(r.status ?? 'unknown').replace('_', ' ')}\n variant={statusVariant[r.status ?? 'unknown'] ?? 'muted'}\n dot\n />\n ),\n },\n {\n key: 'qualityScore',\n header: t('healthybowl.production.batches.table.headers.quality', 'Quality'),\n render: (r: (typeof productionBatches)[0]) =>\n r.qualityScore ? (\n <StatusBadge label={`${r.qualityScore}%`} variant={r.qualityScore >= 90 ? 'success' : 'warning'} />\n ) : (\n <span className=\"text-text-secondary\">—</span>\n ),\n },\n {\n key: 'cost',\n header: t('healthybowl.production.batches.table.headers.cost', 'Cost'),\n render: (r: (typeof productionBatches)[0]) => (\n <span className=\"text-text-primary\">{formatCurrency(r.cost, HB_DEFAULT_CURRENCY)}</span>\n ),\n },\n ];\n\n return (\n <PageLayout\n title={t('healthybowl.production.batches.title', 'Production Batches')}\n description={t('healthybowl.production.batches.description', 'Track all production batches and their status')}\n purpose=\"Every batch of value-added product you make — jams, oils, packaged goods — and where each one is in production. Use it to track work in progress, spot bottlenecks, and know what's ready to sell.\"\n actions={\n <Button onClick={() => setShowCreateModal(true)}>\n <Plus className=\"mr-2 h-4 w-4\" />\n {t('healthybowl.products.batches.actions.createBatch', 'Create Batch')}\n </Button>\n }\n >\n <FilterBar\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={t('healthybowl.production.batches.searchPlaceholder', 'Search batches...')}\n />\n {loadings.production ? (\n <PageLoader />\n ) : errors.production ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <DataTable columns={columns} data={filtered} keyField=\"id\" />\n )}\n\n <ProductionBatchCreateModal open={showCreateModal} onClose={() => setShowCreateModal(false)} onNotify={toast} />\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAM,IAA0E;CAC9E,WAAW;CACX,aAAa;CACb,SAAS;CACT,eAAe;CAChB;AAED,SAAgB,IAAwB;CACtC,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,sBAAmB,aAAU,WAAQ,eAAY,GAAoB,EAEvE,CAAC,GAAQ,KAAa,EAAS,GAAG,EAElC,CAAC,GAAiB,KAAsB,EAAS,GAAM,EACvD,EAAE,WAAQ,UAAO,eAAY,GAAU,EAEvC,IAAW,EAAkB,QAChC,OACE,EAAE,eAAe,IAAI,aAAa,CAAC,SAAS,EAAO,aAAa,CAAC,KACjE,EAAE,WAAW,IAAI,aAAa,CAAC,SAAS,EAAO,aAAa,CAAC,CACjE,EAEK,IAAU;EACd;GACE,KAAK;GACL,QAAQ,EAAE,4DAA4D,UAAU;GAChF,SAAS,MACP,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD,EAAS,WAAU,+BAAgC,CAAA,EACnD,kBAAC,QAAD;KAAM,WAAU;eAAiC,EAAE;KAAmB,CAAA,CAClE;;GAET;EACD;GAAE,KAAK;GAAW,QAAQ,EAAE,wDAAwD,UAAU;GAAE;EAChG;GACE,KAAK;GACL,QAAQ,EAAE,0DAA0D,aAAa;GACjF,SAAS,MACP,kBAAC,QAAD;IAAM,WAAU;cAAuB,EAAW,EAAE,UAAU;IAAQ,CAAA;GAEzE;EACD;GACE,KAAK;GACL,QAAQ,EAAE,wDAAwD,WAAW;GAC7E,SAAS,MACP,kBAAC,QAAD;IAAM,WAAU;cAAuB,EAAE,UAAU,EAAW,E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