@feedmepos/mf-menu 0.18.17 → 0.19.0-beta.2

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 (90) hide show
  1. package/dist/ApplyProduct.vue_vue_type_script_setup_true_lang-DFJJHptK.js +158 -0
  2. package/dist/{ApplyProducts.vue_vue_type_script_setup_true_lang-BJ0b_uKf.js → ApplyProducts.vue_vue_type_script_setup_true_lang-CXoRwrTi.js} +2 -2
  3. package/dist/Catalog-CXzqtCF8.js +551 -0
  4. package/dist/Category-DKbtLbq8.js +387 -0
  5. package/dist/CookingGuide-BKon8TdH.js +862 -0
  6. package/dist/Group-D1UDksBG.js +46 -0
  7. package/dist/{Group-jEtbECLb.js → Group-izOWb_Bh.js} +1 -1
  8. package/dist/Group.vue_vue_type_script_setup_true_lang-DAlQcgYp.js +558 -0
  9. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-Q7es2wmt.js +237 -0
  10. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Bw4uxqAp.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-Db0uYw5O.js} +11723 -11723
  11. package/dist/Ingredient-BIJu9P_9.js +484 -0
  12. package/dist/LinkProductSideSheet-BNdFZThd.js +104 -0
  13. package/dist/PrintRoute--fYPFcy7.js +417 -0
  14. package/dist/{Product-Bnr9oFr2.js → Product-vLtISbkD.js} +1 -1
  15. package/dist/Product.vue_vue_type_script_setup_true_lang-BHCihe6o.js +826 -0
  16. package/dist/Products-JaCNtcHS.js +236 -0
  17. package/dist/Publish-jpmiyB-b.js +525 -0
  18. package/dist/Recipe-B6y-oLPG.js +320 -0
  19. package/dist/Scheduler-Dj1rlr-U.js +222 -0
  20. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-BVAkohGJ.js +48 -0
  21. package/dist/ServingSequence-BhIfCyXl.js +4 -0
  22. package/dist/{Setting-DN8TQdIR.js → Setting-B5R1JfaL.js} +1 -1
  23. package/dist/Setting.vue_vue_type_script_setup_true_lang-xXtg0JOn.js +253 -0
  24. package/dist/Takeaway-BSFSz_JL.js +63 -0
  25. package/dist/{Takeaway-y0Nk0JAb.js → Takeaway-DjFTtbw6.js} +1 -1
  26. package/dist/Takeaway.vue_vue_type_script_setup_true_lang-BUGL0wfZ.js +302 -0
  27. package/dist/TaxSetting-D9Q8XNgJ.js +25 -0
  28. package/dist/Unit-Cr_8O3zB.js +142 -0
  29. package/dist/Variant-loUMfNRB.js +222 -0
  30. package/dist/_id_-0w7KjYyQ.js +189 -0
  31. package/dist/{app-D7e31gIv.js → app-t9ONnc0s.js} +31701 -26207
  32. package/dist/app.js +7 -6
  33. package/dist/apps/mf-menu/src/app.d.ts +2784 -0
  34. package/dist/apps/mf-menu/src/components/feature/Fields/OrderFrom.vue.d.ts +2 -2
  35. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductSideSheet.vue.d.ts +2 -2
  36. package/dist/apps/mf-menu/src/manager/menu/catalog.d.ts +1 -0
  37. package/dist/apps/mf-menu/src/stores/manager/item.d.ts +1 -1
  38. package/dist/apps/mf-menu/src/stores/menu.d.ts +16 -16
  39. package/dist/apps/mf-menu/src/views/Publish/UpdateCatalogDialog.vue.d.ts +12 -12
  40. package/dist/apps/mf-menu/src/views/Scheduler/FilterForm.vue.d.ts +4 -4
  41. package/dist/apps/mf-menu/src/views/Scheduler/SchedulerDialog.vue.d.ts +4 -4
  42. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/assets/{linked-status-D5tq3eE2.js → linked-status-DLL4aRiX.js} +8 -8
  44. package/dist/assets/{validate-menu-AcCpPyQZ.js → validate-menu-CoXc16jh.js} +8 -8
  45. package/dist/{catalog-Ck7lLTN2.js → catalog-4OmC0JA3.js} +66 -62
  46. package/dist/category-BE33DRqp.js +155 -0
  47. package/dist/{currency-CclA5a-2.js → currency-JHgYNbTQ.js} +1 -1
  48. package/dist/{index-DDd9B_ur.js → index-CE3zjhyh.js} +732 -740
  49. package/dist/index-pSg9p-28.js +238 -0
  50. package/dist/item-CEPx51U1.js +6371 -0
  51. package/dist/{lodash-BIQx_fko.js → lodash-VivR_BQ2.js} +1 -1
  52. package/dist/{menu-CYzbNubv.js → menu-ETQrtbbU.js} +1 -1
  53. package/dist/{object-DUtbNpoS.js → object-DEM5FMTB.js} +4 -4
  54. package/dist/scheduler-SRT_5Nio.js +491 -0
  55. package/dist/string-DpfFixWH.js +4 -0
  56. package/dist/style.css +1 -1
  57. package/dist/takeaway-RcvqKigG.js +267 -0
  58. package/dist/{toExcel-BXPcj8Gp.js → toExcel-BcgskY3F.js} +2 -2
  59. package/dist/unit-DLL7xIF1.js +350 -0
  60. package/package.json +4 -2
  61. package/dist/ApplyProduct.vue_vue_type_script_setup_true_lang-D9QsJ4vO.js +0 -155
  62. package/dist/Catalog-CZW54QJU.js +0 -570
  63. package/dist/Category-DvsP_L7d.js +0 -405
  64. package/dist/CookingGuide-DC3uXetk.js +0 -848
  65. package/dist/Group-DK5xqeYX.js +0 -44
  66. package/dist/Group.vue_vue_type_script_setup_true_lang-DGZ9hnPg.js +0 -538
  67. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BQXqlXw4.js +0 -234
  68. package/dist/Ingredient-354LLwdX.js +0 -498
  69. package/dist/LinkProductSideSheet-anxSsu0z.js +0 -102
  70. package/dist/PrintRoute-DrSvtNLX.js +0 -425
  71. package/dist/Product.vue_vue_type_script_setup_true_lang-bBY54Q_1.js +0 -815
  72. package/dist/Products-CZyueqSO.js +0 -234
  73. package/dist/Publish-kRM1UuPk.js +0 -518
  74. package/dist/Recipe-nKpLIJs8.js +0 -345
  75. package/dist/Scheduler-DmZ8atXG.js +0 -233
  76. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-CdsxA-p0.js +0 -48
  77. package/dist/ServingSequence-j00_ko5R.js +0 -4
  78. package/dist/Setting.vue_vue_type_script_setup_true_lang-Cx06MCJs.js +0 -247
  79. package/dist/Takeaway-BXZXCAaM.js +0 -61
  80. package/dist/Takeaway.vue_vue_type_script_setup_true_lang-9WVkdLZF.js +0 -316
  81. package/dist/TaxSetting-DdHx7ACN.js +0 -21
  82. package/dist/Unit-biPvleyL.js +0 -161
  83. package/dist/Variant-BP1IRNQx.js +0 -231
  84. package/dist/_id_-BiaNDI2N.js +0 -188
  85. package/dist/category-KiA5-36F.js +0 -154
  86. package/dist/index-BFeZlU8X.js +0 -232
  87. package/dist/item-Bcg7SiYv.js +0 -6325
  88. package/dist/scheduler-D1tgE0_9.js +0 -480
  89. package/dist/takeaway-BKsoD4EL.js +0 -264
  90. package/dist/unit-CswFvAyc.js +0 -346
@@ -1,815 +0,0 @@
1
- import { ref as j, computed as g, defineComponent as ue, resolveComponent as W, openBlock as v, createBlock as L, withCtx as T, createVNode as i, createElementVNode as _, toDisplayString as ne, unref as r, createElementBlock as A, Fragment as be, renderList as Oe, createTextVNode as Ye, mergeModels as He, useModel as Ze, renderSlot as _e, watch as me, h as D, withModifiers as ke, createCommentVNode as se, resolveDynamicComponent as Je, normalizeStyle as Qe, normalizeClass as oe, nextTick as Xe, watchEffect as et } from "vue";
2
- import { u as ye, a as Me, c as ve, y as pe, F as tt, z as lt, k as ie, g as at, A as Se, i as Ae } from "./app-D7e31gIv.js";
3
- import { _ as we } from "./SchedulerSelector.vue_vue_type_script_setup_true_lang-CdsxA-p0.js";
4
- import { useCoreStore as ot } from "@feedmepos/mf-common";
5
- import { useSnackbar as Ne, useDialog as ze, components as ae, FmButtonVariant as q, FmButtonColorThemeVariant as E, useBreakpoints as De } from "@feedmepos/ui-library";
6
- import "vue-router";
7
- import { u as ge } from "./menu-CYzbNubv.js";
8
- import { u as je } from "./category-KiA5-36F.js";
9
- import "./vuedraggable-WU01qJgi.js";
10
- import { _ as rt, a as Be, u as Ue, c as Ve } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-Bw4uxqAp.js";
11
- import { _ as nt } from "./takeaway-BKsoD4EL.js";
12
- import { f as st } from "./currency-CclA5a-2.js";
13
- import { l as fe } from "./lodash-BIQx_fko.js";
14
- import { u as Re, m as it } from "./item-Bcg7SiYv.js";
15
- import { w as ut } from "./InfoBasic.vue_vue_type_script_setup_true_lang-DxQBDu16.js";
16
- import { F as ct } from "./object-DUtbNpoS.js";
17
- import { _ as Fe } from "./TextChip.vue_vue_type_script_setup_true_lang-CNp85hoQ.js";
18
- import { L as $e } from "./LinkProductSideSheet-anxSsu0z.js";
19
- function dt(P, u) {
20
- const c = j(!0), I = g(() => {
21
- var f, x;
22
- return !c.value && (!u.value || ((f = u.value) == null ? void 0 : f.length) === ((x = P.value) == null ? void 0 : x.length));
23
- }), n = g(() => {
24
- var f, x, y, O;
25
- return !!((f = u.value) != null && f.length && ((x = u.value) == null ? void 0 : x.length) > 0 && ((y = u.value) == null ? void 0 : y.length) < ((O = P.value) == null ? void 0 : O.length));
26
- });
27
- return { allCleared: c, allSelected: I, indeterminate: n, toggleAll: () => {
28
- u.value = void 0, c.value = !c.value;
29
- }, toggleOption: (f) => {
30
- var y, O, B;
31
- let x;
32
- u.value === void 0 && c.value ? x = [f] : u.value === void 0 && !c.value ? x = (y = P.value.map((w) => w.value)) == null ? void 0 : y.filter((w) => w !== f) : (O = u.value) != null && O.includes(f) ? x = (B = u.value) == null ? void 0 : B.filter((w) => w !== f) : x = [...u.value || [], f], x.length === 0 ? (u.value = void 0, c.value = !0) : x.length === P.value.length ? (u.value = void 0, c.value = !1) : u.value = x;
33
- } };
34
- }
35
- const Ie = /* @__PURE__ */ ue({
36
- __name: "CategorySelector",
37
- setup(P) {
38
- const u = ye(), { categories: c, selectedCategories: I } = ge(), n = g(() => u.state.currentCategoryIds), p = g(
39
- () => c.value.map((F) => ({ label: F.name, value: F.id }))
40
- ), K = g(() => {
41
- var F, V, U;
42
- return c.value.length === ((F = I.value) == null ? void 0 : F.length) ? "All" : ((V = I.value) == null ? void 0 : V.length) === 1 ? I.value[0].name : `${(U = I.value) == null ? void 0 : U.length}`;
43
- }), f = g({
44
- get: () => n.value,
45
- set: (F) => {
46
- u.selectCategory(F);
47
- }
48
- }), { allCleared: x, allSelected: y, toggleAll: O, toggleOption: B, indeterminate: w } = dt(p, f);
49
- return (F, V) => {
50
- const U = W("FmIcon"), d = W("FmChip"), G = W("FmMenuItem"), N = W("FmMenu");
51
- return v(), L(N, { "close-on-click": !1 }, {
52
- "menu-button": T(() => [
53
- i(d, {
54
- label: K.value,
55
- class: "fm-typo-en-body-md-600 text-fm-color-neutral-gray-400"
56
- }, {
57
- default: T(() => [
58
- _("p", null, "Category: " + ne(K.value), 1),
59
- i(U, { name: "expand_more" })
60
- ]),
61
- _: 1
62
- }, 8, ["label"])
63
- ]),
64
- default: T(() => [
65
- i(G, {
66
- label: "All",
67
- "has-checkbox": "",
68
- "model-value": r(y),
69
- indeterminate: r(w),
70
- onClick: r(O)
71
- }, null, 8, ["model-value", "indeterminate", "onClick"]),
72
- (v(!0), A(be, null, Oe(p.value, (Y) => {
73
- var H;
74
- return v(), L(G, {
75
- key: Y.value || "",
76
- label: Y.label,
77
- "has-checkbox": "",
78
- "model-value": r(y) || ((H = f.value) == null ? void 0 : H.includes(Y.value)),
79
- onClick: (X) => r(B)(Y.value)
80
- }, null, 8, ["label", "model-value", "onClick"]);
81
- }), 128))
82
- ]),
83
- _: 1
84
- });
85
- };
86
- }
87
- }), Te = (P) => i("div", {
88
- class: "flex flex-1 justify-end"
89
- }, [i("span", null, [P, Ye(" ")])]), mt = /* @__PURE__ */ ue({
90
- __name: "CategorySelectorSingle",
91
- props: /* @__PURE__ */ He({
92
- disabled: { type: Boolean, default: !1 }
93
- }, {
94
- modelValue: {},
95
- modelModifiers: {}
96
- }),
97
- emits: ["update:modelValue"],
98
- setup(P) {
99
- const u = ye(), c = Ze(P, "modelValue"), I = g(() => u.categories.map((n) => ({
100
- label: n.name,
101
- value: n._id || null
102
- })));
103
- return (n, p) => {
104
- const K = W("FmSelect");
105
- return v(), L(K, {
106
- items: I.value,
107
- modelValue: c.value,
108
- "onUpdate:modelValue": p[0] || (p[0] = (f) => c.value = f),
109
- disabled: n.disabled
110
- }, null, 8, ["items", "modelValue", "disabled"]);
111
- };
112
- }
113
- }), Pe = /* @__PURE__ */ ue({
114
- __name: "ImportButton",
115
- setup(P) {
116
- const u = j(!1);
117
- function c() {
118
- u.value = !u.value;
119
- }
120
- return (I, n) => (v(), A(be, null, [
121
- i(rt, {
122
- modelValue: u.value,
123
- "onUpdate:modelValue": n[0] || (n[0] = (p) => u.value = p)
124
- }, null, 8, ["modelValue"]),
125
- _e(I.$slots, "default", { trigger: c })
126
- ], 64));
127
- }
128
- }), vt = {
129
- class: "flex justify-between items-center space-x-8"
130
- }, pt = {
131
- class: "flex space-x-8"
132
- }, ft = {
133
- class: "w-[320px]"
134
- }, gt = {
135
- key: 0,
136
- class: /* @__PURE__ */ oe(["flex-1 flex flex-col", "divide-y divide-fm-color-neutral-gray-100", "overflow-hidden"])
137
- }, yt = {
138
- key: 0,
139
- class: "flex items-center p-4"
140
- }, _t = {
141
- class: /* @__PURE__ */ oe(["mr-8", "fm-typo-en-body-md-400"])
142
- }, bt = {
143
- key: 1,
144
- class: "px-16 py-4 space-x-8 flex justify-end"
145
- }, ht = {
146
- key: 1
147
- }, xt = {
148
- class: "flex space-x-8"
149
- }, Ct = {
150
- key: 1,
151
- class: "pt-8 flex flex-col flex-1 overflow-hidden"
152
- }, kt = {
153
- class: "space-y-8 pb-8"
154
- }, St = {
155
- class: "w-full px-8"
156
- }, wt = {
157
- class: "flex space-x-8 px-8"
158
- }, Vt = {
159
- key: 0,
160
- class: /* @__PURE__ */ oe(["flex flex-col flex-1", "overflow-scroll", "divide-y divide-fm-color-neutral-gray-100", "pb-64"])
161
- }, Ft = ["onClick"], $t = {
162
- class: "min-w-0 flex flex-1 items-start justify-start space-x-16"
163
- }, It = {
164
- class: "flex-1 min-w-0"
165
- }, Tt = {
166
- class: "flex justify-between items-center gap-8 pb-4"
167
- }, Pt = {
168
- class: "flex-1 min-w-0 fm-typo-en-body-lg-600 line-clamp-2"
169
- }, Ot = {
170
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
171
- }, Mt = {
172
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
173
- }, At = {
174
- key: 1
175
- }, Nt = {
176
- class: "flex space-x-8"
177
- }, zt = /* @__PURE__ */ ue({
178
- __name: "ProductTable",
179
- props: {
180
- modelValue: {},
181
- originalValue: {},
182
- isCalculating: {
183
- type: Boolean
184
- }
185
- },
186
- emits: ["update:model-value", "reset:model-value", "update:editing", "update:search-key"],
187
- setup(P, {
188
- emit: u
189
- }) {
190
- const c = P, I = ot(), n = ye();
191
- Be(), Ue();
192
- const p = Ne(), K = ze(), f = Me(p), x = Ae(f);
193
- je({
194
- dialog: K,
195
- menuLoader: x
196
- });
197
- const y = Re();
198
- g(() => !n.state.currentSchedulerId);
199
- const O = I.currentCountry, B = g(() => O.value ? ve.Country.getCountry(O.value) : null), w = g(() => n.rules.item);
200
- g(() => F.value.length === 1 && F.value[0].id === null);
201
- const {
202
- selectedCategories: F
203
- } = ge(), V = g(() => fe.flatten(F.value.map((e) => e.items))), U = u, d = j(!1);
204
- me(() => d.value, (e) => {
205
- U("update:editing", e);
206
- });
207
- const G = (e) => {
208
- at.isBoolean(e) ? d.value = e : d.value = !d.value;
209
- }, N = j(""), Y = g(() => V.value.filter((e) => {
210
- var a;
211
- return !N.value || !N.value.trim() ? !0 : `${e.code} ${e.name} ${he(e)} ${X(e.category || null)} ${(a = pe()[e.orderFrom]) == null ? void 0 : a.label}`.toLowerCase().includes(N.value.toLowerCase());
212
- })), {
213
- categories: H
214
- } = ge(), X = (e) => {
215
- const t = H.value.find((a) => a.id === e || e === null && a.id === "");
216
- return t == null ? void 0 : t.name;
217
- }, re = (e, t, a) => {
218
- let l = fe.clone(c.modelValue);
219
- const s = l[e];
220
- s && (l[e] = {
221
- ...s,
222
- [t]: a
223
- }, U("update:model-value", l));
224
- }, ee = fe.debounce(re, 300), R = (e) => (t) => !!t || `${e} is required`, k = (e) => e >= 0 || "Price must be greater or equal than 0", S = [R("Name")], b = () => [(e) => k(typeof e == "number" ? e : Number(e) ?? 0)], M = pe(), z = j([{
225
- accessorKey: "thumbnail",
226
- header: "",
227
- size: 64,
228
- meta: {
229
- cellClass: "px-0",
230
- headerContentClass: "px-0"
231
- },
232
- cell: (e) => {
233
- var t, a;
234
- return D(Ve, {
235
- src: e.getValue(),
236
- alt: (a = (t = e == null ? void 0 : e.row) == null ? void 0 : t.original) == null ? void 0 : a.name,
237
- className: "my-8 mx-12",
238
- size: 72
239
- });
240
- },
241
- enableSorting: !1
242
- }, {
243
- accessorKey: "code",
244
- header: "Code",
245
- enableSorting: !1,
246
- size: 100,
247
- cell: (e) => {
248
- const t = e.row.original, a = e.getValue() || "--";
249
- if (!d.value) return a;
250
- const l = xe(t._id);
251
- return D(ae.FmTextField, {
252
- disabled: !w.value.code,
253
- modelValue: l == null ? void 0 : l.code,
254
- placeholder: c.modelValue[t._id].fallbackCode,
255
- "onUpdate:modelValue": (s) => {
256
- ee(t._id, "code", s);
257
- }
258
- });
259
- }
260
- }, {
261
- accessorKey: "name",
262
- header: "Product name",
263
- enableSorting: !1,
264
- size: 240,
265
- cell: (e) => {
266
- const t = e.row.original, a = e.getValue();
267
- return d.value ? D(ae.FmTextField, {
268
- disabled: !w.value.name,
269
- modelValue: t.name,
270
- "onUpdate:modelValue": (l) => {
271
- ee(t._id, "name", l);
272
- },
273
- rules: S,
274
- placeholder: t.fallbackName
275
- }) : a;
276
- }
277
- }, {
278
- accessorKey: "price",
279
- header: () => {
280
- var e;
281
- return Te(`Price (${(e = B.value) == null ? void 0 : e.currency.symbol})`);
282
- },
283
- enableSorting: !1,
284
- size: 140,
285
- meta: {
286
- textAlign: "right"
287
- },
288
- cell: (e) => {
289
- var s;
290
- const t = e.getValue();
291
- if (!d.value) return ve.Dinero.fromFdoDinero(t).toFormat();
292
- const a = c.modelValue[e.row.original._id], l = a.fallbackPrice;
293
- return D(nt, {
294
- min: 0,
295
- disabled: !a.editPrice,
296
- // @ts-ignore
297
- placeholder: l ? st(l, !1) : void 0,
298
- modelValue: (s = xe(a._id)) == null ? void 0 : s.price,
299
- // @ts-ignore
300
- "onUpdate:modelValue": (C) => {
301
- re(a._id, "price", C);
302
- },
303
- rules: b()
304
- });
305
- }
306
- }, {
307
- accessorKey: "taxes",
308
- header: () => Te("SST"),
309
- size: 62,
310
- enableSorting: !1,
311
- meta: {
312
- textAlign: "right"
313
- },
314
- cell: (e) => {
315
- const t = e.getValue(), a = e.row.original, l = n.taxSetting.countryTaxOptions, s = n.getSelectedTax(t, a.fallbackTaxes, n.taxSetting.countryTaxOptions), C = l.find((Q) => Q.value === s);
316
- if (!d.value)
317
- return `${C != null && C.meta.rate ? tt(C.meta.rate) : 0}%`;
318
- const o = n.getSelectedTax(t, a.fallbackTaxes, n.taxSetting.countryTaxOptions);
319
- return D(ae.FmSelect, {
320
- disabled: !w.value.tax,
321
- items: n.taxSetting.countryTaxOptions,
322
- modelValue: o,
323
- "onUpdate:modelValue": async (Q) => {
324
- const de = n.decodeTax(Q);
325
- ee(a._id, "taxes", [de]);
326
- }
327
- });
328
- }
329
- }, {
330
- header: "Category",
331
- enableSorting: !1,
332
- size: 140,
333
- cell: (e) => {
334
- const t = e.row.original;
335
- return d.value ? D(mt, {
336
- "model-value": c.modelValue[t._id].category,
337
- disabled: !!(n.state.currentCatalogId || n.state.currentSchedulerId),
338
- "onUpdate:modelValue": async (a) => {
339
- ee(t._id, "category", a);
340
- }
341
- }) : X(t.category || null);
342
- }
343
- }, {
344
- accessorKey: "orderFrom",
345
- header: "Order",
346
- enableSorting: !0,
347
- sortingFn: (e, t) => {
348
- const [a, l] = [e, t].map((s) => M[s.original.orderFrom].sortingIndex);
349
- return a - l;
350
- },
351
- size: 100,
352
- cell: (e) => {
353
- var s, C;
354
- const t = e.getValue(), a = e.row.original, l = pe();
355
- return d.value ? D(ae.FmSelect, {
356
- disabled: !w.value.orderFrom,
357
- items: Object.values(pe()),
358
- modelValue: t,
359
- "onUpdate:modelValue": async (o) => {
360
- re(a._id, "orderFrom", o);
361
- }
362
- }) : D(Fe, {
363
- label: (s = l[t]) == null ? void 0 : s.label,
364
- variant: (C = l[t]) == null ? void 0 : C.variant
365
- });
366
- }
367
- }, {
368
- id: "actions",
369
- size: 52,
370
- meta: {
371
- cellClass: "pl-16",
372
- headerClass: "py-4",
373
- textAlign: "right"
374
- },
375
- header: () => D("div", {
376
- class: "w-full px-4 flex justify-end"
377
- }, [ut(D(ae.FmButton, {
378
- variant: q.Tertiary,
379
- textColor: E.NeutralGray400,
380
- prependIcon: "edit",
381
- class: "flex justify-end",
382
- onClick: G,
383
- type: "button"
384
- }), "Bulk edit")]),
385
- cell: (e) => {
386
- const t = e.row.original;
387
- return D("div", {
388
- class: "px-4 flex justify-end"
389
- }, [D(ae.FmButton, {
390
- icon: "delete",
391
- variant: "tertiary",
392
- textColor: E.NeutralGray400,
393
- onClick: ke(async () => {
394
- await y.deleteItem([{
395
- _id: t._id,
396
- name: t.name,
397
- thumbnail: t.thumbnail
398
- }]);
399
- }, ["stop", "prevent"])
400
- })]);
401
- }
402
- }]);
403
- n.taxSetting.systemCode || z.value.splice(4, 1);
404
- const h = j({}), m = j([]);
405
- me(() => h.value, (e) => {
406
- let t = [];
407
- Object.keys(e).forEach((a) => {
408
- e[a] ? t.push(V.value[parseInt(a)]) : m.value = t.filter((s) => s !== V.value[parseInt(a)]);
409
- }), m.value = t;
410
- }), me(() => V.value, () => {
411
- h.value = {}, m.value = [];
412
- }), me(() => d.value, () => {
413
- h.value = {}, m.value = [];
414
- });
415
- const Z = () => {
416
- h.value = {};
417
- };
418
- async function $() {
419
- await Xe();
420
- const e = () => !!n.currentCatalog || !!n.state.currentSchedulerId, t = (l) => l === "" || l === null ? e() ? "" : null : l, a = Object.values(c.modelValue).filter((l) => {
421
- const s = Object.values(c.originalValue).find((C) => C._id === l._id);
422
- return Se(s, l);
423
- }).map((l) => ({
424
- _id: l._id,
425
- name: l.name,
426
- code: l.code,
427
- price: l.price,
428
- orderFrom: l.orderFrom ?? null,
429
- taxes: l.taxes,
430
- category: t(l.category || null)
431
- }));
432
- await y.updateMany(a), G(!1);
433
- }
434
- const te = async () => {
435
- await y.deleteItem(m.value.map((e) => ({
436
- _id: e._id,
437
- name: e.name,
438
- thumbnail: e.thumbnail
439
- })));
440
- }, J = () => {
441
- U("reset:model-value");
442
- }, le = () => {
443
- Object.entries(c.modelValue).some(([t, a]) => Se(a, c.originalValue[t])) ? K.open({
444
- title: "You have unsaved changes!",
445
- message: "Are you sure you want to discard? You will lose all the changes if discard edit.",
446
- primaryActions: {
447
- text: "Discard",
448
- close: !0,
449
- variant: q.Destructive
450
- },
451
- secondaryActions: {
452
- text: "Cancel",
453
- close: !0
454
- }
455
- }).onPrimary(() => {
456
- J(), G(!1);
457
- }) : (G(!1), J());
458
- }, ce = g(() => ({
459
- thumbnail: !d.value,
460
- actions: !d.value
461
- })), Ee = (e) => {
462
- y.update(e._id);
463
- };
464
- async function Le(e) {
465
- await y.update(e.original._id);
466
- }
467
- function he(e) {
468
- var C;
469
- const t = e.price ?? // TODO: fix type error
470
- // @ts-ignore
471
- e.fallbackPrice ?? ve.Dinero.fromNumber({
472
- number: 0
473
- }).toObject(), a = e.taxes;
474
- n.taxSetting.countryTaxOptions;
475
- const l = ve.Dinero.fromFdoDinero(t).toFormat(), s = (C = B.value) == null ? void 0 : C.currency.symbol;
476
- return n.getSelectedTax(
477
- a,
478
- // TODO: fix type error
479
- // @ts-ignore
480
- e.fallbackTaxes,
481
- n.taxSetting.countryTaxOptions
482
- ), `${s == null ? void 0 : s.toUpperCase()}${l}`;
483
- }
484
- function xe(e) {
485
- var l;
486
- const t = n.currentCatalog, a = n.state.currentSchedulerId;
487
- if (t && a) {
488
- const s = t.override.scheduler[a] ?? {
489
- _id: a
490
- };
491
- return ((l = s == null ? void 0 : s.items) == null ? void 0 : l.filter((o) => o._id === e))[0];
492
- } else return t ? t.override.items[e][0] : a ? n.schedulers.find((o) => o._id === a).items.filter((o) => o._id === e)[0] : V.value.find((s) => s._id === e);
493
- }
494
- const Ke = De(), Ge = g(() => Ke.breakpoints.value.xs), Ce = j(null), qe = lt(Ce), We = g(() => {
495
- var t;
496
- return {
497
- height: `calc(100vh - ${((t = qe.value) == null ? void 0 : t.top) + 24}px)`
498
- };
499
- });
500
- return (e, t) => {
501
- const a = W("fm-search"), l = W("fm-button"), s = W("fm-table"), C = W("fm-form");
502
- return Ge.value ? (v(), A("div", Ct, [_("div", kt, [_("div", St, [i(a, {
503
- "model-value": N.value,
504
- "onUpdate:modelValue": t[4] || (t[4] = (o) => N.value = o),
505
- autofocus: "",
506
- placeholder: "Search products"
507
- }, null, 8, ["model-value"])]), t[6] || (t[6] = _("div", {
508
- class: "w-full h-[1px] bg-fm-color-neutral-gray-100"
509
- }, null, -1)), _("div", wt, [_e(e.$slots, "filter")])]), V.value.length ? (v(), A("div", Vt, [(v(!0), A(be, null, Oe(Y.value, (o) => {
510
- var Q, de;
511
- return v(), A("div", {
512
- key: o._id,
513
- class: "max-w-full py-12 px-16 space-x-16 flex items-center",
514
- onClick: () => Ee(o)
515
- }, [_("div", $t, [i(Ve, {
516
- alt: o.name,
517
- size: 72,
518
- src: o.thumbnail
519
- }, null, 8, ["alt", "src"]), _("div", It, [_("div", Tt, [_("p", Pt, ne(o.name), 1), i(Fe, {
520
- label: (Q = r(M)[o.orderFrom || ""]) == null ? void 0 : Q.label,
521
- variant: (de = r(M)[o.orderFrom || ""]) == null ? void 0 : de.variant
522
- }, null, 8, ["label", "variant"])]), _("p", Ot, ne(he(o)), 1), _("p", Mt, " Category: " + ne(X(o.category || null)), 1)])]), i(l, {
523
- "text-color": r(E).NeutralGray400,
524
- variant: r(q).Tertiary,
525
- "prepend-icon": "delete",
526
- onClick: ke(() => r(y).deleteItem([{
527
- _id: o._id,
528
- name: o.name,
529
- thumbnail: o.thumbnail
530
- }]), ["stop"])
531
- }, null, 8, ["text-color", "variant", "onClick"])], 8, Ft);
532
- }), 128))])) : (v(), A("div", At, [i(ie, {
533
- subtitle: "Start by stocking your store with products your customers will love",
534
- title: "Add your products"
535
- }, {
536
- action: T(() => [_("div", Nt, [i(l, {
537
- variant: r(q).Primary,
538
- label: "Add product",
539
- "prepend-icon": "add",
540
- onClick: t[5] || (t[5] = (o) => r(y).create(null))
541
- }, null, 8, ["variant"]), i(Pe, null, {
542
- default: T(({
543
- trigger: o
544
- }) => [i(l, {
545
- "bg-color": r(E).NeutralGray100,
546
- "text-color": r(E).NeutralGray400,
547
- variant: r(q).Primary,
548
- label: "Import",
549
- "prepend-icon": "download",
550
- onClick: o
551
- }, null, 8, ["bg-color", "text-color", "variant", "onClick"])]),
552
- _: 1
553
- })])]),
554
- _: 1
555
- })]))])) : (v(), L(C, {
556
- key: 0,
557
- "blame-form-child-on-validation-failed": "",
558
- class: "flex flex-col flex-1 space-y-8 overflow-hidden",
559
- onValidationSuccess: $
560
- }, {
561
- default: T(() => [_("div", vt, [_("div", pt, [_e(e.$slots, "filter")]), _("div", ft, [i(a, {
562
- "model-value": N.value,
563
- "onUpdate:modelValue": t[0] || (t[0] = (o) => N.value = o),
564
- autofocus: "",
565
- placeholder: "Search products"
566
- }, null, 8, ["model-value"])])]), V.value.length ? (v(), A("div", gt, [m.value.length && !d.value ? (v(), A("div", yt, [_("p", _t, ne(m.value.length) + " items selected", 1), i(l, {
567
- label: "Deselect all",
568
- type: "button",
569
- variant: "plain",
570
- onClick: Z
571
- }), i(l, {
572
- "border-color": r(E).SystemError300,
573
- "text-color": r(E).SystemError300,
574
- class: "ml-auto",
575
- label: "Remove",
576
- "prepend-icon": "delete",
577
- variant: "secondary",
578
- onClick: te
579
- }, null, 8, ["border-color", "text-color"])])) : se("", !0), d.value ? (v(), A("div", bt, [i(l, {
580
- variant: r(q).Tertiary,
581
- label: "Reset all",
582
- onClick: J
583
- }, null, 8, ["variant"]), i(l, {
584
- variant: r(q).Tertiary,
585
- label: "Cancel",
586
- onClick: le
587
- }, null, 8, ["variant"]), i(l, {
588
- borderColor: r(E).ColorPrimary,
589
- textColor: r(E).ColorPrimary,
590
- variant: r(q).Secondary,
591
- label: "Save",
592
- type: "submit"
593
- }, null, 8, ["borderColor", "textColor", "variant"])])) : se("", !0), _("div", {
594
- ref_key: "tableWrapper",
595
- ref: Ce
596
- }, [(v(), L(Je(d.value ? ct : "div"), {
597
- title: "Bulk edit products",
598
- show: d.value,
599
- "primary-action": {
600
- label: "Save"
601
- },
602
- "secondary-actions": [{
603
- label: "Reset all",
604
- click: J
605
- }, {
606
- label: "Cancel",
607
- click: le
608
- }],
609
- class: "overflow-hidden",
610
- style: Qe(We.value),
611
- onOnPrimary: $,
612
- onOnCancel: le
613
- }, {
614
- default: T(() => [i(s, {
615
- class: oe({
616
- "mt-24": d.value
617
- }),
618
- modelValue: h.value,
619
- "onUpdate:modelValue": t[1] || (t[1] = (o) => h.value = o),
620
- "column-defs": z.value,
621
- "column-visibility": ce.value,
622
- loading: e.isCalculating,
623
- "page-size": V.value.length,
624
- "row-data": Y.value,
625
- selection: d.value ? void 0 : "multiple",
626
- "shrink-at": !1,
627
- "hide-footer": "",
628
- "pin-header-row": "",
629
- onRowClick: t[2] || (t[2] = (o) => d.value ? void 0 : Le(o))
630
- }, null, 8, ["class", "modelValue", "column-defs", "column-visibility", "loading", "page-size", "row-data", "selection"])]),
631
- _: 1
632
- }, 40, ["show", "secondary-actions", "style"]))], 512)])) : (v(), A("div", ht, [i(ie, {
633
- subtitle: "Start by stocking your store with products your customers will love",
634
- title: "Add your products"
635
- }, {
636
- action: T(() => [_("div", xt, [i(l, {
637
- variant: r(q).Primary,
638
- label: "Add product",
639
- "prepend-icon": "add",
640
- onClick: t[3] || (t[3] = (o) => r(y).create(null))
641
- }, null, 8, ["variant"]), i(Pe, null, {
642
- default: T(({
643
- trigger: o
644
- }) => [i(l, {
645
- "bg-color": r(E).NeutralGray100,
646
- "text-color": r(E).NeutralGray400,
647
- variant: r(q).Primary,
648
- label: "Import",
649
- "prepend-icon": "download",
650
- onClick: o
651
- }, null, 8, ["bg-color", "text-color", "variant", "onClick"])]),
652
- _: 1
653
- })])]),
654
- _: 1
655
- })]))]),
656
- _: 3
657
- }));
658
- };
659
- }
660
- }), Dt = {
661
- key: 0,
662
- class: /* @__PURE__ */ oe(["flex flex-col", "flex-1", "overflow-hidden"])
663
- }, jt = {
664
- class: /* @__PURE__ */ oe(["pt-16 xs:pt-0", "flex xs:flex-col", "flex-1", "w-full", "overflow-hidden"])
665
- }, Bt = { class: "flex flex-col flex-1 overflow-hidden" }, Ut = {
666
- key: 1,
667
- class: "pt-16 xs:pt-8 space-y-24"
668
- }, Rt = { class: "flex items-center gap-8 px-16" }, nl = /* @__PURE__ */ ue({
669
- __name: "Product",
670
- setup(P) {
671
- const u = ze(), c = Ne(), I = Me(c), n = Ae(I);
672
- je({
673
- dialog: u,
674
- menuLoader: n
675
- });
676
- const p = ye(), K = g(() => p.rules.item), f = Be(), x = Re(), y = Ue(), O = g(() => !p.state.currentCatalogId), B = g(() => p.rules.item), w = g(() => !p.state.currentSchedulerId), F = j(!1), V = j(!1), U = g(() => {
677
- var k, S, b, M;
678
- if (O.value && w.value) return;
679
- if (w.value) {
680
- const z = (k = p.currentCatalog) == null ? void 0 : k.override.items;
681
- return z ? Object.entries(z).reduce((h, [m, Z]) => {
682
- const $ = Z.find((te) => !te.combinationKey);
683
- return $ && (h[m] = $), h;
684
- }, {}) : {};
685
- }
686
- return ((O.value ? (S = p.currentScheduler) == null ? void 0 : S.items : (M = (b = p.currentCatalog) == null ? void 0 : b.override.scheduler[p.state.currentSchedulerId]) == null ? void 0 : M.items) ?? []).reduce((z, h) => (h.combinationKey || (z[h._id] = h), z), {});
687
- }), d = j({}), G = j({}), N = async () => {
688
- var M, z;
689
- V.value = !0;
690
- const R = !!U.value, k = fe.flatten(H.value.map((h) => h.items)), S = R && F.value ? await it(
691
- p.mergedMenu,
692
- k,
693
- p.state.menu,
694
- (M = p.currentCatalog) == null ? void 0 : M._id,
695
- (z = p.currentScheduler) == null ? void 0 : z._id,
696
- !1
697
- ) : void 0, b = k.reduce((h, m, Z) => {
698
- var te, J, le, ce;
699
- const $ = (te = U.value) == null ? void 0 : te[m._id];
700
- return h[m._id] = {
701
- _id: m._id,
702
- name: m.name,
703
- code: R ? $ == null ? void 0 : $.code : m == null ? void 0 : m.code,
704
- category: m.category,
705
- price: R && B.value.editPrice ? $ == null ? void 0 : $.price : m.price,
706
- orderFrom: R ? $ == null ? void 0 : $.orderFrom : m.orderFrom,
707
- taxes: R ? null : m.taxes,
708
- thumbnail: m.thumbnail,
709
- fallbackPrice: (J = S == null ? void 0 : S[Z]) == null ? void 0 : J.price,
710
- fallbackName: R ? m.name : void 0,
711
- fallbackCode: (le = S == null ? void 0 : S[Z]) == null ? void 0 : le.code,
712
- fallbackOrder: (ce = S == null ? void 0 : S[Z]) == null ? void 0 : ce.orderFrom,
713
- fallbackTaxes: R ? m.taxes : null
714
- }, h;
715
- }, {});
716
- d.value = b, G.value = { ...b }, V.value = !1;
717
- }, { categories: Y, selectedCategories: H } = ge();
718
- et(async () => {
719
- H.value && await N();
720
- });
721
- function X() {
722
- x.create(null);
723
- }
724
- const re = () => {
725
- H.value && N();
726
- }, ee = De();
727
- return g(() => ee.breakpoints.value.xs), (R, k) => {
728
- const S = W("fm-button");
729
- return r(Y).length ? (v(), A("div", Dt, [
730
- _("div", jt, [
731
- _("div", Bt, [
732
- r(H) ? (v(), L(zt, {
733
- key: 0,
734
- "is-calculating": V.value,
735
- "model-value": d.value,
736
- "original-value": G.value,
737
- "onUpdate:modelValue": k[0] || (k[0] = (b) => d.value = b),
738
- "onReset:modelValue": re,
739
- "onUpdate:editing": k[1] || (k[1] = (b) => F.value = b)
740
- }, {
741
- filter: T(() => [
742
- i(Ie),
743
- B.value.multiScheduler ? (v(), L(we, { key: 0 })) : se("", !0)
744
- ]),
745
- _: 1
746
- }, 8, ["is-calculating", "model-value", "original-value"])) : se("", !0)
747
- ])
748
- ])
749
- ])) : (v(), A("div", Ut, [
750
- _("div", Rt, [
751
- i(Ie),
752
- B.value.multiScheduler ? (v(), L(we, { key: 0 })) : se("", !0)
753
- ]),
754
- K.value.create ? (v(), L(ie, {
755
- key: 0,
756
- action: {
757
- text: "Add product",
758
- callback: X
759
- },
760
- subtitle: "Start by stocking your store with products your customers will love",
761
- title: "Add your products"
762
- }, null, 8, ["action"])) : w.value ? (v(), L(ie, {
763
- key: 1,
764
- subtitle: "Add product in this catalog by linking products from main catalog.",
765
- title: "No product linked"
766
- }, {
767
- action: T(() => [
768
- i($e, {
769
- "categorized-items": r(y).linkableItems,
770
- "initial-value": r(y).currentItems,
771
- "show-variant": !1,
772
- onSubmit: k[2] || (k[2] = (b) => r(y).applyProduct(b.map((M) => M._id)))
773
- }, {
774
- default: T(({ trigger: b }) => [
775
- i(S, {
776
- label: "Link product",
777
- "prepend-icon": "link",
778
- onClick: b
779
- }, null, 8, ["onClick"])
780
- ]),
781
- _: 1
782
- }, 8, ["categorized-items", "initial-value"])
783
- ]),
784
- _: 1
785
- })) : (v(), L(ie, {
786
- key: 2,
787
- subtitle: "Apply product in this scheduler by linking products from main catalog.",
788
- title: "No product applied"
789
- }, {
790
- action: T(() => [
791
- i($e, {
792
- "categorized-items": r(f).linkableItems,
793
- "initial-value": r(f).currentItems,
794
- "show-variant": !1,
795
- onSubmit: k[3] || (k[3] = (b) => r(f).applyProduct(b.map((M) => M._id)))
796
- }, {
797
- default: T(({ trigger: b }) => [
798
- i(S, {
799
- label: "Apply scheduler",
800
- onClick: b
801
- }, null, 8, ["onClick"])
802
- ]),
803
- _: 1
804
- }, 8, ["categorized-items", "initial-value"])
805
- ]),
806
- _: 1
807
- }))
808
- ]));
809
- };
810
- }
811
- });
812
- export {
813
- nl as _,
814
- Pe as a
815
- };