@feedmepos/mf-inventory-portal 0.0.22-dev.5 → 0.0.22-dev.50

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 (144) hide show
  1. package/dist/ApprovalView-CyIOcyG5.js +140 -0
  2. package/dist/{BindingsDialog-DQJhC3Mo.js → BindingsDialog-BXePN5iL.js} +10 -10
  3. package/dist/{BindingsPicker-YfbPb_dG.js → BindingsPicker-Bd_qb0aO.js} +15 -15
  4. package/dist/{BindingsTable-D3MVcHXZ.js → BindingsTable-BV-nP9HU.js} +4 -4
  5. package/dist/ClosingTemplateView-CSvWLccZ.js +1829 -0
  6. package/dist/FmDroppableField-DwZ6ujPh.js +154 -0
  7. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DpCoW_-F.js +266 -0
  8. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BpzreBHD.js +435 -0
  9. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-C8k7pSPT.js +51 -0
  10. package/dist/IngredientGroupView-C0hPeD41.js +608 -0
  11. package/dist/IngredientsView-CpwVIGXd.js +1608 -0
  12. package/dist/IntegrationView-Bt8pGAHS.js +1225 -0
  13. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-wsBLYBpB.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-yA-qJUUz.js} +1 -1
  14. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BqcqoKyN.js +116 -0
  15. package/dist/{PurchaseOrderPrintPreview-BcAmgmD8.js → PurchaseOrderPrintPreview-D3ugzCW_.js} +7 -7
  16. package/dist/ReceiveRequestView-D14YTEEe.js +4073 -0
  17. package/dist/RecipeView-D0WsMfKm.js +594 -0
  18. package/dist/Standalone.vue.d.ts +2 -0
  19. package/dist/StockView-sxI0L6MP.js +7770 -0
  20. package/dist/SupplierView-clAkARuW.js +1468 -0
  21. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C9NU1m6S.js +1150 -0
  22. package/dist/TransferTemplateView-DpI6kVqX.js +1258 -0
  23. package/dist/{UnitView-B95q8Xrj.js → UnitView-CneJsDum.js} +18 -18
  24. package/dist/{WarehouseView-CHGXvyeS.js → WarehouseView-DYbFWTlh.js} +176 -177
  25. package/dist/api/bill.d.ts +84 -238
  26. package/dist/api/closing-template.d.ts +6 -4
  27. package/dist/api/inventory.d.ts +282 -91
  28. package/dist/api/netsuite.d.ts +71 -0
  29. package/dist/api/purchase-order-template.d.ts +4 -6
  30. package/dist/api/supplier.d.ts +1 -0
  31. package/dist/{app-CfXF4jdF.js → app-B4pi48sM.js} +26414 -24985
  32. package/dist/app.d.ts +88 -3
  33. package/dist/app.js +3 -3
  34. package/dist/components/FmFilterableMenuOptions.vue.d.ts +54 -0
  35. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  36. package/dist/components/FmMultiselectDialog.vue.d.ts +3 -9
  37. package/dist/components/FmMultiselectDialogProps.d.ts +0 -2
  38. package/dist/components/FmUnitInputRules.d.ts +2 -0
  39. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +5 -5
  40. package/dist/components/map/GoogleMap.vue.d.ts +4 -4
  41. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +2 -2
  42. package/dist/components/shell/inventory/binding-ui.vue.d.ts +2 -2
  43. package/dist/{decimal-BZ7tX47r.js → decimal-C8O2p3Sg.js} +1 -1
  44. package/dist/defineDeepModel-BXP1vLGf.js +13 -0
  45. package/dist/extensions/array.d.ts +1 -0
  46. package/dist/format-time-from-id-DgW7OJL_.js +15 -0
  47. package/dist/format-unit-display-BP4O0Pym.js +1195 -0
  48. package/dist/helper/rules.d.ts +7 -0
  49. package/dist/helper/rules.spec.d.ts +1 -0
  50. package/dist/helper/xlsx.util.d.ts +7 -0
  51. package/dist/router/name.d.ts +1 -0
  52. package/dist/stores/api.d.ts +1 -0
  53. package/dist/stores/feature.d.ts +0 -1
  54. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  55. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  56. package/dist/stores/integration/foodmarkethub.d.ts +391 -0
  57. package/dist/stores/integration/index.d.ts +7 -0
  58. package/dist/stores/integration/netsuite.d.ts +102 -0
  59. package/dist/stores/inventory.d.ts +294 -9
  60. package/dist/stores/location.d.ts +508 -503
  61. package/dist/stores/supplier.d.ts +124 -4
  62. package/dist/style.css +1 -1
  63. package/dist/supplier-D-8XhuF_.js +77 -0
  64. package/dist/tsconfig.app.tsbuildinfo +1 -1
  65. package/dist/use-template-enabled-locations-2-C2E4j3k-.js +85 -0
  66. package/dist/views/closing-template/closing-template-import/ClosingTemplateImport.vue.d.ts +2 -0
  67. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItem.vue.d.ts +12 -0
  68. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItemProps.d.ts +7 -0
  69. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  70. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +877 -1038
  71. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +882 -1049
  72. package/dist/views/closing-template/helpers/import-export.helper.d.ts +58 -0
  73. package/dist/views/ingredient-group/IngredientGroupView.vue.d.ts +3 -0
  74. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialog.vue.d.ts +31 -0
  75. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialogProps.d.ts +12 -0
  76. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupForm.vue.d.ts +20 -0
  77. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupFormProps.d.ts +12 -0
  78. package/dist/views/ingredient-group/composables/use-ingredient-group-actions.d.ts +24 -0
  79. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +215 -0
  80. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +2 -2
  81. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  82. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +5 -5
  83. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +2 -2
  84. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  85. package/dist/views/integration/FoodMarketHub.vue.d.ts +2 -0
  86. package/dist/views/integration/NetSuite.vue.d.ts +2 -0
  87. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +7 -7
  88. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +7 -7
  89. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  90. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +49 -0
  91. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +1961 -87
  92. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  93. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -2
  94. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -1
  95. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +2377 -292
  96. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +2329 -244
  97. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -2
  98. package/dist/views/recipe/composables/use-recipe-form.d.ts +2 -2
  99. package/dist/views/stock/components/StockRecordCard.vue.d.ts +42 -119
  100. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +32 -2
  101. package/dist/views/stock/composables/use-stock-action.d.ts +2 -2
  102. package/dist/views/supplier/components/supplier-import/SupplierImport.vue.d.ts +2 -0
  103. package/dist/views/supplier/components/supplier-import/SupplierImportItem.vue.d.ts +12 -0
  104. package/dist/views/supplier/components/supplier-import/SupplierImportItemProps.d.ts +6 -0
  105. package/dist/views/supplier/composables/use-supplier-actions.d.ts +10 -0
  106. package/dist/views/supplier/helpers/import-export.helper.d.ts +50 -0
  107. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +0 -2
  108. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +0 -1
  109. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  110. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +71 -85
  111. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +39 -2
  112. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -1
  113. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImport.vue.d.ts +2 -0
  114. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItem.vue.d.ts +12 -0
  115. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItemProps.d.ts +9 -0
  116. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1277 -1478
  117. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1697 -906
  118. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +76 -0
  119. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +1 -247
  120. package/dist/views/transfer-template/helpers/template-item.error.helper.d.ts +1 -0
  121. package/dist/views/unit/composables/use-unit-form.d.ts +2 -2
  122. package/dist/{xlsx-BtP1Qjj6.js → xlsx-Dsy-fxZw.js} +1525 -1525
  123. package/dist/xlsx.util-CxGmvsp9.js +78 -0
  124. package/package.json +10 -7
  125. package/dist/ApprovalView-BdaNwUBc.js +0 -129
  126. package/dist/ClosingTemplateView-BpErgepi.js +0 -1030
  127. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D3B7kOlU.js +0 -372
  128. package/dist/IngredientsView-GqrkpCm5.js +0 -1758
  129. package/dist/IntegrationView-7c3MpUzS.js +0 -1141
  130. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BIwdObb1.js +0 -88
  131. package/dist/ReceiveRequestView-BAuXvzQW.js +0 -215
  132. package/dist/RecipeView-C6tZPQ-K.js +0 -581
  133. package/dist/StockView-4uXHYz4E.js +0 -1892
  134. package/dist/SupplierView-CuWvKCWY.js +0 -827
  135. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CTQ9HIqf.js +0 -740
  136. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang--6JoXOLD.js +0 -1409
  137. package/dist/TransferTemplateView-D1Lfi3aW.js +0 -1230
  138. package/dist/defineDeepModel-BKAs9qN6.js +0 -13
  139. package/dist/format-time-from-id-B7ZE4sdX.js +0 -15
  140. package/dist/id-to-date-D1lOqIir.js +0 -30
  141. package/dist/purchase-order-transaction-type-tZ7cj1dz.js +0 -702
  142. package/dist/supplier-BIDBk5S6.js +0 -69
  143. package/dist/use-template-enabled-locations-DlMnS9WJ.js +0 -57
  144. package/dist/xlsx.util-BKFiH-ig.js +0 -109
@@ -1,1758 +0,0 @@
1
- import { ref as z, defineComponent as le, computed as C, resolveComponent as R, openBlock as y, createBlock as B, withCtx as $, createVNode as f, unref as d, createElementBlock as U, Fragment as X, createElementVNode as c, createCommentVNode as O, onMounted as nt, watch as je, normalizeClass as Q, createTextVNode as He, toDisplayString as L, renderList as oe, isRef as Ee, renderSlot as ge, createSlots as Oe, normalizeStyle as ot, Teleport as De, normalizeProps as lt, guardReactiveProps as at } from "vue";
2
- import { u as ae, c as Ye, S as rt, _ as st, A as _e, a as Ge, g as xe, t as qe, F as ve, R as be, U as it, M as ut, d as Ae, b as We, C as Ce, e as Te, f as dt, h as ct, I as mt, i as pt, j as vt } from "./app-CfXF4jdF.js";
3
- import { useDialog as Ke, useSnackbar as Ve, useProxiedModel as Pe, useDialogChild as ft, useBreakpoints as yt } from "@feedmepos/ui-library";
4
- import { i as gt, _ as bt } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
- import { F as K, D as Be, R as he } from "./row-action.enum-PMKMRrZR.js";
6
- import { useI18n as re, useCoreStore as fe } from "@feedmepos/mf-common";
7
- import { defineStore as ht, storeToRefs as _t } from "pinia";
8
- import { c as xt, _ as Vt, F as ze } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
9
- import { u as kt, _ as Ct, a as Ft } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D3B7kOlU.js";
10
- import { g as St, _ as Fe, S as Se } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
11
- import { _ as we, t as Je, d as Qe, s as wt, r as Mt } from "./xlsx.util-BKFiH-ig.js";
12
- import { _ as Me } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
- const $e = ht("ingredientForm", function() {
14
- const i = Ke(), m = Ve(), r = ae(), n = z(!1), { t: l } = re(), o = z();
15
- function p() {
16
- const h = {
17
- unit: {},
18
- mode: K.CREATE,
19
- show: !0,
20
- "onUpdate:show"(u) {
21
- o.value.show = u;
22
- }
23
- };
24
- o.value = h;
25
- }
26
- async function b(h) {
27
- const u = {
28
- unit: Ye(h),
29
- mode: K.UPDATE,
30
- show: !0,
31
- "onUpdate:show"(x) {
32
- o.value.show = x;
33
- }
34
- };
35
- o.value = u;
36
- }
37
- async function _(h) {
38
- n.value = !0;
39
- try {
40
- await r.deleteSku(h), m.open({
41
- title: "Success",
42
- message: `Deleted ${h.name}`,
43
- type: "success"
44
- });
45
- } catch (u) {
46
- u instanceof rt && gt(u) ? i.open({
47
- title: "Cannot delete ingredient",
48
- contentComponent: bt,
49
- contentComponentProps: {
50
- subject: (h == null ? void 0 : h.name) ?? "",
51
- items: u.errorResponse.message
52
- },
53
- secondaryActions: {
54
- text: "Close",
55
- close: !0
56
- }
57
- }) : console.log("unable to delete ingredient", u), m.open({
58
- title: `Cannot delete ${h.name}`,
59
- message: "Please try again.",
60
- type: "error"
61
- }), console.error("failed to delete ingredient", u);
62
- } finally {
63
- n.value = !1;
64
- }
65
- }
66
- function g(h) {
67
- i.open({
68
- title: l("inventory.ingredient.delete.title", [(h == null ? void 0 : h.name) ?? ""]),
69
- closeButton: !1,
70
- message: l("inventory.ingredient.delete.message"),
71
- primaryActions: {
72
- text: l("common.delete"),
73
- close: !0,
74
- variant: "destructive"
75
- },
76
- secondaryActions: {
77
- text: l("common.cancel"),
78
- close: !0
79
- }
80
- }).onPrimary(() => _(h));
81
- }
82
- return {
83
- createIngredient: p,
84
- updateIngredient: b,
85
- deleteIngredient: g,
86
- ingredientDialogProps: o,
87
- ingredientViewLoading: n
88
- };
89
- });
90
- function $t() {
91
- const { updateIngredient: s, deleteIngredient: i } = $e(), { t: m } = re();
92
- async function r(l, o) {
93
- const p = Ye(o);
94
- if (l === he.Edit) {
95
- await s(p);
96
- return;
97
- }
98
- if (l === he.Delete) {
99
- await i(p);
100
- return;
101
- }
102
- }
103
- return { columnDefs: [
104
- {
105
- accessorKey: "code",
106
- header: () => m("inventory.ingredient.code"),
107
- enableSorting: !0,
108
- size: 300
109
- },
110
- {
111
- accessorKey: "name",
112
- header: () => m("inventory.ingredient.name"),
113
- enableSorting: !0,
114
- size: 300
115
- },
116
- {
117
- id: "unit",
118
- header: () => m("inventory.ingredient.unit"),
119
- cell(l) {
120
- var p;
121
- const o = l.row.original;
122
- if (o.trackingMeasurement) {
123
- const b = (p = o.unit.measurements) == null ? void 0 : p.find(
124
- (_) => _.id === o.trackingMeasurement
125
- );
126
- if (b)
127
- return `${b.name} (${b.abbrev})`;
128
- }
129
- return `${o.unit.name} (${o.unit.abbrev})`;
130
- },
131
- enableSorting: !1,
132
- size: "auto"
133
- },
134
- {
135
- id: "action",
136
- header: "",
137
- cell(l) {
138
- return xt(
139
- [Be[he.Edit], Be[he.Delete]],
140
- (o) => {
141
- r(o, l.row.original);
142
- }
143
- );
144
- },
145
- enableSorting: !1,
146
- size: 40,
147
- meta: {
148
- cellClass: "",
149
- headerClass: ""
150
- }
151
- }
152
- ] };
153
- }
154
- const It = /* @__PURE__ */ le({
155
- __name: "ConvertForm",
156
- props: {
157
- modelValue: {},
158
- rootValue: {},
159
- disabled: { type: Boolean }
160
- },
161
- emits: ["update:modelValue"],
162
- setup(s, { emit: i }) {
163
- const m = s, r = C(() => {
164
- var u;
165
- return (u = m.rootValue) == null ? void 0 : u.unit;
166
- }), n = C(() => {
167
- var u;
168
- return (u = m.rootValue) == null ? void 0 : u._id;
169
- }), l = i, { t: o } = re(), p = C({
170
- get() {
171
- return !!m.modelValue;
172
- },
173
- set(u) {
174
- u ? l("update:modelValue", {
175
- measurement: null,
176
- inventoryBindings: []
177
- }) : l("update:modelValue", null);
178
- }
179
- }), b = C(() => St(r.value));
180
- function _(u) {
181
- const x = m.modelValue ?? {};
182
- x.measurement = u ? `${u}` : null, l("update:modelValue", x);
183
- }
184
- function g(u) {
185
- const x = m.modelValue ?? {};
186
- x.inventoryBindings = u, l("update:modelValue", x);
187
- }
188
- const h = C(() => {
189
- if (!m.modelValue) return null;
190
- const u = m.modelValue;
191
- return u.measurement ? b.value.find((x) => x.value === u.measurement) ?? null : b.value.find((x) => x.value === null) ?? null;
192
- });
193
- return (u, x) => {
194
- const D = R("FmSwitch"), w = R("FmSelect"), M = R("FmCard");
195
- return y(), B(M, {
196
- variant: "outlined",
197
- class: "p-16 flex flex-col gap-16"
198
- }, {
199
- default: $(() => {
200
- var S, V;
201
- return [
202
- f(D, {
203
- value: "",
204
- "model-value": p.value,
205
- "onUpdate:modelValue": x[0] || (x[0] = (H) => p.value = H),
206
- label: d(o)("inventory.ingredient.convertible.title"),
207
- sublabel: d(o)("inventory.ingredient.convertible.subtitle"),
208
- labelPlacement: "right"
209
- }, null, 8, ["model-value", "label", "sublabel"]),
210
- p.value ? (y(), U(X, { key: 0 }, [
211
- c("div", null, [
212
- f(w, {
213
- label: d(o)("inventory.ingredient.convertible.convertTo"),
214
- modelValue: (S = h.value) == null ? void 0 : S.value,
215
- "onUpdate:modelValue": _,
216
- items: b.value
217
- }, null, 8, ["label", "modelValue", "items"])
218
- ]),
219
- f(st, {
220
- id: n.value,
221
- "model-value": ((V = u.modelValue) == null ? void 0 : V.inventoryBindings) ?? [],
222
- "onUpdate:modelValue": g,
223
- "exclude-binding-id": n.value,
224
- rules: [d(_e)(1)]
225
- }, null, 8, ["id", "model-value", "exclude-binding-id", "rules"])
226
- ], 64)) : O("", !0)
227
- ];
228
- }),
229
- _: 1
230
- });
231
- };
232
- }
233
- });
234
- function ue() {
235
- return {
236
- low: 6,
237
- mid: 14
238
- };
239
- }
240
- const Rt = { class: "text-fm-color-typo-secondary" }, Ut = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Et = { class: "col-span-2 mt-16" }, Dt = { class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16" }, At = { class: "w-full" }, Tt = {
241
- key: 0,
242
- class: "flex flex-col gap-8"
243
- }, Pt = {
244
- type: "button",
245
- class: "inline-flex h-32 items-center"
246
- }, Bt = {
247
- key: 2,
248
- class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
249
- }, zt = { class: "col-span-2 flex flex-col gap-12" }, Lt = { class: "flex flex-col gap-4" }, Nt = { class: "fm-typo-en-title-sm-800" }, jt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ht = { class: "col-span-2 flex flex-col gap-4" }, Ot = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, Yt = { class: "flex-1 p-12 flex flex-col gap-8" }, Gt = { class: "mx-auto" }, qt = { class: "flex flex-col" }, Wt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Kt = { class: "flex-1 p-12 flex flex-col gap-8" }, Jt = { class: "mx-auto" }, Qt = { class: "flex flex-col" }, Xt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Zt = { class: "flex-1 p-12 flex flex-col gap-8" }, en = { class: "mx-auto" }, tn = { class: "flex flex-col" }, nn = { class: "fm-typo-en-body-sm-600 translate-y-4" };
250
- var Ie = /* @__PURE__ */ ((s) => (s.Daily = "Daily", s.Consumables = "Consumables", s.ShortTerm = "Short term", s.Kitchen = "Kitchen", s))(Ie || {});
251
- const on = /* @__PURE__ */ le({
252
- __name: "IngredientForm",
253
- props: {
254
- mode: {},
255
- modelValue: {},
256
- disabled: { type: Boolean }
257
- },
258
- emits: ["update:modelValue", "click:submit"],
259
- setup(s, { expose: i, emit: m }) {
260
- var pe;
261
- const { t: r } = re(), n = s, l = m, o = ae(), p = fe(), b = We();
262
- function _(t) {
263
- if (t.length === 0) return;
264
- const e = t[0], v = n.modelValue ?? {
265
- unit: o.units.find((k) => k)
266
- };
267
- v.unit || (v.unit = e, l("update:modelValue", v));
268
- }
269
- nt(() => {
270
- _(o.units);
271
- }), je([() => o.units], ([t]) => {
272
- _(t);
273
- });
274
- function g() {
275
- l("click:submit");
276
- }
277
- const h = C({
278
- get() {
279
- var t;
280
- return ((t = n.modelValue) == null ? void 0 : t.code) ?? "";
281
- },
282
- set(t) {
283
- const e = n.modelValue ? {
284
- ...n.modelValue
285
- } : {};
286
- e.code = t, l("update:modelValue", e);
287
- }
288
- }), u = C({
289
- get() {
290
- var t;
291
- return ((t = n.modelValue) == null ? void 0 : t.name) ?? "";
292
- },
293
- set(t) {
294
- const e = n.modelValue ? {
295
- ...n.modelValue
296
- } : {};
297
- e.name = t, l("update:modelValue", e);
298
- }
299
- }), x = C({
300
- get() {
301
- var e, v;
302
- const t = (v = (e = n.modelValue) == null ? void 0 : e.defaultCost) == null ? void 0 : v.costPerUnit;
303
- return t ? +Ge(t) : 0;
304
- },
305
- set(t) {
306
- var v, k, T, I;
307
- const e = n.modelValue ? {
308
- ...n.modelValue
309
- } : {};
310
- e.defaultCost ?? (e.defaultCost = {
311
- costPerUnit: {
312
- amount: 0,
313
- precision: 2,
314
- currency: ((v = xe(p.currentCountry.value)) == null ? void 0 : v.currency) ?? "MYR"
315
- },
316
- measurement: (I = (T = (k = n.modelValue) == null ? void 0 : k.unit) == null ? void 0 : T.measurements) == null ? void 0 : I.find(
317
- (Y) => {
318
- var G;
319
- return Y.id === ((G = n.modelValue) == null ? void 0 : G.trackingMeasurement);
320
- }
321
- )
322
- }), e.defaultCost.costPerUnit = {
323
- ...e.defaultCost.costPerUnit,
324
- ...qe(+t, 4)
325
- }, l("update:modelValue", e);
326
- }
327
- }), D = C(() => {
328
- var e, v, k;
329
- const t = ((e = n.modelValue) == null ? void 0 : e.unit) ?? o.units.find((T) => T);
330
- return t ? {
331
- _id: t._id,
332
- measurement: (v = n.modelValue) == null ? void 0 : v.trackingMeasurement,
333
- name: ((k = t.measurements.find((T) => {
334
- var I;
335
- return T.id === ((I = n.modelValue) == null ? void 0 : I.trackingMeasurement);
336
- })) == null ? void 0 : k.name) ?? t.name
337
- } : null;
338
- }), w = C(
339
- () => o.units.flatMap(({ name: t, _id: e, abbrev: v, measurements: k }) => [
340
- {
341
- label: `${t}`,
342
- value: null,
343
- displayAsSection: !0
344
- },
345
- {
346
- label: `${t} (${v})`,
347
- value: { _id: e },
348
- displayAsSection: !1
349
- },
350
- ...k.map(({ id: T, name: I, abbrev: Y }) => ({
351
- label: `${I} (${Y})`,
352
- value: { _id: e, measurement: T },
353
- displayAsSection: !1
354
- }))
355
- ])
356
- );
357
- function M(t) {
358
- var e, v, k, T, I;
359
- return ((v = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : v._id) === ((k = t.value) == null ? void 0 : k._id) && ((T = n.modelValue) == null ? void 0 : T.trackingMeasurement) === ((I = t.value) == null ? void 0 : I.measurement);
360
- }
361
- function S(t) {
362
- var Y, G;
363
- if (!t) return;
364
- const { _id: e, measurement: v } = t, k = v || void 0, T = o.units.find((ie) => ie._id === e);
365
- if (!T)
366
- return;
367
- const I = n.modelValue ?? {};
368
- I.unit = T, I.trackingMeasurement = k, I.convert && (I.convert.measurement = k || null), b.enableTotalCost && (I.defaultCost = {
369
- measurement: T.measurements.find((ie) => ie.id === k),
370
- costPerUnit: {
371
- ...((Y = I.defaultCost) == null ? void 0 : Y.costPerUnit) ?? {
372
- amount: 0,
373
- precision: 2,
374
- currency: ((G = xe(p.currentCountry.value)) == null ? void 0 : G.currency) ?? "MYR"
375
- }
376
- }
377
- }), l("update:modelValue", I);
378
- }
379
- const V = C({
380
- get() {
381
- var t;
382
- return ((t = n.modelValue) == null ? void 0 : t.operationalGroup) ?? null;
383
- },
384
- set(t) {
385
- const e = n.modelValue ? {
386
- ...n.modelValue
387
- } : {};
388
- e.operationalGroup = t, l("update:modelValue", e);
389
- }
390
- }), H = C(
391
- () => [
392
- ...new Set(
393
- o.skus.map((t) => t.operationalGroup ?? "").filter((t) => t && !Object.values(Ie).includes(t))
394
- )
395
- ].sort()
396
- ), J = C({
397
- get() {
398
- return V.value !== null;
399
- },
400
- set(t) {
401
- t ? V.value = "" : V.value = null;
402
- }
403
- }), ee = C({
404
- get() {
405
- var t;
406
- return ((t = n.modelValue) == null ? void 0 : t.convert) ?? null;
407
- },
408
- set(t) {
409
- const e = n.modelValue ? {
410
- ...n.modelValue
411
- } : {};
412
- t ? e.convert = t : e.convert = null, l("update:modelValue", e);
413
- }
414
- }), de = C(() => ve.options.filter(
415
- (t) => t === ve.enum.FIFO || t === ve.enum.WAVG
416
- ).map((t) => ({
417
- label: r(`inventory.ingredient.valuationMethod.${t}`),
418
- value: t
419
- }))), Z = C({
420
- get() {
421
- var t;
422
- return ((t = n.modelValue) == null ? void 0 : t.valuation) ?? "WAVG";
423
- },
424
- set(t) {
425
- const e = n.modelValue ? {
426
- ...n.modelValue
427
- } : {};
428
- e.valuation = t, l("update:modelValue", e);
429
- }
430
- }), a = z();
431
- i({
432
- validateInputs: () => {
433
- var t, e;
434
- (e = (t = a.value) == null ? void 0 : t.validateInputs) == null || e.call(t);
435
- },
436
- resetInputsValidation: () => {
437
- var t, e;
438
- (e = (t = a.value) == null ? void 0 : t.resetInputsValidation) == null || e.call(t);
439
- },
440
- resetInputs: () => {
441
- var t, e;
442
- (e = (t = a.value) == null ? void 0 : t.resetInputs) == null || e.call(t);
443
- }
444
- });
445
- const N = z(!1), W = C(
446
- () => {
447
- var t, e, v;
448
- return (t = n.modelValue) != null && t._id ? ((v = o.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : v.filter(
449
- (k) => k.from === "INGREDIENT"
450
- )) ?? [] : [];
451
- }
452
- ), se = C(
453
- () => {
454
- var t, e, v;
455
- return (t = n.modelValue) != null && t._id ? ((v = o.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : v.filter(
456
- (k) => k.from === "RECIPE"
457
- )) ?? [] : [];
458
- }
459
- ), te = C(
460
- () => {
461
- var t, e, v;
462
- return (t = n.modelValue) != null && t._id ? ((v = o.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : v.filter((k) => k.from === "MENU")) ?? [] : [];
463
- }
464
- ), A = C(
465
- () => o.skus.map((t) => ({ label: t.name, value: t.code }))
466
- ), E = z((pe = n.modelValue) == null ? void 0 : pe.code);
467
- function ce(t) {
468
- var v;
469
- const e = t.el;
470
- e && ((v = e.querySelector("[x-should-scroll-into=true]")) == null || v.scrollIntoView());
471
- }
472
- function ne(t) {
473
- switch (t) {
474
- case Ce.MY:
475
- return "MYR";
476
- case Ce.SG:
477
- return "SGD";
478
- case Ce.ID:
479
- return "IDR";
480
- default:
481
- return "MYR";
482
- }
483
- }
484
- const me = C(
485
- () => {
486
- var t, e, v, k, T, I;
487
- return ((k = (v = (e = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : e.measurements) == null ? void 0 : v.find(
488
- (Y) => {
489
- var G;
490
- return Y.id === ((G = n.modelValue) == null ? void 0 : G.trackingMeasurement);
491
- }
492
- )) == null ? void 0 : k.abbrev) ?? ((I = (T = n.modelValue) == null ? void 0 : T.unit) == null ? void 0 : I.abbrev);
493
- }
494
- ), P = C({
495
- get() {
496
- var t, e;
497
- return ((e = (t = n.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.low) ?? ue().low;
498
- },
499
- set(t) {
500
- var k;
501
- const e = ((k = n.modelValue) == null ? void 0 : k.thresholds) ?? ue();
502
- e.low = t;
503
- const v = n.modelValue ? {
504
- ...n.modelValue
505
- } : {};
506
- v.thresholds = e, l("update:modelValue", v);
507
- }
508
- }), j = C({
509
- get() {
510
- var t, e;
511
- return ((e = (t = n.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.mid) ?? ue().mid;
512
- },
513
- set(t) {
514
- var k;
515
- const e = ((k = n.modelValue) == null ? void 0 : k.thresholds) ?? ue();
516
- e.mid = t;
517
- const v = n.modelValue ? {
518
- ...n.modelValue
519
- } : {};
520
- v.thresholds = e, l("update:modelValue", v);
521
- }
522
- });
523
- function ye() {
524
- return function(e) {
525
- return typeof (e == null ? void 0 : e.low) != "number" || typeof (e == null ? void 0 : e.mid) != "number" ? "Required" : e.low >= e.mid ? "Days for red indicator should be less than yellow indicator." : !0;
526
- };
527
- }
528
- return (t, e) => {
529
- const v = R("FmTextField"), k = R("FmLabel"), T = R("FmField"), I = R("FmMenuHeader"), Y = R("FmMenuDivider"), G = R("FmMenuItem"), ie = R("FmMenu"), ke = R("FmFormGroup"), Ze = R("FmSelect"), Re = R("FmSwitch"), et = R("FmIcon"), Ue = R("FmStepperField"), tt = R("FmForm");
530
- return y(), B(tt, {
531
- disabled: t.disabled,
532
- ref_key: "formRef",
533
- ref: a,
534
- class: "grid grid-cols-2 gap-24",
535
- onValidationSuccess: g
536
- }, {
537
- default: $(() => [
538
- f(v, {
539
- label: d(r)("inventory.ingredient.code"),
540
- "model-value": h.value,
541
- "onUpdate:modelValue": e[0] || (e[0] = (F) => h.value = F),
542
- rules: [d(be)(), d(it)(A.value, E.value)],
543
- "label-mark": "required"
544
- }, null, 8, ["label", "model-value", "rules"]),
545
- f(v, {
546
- label: d(r)("inventory.ingredient.name"),
547
- "model-value": u.value,
548
- "onUpdate:modelValue": e[1] || (e[1] = (F) => u.value = F),
549
- rules: [d(be)()],
550
- "label-mark": "required"
551
- }, null, 8, ["label", "model-value", "rules"]),
552
- f(ke, {
553
- class: "col-span-2",
554
- "model-value": D.value,
555
- rules: [d(be)()],
556
- "label-mark": "required"
557
- }, {
558
- label: $(() => [
559
- f(k, {
560
- label: d(r)("inventory.ingredient.unit")
561
- }, null, 8, ["label"])
562
- ]),
563
- default: $(({ invalid: F }) => [
564
- f(ie, null, {
565
- "menu-button": $(() => [
566
- f(T, {
567
- class: Q([
568
- "fm-typo-en-body-lg-400",
569
- {
570
- "text-fm-color-typo-primary": !t.disabled,
571
- "text-fm-color-typo-disabled": t.disabled
572
- }
573
- ]),
574
- invalid: F,
575
- "append-icon": "expand_more"
576
- }, {
577
- default: $(() => {
578
- var q;
579
- return [
580
- He(L((q = D.value) == null ? void 0 : q.name), 1)
581
- ];
582
- }),
583
- _: 2
584
- }, 1032, ["class", "invalid"])
585
- ]),
586
- default: $(() => [
587
- c("div", {
588
- class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
589
- onVnodeMounted: ce
590
- }, [
591
- (y(!0), U(X, null, oe(w.value, (q) => (y(), U(X, {
592
- key: q.label
593
- }, [
594
- q.displayAsSection ? (y(), U(X, { key: 0 }, [
595
- f(I, {
596
- label: q.label
597
- }, null, 8, ["label"]),
598
- f(Y)
599
- ], 64)) : (y(), B(G, {
600
- key: 1,
601
- label: q.label,
602
- "model-value": M(q),
603
- onClick: (Ln) => S(q.value),
604
- "x-should-scroll-into": `${M(q)}`
605
- }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
606
- ], 64))), 128))
607
- ], 512)
608
- ]),
609
- _: 2
610
- }, 1024)
611
- ]),
612
- _: 1
613
- }, 8, ["model-value", "rules"]),
614
- d(b).enableTotalCost ? (y(), B(Ze, {
615
- key: 0,
616
- class: "col-span-1",
617
- "model-value": Z.value,
618
- "onUpdate:modelValue": e[2] || (e[2] = (F) => Z.value = F),
619
- items: de.value
620
- }, {
621
- label: $(() => [
622
- f(Me, { "z-index": 50 }, {
623
- default: $(() => [
624
- f(k, {
625
- label: d(r)("inventory.ingredient.valuationMethod.title")
626
- }, null, 8, ["label"])
627
- ]),
628
- _: 1
629
- })
630
- ]),
631
- _: 1
632
- }, 8, ["model-value", "items"])) : O("", !0),
633
- d(b).enableTotalCost ? (y(), B(v, {
634
- key: 1,
635
- "model-value": x.value,
636
- "onUpdate:modelValue": e[3] || (e[3] = (F) => x.value = F),
637
- rules: [d(_e)(0), d(ut)(4)]
638
- }, {
639
- label: $(() => [
640
- f(Me, { "z-index": 50 }, {
641
- default: $(() => [
642
- f(k, {
643
- label: d(r)("inventory.ingredient.pricePerUnit")
644
- }, null, 8, ["label"])
645
- ]),
646
- _: 1
647
- })
648
- ]),
649
- prepend: $(() => {
650
- var F, q;
651
- return [
652
- c("div", Rt, L(ne(((F = d(p).currentCountry) == null ? void 0 : F.value) ?? d(Ae)) === "MYR" ? "RM" : ne(((q = d(p).currentCountry) == null ? void 0 : q.value) ?? d(Ae))), 1)
653
- ];
654
- }),
655
- append: $(() => [
656
- c("div", Ut, " / " + L(me.value), 1)
657
- ]),
658
- _: 1
659
- }, 8, ["model-value", "rules"])) : O("", !0),
660
- c("div", Et, [
661
- f(It, {
662
- "model-value": ee.value,
663
- "onUpdate:modelValue": e[4] || (e[4] = (F) => ee.value = F),
664
- "root-value": t.modelValue
665
- }, null, 8, ["model-value", "root-value"])
666
- ]),
667
- c("div", Dt, [
668
- c("div", At, [
669
- f(Re, {
670
- label: d(r)("inventory.ingredient.operational.applyOperationalGroup"),
671
- sublabel: d(r)("inventory.ingredient.operational.subtitle"),
672
- modelValue: J.value,
673
- "onUpdate:modelValue": e[5] || (e[5] = (F) => J.value = F),
674
- "label-placement": "right"
675
- }, null, 8, ["label", "sublabel", "modelValue"])
676
- ]),
677
- J.value ? (y(), U("div", Tt, [
678
- f(ie, null, {
679
- "menu-button": $(() => [
680
- f(v, {
681
- label: d(r)("inventory.ingredient.operational.operationalLabel"),
682
- modelValue: V.value,
683
- "onUpdate:modelValue": e[6] || (e[6] = (F) => V.value = F),
684
- placeholder: d(r)("inventory.ingredient.operational.operationalLabelHint")
685
- }, {
686
- append: $(() => [
687
- c("button", Pt, [
688
- f(et, { name: "expand_more" })
689
- ])
690
- ]),
691
- _: 1
692
- }, 8, ["label", "modelValue", "placeholder"])
693
- ]),
694
- default: $(() => [
695
- f(I, {
696
- label: d(r)("inventory.ingredient.operational.preset")
697
- }, null, 8, ["label"]),
698
- (y(!0), U(X, null, oe(Object.values(Ie), (F) => (y(), B(G, {
699
- key: F,
700
- label: F,
701
- "model-value": V.value === F,
702
- onClick: (q) => V.value = F
703
- }, null, 8, ["label", "model-value", "onClick"]))), 128)),
704
- H.value.length ? (y(), B(I, {
705
- key: 0,
706
- label: d(r)("inventory.ingredient.operational.custom")
707
- }, null, 8, ["label"])) : O("", !0),
708
- (y(!0), U(X, null, oe(H.value, (F) => (y(), B(G, {
709
- key: F,
710
- label: F,
711
- "model-value": V.value === F,
712
- onClick: (q) => V.value = F
713
- }, null, 8, ["label", "model-value", "onClick"]))), 128))
714
- ]),
715
- _: 1
716
- }),
717
- f(ke, {
718
- "model-value": V.value,
719
- rules: [d(be)()]
720
- }, null, 8, ["model-value", "rules"])
721
- ])) : O("", !0)
722
- ]),
723
- t.mode !== d(K).CREATE ? (y(), U("div", Bt, [
724
- c("div", null, [
725
- f(Re, {
726
- label: d(r)("inventory.ingredient.bindedItems.title"),
727
- modelValue: N.value,
728
- "onUpdate:modelValue": e[7] || (e[7] = (F) => N.value = F),
729
- "label-placement": "right"
730
- }, null, 8, ["label", "modelValue"])
731
- ]),
732
- N.value && W.value.length ? (y(), B(we, {
733
- key: 0,
734
- name: d(r)("inventory.ingredient.bindedItems.ingredient"),
735
- bindings: W.value
736
- }, null, 8, ["name", "bindings"])) : O("", !0),
737
- N.value && se.value.length ? (y(), B(we, {
738
- key: 1,
739
- name: d(r)("inventory.ingredient.bindedItems.recipe"),
740
- bindings: se.value
741
- }, null, 8, ["name", "bindings"])) : O("", !0),
742
- N.value && te.value.length ? (y(), B(we, {
743
- key: 2,
744
- name: d(r)("inventory.ingredient.bindedItems.menu"),
745
- bindings: te.value
746
- }, null, 8, ["name", "bindings"])) : O("", !0)
747
- ])) : O("", !0),
748
- c("div", zt, [
749
- c("div", Lt, [
750
- f(Me, null, {
751
- default: $(() => [
752
- c("div", Nt, L(d(r)("inventory.ingredient.threshold.title")), 1)
753
- ]),
754
- _: 1
755
- }),
756
- c("div", jt, L(d(r)("inventory.ingredient.threshold.subtitle")), 1)
757
- ]),
758
- c("div", Ht, [
759
- f(ke, {
760
- "model-value": { low: P.value, mid: j.value },
761
- rules: [ye()]
762
- }, null, 8, ["model-value", "rules"]),
763
- c("div", Ot, [
764
- c("div", Yt, [
765
- c("div", Gt, [
766
- f(Fe, {
767
- days: P.value,
768
- level: d(Se).low
769
- }, null, 8, ["days", "level"])
770
- ]),
771
- c("div", qt, [
772
- c("div", Wt, L(d(r)("inventory.ingredient.threshold.whenRemaining")), 1),
773
- f(Ue, {
774
- modelValue: P.value,
775
- "onUpdate:modelValue": e[8] || (e[8] = (F) => P.value = F),
776
- rules: [d(_e)(0)]
777
- }, {
778
- append: $(() => e[10] || (e[10] = [
779
- c("div", {
780
- class: "text-fm-color-typo-secondary",
781
- style: { "padding-right": "32px" }
782
- }, "days", -1)
783
- ])),
784
- _: 1
785
- }, 8, ["modelValue", "rules"])
786
- ])
787
- ]),
788
- e[12] || (e[12] = c("div", {
789
- class: "h-full bg-fm-color-neutral-gray-200 relative",
790
- style: { width: "1px" }
791
- }, [
792
- c("div", {
793
- class: "absolute bg-white",
794
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
795
- }, " < ")
796
- ], -1)),
797
- c("div", Kt, [
798
- c("div", Jt, [
799
- f(Fe, {
800
- days: j.value,
801
- level: d(Se).mid
802
- }, null, 8, ["days", "level"])
803
- ]),
804
- c("div", Qt, [
805
- c("div", Xt, L(d(r)("inventory.ingredient.threshold.whenRemaining")), 1),
806
- f(Ue, {
807
- modelValue: j.value,
808
- "onUpdate:modelValue": e[9] || (e[9] = (F) => j.value = F),
809
- rules: [d(_e)(0)]
810
- }, {
811
- append: $(() => e[11] || (e[11] = [
812
- c("div", {
813
- class: "text-fm-color-typo-secondary",
814
- style: { "padding-right": "32px" }
815
- }, "days", -1)
816
- ])),
817
- _: 1
818
- }, 8, ["modelValue", "rules"])
819
- ])
820
- ]),
821
- e[13] || (e[13] = c("div", {
822
- class: "h-full bg-fm-color-neutral-gray-200 relative",
823
- style: { width: "1px" }
824
- }, [
825
- c("div", {
826
- class: "absolute bg-white",
827
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
828
- }, " < ")
829
- ], -1)),
830
- c("div", Zt, [
831
- c("div", en, [
832
- f(Fe, {
833
- days: j.value + 1,
834
- level: d(Se).high
835
- }, null, 8, ["days", "level"])
836
- ]),
837
- c("div", tn, [
838
- c("div", nn, L(d(r)("inventory.ingredient.threshold.stockIsStaple")), 1)
839
- ])
840
- ])
841
- ])
842
- ])
843
- ])
844
- ]),
845
- _: 1
846
- }, 8, ["disabled"]);
847
- };
848
- }
849
- }), ln = { class: "flex gap-4" }, an = /* @__PURE__ */ le({
850
- __name: "IngredientDialog",
851
- props: {
852
- show: { type: Boolean },
853
- unit: {},
854
- mode: { default: K.READ }
855
- },
856
- emits: ["update:show"],
857
- setup(s) {
858
- const i = s, m = ae(), r = Ve(), { t: n } = re(), l = Pe(i, "show"), o = Pe(i, "unit"), p = C(() => {
859
- switch (i.mode) {
860
- case K.READ:
861
- return "";
862
- case K.UPDATE:
863
- return n("inventory.ingredient.update.title");
864
- case K.CREATE:
865
- return n("inventory.ingredient.create.title");
866
- }
867
- return "";
868
- }), b = C(() => {
869
- switch (i.mode) {
870
- case K.READ:
871
- return "";
872
- case K.UPDATE:
873
- return n("common.save");
874
- case K.CREATE:
875
- return n("common.add");
876
- }
877
- return "";
878
- }), _ = z(), g = z(!1);
879
- async function h() {
880
- g.value = !0;
881
- try {
882
- await m.createSku(o.value), l.value = !1, r.open({
883
- title: n("common.success"),
884
- message: n("inventory.ingredient.create.success", { name: o.value.name }),
885
- type: "success"
886
- });
887
- } catch (w) {
888
- w instanceof Te || r.open({
889
- title: n("inventory.ingredient.create.error.title"),
890
- message: n("inventory.ingredient.create.error.message"),
891
- type: "error"
892
- });
893
- } finally {
894
- g.value = !1;
895
- }
896
- }
897
- async function u() {
898
- g.value = !0;
899
- try {
900
- await m.updateSku(o.value), g.value = !1, l.value = !1, r.open({
901
- title: n("common.success"),
902
- message: n("inventory.ingredient.update.success", { name: o.value.name }),
903
- type: "success"
904
- });
905
- } catch (w) {
906
- w instanceof Te || r.open({
907
- title: n("inventory.ingredient.update.error.title"),
908
- message: n("inventory.ingredient.update.error.message"),
909
- type: "error"
910
- });
911
- } finally {
912
- g.value = !1;
913
- }
914
- }
915
- function x() {
916
- var w, M;
917
- (M = (w = _.value) == null ? void 0 : w.validateInputs) == null || M.call(w);
918
- }
919
- function D() {
920
- switch (i.mode) {
921
- case K.READ:
922
- return;
923
- case K.UPDATE:
924
- return u();
925
- case K.CREATE:
926
- return h();
927
- }
928
- }
929
- return (w, M) => {
930
- const S = R("FmButton"), V = R("FmSideSheet");
931
- return y(), B(V, {
932
- "model-value": d(l),
933
- "onUpdate:modelValue": M[3] || (M[3] = (H) => Ee(l) ? l.value = H : null),
934
- header: p.value,
935
- "close-button": "",
936
- "dismiss-away": "",
937
- "max-width": 500
938
- }, {
939
- "side-sheet-footer": $(() => [
940
- c("div", ln, [
941
- f(S, {
942
- loading: g.value,
943
- label: b.value,
944
- onClick: x
945
- }, null, 8, ["loading", "label"]),
946
- f(S, {
947
- disabled: g.value,
948
- label: d(n)("common.close"),
949
- variant: "tertiary",
950
- onClick: M[2] || (M[2] = (H) => l.value = !1)
951
- }, null, 8, ["disabled", "label"])
952
- ])
953
- ]),
954
- default: $(() => [
955
- f(on, {
956
- class: "w-full",
957
- ref_key: "hasValidationExpose",
958
- ref: _,
959
- modelValue: d(o),
960
- "onUpdate:modelValue": M[0] || (M[0] = (H) => Ee(o) ? o.value = H : null),
961
- mode: w.mode,
962
- disabled: g.value,
963
- "onClick:submit": M[1] || (M[1] = (H) => D())
964
- }, null, 8, ["modelValue", "mode", "disabled"])
965
- ]),
966
- _: 1
967
- }, 8, ["model-value", "header"]);
968
- };
969
- }
970
- });
971
- function* rn(s) {
972
- for (; ; )
973
- yield s[Math.floor(Math.random() * s.length)];
974
- }
975
- function sn(s = 4, i = rn("qwertyuiopasdfghjklzxcvbnm".split(""))) {
976
- return Array.from({ length: s }).map(() => i.next().value).join("");
977
- }
978
- function un() {
979
- return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${sn()}`;
980
- }
981
- const dn = {
982
- _id: "",
983
- name: "",
984
- abbrev: "",
985
- precision: 0,
986
- measurements: []
987
- };
988
- function cn(s) {
989
- var m, r, n, l, o;
990
- return {
991
- code: s.code,
992
- name: s.name,
993
- unit: ((m = s.unit.measurements.find((p) => p.id === s.trackingMeasurement)) == null ? void 0 : m.abbrev) ?? s.unit.abbrev,
994
- baseUnit: s.unit.abbrev,
995
- valuationMethod: s.valuation ?? "WAVG",
996
- pricePerUnit: (r = s.defaultCost) != null && r.costPerUnit ? +Ge((n = s.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
997
- thresholdLow: ((l = s.thresholds) == null ? void 0 : l.low) ?? ue().low,
998
- thresholdMid: ((o = s.thresholds) == null ? void 0 : o.mid) ?? ue().mid
999
- };
1000
- }
1001
- function Xe() {
1002
- var n;
1003
- const s = [
1004
- {
1005
- id: "code",
1006
- name: "Code"
1007
- },
1008
- {
1009
- id: "name",
1010
- name: "Name"
1011
- },
1012
- {
1013
- id: "unit",
1014
- name: "Unit"
1015
- },
1016
- {
1017
- id: "baseUnit",
1018
- name: "Base unit"
1019
- }
1020
- ], i = We(), m = fe(), r = xe(m.currentCountry.value);
1021
- return i.enableTotalCost && s.push(
1022
- {
1023
- id: "valuationMethod",
1024
- name: "Valuation method"
1025
- },
1026
- {
1027
- id: "pricePerUnit",
1028
- name: `Price per unit (${r == null ? void 0 : r.currency})`
1029
- }
1030
- ), ((n = m.currentBusiness.value) == null ? void 0 : n.menuVersion) === "v4" && s.push(
1031
- {
1032
- id: "thresholdLow",
1033
- name: "Show RED when remaining"
1034
- },
1035
- {
1036
- id: "thresholdMid",
1037
- name: "Show YELLOW when remaining"
1038
- }
1039
- ), s;
1040
- }
1041
- function mn() {
1042
- const i = ae().skus.map(cn), r = fe().currentBusiness.value, n = Xe(), l = [
1043
- ["Business name:", r == null ? void 0 : r.name],
1044
- ["Business ID:", r == null ? void 0 : r._id],
1045
- ["Menu version", r == null ? void 0 : r.menuVersion],
1046
- [],
1047
- n.map((_) => _.name),
1048
- ...i.map((_) => n.map((g) => _[g.id]))
1049
- ], o = n.map((_) => `system:${_.id}`), p = Je(l, o), b = `${r == null ? void 0 : r.name} ingredients (${dt(/* @__PURE__ */ new Date())}).xlsx`;
1050
- return Qe(p, b), b;
1051
- }
1052
- function pn() {
1053
- const i = fe().currentBusiness.value, m = Xe(), r = [
1054
- ["Business name:", i == null ? void 0 : i.name],
1055
- ["Business ID:", i == null ? void 0 : i._id],
1056
- ["Menu version", i == null ? void 0 : i.menuVersion],
1057
- [],
1058
- m.map((p) => p.name)
1059
- ], n = m.map((p) => `system:${p.id}`), l = Je(r, n), o = "FeedMe ingredients template.xlsx";
1060
- return Qe(l, o), o;
1061
- }
1062
- function vn(s) {
1063
- const [
1064
- i,
1065
- m,
1066
- r,
1067
- n,
1068
- l,
1069
- o,
1070
- ...p
1071
- ] = wt(s);
1072
- if (!i || !i.length || i.some((u) => u.length && !u.startsWith("system:")))
1073
- throw new Error("Missing meta header. Excel file does not come from the template.");
1074
- const b = i.map((u) => u.split(":")[1]), g = ["code", "name", "unit", "baseUnit"].filter((u) => !b.includes(u));
1075
- if (g.length)
1076
- throw new Error(
1077
- `Missing meta headers (${g.join()}). Excel file does not come from the template.`
1078
- );
1079
- return p.map((u, x) => {
1080
- const D = {};
1081
- for (const w in b) {
1082
- const M = b[w];
1083
- Object.assign(D, { [M]: u[w] });
1084
- }
1085
- return {
1086
- index: x,
1087
- data: D
1088
- };
1089
- });
1090
- }
1091
- function Le(s, i, m) {
1092
- var S;
1093
- const n = ae().units, l = new Array(), o = m.filter((V) => V.data.code === s.code);
1094
- o.length > 1 && l.push(
1095
- `Code ${s.code} is already used in row ${o.map((V) => V.index + 6).join()}.`
1096
- );
1097
- const p = n.find((V) => V.abbrev === s.baseUnit), b = p == null ? void 0 : p.measurements.find((V) => V.abbrev === s.unit);
1098
- if (!p)
1099
- l.push(`Cannot find base unit of symbol ${s.baseUnit}.`);
1100
- else if (s.baseUnit !== s.unit && !b) {
1101
- const V = `Cannot find unit conversion for ${s.baseUnit} with symbol ${s.unit || "[empty]"}.`;
1102
- l.push(V);
1103
- }
1104
- const _ = ve.options.find(
1105
- (V) => V === s.valuationMethod
1106
- );
1107
- s.valuationMethod && !_ && l.push(
1108
- `Expected valuation method to be one of ${ve.options.join()} but got ${s.valuationMethod} instead.`
1109
- );
1110
- const h = fe().currentCountry.value, u = (V) => `${V}`.length && mt()(V) === !0, x = u(`${s.pricePerUnit}`) === !0 ? {
1111
- costPerUnit: {
1112
- ...qe(Number(s.pricePerUnit) || 0),
1113
- currency: ((S = xe(h)) == null ? void 0 : S.currency) ?? "MYR"
1114
- },
1115
- measurement: b
1116
- } : void 0, D = u(`${s.thresholdLow}`) && u(`${s.thresholdMid}`) ? {
1117
- low: Number(s.thresholdLow) || 0,
1118
- mid: Number(s.thresholdMid) || 0
1119
- } : void 0;
1120
- return {
1121
- type: "create",
1122
- sku: {
1123
- _id: un(),
1124
- code: s.code,
1125
- name: s.name,
1126
- unit: p ?? n.find((V) => V) ?? dn,
1127
- trackingMeasurement: b == null ? void 0 : b.id,
1128
- valuation: _,
1129
- defaultCost: x,
1130
- thresholds: D
1131
- },
1132
- errors: l,
1133
- excelRowNumber: i + 6
1134
- };
1135
- }
1136
- function fn(s) {
1137
- try {
1138
- const i = vn(s).filter((_) => _.data.code), r = ae().skus, n = ct(r, "code"), l = i.filter((_) => !n[_.data.code]), o = i.filter((_) => n[_.data.code]), p = l.map(
1139
- (_) => Le(_.data, _.index, i)
1140
- ), b = o.map((_) => {
1141
- const g = Le(_.data, _.index, i), h = n[_.data.code];
1142
- return {
1143
- ...g,
1144
- type: "update",
1145
- original: h,
1146
- sku: {
1147
- // to maintain original props not in the import excel, e.g. inventory binding, etc...
1148
- ...h,
1149
- code: g.sku.code || h.code,
1150
- name: g.sku.name || h.name,
1151
- unit: g.sku.unit || h.unit,
1152
- trackingMeasurement: g.sku.trackingMeasurement || h.trackingMeasurement,
1153
- valuation: g.sku.valuation || h.valuation,
1154
- defaultCost: g.sku.defaultCost || h.defaultCost,
1155
- thresholds: g.sku.thresholds || h.thresholds
1156
- }
1157
- };
1158
- });
1159
- return {
1160
- invalidExcel: !1,
1161
- importCreateResult: p,
1162
- importUpdateResult: b
1163
- };
1164
- } catch (i) {
1165
- return {
1166
- invalidExcel: !0,
1167
- invalidExcelMessage: (i == null ? void 0 : i.message) ?? "Invalid excel",
1168
- importCreateResult: [],
1169
- importUpdateResult: []
1170
- };
1171
- }
1172
- }
1173
- const yn = {
1174
- key: 0,
1175
- class: "relative"
1176
- }, gn = ["accept", "disabled"], bn = { class: "flex flex-col gap-8" }, hn = ["accept", "disabled"], _n = /* @__PURE__ */ le({
1177
- __name: "FmDroppableField",
1178
- props: {
1179
- buttonLabel: {},
1180
- label: { default: "" },
1181
- disabled: { type: Boolean, default: !1 },
1182
- accept: { default: "" },
1183
- maxFileSize: { default: 8e6 },
1184
- contentClass: {}
1185
- },
1186
- emits: ["file-upload", "file-rejected"],
1187
- setup(s, { emit: i }) {
1188
- const m = s, r = i, n = z(!1), l = z(null), o = z(null), p = z(), b = (a) => {
1189
- m.disabled || (a.stopPropagation(), a.preventDefault());
1190
- }, _ = (a) => {
1191
- m.disabled || (a.stopPropagation(), a.preventDefault(), n.value = !0);
1192
- }, g = (a) => {
1193
- m.disabled || (a.stopPropagation(), a.preventDefault(), n.value = !1);
1194
- }, h = (a) => {
1195
- var N;
1196
- m.disabled || (a.stopPropagation(), a.preventDefault(), n.value = !1, u((N = a.dataTransfer) == null ? void 0 : N.files));
1197
- };
1198
- function u(a) {
1199
- if (a)
1200
- if (p.value = a, l.value = D(a[0]), o.value = w(a[0]), l.value && o.value)
1201
- r("file-upload", a[0]);
1202
- else {
1203
- const N = x();
1204
- r("file-rejected", [
1205
- {
1206
- file: a[0],
1207
- reason: N
1208
- }
1209
- ]);
1210
- }
1211
- }
1212
- const x = () => {
1213
- const a = new Array();
1214
- return l.value || a.push("invalid-type"), o.value || a.push("invalid-size"), a;
1215
- }, D = (a) => {
1216
- if (!m.accept) return !0;
1217
- const N = m.accept.split(",").map((W) => W.trim());
1218
- for (const W of N)
1219
- if (M(W)) {
1220
- if (V(W) === V(a.type)) return !0;
1221
- } else if (S(a) === W || a.type === W) return !0;
1222
- return !1;
1223
- }, w = (a) => a.size <= m.maxFileSize, M = (a) => a.indexOf("*") !== -1, S = (a) => "." + a.name.split(".").pop(), V = (a) => a.substring(0, a.indexOf("/")), H = C(() => {
1224
- if (n.value) return "Drop file to upload";
1225
- if (l.value) {
1226
- if (!o.value) return `File size exceeds ${m.maxFileSize * 1e-6}mb`;
1227
- } else return "File type is not valid";
1228
- return "";
1229
- }), J = C(() => p.value ? !l.value || !o.value : !1), ee = (a) => {
1230
- const N = a.target;
1231
- u(N.files);
1232
- }, de = C(() => {
1233
- var a;
1234
- return (a = p.value) == null ? void 0 : a.item(0);
1235
- }), Z = z();
1236
- return (a, N) => {
1237
- const W = R("FmLabel"), se = R("FmButton");
1238
- return y(), U("label", {
1239
- class: "fm-droppable-field",
1240
- ref_key: "fmButtonRef",
1241
- ref: Z
1242
- }, [
1243
- a.$slots.default ? (y(), U("div", yn, [
1244
- c("input", {
1245
- accept: a.accept,
1246
- disabled: a.disabled,
1247
- class: "fm-droppable-field__input",
1248
- type: "file",
1249
- onChange: ee
1250
- }, null, 40, gn)
1251
- ])) : O("", !0),
1252
- ge(a.$slots, "default", {
1253
- isDragging: n.value,
1254
- isValidFileType: l.value,
1255
- isValidFileSize: o.value,
1256
- singleValidFile: de.value,
1257
- openFileDialog: () => {
1258
- var te;
1259
- return console.log("click", Z.value), (te = Z.value) == null ? void 0 : te.click();
1260
- }
1261
- }, () => [
1262
- c("div", bn, [
1263
- a.$slots.label ? ge(a.$slots, "label", { key: 0 }, void 0, !0) : (y(), B(W, {
1264
- key: 1,
1265
- label: a.label
1266
- }, null, 8, ["label"]))
1267
- ]),
1268
- c("div", {
1269
- class: Q([[
1270
- a.contentClass ? a.contentClass : "w-full h-full",
1271
- {
1272
- "fm-droppable-field__container--dragging": n.value,
1273
- "fm-droppable-field__container--invalid": J.value && !a.disabled,
1274
- "fm-droppable-field__container--disabled": a.disabled
1275
- }
1276
- ], "fm-droppable-field__container"]),
1277
- onDragenter: b,
1278
- onDragleave: g,
1279
- onDragover: _,
1280
- onDrop: h
1281
- }, [
1282
- (n.value || J.value) && !a.disabled ? (y(), U("div", {
1283
- key: 0,
1284
- class: Q({
1285
- "fm-typo-en-body-lg-600": !0,
1286
- "text-fm-color-primary": n.value,
1287
- "text-fm-color-typo-error": J.value
1288
- })
1289
- }, L(H.value), 3)) : (y(), B(se, {
1290
- key: 1,
1291
- disabled: a.disabled,
1292
- label: a.buttonLabel ?? "Add files",
1293
- size: "md",
1294
- variant: "secondary"
1295
- }, null, 8, ["disabled", "label"])),
1296
- ge(a.$slots, "accept-text", {}, () => [
1297
- m.accept ? (y(), U("div", {
1298
- key: 0,
1299
- class: Q([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-md-400"])
1300
- }, L(`Accepts ${m.accept}`), 3)) : O("", !0)
1301
- ], !0),
1302
- c("input", {
1303
- accept: a.accept,
1304
- disabled: a.disabled,
1305
- class: "fm-droppable-field__input",
1306
- type: "file",
1307
- onChange: ee
1308
- }, null, 40, hn)
1309
- ], 34),
1310
- ge(a.$slots, "helper-text", {}, () => [
1311
- c("div", {
1312
- class: Q([[a.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-sm-400"])
1313
- }, L(`Max size ${m.maxFileSize * 1e-6}mb`), 3)
1314
- ], !0)
1315
- ], !0)
1316
- ], 512);
1317
- };
1318
- }
1319
- }), xn = /* @__PURE__ */ pt(_n, [["__scopeId", "data-v-311b22a0"]]), Vn = { class: "flex items-center gap-12 pl-8" }, kn = { class: "flex flex-col" }, Cn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Fn = {
1320
- key: 0,
1321
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1322
- }, Sn = { key: 0 }, Ne = /* @__PURE__ */ le({
1323
- __name: "ImportIngredientItem",
1324
- props: {
1325
- type: {},
1326
- code: {},
1327
- name: {},
1328
- errors: {}
1329
- },
1330
- setup(s) {
1331
- return (i, m) => {
1332
- const r = R("FmIcon"), n = R("FmTooltip");
1333
- return y(), U("div", Vn, [
1334
- m[0] || (m[0] = c("div", null, "•", -1)),
1335
- c("div", kn, [
1336
- c("div", Cn, [
1337
- c("div", {
1338
- class: Q({
1339
- "text-fm-color-system-error-300": i.errors.length
1340
- })
1341
- }, [
1342
- He(L(i.name) + " ", 1),
1343
- i.type === "create" ? (y(), U("span", Fn, "(new)")) : O("", !0)
1344
- ], 2),
1345
- i.errors.length ? (y(), U("div", Sn, [
1346
- f(n, { "z-index": 50 }, {
1347
- content: $(() => [
1348
- c("ol", null, [
1349
- (y(!0), U(X, null, oe(i.errors, (l, o) => (y(), U("li", { key: o }, L(l), 1))), 128))
1350
- ])
1351
- ]),
1352
- default: $(() => [
1353
- f(r, {
1354
- name: "error",
1355
- size: "sm",
1356
- color: "system-error-300"
1357
- })
1358
- ]),
1359
- _: 1
1360
- })
1361
- ])) : O("", !0)
1362
- ]),
1363
- c("div", {
1364
- class: Q([
1365
- "fm-typo-en-body-sm-400",
1366
- {
1367
- "text-fm-color-system-error-200": i.errors.length,
1368
- "text-fm-color-typo-secondary": !i.errors.length
1369
- }
1370
- ])
1371
- }, L(i.code), 3)
1372
- ])
1373
- ]);
1374
- };
1375
- }
1376
- }), wn = { class: "flex flex-col gap-24" }, Mn = { class: "fm-typo-en-body-md-400" }, $n = { class: "flex flex-col gap-8" }, In = { class: "line-clamp-2 text-ellipsis break-all" }, Rn = {
1377
- key: 2,
1378
- class: "shrink-0"
1379
- }, Un = {
1380
- key: 0,
1381
- class: "flex flex-col"
1382
- }, En = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Dn = {
1383
- key: 0,
1384
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1385
- }, An = { class: "fm-typo-en-body-lg-600" }, Tn = /* @__PURE__ */ le({
1386
- __name: "ImportIngredients",
1387
- setup(s) {
1388
- const i = z(null), m = ft(), r = Ve(), n = z(!1), l = z(new Array()), o = z([]), p = z([]), b = C(
1389
- () => !!l.value.length || o.value.some((u) => u.errors.length) || p.value.some((u) => u.errors.length)
1390
- ), _ = C(
1391
- () => !!o.value.length || !!p.value.length
1392
- ), { t: g } = re();
1393
- async function h(u) {
1394
- l.value = [], o.value = [], p.value = [];
1395
- try {
1396
- n.value = !0;
1397
- const [x] = await Promise.all([
1398
- Mt(u),
1399
- // fake buffer
1400
- new Promise((M) => setTimeout(M, 1e3))
1401
- ]), D = x.SheetNames.find((M) => M);
1402
- if (!D) {
1403
- l.value.push(g("inventory.ingredient.import.fileError.noSheet"));
1404
- return;
1405
- }
1406
- const w = fn(x.Sheets[D]);
1407
- if (w.invalidExcel) {
1408
- l.value.push(w.invalidExcelMessage ?? g("inventory.ingredient.import.fileError.invalidExcel"));
1409
- return;
1410
- }
1411
- if (o.value = w.importCreateResult, p.value = w.importUpdateResult, !o.value.length && !p.value.length) {
1412
- l.value.push(g("inventory.ingredient.import.fileError.noData"));
1413
- return;
1414
- }
1415
- m.emitData(w);
1416
- } catch (x) {
1417
- r.open({
1418
- title: g("inventory.ingredient.import.fileError.unableToRead"),
1419
- message: x == null ? void 0 : x.message,
1420
- type: "error"
1421
- }), console.error("Error in reading file", x);
1422
- } finally {
1423
- l.value.length && r.open({
1424
- title: g("inventory.ingredient.import.fileError.invalidExcel"),
1425
- type: "error"
1426
- }), n.value = !1;
1427
- }
1428
- }
1429
- return je(i, (u) => {
1430
- u && h(u);
1431
- }), (u, x) => {
1432
- const D = R("FmCircularProgress"), w = R("FmIcon"), M = R("FmButton");
1433
- return y(), U("div", wn, [
1434
- c("div", Mn, L(d(g)("inventory.ingredient.import.uploadDescription")), 1),
1435
- f(xn, {
1436
- class: Q({
1437
- "w-full": !0,
1438
- "h-[200px]": !i.value
1439
- }),
1440
- accept: ".xlsx",
1441
- onFileUpload: x[0] || (x[0] = (S) => i.value = S),
1442
- label: d(g)("inventory.ingredient.import.uploadTemplate"),
1443
- "button-label": d(g)("inventory.ingredient.import.selectFile")
1444
- }, Oe({ _: 2 }, [
1445
- i.value ? {
1446
- name: "default",
1447
- fn: $(({ openFileDialog: S }) => [
1448
- c("div", $n, [
1449
- c("div", {
1450
- class: Q([
1451
- "fm-corner-radius-md p-16 flex items-center gap-16",
1452
- {
1453
- "border border-fm-color-neutral-gray-100": n.value,
1454
- "border border-fm-color-neutral-gray-200": !n.value && !b.value,
1455
- "border border-fm-color-system-error-200": b.value
1456
- }
1457
- ])
1458
- }, [
1459
- n.value ? (y(), B(D, {
1460
- key: 0,
1461
- size: "md",
1462
- color: "neutral-gray-200"
1463
- })) : (y(), B(w, {
1464
- key: 1,
1465
- name: b.value ? "error" : "attach_file",
1466
- outline: "",
1467
- color: b.value ? "system-error-300" : void 0
1468
- }, null, 8, ["name", "color"])),
1469
- c("div", {
1470
- class: Q([
1471
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1472
- {
1473
- "text-fm-color-typo-disabled": n.value,
1474
- "text-fm-color-typo-primary": !n.value
1475
- }
1476
- ])
1477
- }, [
1478
- c("div", In, L(i.value.name), 1)
1479
- ], 2),
1480
- n.value ? O("", !0) : (y(), U("div", Rn, [
1481
- f(M, {
1482
- label: d(g)("inventory.ingredient.import.replaceFile"),
1483
- variant: b.value ? "destructive" : "secondary",
1484
- "prepend-icon": b.value ? void 0 : "autorenew",
1485
- onClick: S
1486
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1487
- ]))
1488
- ], 2),
1489
- l.value.length ? (y(), U("div", Un, [
1490
- (y(!0), U(X, null, oe(l.value, (V, H) => (y(), U("div", {
1491
- key: H,
1492
- class: "flex gap-8 items-center"
1493
- }, [
1494
- f(w, {
1495
- name: "error",
1496
- size: "sm",
1497
- color: "system-error-300"
1498
- }),
1499
- c("div", En, L(V), 1)
1500
- ]))), 128))
1501
- ])) : O("", !0)
1502
- ])
1503
- ]),
1504
- key: "0"
1505
- } : void 0
1506
- ]), 1032, ["class", "label", "button-label"]),
1507
- _.value ? (y(), U("div", Dn, [
1508
- c("div", An, L(d(g)("inventory.ingredient.import.summary")), 1),
1509
- (y(!0), U(X, null, oe(o.value, (S) => (y(), B(Ne, {
1510
- key: S.sku._id,
1511
- code: S.sku.code,
1512
- name: S.sku.name,
1513
- errors: S.errors,
1514
- type: "create"
1515
- }, null, 8, ["code", "name", "errors"]))), 128)),
1516
- (y(!0), U(X, null, oe(p.value, (S) => (y(), B(Ne, {
1517
- key: S.sku._id,
1518
- code: S.sku.code,
1519
- name: S.sku.name,
1520
- errors: S.errors,
1521
- type: "update"
1522
- }, null, 8, ["code", "name", "errors"]))), 128))
1523
- ])) : O("", !0)
1524
- ]);
1525
- };
1526
- }
1527
- }), Pn = { class: "flex flex-col py-8" }, Bn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Zn = /* @__PURE__ */ le({
1528
- __name: "IngredientsView",
1529
- setup(s) {
1530
- const i = ae(), m = C(() => i.skus), r = vt(), n = Ke(), l = Ve(), { t: o } = re(), { createIngredient: p, updateIngredient: b } = $e(), { ingredientDialogProps: _, ingredientViewLoading: g } = _t($e()), { columnDefs: h } = $t();
1531
- function u(A) {
1532
- switch (A) {
1533
- case "add":
1534
- return p();
1535
- case "import":
1536
- return W();
1537
- }
1538
- }
1539
- const x = z(""), D = z(!1), w = C(() => D.value || g.value), { breakpoints: M } = yt(), S = C(() => M.value.xs || M.value.sm), V = C(() => S.value ? 10 : 20), H = kt(), J = z(!1), ee = [
1540
- {
1541
- value: "import",
1542
- label: o("common.import")
1543
- },
1544
- {
1545
- value: "export",
1546
- label: o("common.export")
1547
- }
1548
- ];
1549
- function de(A) {
1550
- switch (J.value = !1, A) {
1551
- case "import":
1552
- return W();
1553
- case "export":
1554
- return N();
1555
- }
1556
- }
1557
- const Z = C(() => S.value ? [{ icon: "more_vert", onClick: te }] : [{ icon: "ios_share", onClick: N }]), a = C(() => {
1558
- const A = [
1559
- {
1560
- label: o("inventory.ingredient.create.title"),
1561
- value: "add",
1562
- isPrimary: !0,
1563
- prependIcon: "add"
1564
- }
1565
- ];
1566
- return S.value ? A : [...A, { label: o("inventory.ingredient.import.title"), value: "import" }];
1567
- });
1568
- function N() {
1569
- const A = mn();
1570
- l.open({
1571
- title: o("inventory.ingredient.export.success"),
1572
- message: o("inventory.ingredient.export.filename", [A]),
1573
- type: "success"
1574
- });
1575
- }
1576
- function W() {
1577
- n.open({
1578
- title: o("inventory.ingredient.import.title"),
1579
- contentComponent: Tn,
1580
- overlay: !0,
1581
- closeButton: !0,
1582
- primaryActions: {
1583
- text: o("common.import"),
1584
- close: !1
1585
- },
1586
- secondaryActions: {
1587
- text: o("common.close"),
1588
- close: !0
1589
- },
1590
- tertiaryActions: {
1591
- text: o("inventory.ingredient.import.actions.downloadTemplate"),
1592
- close: !1,
1593
- variant: "plain"
1594
- }
1595
- }).onPrimary((A) => {
1596
- if (!A) {
1597
- l.open({
1598
- title: o("inventory.ingredient.import.error.noData"),
1599
- type: "error"
1600
- });
1601
- return;
1602
- }
1603
- if (!A.importCreateResult.length && !A.importUpdateResult.length) {
1604
- l.open({
1605
- title: o("inventory.ingredient.import.error.invalidContent"),
1606
- message: o("inventory.ingredient.import.error.noImportData"),
1607
- type: "error"
1608
- });
1609
- return;
1610
- }
1611
- if (A.importCreateResult.some((E) => E.errors.length) || A.importUpdateResult.some((E) => E.errors.length)) {
1612
- l.open({
1613
- title: o("inventory.ingredient.import.error.invalidContent"),
1614
- message: o("inventory.ingredient.import.error.hasErrors"),
1615
- type: "error"
1616
- });
1617
- return;
1618
- }
1619
- n.close(), se(A);
1620
- }).onTertiary(pn);
1621
- }
1622
- async function se(A) {
1623
- D.value = !0;
1624
- try {
1625
- const E = [
1626
- ...A.importCreateResult.map(({ sku: P }) => ({ type: "create", sku: P })),
1627
- ...A.importUpdateResult.map(({ sku: P }) => ({ type: "update", sku: P }))
1628
- ], ce = 100;
1629
- let ne = 0;
1630
- const me = () => {
1631
- ne += ce, l.open({
1632
- title: o("inventory.ingredient.import.progress", [
1633
- Math.min(ne, E.length),
1634
- E.length
1635
- ])
1636
- });
1637
- };
1638
- for (const P of E.chunk(100))
1639
- me(), await i.importSkus({
1640
- create: P.filter((j) => j.type === "create").map((j) => j.sku),
1641
- update: P.filter((j) => j.type === "update").map((j) => j.sku)
1642
- });
1643
- l.open({
1644
- title: o("inventory.ingredient.import.success"),
1645
- type: "success"
1646
- });
1647
- } catch (E) {
1648
- l.open({
1649
- title: o("inventory.ingredient.import.error.failed"),
1650
- message: o("inventory.ingredient.import.error.systemMessage", [E == null ? void 0 : E.message]),
1651
- type: "error"
1652
- }), console.error("Error in importing skus", A, E);
1653
- } finally {
1654
- D.value = !1;
1655
- }
1656
- }
1657
- function te() {
1658
- J.value = !0;
1659
- }
1660
- return (A, E) => {
1661
- const ce = R("FmTable"), ne = R("FmCollapsibleTabs"), me = R("FmBottomSheet");
1662
- return y(), B(Ct, {
1663
- title: d(o)("inventory.ingredient.title"),
1664
- actions: a.value,
1665
- "onClick:action": u
1666
- }, {
1667
- default: $(() => [
1668
- c("div", {
1669
- class: Q([
1670
- "flex flex-col gap-8 max-h-full",
1671
- {
1672
- "p-0": S.value,
1673
- "px-24 ": !S.value
1674
- }
1675
- ])
1676
- }, [
1677
- f(Ft, {
1678
- searchable: "",
1679
- search: x.value,
1680
- "onUpdate:search": E[0] || (E[0] = (P) => x.value = P),
1681
- actions: Z.value
1682
- }, null, 8, ["search", "actions"]),
1683
- f(ce, {
1684
- style: ot(d(H).tableHeight),
1685
- "column-defs": d(h),
1686
- "row-data": m.value,
1687
- "search-value": x.value,
1688
- loading: !d(r)._currentLocation || w.value,
1689
- "loading-text": "Loading",
1690
- onRowClick: E[1] || (E[1] = (P) => d(b)(P.original)),
1691
- "page-size": V.value
1692
- }, {
1693
- "list-row": $((P) => [
1694
- f(Vt, {
1695
- row: P,
1696
- onRowClick: d(b)
1697
- }, Oe({
1698
- default: $((j) => {
1699
- var ye, pe, t, e, v, k, T, I, Y, G;
1700
- return [
1701
- c("div", Pn, [
1702
- c("div", Bn, [
1703
- f(d(ze), {
1704
- render: (t = (pe = (ye = j.code) == null ? void 0 : ye.column) == null ? void 0 : pe.columnDef) == null ? void 0 : t.cell,
1705
- props: (v = (e = j.code) == null ? void 0 : e.getContext) == null ? void 0 : v.call(e)
1706
- }, null, 8, ["render", "props"])
1707
- ]),
1708
- c("div", zn, [
1709
- f(d(ze), {
1710
- render: (I = (T = (k = j.name) == null ? void 0 : k.column) == null ? void 0 : T.columnDef) == null ? void 0 : I.cell,
1711
- props: (G = (Y = j.name) == null ? void 0 : Y.getContext) == null ? void 0 : G.call(Y)
1712
- }, null, 8, ["render", "props"])
1713
- ])
1714
- ])
1715
- ];
1716
- }),
1717
- _: 2
1718
- }, [
1719
- D.value ? {
1720
- name: "loading-text",
1721
- fn: $(() => [
1722
- c("div", null, L(d(o)("inventory.ingredient.table.importing")), 1)
1723
- ]),
1724
- key: "0"
1725
- } : void 0
1726
- ]), 1032, ["row", "onRowClick"])
1727
- ]),
1728
- _: 1
1729
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1730
- ], 2),
1731
- (y(), B(De, { to: "body" }, [
1732
- f(an, lt(at(d(_))), null, 16)
1733
- ])),
1734
- (y(), B(De, { to: "body" }, [
1735
- f(me, {
1736
- "dismiss-away": "",
1737
- modelValue: J.value,
1738
- "onUpdate:modelValue": E[3] || (E[3] = (P) => J.value = P)
1739
- }, {
1740
- default: $(() => [
1741
- f(ne, {
1742
- class: "pb-8",
1743
- items: ee,
1744
- "onUpdate:modelValue": E[2] || (E[2] = (P) => de(P))
1745
- })
1746
- ]),
1747
- _: 1
1748
- }, 8, ["modelValue"])
1749
- ]))
1750
- ]),
1751
- _: 1
1752
- }, 8, ["title", "actions"]);
1753
- };
1754
- }
1755
- });
1756
- export {
1757
- Zn as default
1758
- };