@feedmepos/mf-inventory-portal 0.0.17-dev.8 → 0.0.17-dev.9

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