@feedmepos/mf-inventory-portal 0.0.5 → 0.0.7-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 (74) hide show
  1. package/dist/{ApprovalView-CTQdDgGH.js → ApprovalView-BYZcvkso.js} +6 -6
  2. package/dist/BindingsDialog-pdS86VDU.js +94 -0
  3. package/dist/{BindingsPicker-CQIGhTCR.js → BindingsPicker-D891Cfzu.js} +2 -2
  4. package/dist/{BindingsTable-Da4BLkvc.js → BindingsTable-tmr6QwLk.js} +30 -31
  5. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DcixBOcX.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-Bss0q2Zt.js} +7 -7
  6. package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BXU7x6di.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BHcLUkdm.js} +19 -20
  7. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CD89qCIa.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BIww2Noe.js} +1 -1
  8. package/dist/IngredientsView-BH6G7830.js +819 -0
  9. package/dist/{IntegrationView-BRWYO3VE.js → IntegrationView-CfJn6Fzn.js} +3 -3
  10. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-39U8Iavr.js +258 -0
  11. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DBK7mpQS.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-nDxqau1g.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CH9gVYDg.js → PurchaseOrderPrintPreview-Db2U_IQL.js} +1 -1
  13. package/dist/ReceiveRequestView-CgVfcS8C.js +1483 -0
  14. package/dist/{RecipeView-DFG9Wkx-.js → RecipeView-C9_Y_A9b.js} +58 -58
  15. package/dist/StockView-CoUI3Faj.js +1916 -0
  16. package/dist/SupplierView-CNq6wVfN.js +818 -0
  17. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Ffe9bhq8.js → TransferDetails.vue_vue_type_script_setup_true_lang-Cmajrg-9.js} +5 -5
  18. package/dist/{UnitView-C3XVSbJY.js → UnitView-Buyp4Gnc.js} +190 -177
  19. package/dist/{WarehouseView-BntzAdz3.js → WarehouseView-DbUib0PR.js} +56 -56
  20. package/dist/api/inventory.d.ts +33 -0
  21. package/dist/api/stock-estimate.d.ts +16 -0
  22. package/dist/api/stock.d.ts +8 -0
  23. package/dist/app-DM4Thqjw.js +42756 -0
  24. package/dist/app.js +1 -1
  25. package/dist/components/StockForecast.vue.d.ts +12 -0
  26. package/dist/components/StockForecastProps.d.ts +3 -0
  27. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +16 -0
  28. package/dist/components/shell/inventory/binding-ui.vue.d.ts +16 -0
  29. package/dist/core.d.ts +3 -2
  30. package/dist/date2-DpU4LDaP.js +199 -0
  31. package/dist/dayjs.min-D4Q_pHH9.js +13556 -0
  32. package/dist/{decimal-D3a0BwVj.js → decimal-M4vjE6Br.js} +1 -1
  33. package/dist/{fuzzy-BW8ZYsDG.js → fuzzy-fD_FTJWH.js} +1 -1
  34. package/dist/helper/number.d.ts +1 -0
  35. package/dist/{init-date-range-M3Q03-Fd.js → init-date-range-DJ1Nl5TB.js} +1 -1
  36. package/dist/{layout-BvUjg6JS.js → layout-kY567oHX.js} +1 -1
  37. package/dist/{rules-DHfAMDW3.js → rules-CVxh5XVG.js} +3 -3
  38. package/dist/stock-estimate-lkaYlz7I.js +90 -0
  39. package/dist/stores/api.d.ts +1 -0
  40. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  41. package/dist/stores/inventory.d.ts +64 -0
  42. package/dist/stores/stock-estimate.d.ts +11 -0
  43. package/dist/stores/supplier.d.ts +19 -1
  44. package/dist/style.css +1 -1
  45. package/dist/{supplier-DTiiOLtg.js → supplier-evd71Y1H.js} +3 -3
  46. package/dist/tsconfig.app.tsbuildinfo +1 -1
  47. package/dist/{use-inventory-binding-dialog-B6JO7050.js → use-inventory-binding-dialog-CGuXojFC.js} +2 -2
  48. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +32 -0
  49. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +16 -0
  50. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +23 -0
  51. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +213 -7
  52. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +102 -2
  53. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +306 -6
  54. package/dist/views/stock/components/StockRecalculateDialog.vue.d.ts +9 -0
  55. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +32 -0
  56. package/dist/views/stock/type.d.ts +1 -0
  57. package/dist/views/supplier/components/SupplierForm.vue.d.ts +38 -2
  58. package/dist/views/supplier/components/SupplierSupplyItemField.vue.d.ts +45 -0
  59. package/dist/views/supplier/composables/use-supplier-table.d.ts +19 -1
  60. package/dist/{xlsx-BljO4Lx2.js → xlsx-DpBw8KA4.js} +1010 -1010
  61. package/package.json +13 -7
  62. package/dist/BindingsDialog-DvX_DRsO.js +0 -82
  63. package/dist/IngredientsView-2ZKdzsgI.js +0 -739
  64. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CnsDmPTe.js +0 -240
  65. package/dist/ReceiveRequestView-DQBqc3GF.js +0 -1298
  66. package/dist/StockView-DLWMp_I5.js +0 -1733
  67. package/dist/SupplierView-CZhM2ie3.js +0 -607
  68. package/dist/app-BzDhmCVx.js +0 -36639
  69. package/dist/components/shell/inventory/binding-ui.test.d.ts +0 -1
  70. package/dist/components/ui-library/FmSpecialChip.vue.d.ts +0 -79
  71. package/dist/date2-C7HiAWQG.js +0 -209
  72. package/dist/dayjs.min-Db57WhI9.js +0 -282
  73. package/dist/id-to-date-ReZIpUDw.js +0 -30
  74. package/dist/index-D46it8Rk.js +0 -12956
@@ -0,0 +1,819 @@
1
+ import { ref as L, defineComponent as te, computed as m, resolveComponent as y, openBlock as k, createBlock as P, withCtx as M, createVNode as d, createElementBlock as J, Fragment as ne, createElementVNode as w, createCommentVNode as G, onMounted as xe, watch as Ie, unref as i, normalizeClass as pe, createTextVNode as Ae, toDisplayString as ae, renderList as Ue, isRef as ve, normalizeStyle as Ee, Teleport as Re, normalizeProps as De, guardReactiveProps as $e } from "vue";
2
+ import { u as le, c as Fe, S as Pe, g as fe, F as N, d as ge, a as Te, C as ue, b as be, e as Be } from "./app-DM4Thqjw.js";
3
+ import { useDialog as Le, useSnackbar as Ce, useProxiedModel as Ve, useBreakpoints as Oe } from "@feedmepos/ui-library";
4
+ import { i as Ne, _ as ze } from "./is-linked-ingredient-error-C6AghEwR.js";
5
+ import { F as x, D as ye, R as ee } from "./row-action.enum-BwQbURNh.js";
6
+ import { c as Ge, _ as Ye, F as _e, u as qe } from "./layout-kY567oHX.js";
7
+ import { _ as We } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js";
8
+ import { R as se, U as He, A as je, M as Ke } from "./rules-CVxh5XVG.js";
9
+ import { g as Je } from "./use-inventory-binding-dialog-CGuXojFC.js";
10
+ import { _ as Qe } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-39U8Iavr.js";
11
+ import { _ as re } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-BIww2Noe.js";
12
+ import { a as Xe, t as Ze } from "./date2-DpU4LDaP.js";
13
+ import { useCoreStore as en } from "@feedmepos/mf-common";
14
+ function nn() {
15
+ const A = Le(), F = Ce(), g = le(), t = L(!1), l = L();
16
+ function a() {
17
+ const u = {
18
+ unit: {},
19
+ mode: x.CREATE,
20
+ show: !0,
21
+ "onUpdate:show"(b) {
22
+ l.value.show = b;
23
+ }
24
+ };
25
+ l.value = u;
26
+ }
27
+ async function c(u) {
28
+ const b = {
29
+ unit: Fe(u),
30
+ mode: x.UPDATE,
31
+ show: !0,
32
+ "onUpdate:show"(s) {
33
+ l.value.show = s;
34
+ }
35
+ };
36
+ l.value = b;
37
+ }
38
+ async function S(u) {
39
+ t.value = !0;
40
+ try {
41
+ await g.deleteSku(u), F.open({
42
+ title: "Success",
43
+ message: `Deleted ${u.name}`,
44
+ type: "success"
45
+ });
46
+ } catch (b) {
47
+ b instanceof Pe && Ne(b) ? A.open({
48
+ title: "Cannot delete ingredient",
49
+ contentComponent: ze,
50
+ contentComponentProps: {
51
+ subject: (u == null ? void 0 : u.name) ?? "",
52
+ items: b.errorResponse.message
53
+ },
54
+ secondaryActions: {
55
+ text: "Close",
56
+ close: !0
57
+ }
58
+ }) : console.log("unable to delete ingredient", b), F.open({
59
+ title: `Cannot delete ${u.name}`,
60
+ message: "Please try again.",
61
+ type: "error"
62
+ }), console.error("failed to delete ingredient", b);
63
+ } finally {
64
+ t.value = !1;
65
+ }
66
+ }
67
+ function U(u) {
68
+ A.open({
69
+ title: `Delete ${(u == null ? void 0 : u.name) ?? "ingredient"}?`,
70
+ closeButton: !1,
71
+ message: "You may not be able to delete this ingredient if it is linked in any of the inventory modules.",
72
+ primaryActions: {
73
+ text: "Delete",
74
+ close: !0,
75
+ variant: "destructive"
76
+ },
77
+ secondaryActions: {
78
+ text: "Cancel",
79
+ close: !0
80
+ }
81
+ }).onPrimary(() => S(u));
82
+ }
83
+ return {
84
+ createIngredient: a,
85
+ updateIngredient: c,
86
+ deleteIngredient: U,
87
+ ingredientDialogProps: l,
88
+ ingredientViewLoading: t
89
+ };
90
+ }
91
+ function tn({
92
+ updateIngredient: A,
93
+ deleteIngredient: F
94
+ }) {
95
+ async function g(l, a) {
96
+ const c = Fe(a);
97
+ if (l === ee.Edit) {
98
+ await A(c);
99
+ return;
100
+ }
101
+ if (l === ee.Delete) {
102
+ await F(c);
103
+ return;
104
+ }
105
+ }
106
+ return { columnDefs: [
107
+ {
108
+ accessorKey: "code",
109
+ header: "Code",
110
+ enableSorting: !0,
111
+ size: 300
112
+ },
113
+ {
114
+ accessorKey: "name",
115
+ header: "Name",
116
+ enableSorting: !0,
117
+ size: 300
118
+ },
119
+ {
120
+ accessorFn: (l) => {
121
+ var a;
122
+ if (l.trackingMeasurement) {
123
+ const c = (a = l.unit.measurements) == null ? void 0 : a.find(
124
+ (S) => S.id === l.trackingMeasurement
125
+ );
126
+ if (c)
127
+ return `${c.name} (${c.abbrev})`;
128
+ }
129
+ return `${l.unit.name} (${l.unit.abbrev})`;
130
+ },
131
+ header: "Unit",
132
+ enableSorting: !1,
133
+ size: "auto"
134
+ },
135
+ {
136
+ id: "action",
137
+ header: "",
138
+ cell(l) {
139
+ return Ge(
140
+ [ye[ee.Edit], ye[ee.Delete]],
141
+ (a) => {
142
+ g(a, l.row.original);
143
+ }
144
+ );
145
+ },
146
+ enableSorting: !1,
147
+ size: 40,
148
+ meta: {
149
+ cellClass: "",
150
+ headerClass: ""
151
+ }
152
+ }
153
+ ] };
154
+ }
155
+ const ln = /* @__PURE__ */ te({
156
+ __name: "ConvertForm",
157
+ props: {
158
+ modelValue: {},
159
+ rootValue: {},
160
+ disabled: { type: Boolean }
161
+ },
162
+ emits: ["update:modelValue"],
163
+ setup(A, { emit: F }) {
164
+ const g = A, t = m(() => {
165
+ var s;
166
+ return (s = g.rootValue) == null ? void 0 : s.unit;
167
+ }), l = m(() => {
168
+ var s;
169
+ return (s = g.rootValue) == null ? void 0 : s._id;
170
+ }), a = F, c = m({
171
+ get() {
172
+ return !!g.modelValue;
173
+ },
174
+ set(s) {
175
+ s ? a("update:modelValue", {
176
+ measurement: null,
177
+ inventoryBindings: []
178
+ }) : a("update:modelValue", null);
179
+ }
180
+ }), S = m(() => Je(t.value));
181
+ function U(s) {
182
+ const v = g.modelValue ?? {};
183
+ v.measurement = s ? `${s}` : null, a("update:modelValue", v);
184
+ }
185
+ function u(s) {
186
+ const v = g.modelValue ?? {};
187
+ v.inventoryBindings = s, a("update:modelValue", v);
188
+ }
189
+ const b = m(() => {
190
+ if (!g.modelValue) return null;
191
+ const s = g.modelValue;
192
+ return s.measurement ? S.value.find((v) => v.value === s.measurement) ?? null : S.value.find((v) => v.value === null) ?? null;
193
+ });
194
+ return (s, v) => {
195
+ const T = y("FmSwitch"), C = y("FmSelect"), V = y("FmCard");
196
+ return k(), P(V, {
197
+ variant: "outlined",
198
+ class: "p-16 flex flex-col gap-16"
199
+ }, {
200
+ default: M(() => {
201
+ var R, I;
202
+ return [
203
+ d(T, {
204
+ value: "",
205
+ "model-value": c.value,
206
+ "onUpdate:modelValue": v[0] || (v[0] = (E) => c.value = E),
207
+ label: "Convertible",
208
+ sublabel: "Convertible from other recipe or ingredients",
209
+ labelPlacement: "right"
210
+ }, null, 8, ["model-value"]),
211
+ c.value ? (k(), J(ne, { key: 0 }, [
212
+ w("div", null, [
213
+ d(C, {
214
+ label: "Recipes and ingredients convert to",
215
+ modelValue: (R = b.value) == null ? void 0 : R.value,
216
+ "onUpdate:modelValue": U,
217
+ items: S.value
218
+ }, null, 8, ["modelValue", "items"])
219
+ ]),
220
+ d(Qe, {
221
+ id: l.value,
222
+ "model-value": ((I = s.modelValue) == null ? void 0 : I.inventoryBindings) ?? [],
223
+ "onUpdate:modelValue": u,
224
+ "exclude-binding-id": l.value
225
+ }, null, 8, ["id", "model-value", "exclude-binding-id"])
226
+ ], 64)) : G("", !0)
227
+ ];
228
+ }),
229
+ _: 1
230
+ });
231
+ };
232
+ }
233
+ }), on = { class: "text-fm-color-typo-secondary" }, an = { class: "flex gap-[1px] text-fm-color-typo-secondary" }, un = /* @__PURE__ */ w("div", null, "/", -1), sn = { class: "col-span-2 mt-16" }, rn = {
234
+ key: 1,
235
+ 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"
236
+ }, dn = /* @__PURE__ */ te({
237
+ __name: "IngredientForm",
238
+ props: {
239
+ mode: {},
240
+ modelValue: {},
241
+ disabled: { type: Boolean }
242
+ },
243
+ emits: ["update:modelValue", "click:submit"],
244
+ setup(A, { expose: F, emit: g }) {
245
+ var j;
246
+ const t = A, l = g, a = le(), c = en(), S = Te();
247
+ function U(e) {
248
+ if (e.length === 0) return;
249
+ const n = e[0], o = t.modelValue ?? {
250
+ unit: a.units.find((r) => r)
251
+ };
252
+ o.unit || (o.unit = n, l("update:modelValue", o));
253
+ }
254
+ xe(() => {
255
+ U(a.units);
256
+ }), Ie([() => a.units], ([e]) => {
257
+ U(e);
258
+ });
259
+ function u() {
260
+ l("click:submit");
261
+ }
262
+ const b = m({
263
+ get() {
264
+ var e;
265
+ return ((e = t.modelValue) == null ? void 0 : e.code) ?? "";
266
+ },
267
+ set(e) {
268
+ const n = t.modelValue ? {
269
+ ...t.modelValue
270
+ } : {};
271
+ n.code = e, l("update:modelValue", n);
272
+ }
273
+ }), s = m({
274
+ get() {
275
+ var e;
276
+ return ((e = t.modelValue) == null ? void 0 : e.name) ?? "";
277
+ },
278
+ set(e) {
279
+ const n = t.modelValue ? {
280
+ ...t.modelValue
281
+ } : {};
282
+ n.name = e, l("update:modelValue", n);
283
+ }
284
+ }), v = m({
285
+ get() {
286
+ var n, o;
287
+ const e = (o = (n = t.modelValue) == null ? void 0 : n.defaultCost) == null ? void 0 : o.costPerUnit;
288
+ return e ? +Xe(e) : 0;
289
+ },
290
+ set(e) {
291
+ var o, r, _, p;
292
+ const n = t.modelValue ? {
293
+ ...t.modelValue
294
+ } : {};
295
+ n.defaultCost ?? (n.defaultCost = {
296
+ costPerUnit: {
297
+ amount: 0,
298
+ precision: 2,
299
+ currency: ((o = fe(c.currentCountry.value)) == null ? void 0 : o.currency) ?? "MYR"
300
+ },
301
+ measurement: (p = (_ = (r = t.modelValue) == null ? void 0 : r.unit) == null ? void 0 : _.measurements) == null ? void 0 : p.find(
302
+ (B) => {
303
+ var O;
304
+ return B.id === ((O = t.modelValue) == null ? void 0 : O.trackingMeasurement);
305
+ }
306
+ )
307
+ }), n.defaultCost.costPerUnit = {
308
+ ...n.defaultCost.costPerUnit,
309
+ ...Ze(+e, 4)
310
+ }, l("update:modelValue", n);
311
+ }
312
+ }), T = m(() => {
313
+ var n, o, r;
314
+ const e = ((n = t.modelValue) == null ? void 0 : n.unit) ?? a.units.find((_) => _);
315
+ return e ? {
316
+ _id: e._id,
317
+ measurement: (o = t.modelValue) == null ? void 0 : o.trackingMeasurement,
318
+ name: ((r = e.measurements.find((_) => {
319
+ var p;
320
+ return _.id === ((p = t.modelValue) == null ? void 0 : p.trackingMeasurement);
321
+ })) == null ? void 0 : r.name) ?? e.name
322
+ } : null;
323
+ }), C = m(
324
+ () => a.units.flatMap(({ name: e, _id: n, abbrev: o, measurements: r }) => [
325
+ {
326
+ label: `${e}`,
327
+ value: null,
328
+ displayAsSection: !0
329
+ },
330
+ {
331
+ label: `${e} (${o})`,
332
+ value: { _id: n },
333
+ displayAsSection: !1
334
+ },
335
+ ...r.map(({ id: _, name: p, abbrev: B }) => ({
336
+ label: `${p} (${B})`,
337
+ value: { _id: n, measurement: _ },
338
+ displayAsSection: !1
339
+ }))
340
+ ])
341
+ );
342
+ function V(e) {
343
+ var n, o, r, _, p;
344
+ return ((o = (n = t.modelValue) == null ? void 0 : n.unit) == null ? void 0 : o._id) === ((r = e.value) == null ? void 0 : r._id) && ((_ = t.modelValue) == null ? void 0 : _.trackingMeasurement) === ((p = e.value) == null ? void 0 : p.measurement);
345
+ }
346
+ function R(e) {
347
+ var B, O;
348
+ if (!e) return;
349
+ const { _id: n, measurement: o } = e, r = o || void 0, _ = a.units.find((K) => K._id === n);
350
+ if (!_)
351
+ return;
352
+ const p = t.modelValue ?? {};
353
+ p.unit = _, p.trackingMeasurement = r, p.convert && (p.convert.measurement = r || null), S.enableTotalCost && (p.defaultCost = {
354
+ measurement: _.measurements.find((K) => K.id === r),
355
+ costPerUnit: {
356
+ ...((B = p.defaultCost) == null ? void 0 : B.costPerUnit) ?? {
357
+ amount: 0,
358
+ precision: 2,
359
+ currency: ((O = fe(c.currentCountry.value)) == null ? void 0 : O.currency) ?? "MYR"
360
+ }
361
+ }
362
+ }), l("update:modelValue", p);
363
+ }
364
+ const I = m({
365
+ get() {
366
+ var e;
367
+ return ((e = t.modelValue) == null ? void 0 : e.convert) ?? null;
368
+ },
369
+ set(e) {
370
+ const n = t.modelValue ? {
371
+ ...t.modelValue
372
+ } : {};
373
+ e ? n.convert = e : n.convert = null, l("update:modelValue", n);
374
+ }
375
+ }), E = m(() => N.options.filter(
376
+ (e) => e === N.enum.FIFO || e === N.enum.WAVG
377
+ ).map((e) => {
378
+ function n(o) {
379
+ switch (o) {
380
+ case N.enum.WAVG:
381
+ return "Weighted Average (WAVG)";
382
+ case N.enum.FIFO:
383
+ return "First In First Out (FIFO)";
384
+ case N.enum.LIFO:
385
+ return "Last In First Out (LIFO)";
386
+ case N.enum.FEFO:
387
+ return "First Expired First Out (FEFO)";
388
+ }
389
+ return "";
390
+ }
391
+ return {
392
+ label: n(e),
393
+ value: e
394
+ };
395
+ })), Q = m({
396
+ get() {
397
+ var e;
398
+ return ((e = t.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
399
+ },
400
+ set(e) {
401
+ const n = t.modelValue ? {
402
+ ...t.modelValue
403
+ } : {};
404
+ n.valuation = e, l("update:modelValue", n);
405
+ }
406
+ }), D = L();
407
+ F({
408
+ validateInputs: () => {
409
+ var e, n;
410
+ (n = (e = D.value) == null ? void 0 : e.validateInputs) == null || n.call(e);
411
+ },
412
+ resetInputsValidation: () => {
413
+ var e, n;
414
+ (n = (e = D.value) == null ? void 0 : e.resetInputsValidation) == null || n.call(e);
415
+ },
416
+ resetInputs: () => {
417
+ var e, n;
418
+ (n = (e = D.value) == null ? void 0 : e.resetInputs) == null || n.call(e);
419
+ }
420
+ });
421
+ const $ = L(!1), Y = m(
422
+ () => {
423
+ var e, n, o;
424
+ return (e = t.modelValue) != null && e._id ? ((o = a.menu.bindedBySkuId[(n = t.modelValue) == null ? void 0 : n._id]) == null ? void 0 : o.filter(
425
+ (r) => r.from === "INGREDIENT"
426
+ )) ?? [] : [];
427
+ }
428
+ ), q = m(
429
+ () => {
430
+ var e, n, o;
431
+ return (e = t.modelValue) != null && e._id ? ((o = a.menu.bindedBySkuId[(n = t.modelValue) == null ? void 0 : n._id]) == null ? void 0 : o.filter(
432
+ (r) => r.from === "RECIPE"
433
+ )) ?? [] : [];
434
+ }
435
+ ), W = m(
436
+ () => {
437
+ var e, n, o;
438
+ return (e = t.modelValue) != null && e._id ? ((o = a.menu.bindedBySkuId[(n = t.modelValue) == null ? void 0 : n._id]) == null ? void 0 : o.filter((r) => r.from === "MENU")) ?? [] : [];
439
+ }
440
+ ), z = m(
441
+ () => a.skus.map((e) => ({ label: e.name, value: e.code }))
442
+ ), X = L((j = t.modelValue) == null ? void 0 : j.code);
443
+ function Z(e) {
444
+ var o;
445
+ const n = e.el;
446
+ n && ((o = n.querySelector("[x-should-scroll-into=true]")) == null || o.scrollIntoView());
447
+ }
448
+ function H(e) {
449
+ switch (e) {
450
+ case ue.MY:
451
+ return "MYR";
452
+ case ue.SG:
453
+ return "SGD";
454
+ case ue.ID:
455
+ return "IDR";
456
+ default:
457
+ return "MYR";
458
+ }
459
+ }
460
+ return (e, n) => {
461
+ const o = y("FmTextField"), r = y("FmSelect"), _ = y("FmLabel"), p = y("FmField"), B = y("FmMenuHeader"), O = y("FmMenuDivider"), K = y("FmMenuItem"), he = y("FmMenu"), Se = y("FmFormGroup"), ke = y("FmSwitch"), we = y("FmForm");
462
+ return k(), P(we, {
463
+ disabled: e.disabled,
464
+ ref_key: "formRef",
465
+ ref: D,
466
+ class: "grid grid-cols-2 gap-24",
467
+ onValidationSuccess: u
468
+ }, {
469
+ default: M(() => [
470
+ d(o, {
471
+ label: "Code",
472
+ "model-value": b.value,
473
+ "onUpdate:modelValue": n[0] || (n[0] = (f) => b.value = f),
474
+ rules: [i(se)(), i(He)(z.value, X.value)],
475
+ "label-mark": "required"
476
+ }, null, 8, ["model-value", "rules"]),
477
+ d(o, {
478
+ label: "Name",
479
+ "model-value": s.value,
480
+ "onUpdate:modelValue": n[1] || (n[1] = (f) => s.value = f),
481
+ rules: [i(se)()],
482
+ "label-mark": "required"
483
+ }, null, 8, ["model-value", "rules"]),
484
+ d(r, {
485
+ class: "col-span-2",
486
+ "model-value": Q.value,
487
+ "onUpdate:modelValue": n[2] || (n[2] = (f) => Q.value = f),
488
+ label: "Valuation Method",
489
+ items: E.value
490
+ }, null, 8, ["model-value", "items"]),
491
+ d(Se, {
492
+ class: pe([i(S).enableTotalCost ? "col-span-1" : "col-span-2"]),
493
+ "model-value": T.value,
494
+ rules: [i(se)()],
495
+ "label-mark": "required"
496
+ }, {
497
+ label: M(() => [
498
+ d(_, { label: "Unit" })
499
+ ]),
500
+ default: M(({ invalid: f }) => [
501
+ d(he, null, {
502
+ "menu-button": M(() => [
503
+ d(p, {
504
+ class: pe([
505
+ "fm-typo-en-body-lg-400",
506
+ {
507
+ "text-fm-color-typo-primary": !e.disabled,
508
+ "text-fm-color-typo-disabled": e.disabled
509
+ }
510
+ ]),
511
+ invalid: f,
512
+ "append-icon": "expand_more"
513
+ }, {
514
+ default: M(() => {
515
+ var h;
516
+ return [
517
+ Ae(ae((h = T.value) == null ? void 0 : h.name), 1)
518
+ ];
519
+ }),
520
+ _: 2
521
+ }, 1032, ["class", "invalid"])
522
+ ]),
523
+ default: M(() => [
524
+ w("div", {
525
+ class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
526
+ onVnodeMounted: Z
527
+ }, [
528
+ (k(!0), J(ne, null, Ue(C.value, (h) => (k(), J(ne, {
529
+ key: h.label
530
+ }, [
531
+ h.displayAsSection ? (k(), J(ne, { key: 0 }, [
532
+ d(B, {
533
+ label: h.label
534
+ }, null, 8, ["label"]),
535
+ d(O)
536
+ ], 64)) : (k(), P(K, {
537
+ key: 1,
538
+ label: h.label,
539
+ "model-value": V(h),
540
+ onClick: (oe) => R(h.value),
541
+ "x-should-scroll-into": `${V(h)}`
542
+ }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
543
+ ], 64))), 128))
544
+ ], 512)
545
+ ]),
546
+ _: 2
547
+ }, 1024)
548
+ ]),
549
+ _: 1
550
+ }, 8, ["class", "model-value", "rules"]),
551
+ i(S).enableTotalCost ? (k(), P(o, {
552
+ key: 0,
553
+ label: "Price per unit",
554
+ "model-value": v.value,
555
+ "onUpdate:modelValue": n[3] || (n[3] = (f) => v.value = f),
556
+ rules: [i(je)(0), i(Ke)(2)],
557
+ "label-mark": "required"
558
+ }, {
559
+ prepend: M(() => {
560
+ var f, h;
561
+ return [
562
+ w("div", on, ae(H(((f = i(c).currentCountry) == null ? void 0 : f.value) ?? i(ge)) === "MYR" ? "RM" : H(((h = i(c).currentCountry) == null ? void 0 : h.value) ?? i(ge))), 1)
563
+ ];
564
+ }),
565
+ append: M(() => {
566
+ var f, h, oe, ie, de, me;
567
+ return [
568
+ w("div", an, [
569
+ un,
570
+ w("div", null, ae(((ie = (oe = (h = (f = e.modelValue) == null ? void 0 : f.unit) == null ? void 0 : h.measurements) == null ? void 0 : oe.find((Me) => {
571
+ var ce;
572
+ return Me.id === ((ce = e.modelValue) == null ? void 0 : ce.trackingMeasurement);
573
+ })) == null ? void 0 : ie.abbrev) ?? ((me = (de = e.modelValue) == null ? void 0 : de.unit) == null ? void 0 : me.abbrev)), 1)
574
+ ])
575
+ ];
576
+ }),
577
+ _: 1
578
+ }, 8, ["model-value", "rules"])) : G("", !0),
579
+ w("div", sn, [
580
+ d(ln, {
581
+ "model-value": I.value,
582
+ "onUpdate:modelValue": n[4] || (n[4] = (f) => I.value = f),
583
+ "root-value": e.modelValue
584
+ }, null, 8, ["model-value", "root-value"])
585
+ ]),
586
+ e.mode !== i(x).CREATE ? (k(), J("div", rn, [
587
+ w("div", null, [
588
+ d(ke, {
589
+ label: "Show binded items",
590
+ modelValue: $.value,
591
+ "onUpdate:modelValue": n[5] || (n[5] = (f) => $.value = f),
592
+ "label-placement": "right"
593
+ }, null, 8, ["modelValue"])
594
+ ]),
595
+ $.value && Y.value.length ? (k(), P(re, {
596
+ key: 0,
597
+ name: "Ingredient",
598
+ bindings: Y.value
599
+ }, null, 8, ["bindings"])) : G("", !0),
600
+ $.value && q.value.length ? (k(), P(re, {
601
+ key: 1,
602
+ name: "Recipe",
603
+ bindings: q.value
604
+ }, null, 8, ["bindings"])) : G("", !0),
605
+ $.value && W.value.length ? (k(), P(re, {
606
+ key: 2,
607
+ name: "Menu",
608
+ bindings: W.value
609
+ }, null, 8, ["bindings"])) : G("", !0)
610
+ ])) : G("", !0)
611
+ ]),
612
+ _: 1
613
+ }, 8, ["disabled"]);
614
+ };
615
+ }
616
+ }), mn = { class: "flex gap-4" }, cn = /* @__PURE__ */ te({
617
+ __name: "IngredientDialog",
618
+ props: {
619
+ show: { type: Boolean },
620
+ unit: {},
621
+ mode: { default: x.READ }
622
+ },
623
+ emits: ["update:show"],
624
+ setup(A) {
625
+ const F = A, g = le(), t = Ce(), l = Ve(F, "show"), a = Ve(F, "unit"), c = m(() => {
626
+ switch (F.mode) {
627
+ case x.READ:
628
+ return "View ingredient";
629
+ case x.UPDATE:
630
+ return "Edit ingredient";
631
+ case x.CREATE:
632
+ return "Add ingredient";
633
+ }
634
+ return "";
635
+ }), S = m(() => {
636
+ switch (F.mode) {
637
+ case x.READ:
638
+ return "";
639
+ case x.UPDATE:
640
+ return "Save";
641
+ case x.CREATE:
642
+ return "Add";
643
+ }
644
+ return "";
645
+ }), U = L(), u = L(!1);
646
+ async function b() {
647
+ u.value = !0;
648
+ try {
649
+ await g.createSku(a.value), l.value = !1, t.open({
650
+ title: "Success",
651
+ message: "Created " + a.value.name,
652
+ type: "success"
653
+ });
654
+ } catch (C) {
655
+ C instanceof be || t.open({
656
+ title: "Failed to create ingredient",
657
+ message: "Please try again",
658
+ type: "error"
659
+ });
660
+ } finally {
661
+ u.value = !1;
662
+ }
663
+ }
664
+ async function s() {
665
+ u.value = !0;
666
+ try {
667
+ await g.updateSku(a.value), u.value = !1, l.value = !1, t.open({
668
+ title: "Success",
669
+ message: "Updated " + a.value.name,
670
+ type: "success"
671
+ });
672
+ } catch (C) {
673
+ C instanceof be || t.open({
674
+ title: "Failed to update ingredient",
675
+ message: "Please try again",
676
+ type: "error"
677
+ });
678
+ } finally {
679
+ u.value = !1;
680
+ }
681
+ }
682
+ function v() {
683
+ var C, V;
684
+ (V = (C = U.value) == null ? void 0 : C.validateInputs) == null || V.call(C);
685
+ }
686
+ function T() {
687
+ switch (F.mode) {
688
+ case x.READ:
689
+ return;
690
+ case x.UPDATE:
691
+ return s();
692
+ case x.CREATE:
693
+ return b();
694
+ }
695
+ }
696
+ return (C, V) => {
697
+ const R = y("FmButton"), I = y("FmSideSheet");
698
+ return k(), P(I, {
699
+ "model-value": i(l),
700
+ "onUpdate:modelValue": V[3] || (V[3] = (E) => ve(l) ? l.value = E : null),
701
+ header: c.value,
702
+ "close-button": "",
703
+ "dismiss-away": "",
704
+ "max-width": 500
705
+ }, {
706
+ "side-sheet-footer": M(() => [
707
+ w("div", mn, [
708
+ d(R, {
709
+ loading: u.value,
710
+ label: S.value,
711
+ onClick: v
712
+ }, null, 8, ["loading", "label"]),
713
+ d(R, {
714
+ disabled: u.value,
715
+ label: "Close",
716
+ variant: "tertiary",
717
+ onClick: V[2] || (V[2] = (E) => l.value = !1)
718
+ }, null, 8, ["disabled"])
719
+ ])
720
+ ]),
721
+ default: M(() => [
722
+ d(dn, {
723
+ class: "w-full",
724
+ ref_key: "hasValidationExpose",
725
+ ref: U,
726
+ modelValue: i(a),
727
+ "onUpdate:modelValue": V[0] || (V[0] = (E) => ve(a) ? a.value = E : null),
728
+ mode: C.mode,
729
+ disabled: u.value,
730
+ "onClick:submit": V[1] || (V[1] = (E) => T())
731
+ }, null, 8, ["modelValue", "mode", "disabled"])
732
+ ]),
733
+ _: 1
734
+ }, 8, ["model-value", "header"]);
735
+ };
736
+ }
737
+ }), pn = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, vn = { class: "px-8 flex items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, fn = { class: "flex-1 w-full" }, gn = { class: "flex flex-col py-8" }, bn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Vn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, En = /* @__PURE__ */ te({
738
+ __name: "IngredientsView",
739
+ setup(A) {
740
+ const F = le(), g = m(() => F.skus), t = Be(), {
741
+ createIngredient: l,
742
+ updateIngredient: a,
743
+ deleteIngredient: c,
744
+ ingredientDialogProps: S,
745
+ ingredientViewLoading: U
746
+ } = nn(), { columnDefs: u } = tn({ updateIngredient: a, deleteIngredient: c });
747
+ function b(R) {
748
+ R === "add" && l();
749
+ }
750
+ const s = L(""), v = m(() => U.value), { breakpoints: T } = Oe(), C = m(() => T.value.xs || T.value.sm ? 10 : 20), V = qe();
751
+ return (R, I) => {
752
+ const E = y("FmTableToolbar"), Q = y("FmTable");
753
+ return k(), P(We, {
754
+ title: "Ingredient",
755
+ actions: [{ label: "Add ingredient", value: "add", isPrimary: !0, prependIcon: "add" }],
756
+ "onClick:action": b
757
+ }, {
758
+ default: M(() => [
759
+ w("div", pn, [
760
+ w("div", vn, [
761
+ w("div", fn, [
762
+ d(E, {
763
+ searchable: "",
764
+ "search-model": s.value,
765
+ "onUpdate:searchModel": I[0] || (I[0] = (D) => s.value = D)
766
+ }, null, 8, ["search-model"])
767
+ ])
768
+ ]),
769
+ d(Q, {
770
+ style: Ee(i(V).tableHeight),
771
+ "column-defs": i(u),
772
+ "row-data": g.value,
773
+ "search-value": s.value,
774
+ loading: !i(t)._currentLocation || v.value,
775
+ onRowClick: I[1] || (I[1] = (D) => i(a)(D.original)),
776
+ "page-size": C.value
777
+ }, {
778
+ "list-row": M((D) => [
779
+ d(Ye, {
780
+ row: D,
781
+ onRowClick: i(a)
782
+ }, {
783
+ default: M(($) => {
784
+ var Y, q, W, z, X, Z, H, j, e, n;
785
+ return [
786
+ w("div", gn, [
787
+ w("div", bn, [
788
+ d(i(_e), {
789
+ render: (W = (q = (Y = $.code) == null ? void 0 : Y.column) == null ? void 0 : q.columnDef) == null ? void 0 : W.cell,
790
+ props: (X = (z = $.code) == null ? void 0 : z.getContext) == null ? void 0 : X.call(z)
791
+ }, null, 8, ["render", "props"])
792
+ ]),
793
+ w("div", Vn, [
794
+ d(i(_e), {
795
+ render: (j = (H = (Z = $.name) == null ? void 0 : Z.column) == null ? void 0 : H.columnDef) == null ? void 0 : j.cell,
796
+ props: (n = (e = $.name) == null ? void 0 : e.getContext) == null ? void 0 : n.call(e)
797
+ }, null, 8, ["render", "props"])
798
+ ])
799
+ ])
800
+ ];
801
+ }),
802
+ _: 2
803
+ }, 1032, ["row", "onRowClick"])
804
+ ]),
805
+ _: 1
806
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
807
+ ]),
808
+ (k(), P(Re, { to: "body" }, [
809
+ d(cn, De($e(i(S))), null, 16)
810
+ ]))
811
+ ]),
812
+ _: 1
813
+ });
814
+ };
815
+ }
816
+ });
817
+ export {
818
+ En as default
819
+ };