@feedmepos/mf-inventory-portal 0.0.20-dev.1 → 0.0.21-dev.1

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