@feedmepos/mf-inventory-portal 0.0.17-dev.1 → 0.0.17-dev.3

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 (53) hide show
  1. package/dist/{ApprovalView-NJ4FogNu.js → ApprovalView-Cro8o8Th.js} +9 -9
  2. package/dist/{BindingsDialog-B-j1k1SE.js → BindingsDialog-C_6Sc7QV.js} +5 -5
  3. package/dist/{BindingsPicker-CEi3jyh0.js → BindingsPicker-97PCPC7b.js} +6 -6
  4. package/dist/{BindingsTable-DHYJ2Eqm.js → BindingsTable-Hneu1zEK.js} +26 -26
  5. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-1XPAzm5R.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-euQmNhYq.js} +1 -1
  6. package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-DL98UqsQ.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-B1dIpiBE.js} +9 -9
  7. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DqD-jNxc.js → FmUnitInput.vue_vue_type_script_setup_true_lang-RrTqtrzn.js} +3 -3
  8. package/dist/IngredientsView-Chl_Nwza.js +1633 -0
  9. package/dist/{IntegrationView-DxqyRxVR.js → IntegrationView-B1FJBf5V.js} +4 -4
  10. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang--KLpvU2e.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-B1O2tP3s.js} +6 -6
  11. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-HpuL5QhV.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-C7p4N-ql.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-BGbCA7Al.js → PurchaseOrderPrintPreview-Q6w-mECy.js} +4 -4
  13. package/dist/{ReceiveRequestView-C1ae5dRi.js → ReceiveRequestView-DT5pFuLm.js} +13 -13
  14. package/dist/RecipeView-B0B9AjMs.js +581 -0
  15. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-Dov3Uq2z.js +64 -0
  16. package/dist/{StockView-Pyk4MBIQ.js → StockView-Dnz7Q5u_.js} +13 -13
  17. package/dist/{SupplierView-CVZ7bOgA.js → SupplierView-DYUSnY0W.js} +8 -8
  18. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Ctqjw3f1.js → TransferDetails.vue_vue_type_script_setup_true_lang-DG7IgsfE.js} +5 -5
  19. package/dist/{UnitView-DVauPXKw.js → UnitView-CdAqOSI4.js} +7 -7
  20. package/dist/{WarehouseView-BYivsQgQ.js → WarehouseView-AJTCViDZ.js} +4 -4
  21. package/dist/api/inventory.d.ts +102 -0
  22. package/dist/{app-DXqS7qYg.js → app-De0b6M_S.js} +2690 -2664
  23. package/dist/app.js +1 -1
  24. package/dist/components/FmDroppableField.vue.d.ts +75 -0
  25. package/dist/{date2-B96h4mWb.js → date2-DsZfEweX.js} +1 -1
  26. package/dist/{dayjs.min-CQkpEWlm.js → dayjs.min-C3MlIeO6.js} +2 -2
  27. package/dist/{decimal-DQOX97fs.js → decimal-CIfto74W.js} +1 -1
  28. package/dist/{fuzzy-Dr-kBYFA.js → fuzzy-DfJ2CA7_.js} +1 -1
  29. package/dist/helper/random.d.ts +2 -0
  30. package/dist/helper/xlsx.util.d.ts +1 -0
  31. package/dist/{init-date-range-6CJBD0GL.js → init-date-range-DVsJ_QSu.js} +1 -1
  32. package/dist/{layout-CVjYEZxq.js → layout-BrQ7Xgxg.js} +12 -12
  33. package/dist/{rules-B_-yQn9M.js → rules-B32JlLGo.js} +1 -1
  34. package/dist/{stock-estimate-DoU-A7bG.js → stock-estimate-CWilasb_.js} +2 -2
  35. package/dist/stores/inventory.d.ts +1 -0
  36. package/dist/style.css +1 -1
  37. package/dist/{supplier-D2Wuv0oV.js → supplier-BGVPsv_7.js} +1 -1
  38. package/dist/tsconfig.app.tsbuildinfo +1 -1
  39. package/dist/{use-inventory-binding-dialog-Bc0Yx1fK.js → use-inventory-binding-dialog-iyYqvDqU.js} +2 -2
  40. package/dist/views/ingredients/components/import-ingredients/ImportIngredientItem.vue.d.ts +12 -0
  41. package/dist/views/ingredients/components/import-ingredients/ImportIngredientItemProps.d.ts +6 -0
  42. package/dist/views/ingredients/components/import-ingredients/ImportIngredients.vue.d.ts +2 -0
  43. package/dist/views/ingredients/components/import-ingredients/ImportIngredientsProps.d.ts +5 -0
  44. package/dist/views/ingredients/helper/import-export.helper.d.ts +45 -0
  45. package/dist/views/ingredients/helper/sku-id.helper.d.ts +1 -0
  46. package/dist/xlsx-CRnWVsKF.js +24004 -0
  47. package/dist/xlsx.util-BSemF6vC.js +107 -0
  48. package/package.json +4 -4
  49. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-BYi6BUwT.js +0 -49
  50. package/dist/IngredientsView-DNbppADe.js +0 -973
  51. package/dist/RecipeView-BwP8jlG0.js +0 -596
  52. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js +0 -53
  53. package/dist/xlsx-Vw9D2Jo4.js +0 -15510
@@ -1,973 +0,0 @@
1
- import { ref as z, defineComponent as ae, computed as c, resolveComponent as b, openBlock as S, createBlock as B, withCtx as v, createVNode as r, createElementBlock as Q, Fragment as oe, createElementVNode as a, createCommentVNode as Y, onMounted as Re, watch as Ee, unref as m, normalizeClass as ye, createTextVNode as De, toDisplayString as ue, renderList as $e, isRef as be, normalizeStyle as Te, Teleport as Pe, normalizeProps as Be, guardReactiveProps as Le } from "vue";
2
- import { u as se, c as Se, S as Oe, g as Ve, F as G, d as he, a as Ne, C as re, b as xe, e as ze } from "./app-DXqS7qYg.js";
3
- import { useDialog as Ge, useSnackbar as ke, useProxiedModel as Fe, useBreakpoints as We } from "@feedmepos/ui-library";
4
- import { i as Ye, _ as qe } from "./is-linked-ingredient-error-C6AghEwR.js";
5
- import { F as M, D as we, R as le } from "./row-action.enum-BwQbURNh.js";
6
- import { c as He, _ as je, F as Ce, u as Ke } from "./layout-CVjYEZxq.js";
7
- import { _ as Je } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CFjO4TPG.js";
8
- import { R as de, U as Qe, A as ie, M as Xe } from "./rules-B_-yQn9M.js";
9
- import { g as Ze, _ as me, S as ce } from "./StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js";
10
- import { _ as et } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang--KLpvU2e.js";
11
- import { _ as pe } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-BYi6BUwT.js";
12
- import { a as tt, t as lt } from "./date2-B96h4mWb.js";
13
- import { useCoreStore as nt } from "@feedmepos/mf-common";
14
- import { _ as fe } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js";
15
- function ot() {
16
- const A = Ge(), F = ke(), V = se(), l = z(!1), o = z();
17
- function s() {
18
- const d = {
19
- unit: {},
20
- mode: M.CREATE,
21
- show: !0,
22
- "onUpdate:show"(h) {
23
- o.value.show = h;
24
- }
25
- };
26
- o.value = d;
27
- }
28
- async function f(d) {
29
- const h = {
30
- unit: Se(d),
31
- mode: M.UPDATE,
32
- show: !0,
33
- "onUpdate:show"(i) {
34
- o.value.show = i;
35
- }
36
- };
37
- o.value = h;
38
- }
39
- async function C(d) {
40
- l.value = !0;
41
- try {
42
- await V.deleteSku(d), F.open({
43
- title: "Success",
44
- message: `Deleted ${d.name}`,
45
- type: "success"
46
- });
47
- } catch (h) {
48
- h instanceof Oe && Ye(h) ? A.open({
49
- title: "Cannot delete ingredient",
50
- contentComponent: qe,
51
- contentComponentProps: {
52
- subject: (d == null ? void 0 : d.name) ?? "",
53
- items: h.errorResponse.message
54
- },
55
- secondaryActions: {
56
- text: "Close",
57
- close: !0
58
- }
59
- }) : console.log("unable to delete ingredient", h), F.open({
60
- title: `Cannot delete ${d.name}`,
61
- message: "Please try again.",
62
- type: "error"
63
- }), console.error("failed to delete ingredient", h);
64
- } finally {
65
- l.value = !1;
66
- }
67
- }
68
- function U(d) {
69
- A.open({
70
- title: `Delete ${(d == null ? void 0 : d.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(() => C(d));
83
- }
84
- return {
85
- createIngredient: s,
86
- updateIngredient: f,
87
- deleteIngredient: U,
88
- ingredientDialogProps: o,
89
- ingredientViewLoading: l
90
- };
91
- }
92
- function at({
93
- updateIngredient: A,
94
- deleteIngredient: F
95
- }) {
96
- async function V(o, s) {
97
- const f = Se(s);
98
- if (o === le.Edit) {
99
- await A(f);
100
- return;
101
- }
102
- if (o === le.Delete) {
103
- await F(f);
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: (o) => {
122
- var s;
123
- if (o.trackingMeasurement) {
124
- const f = (s = o.unit.measurements) == null ? void 0 : s.find(
125
- (C) => C.id === o.trackingMeasurement
126
- );
127
- if (f)
128
- return `${f.name} (${f.abbrev})`;
129
- }
130
- return `${o.unit.name} (${o.unit.abbrev})`;
131
- },
132
- header: "Unit",
133
- enableSorting: !1,
134
- size: "auto"
135
- },
136
- {
137
- id: "action",
138
- header: "",
139
- cell(o) {
140
- return He(
141
- [we[le.Edit], we[le.Delete]],
142
- (s) => {
143
- V(s, o.row.original);
144
- }
145
- );
146
- },
147
- enableSorting: !1,
148
- size: 40,
149
- meta: {
150
- cellClass: "",
151
- headerClass: ""
152
- }
153
- }
154
- ] };
155
- }
156
- const st = /* @__PURE__ */ ae({
157
- __name: "ConvertForm",
158
- props: {
159
- modelValue: {},
160
- rootValue: {},
161
- disabled: { type: Boolean }
162
- },
163
- emits: ["update:modelValue"],
164
- setup(A, { emit: F }) {
165
- const V = A, l = c(() => {
166
- var i;
167
- return (i = V.rootValue) == null ? void 0 : i.unit;
168
- }), o = c(() => {
169
- var i;
170
- return (i = V.rootValue) == null ? void 0 : i._id;
171
- }), s = F, f = c({
172
- get() {
173
- return !!V.modelValue;
174
- },
175
- set(i) {
176
- i ? s("update:modelValue", {
177
- measurement: null,
178
- inventoryBindings: []
179
- }) : s("update:modelValue", null);
180
- }
181
- }), C = c(() => Ze(l.value));
182
- function U(i) {
183
- const y = V.modelValue ?? {};
184
- y.measurement = i ? `${i}` : null, s("update:modelValue", y);
185
- }
186
- function d(i) {
187
- const y = V.modelValue ?? {};
188
- y.inventoryBindings = i, s("update:modelValue", y);
189
- }
190
- const h = c(() => {
191
- if (!V.modelValue) return null;
192
- const i = V.modelValue;
193
- return i.measurement ? C.value.find((y) => y.value === i.measurement) ?? null : C.value.find((y) => y.value === null) ?? null;
194
- });
195
- return (i, y) => {
196
- const L = b("FmSwitch"), w = b("FmSelect"), x = b("FmCard");
197
- return S(), B(x, {
198
- variant: "outlined",
199
- class: "p-16 flex flex-col gap-16"
200
- }, {
201
- default: v(() => {
202
- var E, I;
203
- return [
204
- r(L, {
205
- value: "",
206
- "model-value": f.value,
207
- "onUpdate:modelValue": y[0] || (y[0] = (R) => f.value = R),
208
- label: "Convertible",
209
- sublabel: "Convertible from other recipe or ingredients",
210
- labelPlacement: "right"
211
- }, null, 8, ["model-value"]),
212
- f.value ? (S(), Q(oe, { key: 0 }, [
213
- a("div", null, [
214
- r(w, {
215
- label: "Recipes and ingredients convert to",
216
- modelValue: (E = h.value) == null ? void 0 : E.value,
217
- "onUpdate:modelValue": U,
218
- items: C.value
219
- }, null, 8, ["modelValue", "items"])
220
- ]),
221
- r(et, {
222
- id: o.value,
223
- "model-value": ((I = i.modelValue) == null ? void 0 : I.inventoryBindings) ?? [],
224
- "onUpdate:modelValue": d,
225
- "exclude-binding-id": o.value
226
- }, null, 8, ["id", "model-value", "exclude-binding-id"])
227
- ], 64)) : Y("", !0)
228
- ];
229
- }),
230
- _: 1
231
- });
232
- };
233
- }
234
- });
235
- function ne() {
236
- return {
237
- low: 6,
238
- mid: 14
239
- };
240
- }
241
- const ut = { class: "text-fm-color-typo-secondary" }, rt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, dt = { class: "col-span-2 mt-16" }, it = {
242
- key: 1,
243
- class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
244
- }, mt = { class: "col-span-2 flex flex-col gap-12" }, ct = { class: "flex flex-col gap-4" }, pt = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Alert threshold", -1), ft = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Configure threshold for days remaining indicator in the stock balance page. ", -1), vt = { class: "col-span-2 flex flex-col gap-4" }, _t = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, gt = { class: "flex-1 p-12 flex flex-col gap-8" }, yt = { class: "mx-auto" }, bt = { class: "flex flex-col" }, Vt = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), ht = /* @__PURE__ */ a("div", {
245
- class: "text-fm-color-typo-secondary",
246
- style: { "padding-right": "32px" }
247
- }, "days", -1), xt = /* @__PURE__ */ a("div", {
248
- class: "h-full bg-fm-color-neutral-gray-200 relative",
249
- style: { width: "1px" }
250
- }, [
251
- /* @__PURE__ */ a("div", {
252
- class: "absolute bg-white",
253
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
254
- }, " < ")
255
- ], -1), Ft = { class: "flex-1 p-12 flex flex-col gap-8" }, wt = { class: "mx-auto" }, Ct = { class: "flex flex-col" }, St = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), kt = /* @__PURE__ */ a("div", {
256
- class: "text-fm-color-typo-secondary",
257
- style: { "padding-right": "32px" }
258
- }, "days", -1), Mt = /* @__PURE__ */ a("div", {
259
- class: "h-full bg-fm-color-neutral-gray-200 relative",
260
- style: { width: "1px" }
261
- }, [
262
- /* @__PURE__ */ a("div", {
263
- class: "absolute bg-white",
264
- style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
265
- }, " < ")
266
- ], -1), It = { class: "flex-1 p-12 flex flex-col gap-8" }, At = { class: "mx-auto" }, Ut = /* @__PURE__ */ a("div", { class: "flex flex-col" }, [
267
- /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "Stock is staple")
268
- ], -1), Rt = /* @__PURE__ */ ae({
269
- __name: "IngredientForm",
270
- props: {
271
- mode: {},
272
- modelValue: {},
273
- disabled: { type: Boolean }
274
- },
275
- emits: ["update:modelValue", "click:submit"],
276
- setup(A, { expose: F, emit: V }) {
277
- var ve;
278
- const l = A, o = V, s = se(), f = nt(), C = Ne();
279
- function U(e) {
280
- if (e.length === 0) return;
281
- const t = e[0], n = l.modelValue ?? {
282
- unit: s.units.find((u) => u)
283
- };
284
- n.unit || (n.unit = t, o("update:modelValue", n));
285
- }
286
- Re(() => {
287
- U(s.units);
288
- }), Ee([() => s.units], ([e]) => {
289
- U(e);
290
- });
291
- function d() {
292
- o("click:submit");
293
- }
294
- const h = c({
295
- get() {
296
- var e;
297
- return ((e = l.modelValue) == null ? void 0 : e.code) ?? "";
298
- },
299
- set(e) {
300
- const t = l.modelValue ? {
301
- ...l.modelValue
302
- } : {};
303
- t.code = e, o("update:modelValue", t);
304
- }
305
- }), i = c({
306
- get() {
307
- var e;
308
- return ((e = l.modelValue) == null ? void 0 : e.name) ?? "";
309
- },
310
- set(e) {
311
- const t = l.modelValue ? {
312
- ...l.modelValue
313
- } : {};
314
- t.name = e, o("update:modelValue", t);
315
- }
316
- }), y = c({
317
- get() {
318
- var t, n;
319
- const e = (n = (t = l.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : n.costPerUnit;
320
- return e ? +tt(e) : 0;
321
- },
322
- set(e) {
323
- var n, u, _, p;
324
- const t = l.modelValue ? {
325
- ...l.modelValue
326
- } : {};
327
- t.defaultCost ?? (t.defaultCost = {
328
- costPerUnit: {
329
- amount: 0,
330
- precision: 2,
331
- currency: ((n = Ve(f.currentCountry.value)) == null ? void 0 : n.currency) ?? "MYR"
332
- },
333
- measurement: (p = (_ = (u = l.modelValue) == null ? void 0 : u.unit) == null ? void 0 : _.measurements) == null ? void 0 : p.find(
334
- (T) => {
335
- var P;
336
- return T.id === ((P = l.modelValue) == null ? void 0 : P.trackingMeasurement);
337
- }
338
- )
339
- }), t.defaultCost.costPerUnit = {
340
- ...t.defaultCost.costPerUnit,
341
- ...lt(+e, 4)
342
- }, o("update:modelValue", t);
343
- }
344
- }), L = c(() => {
345
- var t, n, u;
346
- const e = ((t = l.modelValue) == null ? void 0 : t.unit) ?? s.units.find((_) => _);
347
- return e ? {
348
- _id: e._id,
349
- measurement: (n = l.modelValue) == null ? void 0 : n.trackingMeasurement,
350
- name: ((u = e.measurements.find((_) => {
351
- var p;
352
- return _.id === ((p = l.modelValue) == null ? void 0 : p.trackingMeasurement);
353
- })) == null ? void 0 : u.name) ?? e.name
354
- } : null;
355
- }), w = c(
356
- () => s.units.flatMap(({ name: e, _id: t, abbrev: n, measurements: u }) => [
357
- {
358
- label: `${e}`,
359
- value: null,
360
- displayAsSection: !0
361
- },
362
- {
363
- label: `${e} (${n})`,
364
- value: { _id: t },
365
- displayAsSection: !1
366
- },
367
- ...u.map(({ id: _, name: p, abbrev: T }) => ({
368
- label: `${p} (${T})`,
369
- value: { _id: t, measurement: _ },
370
- displayAsSection: !1
371
- }))
372
- ])
373
- );
374
- function x(e) {
375
- var t, n, u, _, p;
376
- return ((n = (t = l.modelValue) == null ? void 0 : t.unit) == null ? void 0 : n._id) === ((u = e.value) == null ? void 0 : u._id) && ((_ = l.modelValue) == null ? void 0 : _.trackingMeasurement) === ((p = e.value) == null ? void 0 : p.measurement);
377
- }
378
- function E(e) {
379
- var T, P;
380
- if (!e) return;
381
- const { _id: t, measurement: n } = e, u = n || void 0, _ = s.units.find((J) => J._id === t);
382
- if (!_)
383
- return;
384
- const p = l.modelValue ?? {};
385
- p.unit = _, p.trackingMeasurement = u, p.convert && (p.convert.measurement = u || null), C.enableTotalCost && (p.defaultCost = {
386
- measurement: _.measurements.find((J) => J.id === u),
387
- costPerUnit: {
388
- ...((T = p.defaultCost) == null ? void 0 : T.costPerUnit) ?? {
389
- amount: 0,
390
- precision: 2,
391
- currency: ((P = Ve(f.currentCountry.value)) == null ? void 0 : P.currency) ?? "MYR"
392
- }
393
- }
394
- }), o("update:modelValue", p);
395
- }
396
- const I = c({
397
- get() {
398
- var e;
399
- return ((e = l.modelValue) == null ? void 0 : e.convert) ?? null;
400
- },
401
- set(e) {
402
- const t = l.modelValue ? {
403
- ...l.modelValue
404
- } : {};
405
- e ? t.convert = e : t.convert = null, o("update:modelValue", t);
406
- }
407
- }), R = c(() => G.options.filter(
408
- (e) => e === G.enum.FIFO || e === G.enum.WAVG
409
- ).map((e) => {
410
- function t(n) {
411
- switch (n) {
412
- case G.enum.WAVG:
413
- return "Weighted Average (WAVG)";
414
- case G.enum.FIFO:
415
- return "First In First Out (FIFO)";
416
- case G.enum.LIFO:
417
- return "Last In First Out (LIFO)";
418
- case G.enum.FEFO:
419
- return "First Expired First Out (FEFO)";
420
- }
421
- return "";
422
- }
423
- return {
424
- label: t(e),
425
- value: e
426
- };
427
- })), X = c({
428
- get() {
429
- var e;
430
- return ((e = l.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
431
- },
432
- set(e) {
433
- const t = l.modelValue ? {
434
- ...l.modelValue
435
- } : {};
436
- t.valuation = e, o("update:modelValue", t);
437
- }
438
- }), D = z();
439
- F({
440
- validateInputs: () => {
441
- var e, t;
442
- (t = (e = D.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
443
- },
444
- resetInputsValidation: () => {
445
- var e, t;
446
- (t = (e = D.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
447
- },
448
- resetInputs: () => {
449
- var e, t;
450
- (t = (e = D.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
451
- }
452
- });
453
- const $ = z(!1), q = c(
454
- () => {
455
- var e, t, n;
456
- return (e = l.modelValue) != null && e._id ? ((n = s.menu.bindedBySkuId[(t = l.modelValue) == null ? void 0 : t._id]) == null ? void 0 : n.filter(
457
- (u) => u.from === "INGREDIENT"
458
- )) ?? [] : [];
459
- }
460
- ), H = c(
461
- () => {
462
- var e, t, n;
463
- return (e = l.modelValue) != null && e._id ? ((n = s.menu.bindedBySkuId[(t = l.modelValue) == null ? void 0 : t._id]) == null ? void 0 : n.filter(
464
- (u) => u.from === "RECIPE"
465
- )) ?? [] : [];
466
- }
467
- ), j = c(
468
- () => {
469
- var e, t, n;
470
- return (e = l.modelValue) != null && e._id ? ((n = s.menu.bindedBySkuId[(t = l.modelValue) == null ? void 0 : t._id]) == null ? void 0 : n.filter((u) => u.from === "MENU")) ?? [] : [];
471
- }
472
- ), W = c(
473
- () => s.skus.map((e) => ({ label: e.name, value: e.code }))
474
- ), Z = z((ve = l.modelValue) == null ? void 0 : ve.code);
475
- function ee(e) {
476
- var n;
477
- const t = e.el;
478
- t && ((n = t.querySelector("[x-should-scroll-into=true]")) == null || n.scrollIntoView());
479
- }
480
- function K(e) {
481
- switch (e) {
482
- case re.MY:
483
- return "MYR";
484
- case re.SG:
485
- return "SGD";
486
- case re.ID:
487
- return "IDR";
488
- default:
489
- return "MYR";
490
- }
491
- }
492
- const te = c(
493
- () => {
494
- var e, t, n, u, _, p;
495
- return ((u = (n = (t = (e = l.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : n.find(
496
- (T) => {
497
- var P;
498
- return T.id === ((P = l.modelValue) == null ? void 0 : P.trackingMeasurement);
499
- }
500
- )) == null ? void 0 : u.abbrev) ?? ((p = (_ = l.modelValue) == null ? void 0 : _.unit) == null ? void 0 : p.abbrev);
501
- }
502
- ), O = c({
503
- get() {
504
- var e, t;
505
- return ((t = (e = l.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? ne().low;
506
- },
507
- set(e) {
508
- var u;
509
- const t = ((u = l.modelValue) == null ? void 0 : u.thresholds) ?? ne();
510
- t.low = e;
511
- const n = l.modelValue ? {
512
- ...l.modelValue
513
- } : {};
514
- n.thresholds = t, o("update:modelValue", n);
515
- }
516
- }), N = c({
517
- get() {
518
- var e, t;
519
- return ((t = (e = l.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? ne().mid;
520
- },
521
- set(e) {
522
- var u;
523
- const t = ((u = l.modelValue) == null ? void 0 : u.thresholds) ?? ne();
524
- t.mid = e;
525
- const n = l.modelValue ? {
526
- ...l.modelValue
527
- } : {};
528
- n.thresholds = t, o("update:modelValue", n);
529
- }
530
- });
531
- function Me() {
532
- return function(t) {
533
- 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;
534
- };
535
- }
536
- return (e, t) => {
537
- const n = b("FmTextField"), u = b("FmLabel"), _ = b("FmSelect"), p = b("FmField"), T = b("FmMenuHeader"), P = b("FmMenuDivider"), J = b("FmMenuItem"), Ie = b("FmMenu"), _e = b("FmFormGroup"), Ae = b("FmSwitch"), ge = b("FmStepperField"), Ue = b("FmForm");
538
- return S(), B(Ue, {
539
- disabled: e.disabled,
540
- ref_key: "formRef",
541
- ref: D,
542
- class: "grid grid-cols-2 gap-24",
543
- onValidationSuccess: d
544
- }, {
545
- default: v(() => [
546
- r(n, {
547
- label: "Code",
548
- "model-value": h.value,
549
- "onUpdate:modelValue": t[0] || (t[0] = (g) => h.value = g),
550
- rules: [m(de)(), m(Qe)(W.value, Z.value)],
551
- "label-mark": "required"
552
- }, null, 8, ["model-value", "rules"]),
553
- r(n, {
554
- label: "Name",
555
- "model-value": i.value,
556
- "onUpdate:modelValue": t[1] || (t[1] = (g) => i.value = g),
557
- rules: [m(de)()],
558
- "label-mark": "required"
559
- }, null, 8, ["model-value", "rules"]),
560
- r(_, {
561
- class: "col-span-2",
562
- "model-value": X.value,
563
- "onUpdate:modelValue": t[2] || (t[2] = (g) => X.value = g),
564
- items: R.value
565
- }, {
566
- label: v(() => [
567
- r(fe, { "z-index": 50 }, {
568
- default: v(() => [
569
- r(u, { label: "Valuation Method" })
570
- ]),
571
- _: 1
572
- })
573
- ]),
574
- _: 1
575
- }, 8, ["model-value", "items"]),
576
- r(_e, {
577
- class: ye([m(C).enableTotalCost ? "col-span-1" : "col-span-2"]),
578
- "model-value": L.value,
579
- rules: [m(de)()],
580
- "label-mark": "required"
581
- }, {
582
- label: v(() => [
583
- r(u, { label: "Unit" })
584
- ]),
585
- default: v(({ invalid: g }) => [
586
- r(Ie, null, {
587
- "menu-button": v(() => [
588
- r(p, {
589
- class: ye([
590
- "fm-typo-en-body-lg-400",
591
- {
592
- "text-fm-color-typo-primary": !e.disabled,
593
- "text-fm-color-typo-disabled": e.disabled
594
- }
595
- ]),
596
- invalid: g,
597
- "append-icon": "expand_more"
598
- }, {
599
- default: v(() => {
600
- var k;
601
- return [
602
- De(ue((k = L.value) == null ? void 0 : k.name), 1)
603
- ];
604
- }),
605
- _: 2
606
- }, 1032, ["class", "invalid"])
607
- ]),
608
- default: v(() => [
609
- a("div", {
610
- class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
611
- onVnodeMounted: ee
612
- }, [
613
- (S(!0), Q(oe, null, $e(w.value, (k) => (S(), Q(oe, {
614
- key: k.label
615
- }, [
616
- k.displayAsSection ? (S(), Q(oe, { key: 0 }, [
617
- r(T, {
618
- label: k.label
619
- }, null, 8, ["label"]),
620
- r(P)
621
- ], 64)) : (S(), B(J, {
622
- key: 1,
623
- label: k.label,
624
- "model-value": x(k),
625
- onClick: (Nt) => E(k.value),
626
- "x-should-scroll-into": `${x(k)}`
627
- }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
628
- ], 64))), 128))
629
- ], 512)
630
- ]),
631
- _: 2
632
- }, 1024)
633
- ]),
634
- _: 1
635
- }, 8, ["class", "model-value", "rules"]),
636
- m(C).enableTotalCost ? (S(), B(n, {
637
- key: 0,
638
- "model-value": y.value,
639
- "onUpdate:modelValue": t[3] || (t[3] = (g) => y.value = g),
640
- rules: [m(ie)(0), m(Xe)(2)]
641
- }, {
642
- label: v(() => [
643
- r(fe, { "z-index": 50 }, {
644
- default: v(() => [
645
- r(u, { label: "Price per unit" })
646
- ]),
647
- _: 1
648
- })
649
- ]),
650
- prepend: v(() => {
651
- var g, k;
652
- return [
653
- a("div", ut, ue(K(((g = m(f).currentCountry) == null ? void 0 : g.value) ?? m(he)) === "MYR" ? "RM" : K(((k = m(f).currentCountry) == null ? void 0 : k.value) ?? m(he))), 1)
654
- ];
655
- }),
656
- append: v(() => [
657
- a("div", rt, " / " + ue(te.value), 1)
658
- ]),
659
- _: 1
660
- }, 8, ["model-value", "rules"])) : Y("", !0),
661
- a("div", dt, [
662
- r(st, {
663
- "model-value": I.value,
664
- "onUpdate:modelValue": t[4] || (t[4] = (g) => I.value = g),
665
- "root-value": e.modelValue
666
- }, null, 8, ["model-value", "root-value"])
667
- ]),
668
- e.mode !== m(M).CREATE ? (S(), Q("div", it, [
669
- a("div", null, [
670
- r(Ae, {
671
- label: "Show binded items",
672
- modelValue: $.value,
673
- "onUpdate:modelValue": t[5] || (t[5] = (g) => $.value = g),
674
- "label-placement": "right"
675
- }, null, 8, ["modelValue"])
676
- ]),
677
- $.value && q.value.length ? (S(), B(pe, {
678
- key: 0,
679
- name: "Ingredient",
680
- bindings: q.value
681
- }, null, 8, ["bindings"])) : Y("", !0),
682
- $.value && H.value.length ? (S(), B(pe, {
683
- key: 1,
684
- name: "Recipe",
685
- bindings: H.value
686
- }, null, 8, ["bindings"])) : Y("", !0),
687
- $.value && j.value.length ? (S(), B(pe, {
688
- key: 2,
689
- name: "Menu",
690
- bindings: j.value
691
- }, null, 8, ["bindings"])) : Y("", !0)
692
- ])) : Y("", !0),
693
- a("div", mt, [
694
- a("div", ct, [
695
- r(fe, null, {
696
- default: v(() => [
697
- pt
698
- ]),
699
- _: 1
700
- }),
701
- ft
702
- ]),
703
- a("div", vt, [
704
- r(_e, {
705
- "model-value": { low: O.value, mid: N.value },
706
- rules: [Me()]
707
- }, null, 8, ["model-value", "rules"]),
708
- a("div", _t, [
709
- a("div", gt, [
710
- a("div", yt, [
711
- r(me, {
712
- days: O.value,
713
- level: m(ce).low
714
- }, null, 8, ["days", "level"])
715
- ]),
716
- a("div", bt, [
717
- Vt,
718
- r(ge, {
719
- modelValue: O.value,
720
- "onUpdate:modelValue": t[6] || (t[6] = (g) => O.value = g),
721
- rules: [m(ie)(0)]
722
- }, {
723
- append: v(() => [
724
- ht
725
- ]),
726
- _: 1
727
- }, 8, ["modelValue", "rules"])
728
- ])
729
- ]),
730
- xt,
731
- a("div", Ft, [
732
- a("div", wt, [
733
- r(me, {
734
- days: N.value,
735
- level: m(ce).mid
736
- }, null, 8, ["days", "level"])
737
- ]),
738
- a("div", Ct, [
739
- St,
740
- r(ge, {
741
- modelValue: N.value,
742
- "onUpdate:modelValue": t[7] || (t[7] = (g) => N.value = g),
743
- rules: [m(ie)(0)]
744
- }, {
745
- append: v(() => [
746
- kt
747
- ]),
748
- _: 1
749
- }, 8, ["modelValue", "rules"])
750
- ])
751
- ]),
752
- Mt,
753
- a("div", It, [
754
- a("div", At, [
755
- r(me, {
756
- days: N.value + 1,
757
- level: m(ce).high
758
- }, null, 8, ["days", "level"])
759
- ]),
760
- Ut
761
- ])
762
- ])
763
- ])
764
- ])
765
- ]),
766
- _: 1
767
- }, 8, ["disabled"]);
768
- };
769
- }
770
- }), Et = { class: "flex gap-4" }, Dt = /* @__PURE__ */ ae({
771
- __name: "IngredientDialog",
772
- props: {
773
- show: { type: Boolean },
774
- unit: {},
775
- mode: { default: M.READ }
776
- },
777
- emits: ["update:show"],
778
- setup(A) {
779
- const F = A, V = se(), l = ke(), o = Fe(F, "show"), s = Fe(F, "unit"), f = c(() => {
780
- switch (F.mode) {
781
- case M.READ:
782
- return "View ingredient";
783
- case M.UPDATE:
784
- return "Edit ingredient";
785
- case M.CREATE:
786
- return "Add ingredient";
787
- }
788
- return "";
789
- }), C = c(() => {
790
- switch (F.mode) {
791
- case M.READ:
792
- return "";
793
- case M.UPDATE:
794
- return "Save";
795
- case M.CREATE:
796
- return "Add";
797
- }
798
- return "";
799
- }), U = z(), d = z(!1);
800
- async function h() {
801
- d.value = !0;
802
- try {
803
- await V.createSku(s.value), o.value = !1, l.open({
804
- title: "Success",
805
- message: "Created " + s.value.name,
806
- type: "success"
807
- });
808
- } catch (w) {
809
- w instanceof xe || l.open({
810
- title: "Failed to create ingredient",
811
- message: "Please try again",
812
- type: "error"
813
- });
814
- } finally {
815
- d.value = !1;
816
- }
817
- }
818
- async function i() {
819
- d.value = !0;
820
- try {
821
- await V.updateSku(s.value), d.value = !1, o.value = !1, l.open({
822
- title: "Success",
823
- message: "Updated " + s.value.name,
824
- type: "success"
825
- });
826
- } catch (w) {
827
- w instanceof xe || l.open({
828
- title: "Failed to update ingredient",
829
- message: "Please try again",
830
- type: "error"
831
- });
832
- } finally {
833
- d.value = !1;
834
- }
835
- }
836
- function y() {
837
- var w, x;
838
- (x = (w = U.value) == null ? void 0 : w.validateInputs) == null || x.call(w);
839
- }
840
- function L() {
841
- switch (F.mode) {
842
- case M.READ:
843
- return;
844
- case M.UPDATE:
845
- return i();
846
- case M.CREATE:
847
- return h();
848
- }
849
- }
850
- return (w, x) => {
851
- const E = b("FmButton"), I = b("FmSideSheet");
852
- return S(), B(I, {
853
- "model-value": m(o),
854
- "onUpdate:modelValue": x[3] || (x[3] = (R) => be(o) ? o.value = R : null),
855
- header: f.value,
856
- "close-button": "",
857
- "dismiss-away": "",
858
- "max-width": 500
859
- }, {
860
- "side-sheet-footer": v(() => [
861
- a("div", Et, [
862
- r(E, {
863
- loading: d.value,
864
- label: C.value,
865
- onClick: y
866
- }, null, 8, ["loading", "label"]),
867
- r(E, {
868
- disabled: d.value,
869
- label: "Close",
870
- variant: "tertiary",
871
- onClick: x[2] || (x[2] = (R) => o.value = !1)
872
- }, null, 8, ["disabled"])
873
- ])
874
- ]),
875
- default: v(() => [
876
- r(Rt, {
877
- class: "w-full",
878
- ref_key: "hasValidationExpose",
879
- ref: U,
880
- modelValue: m(s),
881
- "onUpdate:modelValue": x[0] || (x[0] = (R) => be(s) ? s.value = R : null),
882
- mode: w.mode,
883
- disabled: d.value,
884
- "onClick:submit": x[1] || (x[1] = (R) => L())
885
- }, null, 8, ["modelValue", "mode", "disabled"])
886
- ]),
887
- _: 1
888
- }, 8, ["model-value", "header"]);
889
- };
890
- }
891
- }), $t = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Tt = { class: "px-8 flex items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, Pt = { class: "flex-1 w-full" }, Bt = { class: "flex flex-col py-8" }, Lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ot = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ll = /* @__PURE__ */ ae({
892
- __name: "IngredientsView",
893
- setup(A) {
894
- const F = se(), V = c(() => F.skus), l = ze(), {
895
- createIngredient: o,
896
- updateIngredient: s,
897
- deleteIngredient: f,
898
- ingredientDialogProps: C,
899
- ingredientViewLoading: U
900
- } = ot(), { columnDefs: d } = at({ updateIngredient: s, deleteIngredient: f });
901
- function h(E) {
902
- E === "add" && o();
903
- }
904
- const i = z(""), y = c(() => U.value), { breakpoints: L } = We(), w = c(() => L.value.xs || L.value.sm ? 10 : 20), x = Ke();
905
- return (E, I) => {
906
- const R = b("FmTableToolbar"), X = b("FmTable");
907
- return S(), B(Je, {
908
- title: "Ingredient",
909
- actions: [{ label: "Add ingredient", value: "add", isPrimary: !0, prependIcon: "add" }],
910
- "onClick:action": h
911
- }, {
912
- default: v(() => [
913
- a("div", $t, [
914
- a("div", Tt, [
915
- a("div", Pt, [
916
- r(R, {
917
- searchable: "",
918
- "search-model": i.value,
919
- "onUpdate:searchModel": I[0] || (I[0] = (D) => i.value = D)
920
- }, null, 8, ["search-model"])
921
- ])
922
- ]),
923
- r(X, {
924
- style: Te(m(x).tableHeight),
925
- "column-defs": m(d),
926
- "row-data": V.value,
927
- "search-value": i.value,
928
- loading: !m(l)._currentLocation || y.value,
929
- onRowClick: I[1] || (I[1] = (D) => m(s)(D.original)),
930
- "page-size": w.value
931
- }, {
932
- "list-row": v((D) => [
933
- r(je, {
934
- row: D,
935
- onRowClick: m(s)
936
- }, {
937
- default: v(($) => {
938
- var q, H, j, W, Z, ee, K, te, O, N;
939
- return [
940
- a("div", Bt, [
941
- a("div", Lt, [
942
- r(m(Ce), {
943
- render: (j = (H = (q = $.code) == null ? void 0 : q.column) == null ? void 0 : H.columnDef) == null ? void 0 : j.cell,
944
- props: (Z = (W = $.code) == null ? void 0 : W.getContext) == null ? void 0 : Z.call(W)
945
- }, null, 8, ["render", "props"])
946
- ]),
947
- a("div", Ot, [
948
- r(m(Ce), {
949
- render: (te = (K = (ee = $.name) == null ? void 0 : ee.column) == null ? void 0 : K.columnDef) == null ? void 0 : te.cell,
950
- props: (N = (O = $.name) == null ? void 0 : O.getContext) == null ? void 0 : N.call(O)
951
- }, null, 8, ["render", "props"])
952
- ])
953
- ])
954
- ];
955
- }),
956
- _: 2
957
- }, 1032, ["row", "onRowClick"])
958
- ]),
959
- _: 1
960
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
961
- ]),
962
- (S(), B(Pe, { to: "body" }, [
963
- r(Dt, Be(Le(m(C))), null, 16)
964
- ]))
965
- ]),
966
- _: 1
967
- });
968
- };
969
- }
970
- });
971
- export {
972
- ll as default
973
- };