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

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