@feedmepos/mf-report 5.18.2-beta.2 → 5.18.2-beta.4

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.
@@ -0,0 +1,221 @@
1
+ import { defineComponent as X, resolveComponent as J, createBlock as Y, openBlock as I, unref as u, isRef as fe, withCtx as F, createElementVNode as j, createVNode as x, toDisplayString as W, createTextVNode as pe, onMounted as Z, watch as h, ref as A, computed as G, onBeforeMount as ge, onBeforeUnmount as ye, createElementBlock as $, Fragment as ve } from "vue";
2
+ import { detectLocale as C, useCoreStore as B } from "@feedmepos/mf-common";
3
+ import { u as Se, d as i, a as De, b as K, c as Ie, e as he, f as Re, s as qe, g as Oe } from "./vue-i18n-CTLGxUiF.js";
4
+ import { storeToRefs as b } from "pinia";
5
+ import { u as _e, a as we, b as Le } from "./BaseDialog.vue_vue_type_script_setup_true_lang-djyc20Cp.js";
6
+ import { _ as be, u as Ce } from "./NavigationTab.vue_vue_type_script_setup_true_lang-CDxb2Mjg.js";
7
+ import { u as P } from "./message-dialog-UoMWOnil.js";
8
+ import { useRoute as Ee, useRouter as ke } from "vue-router";
9
+ const Ne = { class: "fm-typo-en-body-md-400 text-ellipsis overflow-hidden" }, Fe = /* @__PURE__ */ X({
10
+ __name: "Dialog",
11
+ setup(R) {
12
+ const { t: r } = Se(), f = P(), { isOpened: c, message: v, title: S } = b(P());
13
+ return (q, g) => {
14
+ const O = J("FmButton"), E = J("FmDialog");
15
+ return I(), Y(E, {
16
+ modelValue: u(c),
17
+ "onUpdate:modelValue": g[0] || (g[0] = (k) => fe(c) ? c.value = k : null),
18
+ overlay: "",
19
+ "close-button": !1
20
+ }, {
21
+ "dialog-header": F(() => [
22
+ pe(W(u(S)), 1)
23
+ ]),
24
+ default: F(() => [
25
+ j("p", Ne, W(u(v)), 1)
26
+ ]),
27
+ "dialog-footer": F(() => [
28
+ g[1] || (g[1] = j("div", { class: "grow" }, null, -1)),
29
+ x(O, {
30
+ label: u(r)("report.common.cancel"),
31
+ variant: "tertiary",
32
+ onClick: u(f).dismiss
33
+ }, null, 8, ["label", "onClick"]),
34
+ x(O, {
35
+ label: u(r)("report.common.confirm"),
36
+ onClick: u(f).confirm
37
+ }, null, 8, ["label", "onClick"])
38
+ ]),
39
+ _: 1
40
+ }, 8, ["modelValue"]);
41
+ };
42
+ }
43
+ }), H = A(C());
44
+ function $e() {
45
+ const R = (r) => {
46
+ switch (H.value = r, r) {
47
+ case "zh-CN":
48
+ i.locale("zh-cn");
49
+ break;
50
+ default:
51
+ i.locale("en");
52
+ break;
53
+ }
54
+ };
55
+ return Z(() => {
56
+ R(C());
57
+ }), h(() => C(), R, { deep: !0, immediate: !0 }), {
58
+ currentLocale: H
59
+ };
60
+ }
61
+ i.locale(C() === "zh-CN" ? "zh-cn" : "en");
62
+ const Be = ["src"], Je = ["src"], Ke = /* @__PURE__ */ X({
63
+ __name: "App",
64
+ setup(R) {
65
+ const { businessId: r, token: f, country: c } = b(De()), { sessionUser: v, currentBusiness: S, currentCountry: q, registerSidebarComponent: g } = B(), { getRestaurantAndWarehouse: O, getBusinessSetting: E } = K(), { getFeatureFlags: k } = Ie(), { version: p } = b(_e()), { getSettings: M } = he(), { promptLoader: ee } = Re(), e = Ee(), T = ke(), te = G(() => `https://portal-v1.feedmedev.cc/b/${r.value}/report/CLOSE_UP?showHeader=false&country=${c.value.toUpperCase()}&menuOption=business-report&token=${f.value}&v2=true&reportV5Button=true`), ae = G(() => `https://report-v4.feedmedev.cc?businessId=${r.value}&country=${c.value}&token=${f.value}&reportV3Button=true`);
66
+ h(
67
+ [() => S.value, () => v.value, () => q.value],
68
+ () => {
69
+ var t, o;
70
+ const a = ((t = S.value) == null ? void 0 : t.id) ?? "";
71
+ S.value && v.value && q.value && (qe(c.value), r.value !== a && (r.value = a), f.value = ((o = v.value) == null ? void 0 : o.token) ?? "", c.value = q.value ?? "", e.query.businessId !== r.value && T.replace({
72
+ name: e.name,
73
+ params: e.params,
74
+ query: { ...e.query, businessId: r.value }
75
+ }));
76
+ },
77
+ { immediate: !0 }
78
+ );
79
+ function U(a) {
80
+ if (typeof a.data == "string")
81
+ try {
82
+ const t = JSON.parse(a.data);
83
+ (t == null ? void 0 : t.token) !== "" && (t == null ? void 0 : t.token) !== void 0 && (f.value = t.token);
84
+ } catch (t) {
85
+ console.error(t);
86
+ }
87
+ }
88
+ function z(a) {
89
+ if (typeof a.data == "string")
90
+ try {
91
+ const t = JSON.parse(a.data);
92
+ (t == null ? void 0 : t.v5) === !0 ? p.value = N.value : (t == null ? void 0 : t.v3) === !0 && (p.value = "v3");
93
+ } catch (t) {
94
+ console.error(t);
95
+ }
96
+ }
97
+ h(p, () => {
98
+ ["v3", "v4"].includes(p.value) ? B().hideSidebarToggle(!0) : B().hideSidebarToggle(!1);
99
+ }), ge(() => {
100
+ g(be);
101
+ }), Z(() => {
102
+ console.log("5.18.2-beta.4", !0), window.addEventListener("message", U), window.addEventListener("message", z);
103
+ });
104
+ const D = we(), Q = Ce(), n = K();
105
+ ye(() => {
106
+ window.removeEventListener("message", U), window.removeEventListener("message", z), D.$dispose(), Q.$dispose();
107
+ });
108
+ const { getReports: ne, getOverviewReport: re, getReportConfig: V, currentReportId: oe } = D, { currentReportId: se } = b(D), { getSchema: ie } = Le(), { fetchSchedules: ue } = Q, { init: ce } = Oe(), N = A("v5"), _ = A(!1);
109
+ function le() {
110
+ const a = e.query.startDate ? i(e.query.startDate).startOf("day").toISOString() : void 0, t = e.query.endDate ? i(e.query.endDate).endOf("day").toISOString() : void 0, o = e.query.timeStart ? JSON.parse(e.query.timeStart) : void 0, l = e.query.timeEnd ? JSON.parse(e.query.timeEnd) : void 0, d = e.query.compareStartDate ? i(e.query.compareStartDate).startOf("day").toISOString() : void 0, y = e.query.compareEndDate ? i(e.query.compareEndDate).endOf("day").toISOString() : void 0, w = e.query.isAllLocation === "true";
111
+ let m = [];
112
+ w ? m = n.selectedLocationIds : m = e.query.locationIds ? JSON.parse(e.query.locationIds) : void 0;
113
+ const L = e.query.reportId || oe;
114
+ if (L && L !== D.currentReportId && D.updateCurrentReportId(L), a || t) {
115
+ const s = n.dateRange;
116
+ (s.startDate !== a || s.endDate !== t) && n.setDateRange({ startDate: a, endDate: t });
117
+ }
118
+ if (o || l) {
119
+ const s = n.timeRange;
120
+ (s.start !== o || s.end !== l) && n.setTimeRange({ start: o, end: l });
121
+ }
122
+ if (d || y) {
123
+ const s = n.compareDateRange;
124
+ (s.startDate !== d || s.endDate !== y) && n.setCompareDateRange({
125
+ startDate: d,
126
+ endDate: y
127
+ });
128
+ }
129
+ if (!w && Array.isArray(m)) {
130
+ const s = n.selectedLocationIds;
131
+ s.length === m.length && s.every((de, me) => de === m[me]) || n.setSelectedLocationIds(m);
132
+ }
133
+ return {
134
+ reportId: L,
135
+ startDate: e.query.startDate,
136
+ endDate: e.query.endDate,
137
+ timeStart: e.query.timeStart,
138
+ timeEnd: e.query.timeEnd,
139
+ compareStartDate: e.query.compareStartDate,
140
+ compareEndDate: e.query.compareEndDate,
141
+ locationIds: e.query.locationIds,
142
+ isAllLocation: e.query.isAllLocation
143
+ };
144
+ }
145
+ return h(
146
+ () => r.value,
147
+ async () => {
148
+ r.value !== "" && (_.value = !1, await ee(async () => {
149
+ await ce({
150
+ apiKey: "MaGoXrEWuEJNpWgKTqseee",
151
+ url: "https://flag.feedme.farm/api/v1/",
152
+ enableAnalytics: !1,
153
+ cacheFlags: !1
154
+ });
155
+ const a = await V();
156
+ N.value = a.version, p.value = N.value, await Promise.all([
157
+ k(),
158
+ V(),
159
+ re(),
160
+ ne(),
161
+ ie(),
162
+ ue(),
163
+ O(
164
+ e.query.locationIds ? JSON.parse(e.query.locationIds) : null
165
+ ),
166
+ M()
167
+ ]), await E(), le();
168
+ }), _.value = !0);
169
+ },
170
+ {
171
+ immediate: !0
172
+ }
173
+ ), h(
174
+ () => (_.value, {
175
+ reportId: se.value,
176
+ selectedLocationIds: n.selectedLocationIds,
177
+ dateRange: n.dateRange,
178
+ timeRange: n.timeRange,
179
+ compareDateRange: n.compareDateRange
180
+ }),
181
+ (a) => {
182
+ if (!_.value || !a.reportId) return;
183
+ const t = a.selectedLocationIds, o = a.dateRange, l = a.timeRange, d = a.compareDateRange, y = {
184
+ ...e.query,
185
+ reportId: a.reportId,
186
+ startDate: o.startDate ? i(o.startDate).startOf("day").toISOString() : void 0,
187
+ endDate: o.endDate ? i(o.endDate).endOf("day").toISOString() : void 0,
188
+ compareStartDate: d.startDate ? i(d.startDate).startOf("day").toISOString() : void 0,
189
+ compareEndDate: d.endDate ? i(d.endDate).endOf("day").toISOString() : void 0,
190
+ timeStart: l.start ? JSON.stringify(l.start) : void 0,
191
+ timeEnd: l.end ? JSON.stringify(l.end) : void 0,
192
+ locationIds: t.length === n.locations.length ? null : t.length > 0 ? JSON.stringify(t) : void 0,
193
+ isAllLocation: String(t.length === n.locations.length)
194
+ }, w = JSON.stringify(e.query), m = JSON.stringify(y);
195
+ w !== m && T.replace({
196
+ name: e.name,
197
+ params: e.params,
198
+ query: y
199
+ });
200
+ },
201
+ { deep: !0 }
202
+ ), $e(), (a, t) => {
203
+ const o = J("router-view");
204
+ return I(), $(ve, null, [
205
+ x(Fe),
206
+ u(p) === "v3" ? (I(), $("iframe", {
207
+ key: 0,
208
+ class: "bg-white h-full w-full",
209
+ src: te.value
210
+ }, null, 8, Be)) : u(p) === "v4" ? (I(), $("iframe", {
211
+ key: 1,
212
+ class: "bg-white h-full w-full",
213
+ src: ae.value
214
+ }, null, 8, Je)) : (I(), Y(o, { key: 2 }))
215
+ ], 64);
216
+ };
217
+ }
218
+ });
219
+ export {
220
+ Ke as default
221
+ };