@feedmepos/mf-connect 0.1.98-beta.40 → 0.1.98-beta.41

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 (151) hide show
  1. package/dist/App-C6JJ9uQ8.js +4785 -0
  2. package/dist/AuditLogs-CAlgtDgx.js +2014 -0
  3. package/dist/Bin-D8jwhwER.js +166 -0
  4. package/dist/Broadcast-CP8DRfkT.js +269 -0
  5. package/dist/CampaignAnalytic-MVjYBFvu.js +1826 -0
  6. package/dist/CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DeLURz87.js +122 -0
  7. package/dist/Card-QribXJwZ.js +911 -0
  8. package/dist/ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js +97 -0
  9. package/dist/Collections-X9xbt43V.js +541 -0
  10. package/dist/Credit-QmbsW1eb.js +286 -0
  11. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-Du7fRSZC.js +128 -0
  12. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +58 -0
  13. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-ClNieHSo.js +3382 -0
  14. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CrGHTNhg.js +351 -0
  15. package/dist/Experience-CPGMg847.js +285 -0
  16. package/dist/FileSaver.min-CK67LsPG.js +74 -0
  17. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +129 -0
  18. package/dist/FmTableSelection.vue_vue_type_script_setup_true_lang-DzcUc0_w.js +52 -0
  19. package/dist/Game-BrkiEFCS.js +356 -0
  20. package/dist/GiftCardSetup-DXNBHF1A.js +542 -0
  21. package/dist/Grab-BgtDzK1B.js +301 -0
  22. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-Dzv2AkKN.js +145 -0
  23. package/dist/Index-KJgzalOd.js +259 -0
  24. package/dist/JsonViewer-v8_C7l5N.js +87 -0
  25. package/dist/LocationPicker.vue_vue_type_script_setup_true_lang-C6SBLJGQ.js +48 -0
  26. package/dist/LottieAnimation.vue_vue_type_script_setup_true_lang-Dj74lJ7b.js +18737 -0
  27. package/dist/LoyaltyDashboard-B2JpbC01.js +1345 -0
  28. package/dist/MainLayout-DlfTKHQ-.js +143 -0
  29. package/dist/Marketing-Crx_JQpi.js +236 -0
  30. package/dist/MarketingMaterialEdit-BfsdcMXJ.js +1036 -0
  31. package/dist/Member-C50Nrsko.js +281 -0
  32. package/dist/MemberList-C9uUKw1o.js +1603 -0
  33. package/dist/MemberOverview-wL_ailso.js +58 -0
  34. package/dist/MemberTransactions-DZ7zPOHX.js +45 -0
  35. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-Du_ZGsbX.js +60957 -0
  36. package/dist/MetricInfoTooltip.vue_vue_type_script_setup_true_lang-Bg_0YlwG.js +38 -0
  37. package/dist/Mission-D_km8zi6.js +360 -0
  38. package/dist/Overview-BBieK6qQ.js +1080 -0
  39. package/dist/Overview-B_kmLOcc.js +1316 -0
  40. package/dist/Point-D0q9N7f9.js +288 -0
  41. package/dist/Promotion-DoFTy-NK.js +423 -0
  42. package/dist/Queue-Dh5sDRHW.js +261 -0
  43. package/dist/Record-0owEBKqN.js +342 -0
  44. package/dist/Review-DV2fnpOH.js +45 -0
  45. package/dist/ReviewFacebookCallback-D8mnAPzR.js +238 -0
  46. package/dist/ReviewGoogleCallback-CLzt_ox2.js +213 -0
  47. package/dist/Reward-Co20Xrss.js +442 -0
  48. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-0qU49c47.js +150 -0
  49. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-qdvaXPhJ.js +1913 -0
  50. package/dist/Segment-7dQKeHWK.js +1017 -0
  51. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-BUVrUifO.js +181 -0
  52. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-DDsV9TD9.js +189 -0
  53. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-DqPZpddc.js +226 -0
  54. package/dist/Setting-Bvahxs-y.js +2047 -0
  55. package/dist/SettingAdvertisements-fbXLRwfb.js +264 -0
  56. package/dist/Settings-C_HWDFN8.js +179 -0
  57. package/dist/Store-8yBKDR1b.js +2413 -0
  58. package/dist/StoreRewards-DKaJvoJs.js +540 -0
  59. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-D23XzJD7.js +1075 -0
  60. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-JaFhCK_L.js +7007 -0
  61. package/dist/Tier-CD-CjXC3.js +972 -0
  62. package/dist/Title-C_lcgye8.js +569 -0
  63. package/dist/Transaction-BvUYm-rT.js +39 -0
  64. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-C3Yacz7K.js +130 -0
  65. package/dist/Voucher-CYaG0GLU.js +444 -0
  66. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-DF2JqzRe.js +421 -0
  67. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-B4UPqSNc.js +56 -0
  68. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  69. package/dist/app-CE5hQ4Uq.js +60740 -0
  70. package/dist/app-wDQR6dpb.js +39 -0
  71. package/dist/app.js +7 -0
  72. package/dist/business-CE_4siXc.js +82 -0
  73. package/dist/campaign-BP6rvSpg.js +255 -0
  74. package/dist/campaign-CXQtKpeb.js +100 -0
  75. package/dist/campaign-CpzFl8Vr.js +4 -0
  76. package/dist/campaign.enum-Dx-Zo68Q.js +26 -0
  77. package/dist/campaign.fn-DKnBpE1N.js +776 -0
  78. package/dist/collectible.enum-Liy2wH3s.js +19 -0
  79. package/dist/collection.fn-Cg16QZSp.js +26 -0
  80. package/dist/duplicateCampaign-DbtVAGsT.js +51 -0
  81. package/dist/effect-CLI8NI4O.js +89 -0
  82. package/dist/email-addresses-DlLiZ1io.js +705 -0
  83. package/dist/export-6Hr34dBU.js +97 -0
  84. package/dist/feedme.ico +0 -0
  85. package/dist/google-C3S8u0mT.js +4 -0
  86. package/dist/helper-vkjFqj70.js +86 -0
  87. package/dist/index-BIyKgw4m.js +72 -0
  88. package/dist/index-BLQJ-rv3.js +31 -0
  89. package/dist/index-BbTIqReL.js +67 -0
  90. package/dist/index-BuMfQxMf.js +897 -0
  91. package/dist/index-C8cXXcLk.js +45 -0
  92. package/dist/index-CSVhIZSY.js +8919 -0
  93. package/dist/index-CVHacTbc.js +151 -0
  94. package/dist/index-C_H8jFYf.js +2743 -0
  95. package/dist/index-CmNsGhDf.js +2706 -0
  96. package/dist/index-CnTeeRyJ.js +53 -0
  97. package/dist/index-CuvNtC_M.js +61 -0
  98. package/dist/index-CzbNobLv.js +1139 -0
  99. package/dist/index-D06n1h1b.js +146 -0
  100. package/dist/index-D4SDAfbP.js +27550 -0
  101. package/dist/index-DVnYQ3Hs.js +85 -0
  102. package/dist/index-DcjnS5Sv.js +28900 -0
  103. package/dist/index-Dx9h0FNH.js +3 -0
  104. package/dist/index-YgP4ihQL.js +32 -0
  105. package/dist/index-kedErkLZ.js +2963 -0
  106. package/dist/index-lnQT4P3d.js +55 -0
  107. package/dist/index-vh86FiIQ.js +10 -0
  108. package/dist/index.esm2017-Jhv2lkrq.js +3069 -0
  109. package/dist/loading-NY-FPxVY.js +72 -0
  110. package/dist/lodash-BC_P6kLg.js +3678 -0
  111. package/dist/membership-BWaK-9FY.js +255 -0
  112. package/dist/moment-D7p2TMB-.js +2583 -0
  113. package/dist/money-COoh4GXK.js +15 -0
  114. package/dist/number-BX5OEXgq.js +12 -0
  115. package/dist/object-BYyQ0PZp.js +18 -0
  116. package/dist/objectId-dwaoBfJX.js +7 -0
  117. package/dist/objectid-1SUSRtmY.js +145 -0
  118. package/dist/plugins-ur-FAoye.js +1788 -0
  119. package/dist/remy-Qz_pNsUS.js +13 -0
  120. package/dist/reward-DSsylZ22.js +36 -0
  121. package/dist/rule-BM9GUd1C.js +1969 -0
  122. package/dist/rule-builder-gC9LH2AC.js +126 -0
  123. package/dist/string-Gcy5IM_H.js +32 -0
  124. package/dist/style.css +4 -0
  125. package/dist/template-CUV3AMFI.js +188 -0
  126. package/dist/tier-BJDhpH6X.js +4 -0
  127. package/dist/tiers/tier=1.png +0 -0
  128. package/dist/tiers/tier=2.png +0 -0
  129. package/dist/tiers/tier=3.png +0 -0
  130. package/dist/tiers/tier=4.png +0 -0
  131. package/dist/timezone-BFZhekOU.js +20 -0
  132. package/dist/titles/type=diamond.png +0 -0
  133. package/dist/titles/type=drinks.png +0 -0
  134. package/dist/titles/type=food.png +0 -0
  135. package/dist/titles/type=heart.png +0 -0
  136. package/dist/titles/type=medal.png +0 -0
  137. package/dist/titles/type=spend.png +0 -0
  138. package/dist/titles/type=thank-you.png +0 -0
  139. package/dist/titles/type=thumbs-up.png +0 -0
  140. package/dist/titles/type=years.png +0 -0
  141. package/dist/transaction.fn-C5MlkEIC.js +64 -0
  142. package/dist/trigger-CbjiuoSo.js +213 -0
  143. package/dist/tslib.es6-BCqqvLQ_.js +44 -0
  144. package/dist/type_drinks-D6jnpvwV.js +4 -0
  145. package/dist/useMarketingMaterialActions-BLisTieA.js +96 -0
  146. package/dist/usePagination-Caah4sJr.js +220 -0
  147. package/dist/user-BZC4P_jL.js +55 -0
  148. package/dist/vue-i18n-BYz7XAr_.js +2365 -0
  149. package/dist/xlsx-Bn7BqUFA.js +15491 -0
  150. package/dist/zod-DHH42rXG.js +91 -0
  151. package/package.json +1 -1
@@ -0,0 +1,213 @@
1
+ import { defineComponent as E, onMounted as T, ref as w, computed as B, openBlock as d, createElementBlock as p, Fragment as F, renderList as j, normalizeClass as z, unref as e, createElementVNode as m, createVNode as u, toDisplayString as y, createCommentVNode as S, createBlock as P, resolveComponent as U, isRef as V } from "vue";
2
+ import { u as A } from "./vue-i18n-BYz7XAr_.js";
3
+ import { components as v } from "@feedmepos/ui-library";
4
+ import { r as C } from "./index-BIyKgw4m.js";
5
+ import { u as H } from "./business-CE_4siXc.js";
6
+ import { _ as D } from "./LocationPicker.vue_vue_type_script_setup_true_lang-C6SBLJGQ.js";
7
+ import { R as O } from "./app-CE5hQ4Uq.js";
8
+ import { useRouter as W } from "vue-router";
9
+ const q = { class: "flex flex-col gap-8" }, J = ["onClick"], K = { class: "fm-typo-en-body-md-600 flex-1 truncate" }, Q = {
10
+ key: 0,
11
+ class: "fm-typo-en-body-sm-400 text-fm-color-primary-500 shrink-0"
12
+ }, X = /* @__PURE__ */ E({
13
+ __name: "GoogleLocationMapping",
14
+ props: {
15
+ locations: {}
16
+ },
17
+ emits: ["update:locations"],
18
+ setup(k, { emit: a }) {
19
+ const N = k, b = a, i = H();
20
+ T(() => i.readLocations());
21
+ const g = w(null), h = B(() => {
22
+ const l = /* @__PURE__ */ new Set();
23
+ for (const r of N.locations)
24
+ r.locationId && l.add(r.locationId);
25
+ return l;
26
+ });
27
+ function L(l) {
28
+ return i.locations.filter((r) => {
29
+ const t = r._id.toString();
30
+ return !h.value.has(t) || l.locationId === t;
31
+ });
32
+ }
33
+ function f(l, r) {
34
+ const t = r._id.toString(), _ = N.locations.map((n) => {
35
+ if (n.googleLocationName !== l) return n;
36
+ const o = n.locationId === t;
37
+ return {
38
+ ...n,
39
+ locationId: o ? null : t,
40
+ locationName: o ? null : r.name
41
+ };
42
+ });
43
+ b("update:locations", _);
44
+ }
45
+ function I(l) {
46
+ g.value = g.value === l ? null : l;
47
+ }
48
+ return (l, r) => (d(), p("div", q, [
49
+ (d(!0), p(F, null, j(k.locations, (t) => (d(), p("div", {
50
+ key: t.googleLocationName,
51
+ class: z([
52
+ "rounded-lg border overflow-hidden transition-colors",
53
+ e(g) === t.googleLocationName ? "border-fm-color-primary-500" : "border-fm-color-neutral-gray-200"
54
+ ])
55
+ }, [
56
+ m("button", {
57
+ class: "w-full flex items-center gap-12 p-16 bg-white text-left hover:bg-fm-color-neutral-gray-50 transition-colors",
58
+ onClick: (_) => I(t.googleLocationName)
59
+ }, [
60
+ u(e(v).FmIcon, {
61
+ name: "storefront",
62
+ class: "text-fm-color-neutral-gray-400 shrink-0"
63
+ }),
64
+ m("span", K, y(t.displayName || t.googleLocationName), 1),
65
+ t.locationName ? (d(), p("span", Q, y(t.locationName), 1)) : S("", !0),
66
+ u(e(v).FmIcon, {
67
+ name: e(g) === t.googleLocationName ? "expand_less" : "expand_more",
68
+ class: "text-fm-color-neutral-gray-400 shrink-0"
69
+ }, null, 8, ["name"])
70
+ ], 8, J),
71
+ e(g) === t.googleLocationName ? (d(), P(D, {
72
+ key: 0,
73
+ locations: L(t),
74
+ "selected-ids": t.locationId ? [t.locationId] : [],
75
+ onToggle: (_) => f(t.googleLocationName, _)
76
+ }, null, 8, ["locations", "selected-ids", "onToggle"])) : S("", !0)
77
+ ], 2))), 128))
78
+ ]));
79
+ }
80
+ }), Y = { class: "flex flex-col min-h-full gap-16 p-24" }, Z = {
81
+ key: 0,
82
+ class: "flex flex-col items-center justify-center flex-1 gap-16"
83
+ }, ee = { class: "fm-typo-en-body-md-400 text-fm-color-neutral-gray-400" }, oe = {
84
+ key: 1,
85
+ class: "flex flex-col items-center justify-center flex-1 gap-16"
86
+ }, te = { class: "fm-typo-en-body-lg-600" }, ne = { class: "fm-typo-en-body-md-400 text-fm-color-neutral-gray-400" }, ae = {
87
+ key: 2,
88
+ class: "flex flex-col items-center justify-center flex-1 gap-16"
89
+ }, le = { class: "fm-typo-en-body-lg-600" }, se = { class: "fm-typo-en-body-md-400 text-fm-color-neutral-gray-400" }, ce = { class: "fm-typo-en-body-lg-600" }, ie = { class: "flex gap-8 justify-end mt-auto pt-8" }, ve = /* @__PURE__ */ E({
90
+ __name: "ReviewGoogleCallback",
91
+ setup(k) {
92
+ const { t: a } = A(), N = W();
93
+ function b() {
94
+ return N.replace({ name: O["$connect-REVIEW_SETTINGS"] });
95
+ }
96
+ const i = w([]), g = w(!1), h = w(!1), L = w(!1), f = w(null), I = B(
97
+ () => i.value.some((n) => n.locationId !== null)
98
+ );
99
+ function l(n, o) {
100
+ return n instanceof Error ? n.message : o;
101
+ }
102
+ function r(n, o) {
103
+ const x = new Map(
104
+ o.map((s) => [s.googleLocationName, s.location])
105
+ );
106
+ return n.map((s) => {
107
+ const c = x.get(s.googleLocationName) ?? null;
108
+ return {
109
+ googleLocationName: s.googleLocationName,
110
+ displayName: s.displayName,
111
+ locationId: (c == null ? void 0 : c._id) ?? null,
112
+ locationName: (c == null ? void 0 : c.name) ?? null
113
+ };
114
+ });
115
+ }
116
+ async function t() {
117
+ var s;
118
+ const n = new URLSearchParams(window.location.search), o = n.get("code"), x = n.get("state");
119
+ if (!o || !x) {
120
+ f.value = a("connect.review.noToken");
121
+ return;
122
+ }
123
+ g.value = !0;
124
+ try {
125
+ const c = await C.getSource(), R = ((s = c == null ? void 0 : c.google) == null ? void 0 : s.locations) ?? [], M = window.location.pathname.replace(/\/review(?:\/.*)?$/, ""), G = `${window.location.origin}${M}/review/google/callback`, $ = await C.connectGoogle(o, G, x);
126
+ i.value = r(($ == null ? void 0 : $.locations) ?? [], R), i.value.length === 0 && (f.value = a("connect.review.google.noLocations"));
127
+ } catch (c) {
128
+ f.value = l(c, a("connect.review.google.failed"));
129
+ } finally {
130
+ g.value = !1;
131
+ }
132
+ }
133
+ async function _() {
134
+ const n = i.value.map((o) => ({
135
+ googleLocationName: o.googleLocationName,
136
+ displayName: o.displayName,
137
+ locationId: o.locationId
138
+ }));
139
+ if (n.length === 0) {
140
+ f.value = a("connect.review.noMappings");
141
+ return;
142
+ }
143
+ h.value = !0;
144
+ try {
145
+ await C.updateGoogleLocations(n), L.value = !0, setTimeout(b, 2e3);
146
+ } catch (o) {
147
+ f.value = l(o, a("connect.review.google.failed"));
148
+ } finally {
149
+ h.value = !1;
150
+ }
151
+ }
152
+ return T(t), (n, o) => {
153
+ const x = U("FmPageHead");
154
+ return d(), p(F, null, [
155
+ u(x, {
156
+ title: e(a)("connect.navigation.review")
157
+ }, null, 8, ["title"]),
158
+ m("div", Y, [
159
+ e(g) ? (d(), p("div", Z, [
160
+ u(e(v).FmIcon, {
161
+ name: "sync",
162
+ size: "xl",
163
+ class: "animate-spin text-fm-color-neutral-gray-400"
164
+ }),
165
+ m("p", ee, y(e(a)("connect.review.google.fetching")), 1)
166
+ ])) : e(L) ? (d(), p("div", oe, [
167
+ u(e(v).FmIcon, {
168
+ name: "check_circle",
169
+ size: "xl",
170
+ class: "text-fm-color-typo-success"
171
+ }),
172
+ m("p", te, y(e(a)("connect.review.google.success")), 1),
173
+ m("p", ne, y(e(a)("connect.review.redirecting")), 1)
174
+ ])) : e(f) ? (d(), p("div", ae, [
175
+ u(e(v).FmIcon, {
176
+ name: "error",
177
+ size: "xl",
178
+ class: "text-fm-color-system-error-500"
179
+ }),
180
+ m("p", le, y(e(a)("connect.review.errorTitle")), 1),
181
+ m("p", se, y(e(f)), 1),
182
+ u(e(v).FmButton, {
183
+ label: e(a)("connect.review.goBack"),
184
+ onClick: o[0] || (o[0] = (s) => b())
185
+ }, null, 8, ["label"])
186
+ ])) : e(i).length > 0 ? (d(), p(F, { key: 3 }, [
187
+ m("p", ce, y(e(a)("connect.review.google.selectLocation")), 1),
188
+ u(X, {
189
+ locations: e(i),
190
+ "onUpdate:locations": o[1] || (o[1] = (s) => V(i) ? i.value = s : null)
191
+ }, null, 8, ["locations"]),
192
+ m("div", ie, [
193
+ u(e(v).FmButton, {
194
+ variant: "outlined",
195
+ label: e(a)("connect.review.cancel"),
196
+ onClick: o[2] || (o[2] = (s) => b())
197
+ }, null, 8, ["label"]),
198
+ u(e(v).FmButton, {
199
+ label: e(a)("connect.review.connect"),
200
+ disabled: !e(I),
201
+ loading: e(h),
202
+ onClick: _
203
+ }, null, 8, ["label", "disabled", "loading"])
204
+ ])
205
+ ], 64)) : S("", !0)
206
+ ])
207
+ ], 64);
208
+ };
209
+ }
210
+ });
211
+ export {
212
+ ve as default
213
+ };
@@ -0,0 +1,442 @@
1
+ import { defineComponent as X, ref as x, computed as H, resolveComponent as w, openBlock as b, createBlock as h, unref as t, isRef as Z, withCtx as A, createElementVNode as f, createVNode as d, createCommentVNode as k, createElementBlock as M, Fragment as Y, h as _, onMounted as q, toDisplayString as B } from "vue";
2
+ import { _ as z } from "./campaign-CpzFl8Vr.js";
3
+ import { useDialog as Q, components as L } from "@feedmepos/ui-library";
4
+ import { u as G } from "./loading-NY-FPxVY.js";
5
+ import { u as J, C as ee } from "./membership-BWaK-9FY.js";
6
+ import { f as j, p as te } from "./plugins-ur-FAoye.js";
7
+ import { u as oe } from "./vue-i18n-BYz7XAr_.js";
8
+ import { c as ae } from "./object-BYyQ0PZp.js";
9
+ import { Z as F } from "./zod-DHH42rXG.js";
10
+ import "./index-CSVhIZSY.js";
11
+ import { a as N } from "./index-lnQT4P3d.js";
12
+ import { useCoreStore as le } from "@feedmepos/mf-common";
13
+ import { _ as ne, a as ie } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-DF2JqzRe.js";
14
+ import { b as re } from "./EffectSheet.vue_vue_type_style_index_0_lang-CrGHTNhg.js";
15
+ import { J as K } from "./JsonViewer-v8_C7l5N.js";
16
+ import { _ as se } from "./ZodTextField.vue_vue_type_script_setup_true_lang-B4UPqSNc.js";
17
+ import { i as de } from "./helper-vkjFqj70.js";
18
+ import { u as pe, r as P } from "./reward-DSsylZ22.js";
19
+ import "./index-Dx9h0FNH.js";
20
+ import { C as ce } from "./campaign.fn-DKnBpE1N.js";
21
+ import { e as me } from "./effect-CLI8NI4O.js";
22
+ import { useRouter as ue } from "vue-router";
23
+ import { R as ye } from "./app-CE5hQ4Uq.js";
24
+ const fe = { class: "flex gap-8 items-center justify-start" }, we = /* @__PURE__ */ X({
25
+ __name: "EditRewardSheet",
26
+ emits: ["update"],
27
+ setup(W, { expose: n, emit: I }) {
28
+ const p = J(), { minor: C } = G, v = x(!1), a = x({}), y = x(), R = H(() => {
29
+ var l;
30
+ return ((l = a.value.option) == null ? void 0 : l.collectibleType) === "CREDIT" ? N.superRefine((e, o) => {
31
+ var i, m, g, r;
32
+ !((m = (i = e.option) == null ? void 0 : i.validityOption) != null && m.validForDay) && !((r = (g = e.option) == null ? void 0 : g.validityOption) != null && r.validBefore) && o.addIssue({
33
+ code: "custom",
34
+ path: [],
35
+ message: "Credit validity must be set"
36
+ });
37
+ }) : N;
38
+ }), u = H(() => {
39
+ const l = R.value.safeParse(a.value);
40
+ return l.success ? [] : l.error.errors;
41
+ });
42
+ function O(l, e) {
43
+ l && (y.value = void 0, a.value = e), v.value = l;
44
+ }
45
+ const D = I;
46
+ async function S() {
47
+ const l = R.value.safeParse(a.value);
48
+ !l.success || !l.data || (await C(
49
+ async () => {
50
+ var e;
51
+ l.data.option.type === "VOUCHER" && y.value && (l.data.option.collectibleConfig.image = await j.update(
52
+ ((e = l.data.option.collectibleConfig) == null ? void 0 : e.image) || j.collectibleImagePath(void 0, y.value),
53
+ y.value
54
+ ));
55
+ },
56
+ {
57
+ message: "Uploading reward image",
58
+ successMessage: "Reward image updated"
59
+ }
60
+ ), D("update", l.data));
61
+ }
62
+ function T(l) {
63
+ l === "VOUCHER" ? a.value.option = {
64
+ collectible: null,
65
+ type: "VOUCHER",
66
+ collectibleConfig: de("VOUCHER", {
67
+ business: le().currentBusiness.value._id
68
+ }),
69
+ earningOption: {
70
+ amount: 1,
71
+ type: "FIXED"
72
+ },
73
+ validityOption: {
74
+ validForDay: 7
75
+ }
76
+ } : a.value.option = {
77
+ collectible: p.loyaltyRewards.raw[0]._id,
78
+ collectibleType: p.loyaltyRewards.raw[0].type,
79
+ type: "LOYALTY",
80
+ earningOption: {
81
+ amount: 1,
82
+ type: "FIXED"
83
+ },
84
+ validityOption: {
85
+ validForDay: 7
86
+ }
87
+ };
88
+ }
89
+ function $(l) {
90
+ a.value.option.collectible = l, a.value.option.collectibleType = p.loyaltyRewards.raw.find(
91
+ (e) => e._id === l
92
+ ).type;
93
+ }
94
+ const V = x();
95
+ return n({
96
+ showSheet: O
97
+ }), (l, e) => {
98
+ const o = w("FmSelect"), i = w("FmForm"), m = w("FmButton"), g = w("FmSideSheet");
99
+ return b(), h(g, {
100
+ "max-width": 560,
101
+ modelValue: t(v),
102
+ "onUpdate:modelValue": [
103
+ e[8] || (e[8] = (r) => Z(v) ? v.value = r : null),
104
+ e[9] || (e[9] = (r) => v.value = r)
105
+ ],
106
+ header: "Edit reward"
107
+ }, {
108
+ "side-sheet-footer": A(() => [
109
+ f("div", fe, [
110
+ d(m, {
111
+ variant: "primary",
112
+ type: "button",
113
+ label: "Confirm",
114
+ disabled: t(u).length > 0,
115
+ onClick: e[6] || (e[6] = (r) => S())
116
+ }, null, 8, ["disabled"]),
117
+ d(m, {
118
+ variant: "secondary",
119
+ type: "button",
120
+ label: "Cancel",
121
+ onClick: e[7] || (e[7] = (r) => v.value = !1)
122
+ })
123
+ ])
124
+ ]),
125
+ default: A(() => [
126
+ d(K, { json: t(a) }, null, 8, ["json"]),
127
+ d(i, {
128
+ class: "flex flex-col gap-y-24",
129
+ ref_key: "formRef",
130
+ ref: V,
131
+ onValidationSuccess: e[5] || (e[5] = (r) => S())
132
+ }, {
133
+ default: A(() => {
134
+ var r, E, c;
135
+ return [
136
+ d(se, {
137
+ modelValue: t(a).name,
138
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => t(a).name = s),
139
+ label: "Reward Name",
140
+ schema: t(F).typeAtPath(t(R), "name", []),
141
+ "error-text": t(F).helperText(t(u), "name")
142
+ }, null, 8, ["modelValue", "schema", "error-text"]),
143
+ d(o, {
144
+ label: "Reward Type",
145
+ disabled: !!t(a)._id,
146
+ items: [
147
+ { label: "Voucher", value: "VOUCHER" },
148
+ { label: "Loyalty", value: "LOYALTY" }
149
+ ],
150
+ "model-value": t(a).option.type,
151
+ "onUpdate:modelValue": T
152
+ }, null, 8, ["disabled", "model-value"]),
153
+ t(a).option.type == "LOYALTY" ? (b(), h(o, {
154
+ key: 0,
155
+ label: "Loyalty type",
156
+ items: t(p).loyaltyRewards.items,
157
+ "model-value": t(a).option.collectible,
158
+ "onUpdate:modelValue": $
159
+ }, null, 8, ["items", "model-value"])) : k("", !0),
160
+ t(a).option.type === "LOYALTY" ? (b(), M(Y, { key: 1 }, [
161
+ e[10] || (e[10] = f("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
162
+ ((r = t(p).loyaltyRewards.items.find(
163
+ (s) => {
164
+ var U;
165
+ return s.value === ((U = t(a)) == null ? void 0 : U.option.collectible);
166
+ }
167
+ )) == null ? void 0 : r.raw.type) !== "TITLE" ? (b(), h(ne, {
168
+ key: 0,
169
+ class: "mt-[-8px]",
170
+ rules: [
171
+ t(F).ruleAtPath(t(R), "option.earningOption", [
172
+ t(a).option.type
173
+ ])
174
+ ],
175
+ "helper-state": t(F).helperState(t(u), "option.earningOption"),
176
+ "error-text": t(F).helperText(t(u), "option.earningOption"),
177
+ "fixed-type": !0,
178
+ "model-value": t(a).option.earningOption,
179
+ "onUpdate:modelValue": e[1] || (e[1] = (s) => t(a).option.earningOption = s)
180
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"])) : k("", !0),
181
+ d(re, {
182
+ class: "!gap-24",
183
+ "for-credit": t(a).option.type === "LOYALTY" && ((E = t(p).loyaltyRewards.items.find(
184
+ (s) => {
185
+ var U;
186
+ return s.value === ((U = t(a).option) == null ? void 0 : U.collectible);
187
+ }
188
+ )) == null ? void 0 : E.raw.type) === "CREDIT",
189
+ type: t(a).option.type === "VOUCHER" ? "range" : "custom",
190
+ rules: [
191
+ t(F).ruleAtPath(t(R), "option.validityOption", [
192
+ t(a).option.type
193
+ ])
194
+ ],
195
+ "model-value": t(a).option.validityOption,
196
+ "onUpdate:modelValue": e[2] || (e[2] = (s) => t(a).option.validityOption = s)
197
+ }, null, 8, ["for-credit", "type", "rules", "model-value"])
198
+ ], 64)) : k("", !0),
199
+ t(a).option.type === "VOUCHER" ? (b(), h(ie, {
200
+ key: 2,
201
+ "reward-image": t(y),
202
+ "model-value": ((c = t(a)) == null ? void 0 : c.option.collectibleConfig) ?? void 0,
203
+ "onUpdate:modelValue": e[3] || (e[3] = (s) => t(a).option.collectibleConfig = s),
204
+ "onUpdate:rewardImage": e[4] || (e[4] = (s) => y.value = s)
205
+ }, null, 8, ["reward-image", "model-value"])) : k("", !0),
206
+ d(K, { json: t(u) }, null, 8, ["json"])
207
+ ];
208
+ }),
209
+ _: 1
210
+ }, 512)
211
+ ]),
212
+ _: 1
213
+ }, 8, ["modelValue"]);
214
+ };
215
+ }
216
+ }), ve = { class: "px-24 flex flex-col gap-y-16" }, ge = { class: "flex items-center justify-between w-full" }, be = { class: "flex flex-col gap-16 text-center" }, Re = { class: "fm-typo-en-title-sm-800" }, Ce = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ke = /* @__PURE__ */ X({
217
+ __name: "Reward",
218
+ setup(W) {
219
+ const { t: n } = oe(), I = {
220
+ label: n("connect.storeRewards.create"),
221
+ value: "create",
222
+ isPrimary: !0,
223
+ prependIcon: "add"
224
+ }, p = J(), C = pe(), { global: v, minor: a } = G, y = ue(), R = Q(), u = x({
225
+ searchKey: "",
226
+ columnFilters: []
227
+ }), O = H(() => C.rewards);
228
+ function D(e) {
229
+ y.push({
230
+ name: ye["$connect-STORE_REWARD_COLLECTIONS"],
231
+ params: { id: e }
232
+ });
233
+ }
234
+ const S = [
235
+ {
236
+ header: n("connect.storeRewards.table.name"),
237
+ accessorFn: (e) => e.name
238
+ },
239
+ {
240
+ header: n("connect.storeRewards.table.type"),
241
+ cell(e) {
242
+ return e.row.original.collectibleConfig ? ee[e.row.original.collectibleConfig.type].chip() : "N/A";
243
+ }
244
+ },
245
+ {
246
+ header: n("connect.storeRewards.table.summary"),
247
+ accessorFn: (e) => {
248
+ var o, i;
249
+ if (e.option.type === "VOUCHER")
250
+ return me((i = (o = e.option.collectibleConfig) == null ? void 0 : o.extras) == null ? void 0 : i.effect);
251
+ if (e.option.collectibleType == "TITLE") {
252
+ const m = p.sortedTitles.find(
253
+ (g) => g._id == e.option.collectible
254
+ );
255
+ return `Get ${m == null ? void 0 : m.name} valid for ${e.option.validityOption.validForDay} days`;
256
+ }
257
+ return `Get ${e.option.earningOption.amount} ${ce.formattedType(e.option.collectibleType)}`;
258
+ }
259
+ },
260
+ {
261
+ header: n("connect.storeRewards.table.actions"),
262
+ cell(e) {
263
+ return _("div", { class: "flex items-center justify-end gap-4" }, [
264
+ _(
265
+ L.FmMenu,
266
+ {
267
+ placement: "bottom-end",
268
+ onClick: (o) => {
269
+ o.stopPropagation();
270
+ }
271
+ },
272
+ {
273
+ "menu-button": () => _(L.FmButton, {
274
+ icon: "more_vert",
275
+ iconColor: "neutral-gray-400",
276
+ variant: "tertiary"
277
+ }),
278
+ default: () => [
279
+ e.row.original.option.type === "VOUCHER" && _(L.FmMenuItem, {
280
+ label: "View collections",
281
+ onClick: async (o) => {
282
+ o.stopPropagation(), D(
283
+ e.row.original.option.collectible
284
+ );
285
+ }
286
+ }),
287
+ _(
288
+ L.FmMenuItem,
289
+ {
290
+ onClick: async (o) => {
291
+ o.stopPropagation(), $(e.row.original);
292
+ }
293
+ },
294
+ {
295
+ label: _(
296
+ "div",
297
+ {
298
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
299
+ },
300
+ "Delete"
301
+ )
302
+ }
303
+ )
304
+ ]
305
+ }
306
+ )
307
+ ]);
308
+ }
309
+ }
310
+ ], T = x();
311
+ async function $(e) {
312
+ await te.remove(
313
+ n("connect.storeRewards.delete.confirm"),
314
+ n("connect.storeRewards.delete.title")
315
+ ) && await a(
316
+ async () => {
317
+ await P.deleteReward(e._id), await C.readRewards();
318
+ },
319
+ {
320
+ message: n("connect.storeRewards.delete.message"),
321
+ successMessage: n("connect.storeRewards.delete.success")
322
+ }
323
+ );
324
+ }
325
+ async function V(e) {
326
+ var o;
327
+ e || (e = {
328
+ name: "",
329
+ option: {
330
+ type: "LOYALTY",
331
+ collectible: p.loyaltyRewards.items[0].value,
332
+ collectibleType: p.loyaltyRewards.items[0].raw.type,
333
+ validityOption: {
334
+ validForDay: 7
335
+ },
336
+ earningOption: {
337
+ type: "FIXED",
338
+ amount: 1
339
+ }
340
+ }
341
+ }), (o = T.value) == null || o.showSheet(!0, ae(e));
342
+ }
343
+ async function l(e) {
344
+ let o = !1;
345
+ e._id && e.option.type === "VOUCHER" && await new Promise((i) => {
346
+ R.open({
347
+ title: "Confirmation",
348
+ message: "This will change all future vouchers? Would you like to update previous claimed vouchers expiry date and discount?",
349
+ primaryActions: { text: "Update all", close: !0 },
350
+ secondaryActions: { text: "Update future only", close: !0 }
351
+ }).onPrimary(async () => {
352
+ o = !0, i();
353
+ }).onSecondary(async () => {
354
+ i();
355
+ });
356
+ }), await a(
357
+ async () => {
358
+ var i;
359
+ e.collectibleConfig = void 0, e._id ? await P.updateReward(e._id, {
360
+ ...e,
361
+ updateCollection: o
362
+ }) : await P.createReward(e), await C.readRewards(), (i = T.value) == null || i.showSheet(!1);
363
+ },
364
+ {
365
+ message: "Updating reward",
366
+ successMessage: "Reward updated successfully"
367
+ }
368
+ );
369
+ }
370
+ return q(async () => {
371
+ await v(async () => {
372
+ await p.readMembership(), await p.readRewards(), await C.readRewards();
373
+ });
374
+ }), (e, o) => {
375
+ const i = w("FmPageHead"), m = w("FmSearch"), g = w("FmTable"), r = w("FmButton"), E = w("FmCard");
376
+ return b(), M(Y, null, [
377
+ d(i, {
378
+ title: t(n)("connect.reward.title"),
379
+ actions: [I],
380
+ "back-button": !0,
381
+ "onClick:action": o[0] || (o[0] = () => V()),
382
+ "onClick:back": o[1] || (o[1] = () => {
383
+ var c;
384
+ return (c = t(y)) == null ? void 0 : c.back();
385
+ })
386
+ }, null, 8, ["title", "actions"]),
387
+ f("div", ve, [
388
+ t(O) && t(O).length > 0 ? (b(), M(Y, { key: 0 }, [
389
+ f("div", ge, [
390
+ o[6] || (o[6] = f("div", { class: "flex gap-8" }, null, -1)),
391
+ d(m, {
392
+ modelValue: t(u).searchKey,
393
+ "onUpdate:modelValue": o[2] || (o[2] = (c) => t(u).searchKey = c),
394
+ class: "",
395
+ placeholder: "search",
396
+ collapsible: ""
397
+ }, null, 8, ["modelValue"])
398
+ ]),
399
+ d(g, {
400
+ "row-data": t(O),
401
+ "column-defs": S,
402
+ "search-value": t(u).searchKey,
403
+ "column-filter": t(u).columnFilters,
404
+ onRowClick: o[3] || (o[3] = (c) => V(c.original)),
405
+ "hide-footer": t(O).length < 10
406
+ }, null, 8, ["row-data", "search-value", "column-filter", "hide-footer"])
407
+ ], 64)) : (b(), h(E, {
408
+ key: 1,
409
+ variant: "outlined",
410
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
411
+ }, {
412
+ default: A(() => [
413
+ o[7] || (o[7] = f("img", {
414
+ src: z,
415
+ class: "aspect-square w-[150px]"
416
+ }, null, -1)),
417
+ f("div", be, [
418
+ f("div", Re, B(t(n)("connect.storeRewards.empty.title")), 1),
419
+ f("div", Ce, B(t(n)("connect.storeRewards.empty.description")), 1)
420
+ ]),
421
+ d(r, {
422
+ variant: "primary",
423
+ label: t(n)("connect.storeRewards.empty.action"),
424
+ onClick: o[4] || (o[4] = (c) => V()),
425
+ icon: "add"
426
+ }, null, 8, ["label"])
427
+ ]),
428
+ _: 1
429
+ })),
430
+ d(we, {
431
+ ref_key: "rewardSheetRef",
432
+ ref: T,
433
+ onUpdate: o[5] || (o[5] = (c) => l(c))
434
+ }, null, 512)
435
+ ])
436
+ ], 64);
437
+ };
438
+ }
439
+ });
440
+ export {
441
+ Ke as default
442
+ };