@feedmepos/mf-inventory-portal 0.0.16-dev.4 → 0.0.16

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