@feedmepos/mf-menu 0.31.42-prod → 0.31.43-prod

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 (67) hide show
  1. package/dist/{App-2JChZsbD.js → App-DudzVdxN.js} +8 -8
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-D2LLOZrw.js → ApplyProduct.vue_vue_type_script_setup_true_lang-Cx6BY_nW.js} +3 -3
  3. package/dist/{Catalog-BmiGl1s_.js → Catalog-BMuTQtqx.js} +6 -6
  4. package/dist/{Category-BV4b15dp.js → Category-CUZ_xxMs.js} +4 -4
  5. package/dist/{Category-C4aYzE74.js → Category-NDkmqvdw.js} +6 -6
  6. package/dist/{CookingGuide-CcdqS3EL.js → CookingGuide-3SgKZVRT.js} +4 -4
  7. package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-Brcc_WN7.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-FuOBls0m.js} +1 -1
  8. package/dist/{Group-DYnOQq0q.js → Group-ClTlb1X2.js} +1 -1
  9. package/dist/{Group-DTRgvVko.js → Group-CvUWYuaR.js} +3 -3
  10. package/dist/{Group.vue_vue_type_script_setup_true_lang-BJiPe3tH.js → Group.vue_vue_type_script_setup_true_lang-jbtZjvRL.js} +7 -7
  11. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BBeDpoKA.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-C_nvZOlm.js} +5 -5
  12. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Do-V1ceo.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-BiwIRHka.js} +15325 -15684
  13. package/dist/{Ingredient-BGRNUHBO.js → Ingredient-C3a4gt_G.js} +3 -3
  14. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-B8UmHWQq.js → InventoryBinding.vue_vue_type_script_setup_true_lang-CYoMl-_4.js} +1052 -1052
  15. package/dist/{LinkProductSideSheet-zAHlypah.js → LinkProductSideSheet-4GgEt5LN.js} +3 -3
  16. package/dist/{MenuSetting-CJb8sWNZ.js → MenuSetting-DMDHHBs2.js} +5 -5
  17. package/dist/{PrintRoute-nSaHp9qi.js → PrintRoute-D8mE_R6M.js} +4 -4
  18. package/dist/{Product-BULdwb1Q.js → Product-B7oT5kJ6.js} +1 -1
  19. package/dist/{Product.vue_vue_type_script_setup_true_lang-CBh0gBr2.js → Product.vue_vue_type_script_setup_true_lang-CUn6_bGq.js} +13 -13
  20. package/dist/{ProductInternalTools-CPDtesKz.js → ProductInternalTools-BPnnO5dR.js} +5 -5
  21. package/dist/Products-iYZPVp8Y.js +675 -0
  22. package/dist/{Publish-DHIlFwkI.js → Publish-BCFYIz0P.js} +3 -3
  23. package/dist/{Recipe-CldQTZfD.js → Recipe-Be6kHRWd.js} +4 -4
  24. package/dist/{Scheduler-DHQiJk0r.js → Scheduler-DTULqkZU.js} +3 -3
  25. package/dist/{ServingSequence-HAF3-DVb.js → ServingSequence-1B2t3IOz.js} +3 -3
  26. package/dist/{Setting-C0tsedhx.js → Setting-Bfx_kAhO.js} +5 -5
  27. package/dist/{Subcategory-DeUrA-yT.js → Subcategory-CspNxL0A.js} +4 -4
  28. package/dist/{Takeaway-BAl6SWU-.js → Takeaway-8ZrctPk8.js} +4 -4
  29. package/dist/{Takeaway-CnqY1GJT.js → Takeaway-DS9QWvP4.js} +1 -1
  30. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-BLIT_vSE.js → Takeaway.vue_vue_type_script_setup_true_lang-DPtA07uy.js} +5 -5
  31. package/dist/{Thumbnail.vue_vue_type_script_setup_true_lang-CTXytwNl.js → Thumbnail.vue_vue_type_script_setup_true_lang-CdaiLu5o.js} +4 -4
  32. package/dist/{TreeEditorOpenner.vue_vue_type_script_setup_true_lang-DC64EAri.js → TreeEditorOpenner.vue_vue_type_script_setup_true_lang-C39Fg0ZP.js} +14 -14
  33. package/dist/{Unit-BNghOE-p.js → Unit-qDXlKpxA.js} +2 -2
  34. package/dist/{Variant-BJgWQnCr.js → Variant-tGw0WZcw.js} +3 -3
  35. package/dist/{_id_-DyxLgR7H.js → _id_-nUIFi5Lq.js} +10 -10
  36. package/dist/{app-CUB5WG-_.js → app-B-AEzoH6.js} +1 -1
  37. package/dist/{app-BrdLq53I.js → app-BPqH1NSp.js} +25 -25
  38. package/dist/app.js +1 -1
  39. package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +123 -0
  40. package/dist/apps/mf-menu/src/helper/menuExport.d.ts +32 -0
  41. package/dist/apps/mf-menu/src/helper/{import-export.d.ts → menuImport.d.ts} +3 -127
  42. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/assets/{linked-status-Dydn-qHJ.js → linked-status-CXZIhnqe.js} +2 -2
  44. package/dist/assets/{override-menu-BZxKccD-.js → override-menu-xw0Dqkm6.js} +2 -2
  45. package/dist/assets/{validate-menu-yzthJ_kL.js → validate-menu-ByQAWT_D.js} +2 -2
  46. package/dist/{catalog-D_-zPbeP.js → catalog-DLqIkhbq.js} +1 -1
  47. package/dist/{catalogSetting-DYqtFHuW.js → catalogSetting-CD1xVSYG.js} +1 -1
  48. package/dist/{category-Ds6mhoE_.js → category-CrJofVZH.js} +1 -1
  49. package/dist/{currency-D0LVH4Rm.js → currency-DvON4euj.js} +1 -1
  50. package/dist/{customAttributes-B0VHSDMv.js → customAttributes-C81bk6Ag.js} +1 -1
  51. package/dist/{dayjs.min-Dv2twIbC.js → dayjs.min-DkxnzHIf.js} +1 -1
  52. package/dist/{index-DZ46q9oh.js → index-Bi-tjPhn.js} +1 -1
  53. package/dist/{index-BHoiDppz.js → index-DoMiLJrG.js} +3 -3
  54. package/dist/{index-DKi3mpaS.js → index-Y2Y_5NeG.js} +1 -1
  55. package/dist/{index-N5K98R3Q.js → index-k8JBMmlm.js} +4 -4
  56. package/dist/{item-C8iSUmWK.js → item-BI77lImE.js} +16 -16
  57. package/dist/{jszip.min-ubvTgNXq.js → jszip.min-K1Xi3iCG.js} +689 -689
  58. package/dist/{menu-Cvzv8myY.js → menu-Cg_li9fp.js} +5 -5
  59. package/dist/{menu-CdKiY8ht.js → menu-v8tF5owz.js} +1 -1
  60. package/dist/{menuV2-h9I06V2J.js → menuV2-BmOhyQh2.js} +46 -46
  61. package/dist/{priceTier-B_8G5Phm.js → priceTier-D89QKPQZ.js} +1 -1
  62. package/dist/{scheduler-C7YXb2vA.js → scheduler-CFnDK-I3.js} +4 -4
  63. package/dist/{subcategory-BoSu3WbF.js → subcategory-CyIY_sdl.js} +2 -2
  64. package/dist/{toExcel-Da46LGX1.js → toExcel-DIGelQ9s.js} +2 -2
  65. package/dist/{unit-a1gpxhcI.js → unit-Bk_zO_6l.js} +2 -2
  66. package/package.json +2 -2
  67. package/dist/Products-B_VJPTVs.js +0 -286
@@ -0,0 +1,675 @@
1
+ var le = Object.defineProperty;
2
+ var ue = (x, e, i) => e in x ? le(x, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : x[e] = i;
3
+ var $ = (x, e, i) => ue(x, typeof e != "symbol" ? e + "" : e, i);
4
+ import { defineComponent as W, computed as S, ref as te, resolveComponent as G, createBlock as D, openBlock as E, unref as l, withCtx as I, createElementVNode as M, toDisplayString as oe, createVNode as _, createCommentVNode as ae, createElementBlock as j, Fragment as B } from "vue";
5
+ import { D as K } from "./dayjs.min-DkxnzHIf.js";
6
+ import { m as R, A as P, f as y, a as H, b as L, e as A, n as O, w as de } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-BiwIRHka.js";
7
+ import { J as pe, F as fe } from "./jszip.min-K1Xi3iCG.js";
8
+ import { u as ne, G as re, B as J, e as z, A as ie, D as he, H as q, I as X } from "./menu-Cg_li9fp.js";
9
+ import { useCoreStore as be, useI18n as ye } from "@feedmepos/mf-common";
10
+ import { useDialog as se, useDialogChild as ge, useSnackbar as ce, useBreakpoints as _e, FmButtonVariant as U, FmButtonColorThemeVariant as N } from "@feedmepos/ui-library";
11
+ import { _ as Y } from "./ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js";
12
+ import { _ as ke, a as Z } from "./BottomSheetMenuItem.vue_vue_type_script_setup_true_lang-DhrXKy3b.js";
13
+ import { _ as ve } from "./PageLayout.vue_vue_type_script_setup_true_lang-2f0QfweQ.js";
14
+ import { u as we, a as xe } from "./menu-v8tF5owz.js";
15
+ import { u as Fe } from "./item-BI77lImE.js";
16
+ import { _ as Q, a as Ce } from "./Product.vue_vue_type_script_setup_true_lang-CUn6_bGq.js";
17
+ import { L as ee } from "./LinkProductSideSheet-4GgEt5LN.js";
18
+ import { _ as Me } from "./TreeEditorOpenner.vue_vue_type_script_setup_true_lang-C39Fg0ZP.js";
19
+ import { u as Ie } from "./Thumbnail.vue_vue_type_script_setup_true_lang-CdaiLu5o.js";
20
+ import { m as Ee } from "./toExcel-DIGelQ9s.js";
21
+ const Te = { class: "space-y-24 mb-24" }, Se = ["innerHTML"], De = { class: "flex justify-end gap-8" }, Ne = /* @__PURE__ */ W({
22
+ __name: "ConfirmActionDialog",
23
+ props: {
24
+ description: {},
25
+ value: {},
26
+ message: { default: "To confirm your action, type <b>[[value]]</b> in the text field." }
27
+ },
28
+ setup(x) {
29
+ const e = x, i = S(() => e.message.replace("[[value]]", e.value)), a = te(""), t = se(), { emitAction: n } = ge();
30
+ return (r, o) => {
31
+ const c = G("FmTextField"), s = G("FmButton"), u = G("FmForm");
32
+ return E(), D(u, {
33
+ "on-validation-success": () => l(n)("primary"),
34
+ "blame-form-child-on-validation-failed": ""
35
+ }, {
36
+ default: I(() => [
37
+ M("div", Te, [
38
+ M("div", null, oe(r.description), 1),
39
+ M("div", { innerHTML: i.value }, null, 8, Se),
40
+ M("div", null, [
41
+ _(c, {
42
+ modelValue: a.value,
43
+ "onUpdate:modelValue": [
44
+ o[0] || (o[0] = (m) => a.value = m),
45
+ o[1] || (o[1] = () => {
46
+ })
47
+ ],
48
+ placeholder: r.value,
49
+ rules: [(m) => m === r.value || "Value does not match"]
50
+ }, null, 8, ["modelValue", "placeholder", "rules"])
51
+ ]),
52
+ M("div", De, [
53
+ _(s, {
54
+ label: "Cancel",
55
+ variant: "secondary",
56
+ onClick: o[2] || (o[2] = (m) => l(t).close())
57
+ }),
58
+ _(s, {
59
+ label: "Confirm",
60
+ type: "submit"
61
+ })
62
+ ])
63
+ ])
64
+ ]),
65
+ _: 1
66
+ }, 8, ["on-validation-success"]);
67
+ };
68
+ }
69
+ }), Ke = /* @__PURE__ */ W({
70
+ __name: "Migrate",
71
+ setup(x) {
72
+ const e = ne(), i = be(), a = ce(), { minor: t } = re(a), n = te(!1), r = se();
73
+ async function o() {
74
+ c.value || n.value || r.open({
75
+ title: "Migrate to new version",
76
+ contentComponent: Ne,
77
+ contentComponentProps: {
78
+ value: "MIGRATE",
79
+ description: "Do you want to migrate to new version? Once migrate it will unable to revert to the older version."
80
+ }
81
+ }).onPrimary(async () => {
82
+ r.close(), await t(
83
+ async () => {
84
+ await e.migrate(), setTimeout(() => {
85
+ window.location.reload();
86
+ }, 2e3);
87
+ },
88
+ {
89
+ isLoading: n,
90
+ customId: e.state.menu._id,
91
+ message: "Migrating menu",
92
+ successMessage: "Migration completed"
93
+ }
94
+ );
95
+ });
96
+ }
97
+ const c = S(() => {
98
+ const s = i.restaurants.value;
99
+ if (!s.length) return "Required at least one restaurant to migrate";
100
+ const u = s.filter((d) => !d.posVersion || !J.Pos.canUse({ feature: z.F_FEATURE.enum.menuV4, posVersion: d.posVersion }));
101
+ return u.length ? `Upgrade POS to V${J.Pos.minVersionToUse(z.F_FEATURE.enum.menuV4)} to use new menu: ${u.map((d) => d.profile.name).join(", ")}` : null;
102
+ });
103
+ return S(() => c.value ? c.value : "Migrate your menu to new version to enjoy more features. Content of new menu will remain the same as current."), (s, u) => {
104
+ const m = G("FmSnackbar");
105
+ return !c.value && l(e).version !== l(ie.F_MENU_VERSION).enum.v4 ? (E(), D(m, {
106
+ key: 0,
107
+ class: "!max-w-full",
108
+ title: "New version of menu is out now!",
109
+ description: "Migrate your current menu version to the latest to enjoy more features such as product sequential dispatch, serving sequence, scheduler and more! Your content and current setting will be preserved.",
110
+ variant: "info",
111
+ action: "Migrate",
112
+ "z-index": 0,
113
+ onOnAction: o
114
+ })) : ae("", !0);
115
+ };
116
+ }
117
+ });
118
+ class Ge {
119
+ constructor(e) {
120
+ $(this, "menu");
121
+ $(this, "categoryMap");
122
+ $(this, "takeawayMap");
123
+ this.menu = e, this.categoryMap = e.modules.category.reduce((i, a) => (i[a._id] = a, i), {}), this.takeawayMap = e.modules.takeaway.reduce((i, a) => (i[a._id] = a, i), {});
124
+ }
125
+ transformData() {
126
+ let e = [], i = [];
127
+ return this.menu.modules.item.forEach((a) => {
128
+ var c;
129
+ const t = a.variant ? R(this.menu, a.variant.variantGroupIds) : {}, n = this.transformProductToDataRow(a, t), o = (((c = a.variant) == null ? void 0 : c.variantCombinations) ?? []).reduce(
130
+ (s, u) => {
131
+ const m = this.transformProductToDataRow(
132
+ a,
133
+ t,
134
+ u.combinationKey
135
+ );
136
+ return s.push(m), s;
137
+ },
138
+ [n]
139
+ );
140
+ i = [...i, ...o.flatMap((s) => Object.keys(s.tag))], e = [...e, ...o];
141
+ }), {
142
+ rows: e,
143
+ metaData: {
144
+ tags: [...new Set(i)],
145
+ priceTiers: []
146
+ }
147
+ };
148
+ }
149
+ transformOverrideData(e) {
150
+ let i = [], a = [], t = [];
151
+ const n = e.reduce(
152
+ (r, o) => (r[o._id] || (r[o._id] = []), o.combinationKey && r[o._id].push(o.combinationKey), r),
153
+ {}
154
+ );
155
+ for (let r = 0; r < e.length; r++) {
156
+ const o = e[r], c = this.menu.modules.item.find((s) => s._id === o._id);
157
+ if (c && c.variant) {
158
+ const s = c.variant.variantCombinations.map(
159
+ (p) => p.combinationKey
160
+ ), u = n[o._id] || [], m = s.filter((p) => !u.includes(p)), d = [];
161
+ if (m.forEach((p) => {
162
+ const k = c.variant.variantCombinations.find(
163
+ (b) => b.combinationKey === p
164
+ );
165
+ k && (d.push({
166
+ _id: o._id,
167
+ combinationKey: p,
168
+ price: k.price,
169
+ orderFrom: k.orderFrom
170
+ }), n[o._id].push(p));
171
+ }), d.length > 0) {
172
+ const p = e.findIndex((b) => b._id === o._id && !b.combinationKey), k = p >= 0 ? p + 1 : r + 1;
173
+ e.splice(k, 0, ...d), r += d.length;
174
+ }
175
+ }
176
+ }
177
+ for (let r = 0; r < e.length; r++) {
178
+ const o = e[r], c = this.menu.modules.item.find((d) => d._id === o._id);
179
+ if (!c)
180
+ throw new Error(`Invalid item ${o._id} in catalog`);
181
+ const s = c.variant ? R(this.menu, c.variant.variantGroupIds) : {}, m = [this.transformOverrideDataToRow(o, s)];
182
+ t = [...t, ...m.flatMap((d) => Object.keys(d.priceTier))], a = [...a, ...m.flatMap((d) => Object.keys(d.tag))], i = [...i, ...m];
183
+ }
184
+ return {
185
+ rows: i,
186
+ metaData: {
187
+ tags: [...new Set(a)],
188
+ priceTiers: []
189
+ }
190
+ };
191
+ }
192
+ transformProductToDataRow(e, i, a) {
193
+ var o, c, s;
194
+ const t = (o = e.variant) == null ? void 0 : o.variantCombinations.find(
195
+ (u) => u.combinationKey === a
196
+ );
197
+ if (a && !t)
198
+ throw new Error(`Invalid combination key ${a}`);
199
+ const n = e.category ? (c = this.categoryMap[e.category]) == null ? void 0 : c.name : P;
200
+ let r;
201
+ if (t ? r = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0 : r = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0, !n)
202
+ throw new Error(`Invalid category ${e.category}`);
203
+ return {
204
+ _id: e._id,
205
+ code: t && t.code || e.code,
206
+ name: e.name,
207
+ variantKey: (t == null ? void 0 : t.combinationKey) ?? "",
208
+ variantName: t ? i[t.combinationKey] : "",
209
+ category: n,
210
+ orderFrom: t ? t.orderFrom ?? e.orderFrom : e.orderFrom,
211
+ perXUnit: e.perXUnit || "",
212
+ unit: e.unit || "",
213
+ openPrice: e.openPrice === !0 ? "T" : "",
214
+ price: t ? t.price ? parseFloat(y(t.price)) : parseFloat(y(e.price)) : parseFloat(y(e.price)),
215
+ priceTier: e.priceTiers || {},
216
+ trackingCost: e.costing ? parseFloat(y(e.costing)) : "",
217
+ minPrice: e.minPrice ? parseFloat(y(e.minPrice)) : "",
218
+ groupByParent: ((s = e.print) == null ? void 0 : s.toRoot) === !0 ? "" : "T",
219
+ takeawayName: (r == null ? void 0 : r.name) || "",
220
+ takeawayPrice: r != null && r.price ? parseFloat(y(r == null ? void 0 : r.price)) : "",
221
+ tag: e.customAttributes || {}
222
+ };
223
+ }
224
+ transformOverrideDataToRow(e, i, a) {
225
+ var c, s;
226
+ const t = this.menu.modules.item.find((u) => u._id === e._id);
227
+ if (!t)
228
+ throw new Error(`Invalid item ${e._id} in catelog`);
229
+ const n = (c = t.variant) == null ? void 0 : c.variantCombinations.find(
230
+ (u) => u.combinationKey === e.combinationKey
231
+ );
232
+ if (a && !n)
233
+ throw new Error(`Invalid combination key ${a}`);
234
+ const r = () => {
235
+ var u, m;
236
+ return e.category ? e.category ? (m = this.categoryMap[e.category]) == null ? void 0 : m.name : P : t.category ? (u = this.categoryMap[t.category]) == null ? void 0 : u.name : P;
237
+ };
238
+ let o;
239
+ return n ? e.takeawayUsed ? o = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : o = n.takeawayUsed ? this.takeawayMap[n.takeawayUsed] : void 0 : e.takeawayUsed ? o = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : o = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0, {
240
+ _id: e._id,
241
+ code: e.code ? e.code : n && n.code || t.code,
242
+ name: t.name,
243
+ variantKey: e.combinationKey ? e.combinationKey : (n == null ? void 0 : n.combinationKey) ?? "",
244
+ variantName: n ? i[n.combinationKey] : "",
245
+ category: r(),
246
+ orderFrom: e.orderFrom ? e.orderFrom : n ? n.orderFrom ?? t.orderFrom : t.orderFrom,
247
+ perXUnit: t.perXUnit || "",
248
+ unit: t.unit || "",
249
+ openPrice: t.openPrice === !0 ? "T" : "",
250
+ price: e.price ? parseFloat(y(e.price)) : n ? n.price ? parseFloat(y(n.price)) : parseFloat(y(t.price)) : parseFloat(y(t.price)),
251
+ priceTier: t.priceTiers || {},
252
+ trackingCost: t.costing ? parseFloat(y(t.costing)) : "",
253
+ minPrice: e.minPrice ? parseFloat(y(e.minPrice)) : t.minPrice ? parseFloat(y(t.minPrice)) : "",
254
+ groupByParent: ((s = t.print) == null ? void 0 : s.toRoot) === !0 ? "" : "T",
255
+ takeawayName: (o == null ? void 0 : o.name) || "",
256
+ takeawayPrice: o != null && o.price ? parseFloat(y(o == null ? void 0 : o.price)) : "",
257
+ tag: t.customAttributes || {}
258
+ };
259
+ }
260
+ transformAddonGroup() {
261
+ return this.mapAddonGroup(this.menu.modules.group);
262
+ }
263
+ transformOverrideAddonGroup(e) {
264
+ return this.mapCatalogAddonGroup(e);
265
+ }
266
+ mapCatalogAddonGroup(e) {
267
+ const i = this.menu.modules.group.map((t) => t._id), a = e.map((t) => t._id);
268
+ return i.forEach((t) => {
269
+ if (!a.includes(t)) {
270
+ const n = this.menu.modules.group.find((r) => r._id === t);
271
+ e.push({
272
+ ...n,
273
+ groupKey: ""
274
+ });
275
+ }
276
+ }), e.sort((t, n) => i.indexOf(t._id) - i.indexOf(n._id)), e.flatMap((t) => {
277
+ const n = this.menu.modules.group.find((o) => o._id === t._id);
278
+ if (!n)
279
+ throw new Error("Invalid addon group id");
280
+ const r = {};
281
+ return n.items.map((o, c) => {
282
+ var b, w, F;
283
+ const s = this.menu.modules.item.find((g) => g._id === o._id);
284
+ if (!s)
285
+ throw new Error("Invalid item id");
286
+ let u;
287
+ o.combinationKey && (u = (b = s.variant) == null ? void 0 : b.variantCombinations.find(
288
+ (g) => g.combinationKey === o.combinationKey
289
+ ));
290
+ const m = (w = t.items) == null ? void 0 : w.find(
291
+ (g) => g._id === o._id && g.combinationKey === o.combinationKey
292
+ ), d = s.name, p = R(
293
+ this.menu,
294
+ ((F = s.variant) == null ? void 0 : F.variantGroupIds) ?? []
295
+ ), k = (m == null ? void 0 : m.price) ?? o.price ?? (u == null ? void 0 : u.price) ?? s.price;
296
+ return o.name && !o.combinationKey && (r[o._id] = o.name), {
297
+ id: t._id,
298
+ name: n.name,
299
+ min: n.min,
300
+ max: n.max,
301
+ stackable: n.stackable === !0 ? "T" : "",
302
+ itemId: o._id,
303
+ itemCode: s.code || "",
304
+ itemName: d,
305
+ itemNameOverrider: r[o._id] || "",
306
+ combinationKey: o.combinationKey ?? "",
307
+ combinationName: o.combinationKey ? p[o.combinationKey] : "",
308
+ price: parseFloat(y(k)),
309
+ priceTier: o.priceTiers || {},
310
+ orderFrom: (m == null ? void 0 : m.orderFrom) ?? o.orderFrom ?? s.orderFrom ?? "ALL",
311
+ isDefault: o.isDefault === !0 ? "T" : "",
312
+ index: c
313
+ };
314
+ });
315
+ });
316
+ }
317
+ mapAddonGroup(e) {
318
+ return e.flatMap((i) => {
319
+ let a = {};
320
+ return a = i.items.reduce((t, n) => (t[n._id] || n.name && !n.combinationKey && (t[n._id] = n.name), t), {}), i.items.map((t, n) => {
321
+ var u, m;
322
+ const r = this.menu.modules.item.find((d) => d._id === t._id);
323
+ if (!r)
324
+ throw new Error("Invalid item id");
325
+ let o;
326
+ t.combinationKey && (o = (u = r.variant) == null ? void 0 : u.variantCombinations.find(
327
+ (d) => d.combinationKey === t.combinationKey
328
+ ));
329
+ const c = t.price ?? (o == null ? void 0 : o.price) ?? r.price, s = R(
330
+ this.menu,
331
+ ((m = r.variant) == null ? void 0 : m.variantGroupIds) ?? []
332
+ );
333
+ return {
334
+ id: i._id,
335
+ name: i.name,
336
+ min: i.min,
337
+ max: i.max,
338
+ stackable: i.stackable === !0 ? "T" : "",
339
+ itemId: t._id,
340
+ itemCode: r.code || "",
341
+ itemName: r.name,
342
+ itemNameOverrider: a[t._id] || "",
343
+ combinationKey: t.combinationKey ?? "",
344
+ combinationName: t.combinationKey ? s[t.combinationKey] : "",
345
+ price: parseFloat(y(c)),
346
+ priceTier: t.priceTiers || {},
347
+ orderFrom: t.orderFrom ?? r.orderFrom,
348
+ isDefault: t.isDefault === !0 ? "T" : "",
349
+ index: n
350
+ };
351
+ });
352
+ });
353
+ }
354
+ transformItemsLinkWithGroup() {
355
+ const e = {}, i = this.menu.modules.item.reduce((a, t) => (a[t._id] = {
356
+ itemId: t._id,
357
+ itemName: t.name,
358
+ defaultCatalog: ""
359
+ }, a), {});
360
+ return this.menu.modules.group.forEach((a) => {
361
+ e[a._id] = JSON.parse(JSON.stringify(i));
362
+ }), this.menu.modules.item.forEach((a) => {
363
+ a.groups.length > 0 && a.groups.forEach((t) => {
364
+ e[t._id][a._id] = {
365
+ ...e[t._id][a._id],
366
+ defaultCatalog: "T"
367
+ };
368
+ });
369
+ }), e;
370
+ }
371
+ exportToExcel() {
372
+ var k;
373
+ const e = [], { rows: i, metaData: a } = this.transformData();
374
+ a.priceTiers = ((k = this.menu.priceTierSettings) == null ? void 0 : k.map((b) => b.key)) || [];
375
+ const t = i.map(({ priceTier: b, tag: w, ...F }) => {
376
+ const g = Object.entries(F), C = g.findIndex(([h]) => h === "price");
377
+ return [
378
+ ...g.slice(0, C + 1).map(([, h]) => h),
379
+ ...a.priceTiers.map(
380
+ (h) => parseFloat(y(b[h])) || ""
381
+ ),
382
+ ...g.slice(C + 1).map(([, h]) => h),
383
+ ...a.tags.map((h) => w[h] || "")
384
+ ];
385
+ }), n = this.createWorkbookExcelJS(
386
+ t,
387
+ "Default Catalog",
388
+ this.exportCatalogToExcelExcelJS()
389
+ ), r = n.worksheets[0];
390
+ H(r, a.tags, a.priceTiers), this.formatWorkbookCell(n);
391
+ const c = this.transformAddonGroup().map(({ priceTier: b, ...w }) => {
392
+ const { index: F, ...g } = w, C = Object.entries(g), h = C.findIndex(([f]) => f === "price");
393
+ return [
394
+ ...C.slice(0, h + 1).map(([, f]) => f),
395
+ ...a.priceTiers.map(
396
+ (f) => parseFloat(y(b[f])) || ""
397
+ ),
398
+ ...C.slice(h + 1).map(([, f]) => f)
399
+ ];
400
+ }), s = this.createWorkbookExcelJS(
401
+ c,
402
+ "Default AddonGroup",
403
+ this.exportCatalogAddonToExcelExcelJS()
404
+ ), u = s.worksheets[0];
405
+ L(u, a.priceTiers), this.formatWorkbookCell(s);
406
+ const m = this.transformItemsLinkWithGroup(), d = Object.keys(m), p = new A.Workbook();
407
+ if (d.length > 0)
408
+ d.forEach((b, w) => {
409
+ const F = Object.values(m[b]), g = this.menu.modules.group.find((f) => f._id === b);
410
+ if (!g) throw new Error(`Group not found for id: ${b}`);
411
+ const C = O(`${w + 1}. ${g.name}`), h = p.addWorksheet(C);
412
+ h.columns = [
413
+ { header: "Group ID", key: "groupId" },
414
+ { header: "Item ID", key: "itemId" },
415
+ { header: "Item Name", key: "itemName" },
416
+ { header: "Default Catalog", key: "defaultCatalog" }
417
+ ], F.forEach((f) => {
418
+ h.addRow({
419
+ groupId: b,
420
+ itemId: f.itemId,
421
+ itemName: f.itemName,
422
+ defaultCatalog: f.defaultCatalog
423
+ });
424
+ });
425
+ });
426
+ else {
427
+ const b = p.addWorksheet("Group Name");
428
+ b.columns = [
429
+ { header: "Group ID", key: "groupId" },
430
+ { header: "Item ID", key: "itemId" },
431
+ { header: "Item Name", key: "itemName" },
432
+ { header: "Default Catalog", key: "defaultCatalog" }
433
+ ];
434
+ }
435
+ return this.formatWorkbookCell(p), e.push(n, s, p), e;
436
+ }
437
+ createWorkbookExcelJS(e, i, a) {
438
+ const t = new A.Workbook(), n = t.addWorksheet(i);
439
+ return e.forEach((r) => {
440
+ n.addRow(r);
441
+ }), a && a.worksheets.forEach((r) => {
442
+ const o = t.addWorksheet(r.name);
443
+ r.eachRow({ includeEmpty: !0 }, (c) => {
444
+ const s = c.values;
445
+ o.addRow(s.slice(1));
446
+ });
447
+ }), t;
448
+ }
449
+ formatWorkbookCell(e) {
450
+ e.eachSheet((i) => {
451
+ i.eachRow({ includeEmpty: !0 }, (t) => {
452
+ t.eachCell({ includeEmpty: !0 }, (n) => {
453
+ n.font = {
454
+ name: "Calibri",
455
+ size: 12
456
+ }, t.number === 1 && (n.fill = {
457
+ type: "pattern",
458
+ pattern: "solid",
459
+ fgColor: { argb: "FABF8F" }
460
+ }, n.alignment = { horizontal: "center", vertical: "middle" });
461
+ });
462
+ });
463
+ const a = i.getRow(1);
464
+ i.autoFilter = {
465
+ from: {
466
+ row: 1,
467
+ column: 1
468
+ },
469
+ to: {
470
+ row: 1,
471
+ column: a.cellCount
472
+ }
473
+ };
474
+ });
475
+ }
476
+ exportCatalogToExcelExcelJS() {
477
+ const e = new A.Workbook();
478
+ return this.menu.modules.catalog.forEach((i) => {
479
+ const a = Object.values(i.override.items).flatMap((s) => s), { rows: t, metaData: n } = this.transformOverrideData(a), r = t.map(({ priceTier: s, tag: u, ...m }) => [
480
+ ...Object.entries(m).map(([, p]) => p),
481
+ ...n.tags.map((p) => u[p] || "")
482
+ ]), o = O(i.name), c = e.addWorksheet(o);
483
+ r.forEach((s) => {
484
+ c.addRow(s);
485
+ }), H(c, n.tags, n.priceTiers, i);
486
+ }), e;
487
+ }
488
+ exportCatalogAddonToExcelExcelJS() {
489
+ const e = new A.Workbook();
490
+ return this.menu.modules.catalog.forEach((i) => {
491
+ const a = Object.values(i.override.groups).flatMap(
492
+ (c) => c
493
+ ), n = this.transformOverrideAddonGroup(a).map(({ priceTier: c, ...s }) => {
494
+ const { index: u, ...m } = s;
495
+ return [...Object.entries(m).map(([, p]) => p)];
496
+ }), r = O(i.name), o = e.addWorksheet(r);
497
+ n.forEach((c) => {
498
+ o.addRow(c);
499
+ }), L(o);
500
+ }), e;
501
+ }
502
+ }
503
+ const Ve = { class: "flex-1 flex justify-between gap-8 pl-8" }, $e = { class: "flex items-center" }, Re = { class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4" }, Ae = { class: "fm-typo-en-body-md-600 font-semibold" }, Pe = { class: "flex gap-8" }, nt = /* @__PURE__ */ W({
504
+ __name: "Products",
505
+ setup(x) {
506
+ const { t: e } = ye(), i = re(ce()), a = ne(), t = S(() => a.rules.item), n = Fe(), r = S(() => !a.state.currentSchedulerId), { selectedCategories: o } = we(), c = S(() => ({
507
+ ...he.menuV4ToV3(q(a.state.menu)),
508
+ _id: a.state.menu._id,
509
+ _rev: a.state.menu._rev
510
+ })), s = S(() => {
511
+ const h = X.flatten(o.value.map((f) => f.items));
512
+ return X.uniqBy(h, (f) => f._id).length;
513
+ });
514
+ async function u(h, f) {
515
+ const T = new pe();
516
+ for (let V = 0; V < h.length; V++) {
517
+ const me = await h[V].xlsx.writeBuffer();
518
+ T.file(`${f[V]}.xlsx`, me);
519
+ }
520
+ const v = await T.generateAsync({ type: "blob" });
521
+ fe.saveAs(v, `books_${K().format("DD-MM-YYYY_HH-mm")}.zip`);
522
+ }
523
+ async function m() {
524
+ await i.minor(
525
+ async () => {
526
+ if (await a.readMenu(), a.version === ie.F_MENU_VERSION.enum.v4) {
527
+ const h = q(a.state.menu), f = new Ge(h).exportToExcel(), T = [
528
+ `menu_${K().format("DD-MM-YYYY_HH-mm")}`,
529
+ `addonGroup_${K().format("DD-MM-YYYY_HH-mm")}`,
530
+ `itemLinkedAddon${K().format("DD-MM-YYYY_HH-mm")}`
531
+ ];
532
+ u(f, T);
533
+ } else {
534
+ const h = Ee(c.value), f = `menu_${K().format("DD-MM-YYYY_HH-mm")}`;
535
+ await de(h, `${f}.xlsx`, {
536
+ bookType: "xlsx",
537
+ bookSST: !1,
538
+ type: "array"
539
+ });
540
+ }
541
+ },
542
+ { successMessage: "Menu exported", customId: a.state.menu._id }
543
+ );
544
+ }
545
+ const {
546
+ menuItems: d,
547
+ categories: p,
548
+ linkItemRules: k,
549
+ handleSubmit: b,
550
+ catalogManager: w,
551
+ schedulerManager: F
552
+ } = Ie(!1), g = _e(), C = S(() => g.breakpoints.value.xs);
553
+ return xe().resetOnMount(), (h, f) => {
554
+ const T = G("fm-button");
555
+ return E(), D(ve, {
556
+ heading: l(e)("menu.products.title")
557
+ }, {
558
+ default: I(() => [
559
+ _(Ke),
560
+ _(Ce)
561
+ ]),
562
+ "append-heading": I(() => [
563
+ M("div", Ve, [
564
+ M("div", $e, [
565
+ M("div", Re, [
566
+ M("p", Ae, oe(s.value), 1)
567
+ ])
568
+ ]),
569
+ M("div", Pe, [
570
+ C.value ? (E(), D(Q, { key: 1 }, {
571
+ default: I(({ trigger: v }) => [
572
+ _(ke, null, {
573
+ default: I(() => [
574
+ _(Z, {
575
+ label: l(e)("menu.products.actions.export"),
576
+ onClick: m
577
+ }, null, 8, ["label"]),
578
+ _(Z, {
579
+ label: l(e)("menu.products.actions.import"),
580
+ onClick: v
581
+ }, null, 8, ["label", "onClick"])
582
+ ]),
583
+ _: 2
584
+ }, 1024)
585
+ ]),
586
+ _: 1
587
+ })) : (E(), j(B, { key: 0 }, [
588
+ _(Me, null, {
589
+ default: I(({ trigger: v }) => [
590
+ _(T, {
591
+ label: l(e)("menu.tree_editor.title"),
592
+ "bg-color": l(N).NeutralGray100,
593
+ "text-color": l(N).TypoSecondary,
594
+ variant: l(U).Primary,
595
+ onClick: v
596
+ }, null, 8, ["label", "bg-color", "text-color", "variant", "onClick"])
597
+ ]),
598
+ _: 1
599
+ }),
600
+ _(T, {
601
+ "bg-color": l(N).NeutralGray100,
602
+ "text-color": l(N).TypoSecondary,
603
+ variant: l(U).Primary,
604
+ label: l(e)("menu.products.actions.export"),
605
+ onClick: m
606
+ }, null, 8, ["bg-color", "text-color", "variant", "label"]),
607
+ _(Q, null, {
608
+ default: I(({ trigger: v }) => [
609
+ _(T, {
610
+ "bg-color": l(N).NeutralGray100,
611
+ "text-color": l(N).TypoSecondary,
612
+ variant: l(U).Primary,
613
+ label: l(e)("menu.products.actions.import"),
614
+ onClick: v
615
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])
616
+ ]),
617
+ _: 1
618
+ })
619
+ ], 64)),
620
+ s.value > 0 ? (E(), j(B, { key: 2 }, [
621
+ t.value.create ? (E(), D(Y, {
622
+ key: 0,
623
+ label: l(e)("menu.products.actions.add"),
624
+ "prepend-icon": "add",
625
+ onClick: f[0] || (f[0] = (v) => l(n).create(null))
626
+ }, null, 8, ["label"])) : r.value ? (E(), D(ee, {
627
+ key: 1,
628
+ "categorized-items": l(w).linkableItems.value,
629
+ "initial-value": l(w).currentItems.value,
630
+ "show-variant": !1,
631
+ "menu-items": l(d),
632
+ categories: l(p),
633
+ "link-item-rules": l(k),
634
+ "no-scheduler": r.value,
635
+ onSubmit: l(b)
636
+ }, {
637
+ default: I(({ trigger: v }) => [
638
+ _(Y, {
639
+ label: l(e)("menu.products.actions.link"),
640
+ "prepend-icon": "link",
641
+ onClick: v
642
+ }, null, 8, ["label", "onClick"])
643
+ ]),
644
+ _: 1
645
+ }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"])) : (E(), D(ee, {
646
+ key: 2,
647
+ "categorized-items": l(F).linkableItems.value,
648
+ "initial-value": l(F).currentItems.value,
649
+ "show-variant": !1,
650
+ "menu-items": l(d),
651
+ categories: l(p),
652
+ "link-item-rules": l(k),
653
+ "no-scheduler": r.value,
654
+ onSubmit: l(b)
655
+ }, {
656
+ default: I(({ trigger: v }) => [
657
+ _(Y, {
658
+ label: l(e)("menu.products.actions.apply_scheduler"),
659
+ onClick: v
660
+ }, null, 8, ["label", "onClick"])
661
+ ]),
662
+ _: 1
663
+ }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"]))
664
+ ], 64)) : ae("", !0)
665
+ ])
666
+ ])
667
+ ]),
668
+ _: 1
669
+ }, 8, ["heading"]);
670
+ };
671
+ }
672
+ });
673
+ export {
674
+ nt as default
675
+ };
@@ -1,11 +1,11 @@
1
1
  import { defineComponent as K, ref as I, computed as S, onMounted as ne, resolveComponent as C, createElementBlock as R, openBlock as h, createVNode as n, createElementVNode as o, toDisplayString as F, unref as i, Fragment as E, renderList as j, createBlock as O, withCtx as L, createCommentVNode as ue, withModifiers as z, h as H } from "vue";
2
- import { D as X } from "./dayjs.min-Dv2twIbC.js";
2
+ import { D as X } from "./dayjs.min-DkxnzHIf.js";
3
3
  import { useRouter as ie } from "vue-router";
4
- import { B as re, e as ce, G as Z, a8 as de, H as J, I as me, u as pe, A as ge, a0 as ve } from "./menu-Cvzv8myY.js";
4
+ import { B as re, e as ce, G as Z, a8 as de, H as J, I as me, u as pe, A as ge, a0 as ve } from "./menu-Cg_li9fp.js";
5
5
  import { useI18n as Y, useCoreStore as be, RestaurantSelector as fe } from "@feedmepos/mf-common";
6
6
  import { useSnackbar as ee, useDialogChild as _e, useDialog as he, components as Q } from "@feedmepos/ui-library";
7
7
  import { _ as ye } from "./TextChip.vue_vue_type_script_setup_true_lang-8frWuZFL.js";
8
- import { _ as Ce } from "./app-BrdLq53I.js";
8
+ import { _ as Ce } from "./app-BPqH1NSp.js";
9
9
  import { a as ke, w as we } from "./tooltip-B5BiPMx9.js";
10
10
  import { u as xe } from "./discardConfirm-BHni0LNu.js";
11
11
  import { _ as Ve } from "./index.vue_vue_type_script_setup_true_lang-BgqsTzLI.js";