@feedmepos/mf-inventory-portal 0.0.22-dev.3 → 0.0.22-dev.31

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