@feedmepos/mf-connect 0.1.9-prod → 0.1.11-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 (90) hide show
  1. package/dist/{Analytic-8Ew7y5t9.js → Analytic-Bbt1kP2U.js} +24 -23
  2. package/dist/{App-3BVNH3r-.js → App-CVA65EVC.js} +56 -51
  3. package/dist/{Broadcast-CrsPUhLT.js → Broadcast-BJXK8OE5.js} +8 -8
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DE300Y56.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DDEx0cK9.js} +7 -7
  5. package/dist/Card-DFiUkfYj.js +895 -0
  6. package/dist/{Collections-djS9hLI8.js → Collections-qVnvveUf.js} +24 -29
  7. package/dist/{Credit-D4KEvIov.js → Credit-BWHTbAG-.js} +8 -8
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-BjM81fmS.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-4_cHlWUJ.js} +648 -1284
  9. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-aEWfdpCg.js → EffectSheet.vue_vue_type_style_index_0_lang-DLgZd4HU.js} +19 -19
  10. package/dist/{Experience-2FPLO7aV.js → Experience-BmGSus53.js} +8 -8
  11. package/dist/{Game-e_UjVJgU.js → Game-49w7XN5k.js} +8 -8
  12. package/dist/Index-D-7hsAaE.js +258 -0
  13. package/dist/{Marketing-B2hCjZ2r.js → Marketing-DtbJxS_j.js} +5 -5
  14. package/dist/{Member-D_ykRIBb.js → Member-jZks4pw_.js} +4 -4
  15. package/dist/{MemberList-LmzzYxEn.js → MemberList-BqO54kPC.js} +193 -189
  16. package/dist/{MemberTransactions-B2vqlKaP.js → MemberTransactions-CLK7VmPw.js} +1 -1
  17. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-DQ2ubF0N.js → MessageInput.vue_vue_type_script_setup_true_lang-ef2Qrdvd.js} +2 -2
  18. package/dist/Mission-LGC1CGrB.js +273 -0
  19. package/dist/Overview-Dm_ycoqZ.js +1078 -0
  20. package/dist/{Point-DFriwWWY.js → Point-BBNJ9cc5.js} +8 -8
  21. package/dist/{Promotion-Db3IEs2F.js → Promotion-DFh9IEmP.js} +9 -9
  22. package/dist/Record-oBmJTn3G.js +338 -0
  23. package/dist/Reward-DR_HzrrM.js +441 -0
  24. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-Du_0o2b9.js +150 -0
  25. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-CxXugphA.js +1638 -0
  26. package/dist/{Segment-CE8q9JV2.js → Segment-DjyHLWZC.js} +13 -13
  27. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-stTwgie4.js +181 -0
  28. package/dist/{Setting-Vcz1S27V.js → Setting-a7Tw-3ht.js} +31 -31
  29. package/dist/Store-HWGWswEm.js +1744 -0
  30. package/dist/{StoreRewards-Dt30AkWo.js → StoreRewards-s4cX1bFH.js} +12 -12
  31. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Dq4qIXZu.js +1132 -0
  32. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-f59onlgt.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-BQpbScyf.js} +1 -1
  33. package/dist/{Tier-a6yXEtLd.js → Tier-C7kiLjzE.js} +19 -19
  34. package/dist/{Title-A3-2EI0w.js → Title-BPv1ZiHg.js} +19 -19
  35. package/dist/{Transaction-DswABr2P.js → Transaction-HdR7RiGY.js} +2 -2
  36. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-D3VgIQb-.js +130 -0
  37. package/dist/{Voucher-DEoVgZYa.js → Voucher-Y5Lh5xms.js} +11 -11
  38. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-CFKID7mS.js +419 -0
  39. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-ccc1vxjS.js → ZodTextField.vue_vue_type_script_setup_true_lang-6asSbt53.js} +1 -1
  40. package/dist/{app-C23GfQGq.js → app-Bh2mviM1.js} +1 -1
  41. package/dist/{app-C66C2KLW.js → app-MbHo43vs.js} +982 -698
  42. package/dist/app.js +1 -1
  43. package/dist/{business-DNAVZOSH.js → business-DMzeDNMd.js} +1 -1
  44. package/dist/{campaign-Cv0HaUD1.js → campaign-2swZVVbi.js} +2 -2
  45. package/dist/campaign.enum-CHI6p9lH.js +20 -0
  46. package/dist/campaign.fn-DNwV5ZWO.js +758 -0
  47. package/dist/collectible.enum-Y3ALLTcR.js +19 -0
  48. package/dist/{collection.fn-Dxzr2oPt.js → collection.fn-CfvnmVQa.js} +2 -2
  49. package/dist/dto-DseG41FR.js +2018 -0
  50. package/dist/{effect-CUuL8Tci.js → effect-BH4hGy1N.js} +1 -1
  51. package/dist/{email-addresses-Yt3s7i2b.js → email-addresses-doOfKmSj.js} +1 -1
  52. package/dist/{export-CNg5YWMm.js → export-DGrsZa4F.js} +3 -3
  53. package/dist/{helper-DzmKNFue.js → helper-3ohDu5Tn.js} +1 -1
  54. package/dist/{index-BK8X9RF6.js → index-B8HMoADH.js} +3 -3
  55. package/dist/{index-D0obMrAS.js → index-BUzeShnL.js} +173 -62
  56. package/dist/index-BWwF7uuk.js +1049 -0
  57. package/dist/index-BXw9yi-G.js +32 -0
  58. package/dist/{index-yzH5eyKW.js → index-C-ozJGq6.js} +1 -1
  59. package/dist/{index-CsCgQ8gt.js → index-CDT7BpQ3.js} +1 -1
  60. package/dist/{index-Dnf7j71V.js → index-CKfeyWFN.js} +9 -3
  61. package/dist/{index-9CXt2kbQ.js → index-CKji0U5N.js} +293 -287
  62. package/dist/{index-QuBsnXgx.js → index-CVlbqA1t.js} +1 -1
  63. package/dist/{index-B88e_9YI.js → index-D5CHO7oc.js} +1 -1
  64. package/dist/{index-O9lB54LY.js → index-rYTZxC9p.js} +1348 -1342
  65. package/dist/index-vh86FiIQ.js +10 -0
  66. package/dist/index-wBdTUnZ6.js +54 -0
  67. package/dist/{index.esm2017-TpBElhnN.js → index.esm2017-D-hthfW3.js} +1 -1
  68. package/dist/{loading-ChoC5E9d.js → loading-DQnXnCXT.js} +156 -153
  69. package/dist/{membership-CU-k0-Tf.js → membership-C3envHTy.js} +52 -44
  70. package/dist/{money-DANmyTBj.js → money-Dm7B8wUJ.js} +1 -1
  71. package/dist/{number-DrocTWDD.js → number-Swjcamr8.js} +1 -1
  72. package/dist/objectid-xH_8eWzr.js +145 -0
  73. package/dist/reward-DOggYNm3.js +36 -0
  74. package/dist/{rule-BQLmpER9.js → rule-BQy3e3DE.js} +4 -3
  75. package/dist/{rule-builder-3YRdr18A.js → rule-builder-CPWmw5lP.js} +1 -1
  76. package/dist/{template-DOKU1QkY.js → template-Dprn2jD_.js} +4 -4
  77. package/dist/trigger-BUY-zCBi.js +144 -0
  78. package/dist/{usePagination-JGI7x0W7.js → usePagination-CEQLUMQ7.js} +1 -1
  79. package/dist/user-DIK4sBIA.js +54 -0
  80. package/dist/{vue-i18n-Bch1JmhI.js → vue-i18n-B7ledd-g.js} +120 -120
  81. package/package.json +2 -2
  82. package/dist/Card-DndggRLr.js +0 -1036
  83. package/dist/Mission-CsLdMq1M.js +0 -261
  84. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-_P2yImhi.js +0 -1804
  85. package/dist/Store-C8kT7JN5.js +0 -1531
  86. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Cc2F_06x.js +0 -1065
  87. package/dist/dto-CcrufW2j.js +0 -2770
  88. package/dist/index-C7745kXl.js +0 -755
  89. package/dist/index-CZ28ywyB.js +0 -298
  90. package/dist/user-Bm4KttFq.js +0 -37
@@ -0,0 +1,441 @@
1
+ import { defineComponent as X, ref as F, computed as H, resolveComponent as f, openBlock as b, createBlock as U, unref as t, isRef as Z, withCtx as A, createElementVNode as w, createVNode as c, createCommentVNode as k, createElementBlock as M, Fragment as Y, h as O, 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 { f as j, u as G, p as ee } from "./loading-DQnXnCXT.js";
5
+ import { u as J, C as te } from "./membership-C3envHTy.js";
6
+ import { u as oe } from "./vue-i18n-B7ledd-g.js";
7
+ import { c as ae } from "./object-qECH92oz.js";
8
+ import { Z as h } from "./zod-Bg2FbC-D.js";
9
+ import "./index-rYTZxC9p.js";
10
+ import { a as N } from "./index-wBdTUnZ6.js";
11
+ import { useCoreStore as ne } from "@feedmepos/mf-common";
12
+ import { _ as le, a as ie } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-CFKID7mS.js";
13
+ import { _ as re } from "./EffectSheet.vue_vue_type_style_index_0_lang-DLgZd4HU.js";
14
+ import { J as K } from "./JsonViewer-v8_C7l5N.js";
15
+ import { _ as se } from "./ZodTextField.vue_vue_type_script_setup_true_lang-6asSbt53.js";
16
+ import { i as ce } from "./helper-3ohDu5Tn.js";
17
+ import { u as de, r as P } from "./reward-DOggYNm3.js";
18
+ import "./index-C-ozJGq6.js";
19
+ import { C as pe } from "./campaign.fn-DNwV5ZWO.js";
20
+ import { e as me } from "./effect-BH4hGy1N.js";
21
+ import { useRouter as ue } from "vue-router";
22
+ import { R as ye } from "./app-MbHo43vs.js";
23
+ const fe = /* @__PURE__ */ w("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1), we = { class: "flex gap-8 items-center justify-start" }, ve = /* @__PURE__ */ X({
24
+ __name: "EditRewardSheet",
25
+ emits: ["update"],
26
+ setup(W, { expose: l, emit: I }) {
27
+ const d = J(), { minor: C } = G, v = F(!1), o = F({}), y = F(), R = H(() => {
28
+ var n;
29
+ return ((n = o.value.option) == null ? void 0 : n.collectibleType) === "CREDIT" ? N.superRefine((e, a) => {
30
+ var i, m, g, r;
31
+ !((m = (i = e.option) == null ? void 0 : i.validityOption) != null && m.validForDay) && !((r = (g = e.option) == null ? void 0 : g.validityOption) != null && r.validBefore) && a.addIssue({
32
+ code: "custom",
33
+ path: [],
34
+ message: "Credit validity must be set"
35
+ });
36
+ }) : N;
37
+ }), u = H(() => {
38
+ const n = R.value.safeParse(o.value);
39
+ return n.success ? [] : n.error.errors;
40
+ });
41
+ function _(n, e) {
42
+ n && (y.value = void 0, o.value = e), v.value = n;
43
+ }
44
+ const $ = I;
45
+ async function S() {
46
+ const n = R.value.safeParse(o.value);
47
+ !n.success || !n.data || (await C(
48
+ async () => {
49
+ var e;
50
+ n.data.option.type === "VOUCHER" && y.value && (n.data.option.collectibleConfig.image = await j.update(
51
+ ((e = n.data.option.collectibleConfig) == null ? void 0 : e.image) || j.collectibleImagePath(void 0, y.value),
52
+ y.value
53
+ ));
54
+ },
55
+ {
56
+ message: "Uploading reward image",
57
+ successMessage: "Reward image updated"
58
+ }
59
+ ), $("update", n.data));
60
+ }
61
+ function x(n) {
62
+ n === "VOUCHER" ? o.value.option = {
63
+ collectible: null,
64
+ type: "VOUCHER",
65
+ collectibleConfig: ce("VOUCHER", {
66
+ business: ne().currentBusiness.value._id
67
+ }),
68
+ earningOption: {
69
+ amount: 1,
70
+ type: "FIXED"
71
+ },
72
+ validityOption: {
73
+ validForDay: 7
74
+ }
75
+ } : o.value.option = {
76
+ collectible: d.loyaltyRewards.raw[0]._id,
77
+ collectibleType: d.loyaltyRewards.raw[0].type,
78
+ type: "LOYALTY",
79
+ earningOption: {
80
+ amount: 1,
81
+ type: "FIXED"
82
+ },
83
+ validityOption: {
84
+ validForDay: 7
85
+ }
86
+ };
87
+ }
88
+ function D(n) {
89
+ o.value.option.collectible = n, o.value.option.collectibleType = d.loyaltyRewards.raw.find(
90
+ (e) => e._id === n
91
+ ).type;
92
+ }
93
+ const T = F();
94
+ return l({
95
+ showSheet: _
96
+ }), (n, e) => {
97
+ const a = f("FmSelect"), i = f("FmForm"), m = f("FmButton"), g = f("FmSideSheet");
98
+ return b(), U(g, {
99
+ "max-width": 560,
100
+ modelValue: t(v),
101
+ "onUpdate:modelValue": [
102
+ e[8] || (e[8] = (r) => Z(v) ? v.value = r : null),
103
+ e[9] || (e[9] = (r) => v.value = r)
104
+ ],
105
+ header: "Edit reward"
106
+ }, {
107
+ "side-sheet-footer": A(() => [
108
+ w("div", we, [
109
+ c(m, {
110
+ variant: "primary",
111
+ type: "button",
112
+ label: "Confirm",
113
+ disabled: t(u).length > 0,
114
+ onClick: e[6] || (e[6] = (r) => S())
115
+ }, null, 8, ["disabled"]),
116
+ c(m, {
117
+ variant: "secondary",
118
+ type: "button",
119
+ label: "Cancel",
120
+ onClick: e[7] || (e[7] = (r) => v.value = !1)
121
+ })
122
+ ])
123
+ ]),
124
+ default: A(() => [
125
+ c(K, { json: t(o) }, null, 8, ["json"]),
126
+ c(i, {
127
+ class: "flex flex-col gap-y-24",
128
+ ref_key: "formRef",
129
+ ref: T,
130
+ onValidationSuccess: e[5] || (e[5] = (r) => S())
131
+ }, {
132
+ default: A(() => {
133
+ var r, E, p;
134
+ return [
135
+ c(se, {
136
+ modelValue: t(o).name,
137
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => t(o).name = s),
138
+ label: "Reward Name",
139
+ schema: t(h).typeAtPath(t(R), "name", []),
140
+ "error-text": t(h).helperText(t(u), "name")
141
+ }, null, 8, ["modelValue", "schema", "error-text"]),
142
+ c(a, {
143
+ label: "Reward Type",
144
+ disabled: !!t(o)._id,
145
+ items: [
146
+ { label: "Voucher", value: "VOUCHER" },
147
+ { label: "Loyalty", value: "LOYALTY" }
148
+ ],
149
+ "model-value": t(o).option.type,
150
+ "onUpdate:modelValue": x
151
+ }, null, 8, ["disabled", "model-value"]),
152
+ t(o).option.type == "LOYALTY" ? (b(), U(a, {
153
+ key: 0,
154
+ label: "Loyalty type",
155
+ items: t(d).loyaltyRewards.items,
156
+ "model-value": t(o).option.collectible,
157
+ "onUpdate:modelValue": D
158
+ }, null, 8, ["items", "model-value"])) : k("", !0),
159
+ t(o).option.type === "LOYALTY" ? (b(), M(Y, { key: 1 }, [
160
+ fe,
161
+ ((r = t(d).loyaltyRewards.items.find(
162
+ (s) => {
163
+ var V;
164
+ return s.value === ((V = t(o)) == null ? void 0 : V.option.collectible);
165
+ }
166
+ )) == null ? void 0 : r.raw.type) !== "TITLE" ? (b(), U(le, {
167
+ key: 0,
168
+ class: "mt-[-8px]",
169
+ rules: [
170
+ t(h).ruleAtPath(t(R), "option.earningOption", [
171
+ t(o).option.type
172
+ ])
173
+ ],
174
+ "helper-state": t(h).helperState(t(u), "option.earningOption"),
175
+ "error-text": t(h).helperText(t(u), "option.earningOption"),
176
+ "fixed-type": !0,
177
+ "model-value": t(o).option.earningOption,
178
+ "onUpdate:modelValue": e[1] || (e[1] = (s) => t(o).option.earningOption = s)
179
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"])) : k("", !0),
180
+ c(re, {
181
+ class: "!gap-24",
182
+ "for-credit": t(o).option.type === "LOYALTY" && ((E = t(d).loyaltyRewards.items.find(
183
+ (s) => {
184
+ var V;
185
+ return s.value === ((V = t(o).option) == null ? void 0 : V.collectible);
186
+ }
187
+ )) == null ? void 0 : E.raw.type) === "CREDIT",
188
+ type: t(o).option.type === "VOUCHER" ? "range" : "custom",
189
+ rules: [
190
+ t(h).ruleAtPath(t(R), "option.validityOption", [
191
+ t(o).option.type
192
+ ])
193
+ ],
194
+ "model-value": t(o).option.validityOption,
195
+ "onUpdate:modelValue": e[2] || (e[2] = (s) => t(o).option.validityOption = s)
196
+ }, null, 8, ["for-credit", "type", "rules", "model-value"])
197
+ ], 64)) : k("", !0),
198
+ t(o).option.type === "VOUCHER" ? (b(), U(ie, {
199
+ key: 2,
200
+ "reward-image": t(y),
201
+ "model-value": ((p = t(o)) == null ? void 0 : p.option.collectibleConfig) ?? void 0,
202
+ "onUpdate:modelValue": e[3] || (e[3] = (s) => t(o).option.collectibleConfig = s),
203
+ "onUpdate:rewardImage": e[4] || (e[4] = (s) => y.value = s)
204
+ }, null, 8, ["reward-image", "model-value"])) : k("", !0),
205
+ c(K, { json: t(u) }, null, 8, ["json"])
206
+ ];
207
+ }),
208
+ _: 1
209
+ }, 512)
210
+ ]),
211
+ _: 1
212
+ }, 8, ["modelValue"]);
213
+ };
214
+ }
215
+ }), ge = { class: "px-24 flex flex-col gap-y-16" }, be = { class: "flex items-center justify-between w-full" }, Re = /* @__PURE__ */ w("div", { class: "flex gap-8" }, null, -1), Ce = /* @__PURE__ */ w("img", {
216
+ src: z,
217
+ class: "aspect-square w-[150px]"
218
+ }, null, -1), _e = { class: "flex flex-col gap-16 text-center" }, Oe = { class: "fm-typo-en-title-sm-800" }, he = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ge = /* @__PURE__ */ X({
219
+ __name: "Reward",
220
+ setup(W) {
221
+ const { t: l } = oe(), I = {
222
+ label: l("connect.storeRewards.create"),
223
+ value: "create",
224
+ isPrimary: !0,
225
+ prependIcon: "add"
226
+ }, d = J(), C = de(), { global: v, minor: o } = G, y = ue(), R = Q(), u = F({
227
+ searchKey: "",
228
+ columnFilters: []
229
+ }), _ = H(() => C.rewards);
230
+ function $(e) {
231
+ y.push({
232
+ name: ye["$connect-STORE_REWARD_COLLECTIONS"],
233
+ params: { id: e }
234
+ });
235
+ }
236
+ const S = [
237
+ {
238
+ header: l("connect.storeRewards.table.name"),
239
+ accessorFn: (e) => e.name
240
+ },
241
+ {
242
+ header: l("connect.storeRewards.table.type"),
243
+ cell(e) {
244
+ return e.row.original.collectibleConfig ? te[e.row.original.collectibleConfig.type].chip() : "N/A";
245
+ }
246
+ },
247
+ {
248
+ header: l("connect.storeRewards.table.summary"),
249
+ accessorFn: (e) => {
250
+ var a, i;
251
+ if (e.option.type === "VOUCHER")
252
+ return me((i = (a = e.option.collectibleConfig) == null ? void 0 : a.extras) == null ? void 0 : i.effect);
253
+ if (e.option.collectibleType == "TITLE") {
254
+ const m = d.sortedTitles.find(
255
+ (g) => g._id == e.option.collectible
256
+ );
257
+ return `Get ${m == null ? void 0 : m.name} valid for ${e.option.validityOption.validForDay} days`;
258
+ }
259
+ return `Get ${e.option.earningOption.amount} ${pe.formattedType(e.option.collectibleType)}`;
260
+ }
261
+ },
262
+ {
263
+ header: l("connect.storeRewards.table.actions"),
264
+ cell(e) {
265
+ return O("div", { class: "flex items-center justify-end gap-4" }, [
266
+ O(
267
+ L.FmMenu,
268
+ {
269
+ placement: "bottom-end",
270
+ onClick: (a) => {
271
+ a.stopPropagation();
272
+ }
273
+ },
274
+ {
275
+ "menu-button": () => O(L.FmButton, {
276
+ icon: "more_vert",
277
+ iconColor: "neutral-gray-400",
278
+ variant: "tertiary"
279
+ }),
280
+ default: () => [
281
+ e.row.original.option.type === "VOUCHER" && O(L.FmMenuItem, {
282
+ label: "View collections",
283
+ onClick: async (a) => {
284
+ a.stopPropagation(), $(
285
+ e.row.original.option.collectible
286
+ );
287
+ }
288
+ }),
289
+ O(
290
+ L.FmMenuItem,
291
+ {
292
+ onClick: async (a) => {
293
+ a.stopPropagation(), D(e.row.original);
294
+ }
295
+ },
296
+ {
297
+ label: O(
298
+ "div",
299
+ {
300
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
301
+ },
302
+ "Delete"
303
+ )
304
+ }
305
+ )
306
+ ]
307
+ }
308
+ )
309
+ ]);
310
+ }
311
+ }
312
+ ], x = F();
313
+ async function D(e) {
314
+ await ee.remove(
315
+ l("connect.storeRewards.delete.confirm"),
316
+ l("connect.storeRewards.delete.title")
317
+ ) && await o(
318
+ async () => {
319
+ await P.deleteReward(e._id), await C.readRewards();
320
+ },
321
+ {
322
+ message: l("connect.storeRewards.delete.message"),
323
+ successMessage: l("connect.storeRewards.delete.success")
324
+ }
325
+ );
326
+ }
327
+ async function T(e) {
328
+ var a;
329
+ e || (e = {
330
+ name: "",
331
+ option: {
332
+ type: "LOYALTY",
333
+ collectible: d.loyaltyRewards.items[0].value,
334
+ collectibleType: d.loyaltyRewards.items[0].raw.type,
335
+ validityOption: {
336
+ validForDay: 7
337
+ },
338
+ earningOption: {
339
+ type: "FIXED",
340
+ amount: 1
341
+ }
342
+ }
343
+ }), (a = x.value) == null || a.showSheet(!0, ae(e));
344
+ }
345
+ async function n(e) {
346
+ let a = !1;
347
+ e._id && e.option.type === "VOUCHER" && await new Promise((i) => {
348
+ R.open({
349
+ title: "Confirmation",
350
+ message: "This will change all future vouchers? Would you like to update previous claimed vouchers expiry date and discount?",
351
+ primaryActions: { text: "Update all", close: !0 },
352
+ secondaryActions: { text: "Update future only", close: !0 }
353
+ }).onPrimary(async () => {
354
+ a = !0, i();
355
+ }).onSecondary(async () => {
356
+ i();
357
+ });
358
+ }), await o(
359
+ async () => {
360
+ var i;
361
+ e.collectibleConfig = void 0, e._id ? await P.updateReward(e._id, {
362
+ ...e,
363
+ updateCollection: a
364
+ }) : await P.createReward(e), await C.readRewards(), (i = x.value) == null || i.showSheet(!1);
365
+ },
366
+ {
367
+ message: "Updating reward",
368
+ successMessage: "Reward updated successfully"
369
+ }
370
+ );
371
+ }
372
+ return q(async () => {
373
+ await v(async () => {
374
+ await d.readMembership(), await d.readRewards(), await C.readRewards();
375
+ });
376
+ }), (e, a) => {
377
+ const i = f("FmPageHead"), m = f("FmSearch"), g = f("FmTable"), r = f("FmButton"), E = f("FmCard");
378
+ return b(), M(Y, null, [
379
+ c(i, {
380
+ title: t(l)("connect.reward.title"),
381
+ actions: [I],
382
+ "back-button": !0,
383
+ "onClick:action": a[0] || (a[0] = () => T()),
384
+ "onClick:back": a[1] || (a[1] = () => {
385
+ var p;
386
+ return (p = t(y)) == null ? void 0 : p.back();
387
+ })
388
+ }, null, 8, ["title", "actions"]),
389
+ w("div", ge, [
390
+ t(_) && t(_).length > 0 ? (b(), M(Y, { key: 0 }, [
391
+ w("div", be, [
392
+ Re,
393
+ c(m, {
394
+ modelValue: t(u).searchKey,
395
+ "onUpdate:modelValue": a[2] || (a[2] = (p) => t(u).searchKey = p),
396
+ class: "",
397
+ placeholder: "search",
398
+ collapsible: ""
399
+ }, null, 8, ["modelValue"])
400
+ ]),
401
+ c(g, {
402
+ "row-data": t(_),
403
+ "column-defs": S,
404
+ "search-value": t(u).searchKey,
405
+ "column-filter": t(u).columnFilters,
406
+ onRowClick: a[3] || (a[3] = (p) => T(p.original)),
407
+ "hide-footer": t(_).length < 10
408
+ }, null, 8, ["row-data", "search-value", "column-filter", "hide-footer"])
409
+ ], 64)) : (b(), U(E, {
410
+ key: 1,
411
+ variant: "outlined",
412
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
413
+ }, {
414
+ default: A(() => [
415
+ Ce,
416
+ w("div", _e, [
417
+ w("div", Oe, B(t(l)("connect.storeRewards.empty.title")), 1),
418
+ w("div", he, B(t(l)("connect.storeRewards.empty.description")), 1)
419
+ ]),
420
+ c(r, {
421
+ variant: "primary",
422
+ label: t(l)("connect.storeRewards.empty.action"),
423
+ onClick: a[4] || (a[4] = (p) => T()),
424
+ icon: "add"
425
+ }, null, 8, ["label"])
426
+ ]),
427
+ _: 1
428
+ })),
429
+ c(ve, {
430
+ ref_key: "rewardSheetRef",
431
+ ref: x,
432
+ onUpdate: a[5] || (a[5] = (p) => n(p))
433
+ }, null, 512)
434
+ ])
435
+ ], 64);
436
+ };
437
+ }
438
+ });
439
+ export {
440
+ Ge as default
441
+ };
@@ -0,0 +1,150 @@
1
+ import { ref as p, defineComponent as T, computed as x, resolveComponent as y, openBlock as U, createBlock as G, unref as e, isRef as $, withCtx as b, createElementVNode as v, createVNode as u, toDisplayString as j } from "vue";
2
+ import { u as B } from "./loading-DQnXnCXT.js";
3
+ import { J as P } from "./JsonViewer-v8_C7l5N.js";
4
+ import { _ as D } from "./ZodTextField.vue_vue_type_script_setup_true_lang-6asSbt53.js";
5
+ import { _ as I } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-D3VgIQb-.js";
6
+ import { Z as L } from "./zod-Bg2FbC-D.js";
7
+ import { u as V } from "./app-wDQR6dpb.js";
8
+ import { defineStore as N } from "pinia";
9
+ import { r as k } from "./index-BXw9yi-G.js";
10
+ import "./index-CKji0U5N.js";
11
+ import "./index-rYTZxC9p.js";
12
+ import "./index-BWwF7uuk.js";
13
+ import { c as E } from "./index-BUzeShnL.js";
14
+ import "./index-CVlbqA1t.js";
15
+ import "./index-wBdTUnZ6.js";
16
+ import { u as J } from "./vue-i18n-B7ledd-g.js";
17
+ import { c as C } from "./object-qECH92oz.js";
18
+ import { useDialog as Z } from "@feedmepos/ui-library";
19
+ const A = N("mf-connect-referral", () => {
20
+ const h = p();
21
+ return {
22
+ readReferralProgram: async () => {
23
+ const c = await k.read();
24
+ h.value = c;
25
+ },
26
+ referralProgram: h
27
+ };
28
+ }), H = { class: "flex flex-col space-y-16 pr-12" }, M = { class: "fm-typo-en-title-sm-800" }, O = { class: "flex items-center gap-8" }, W = /* @__PURE__ */ T({
29
+ __name: "EditReferralTierSheet",
30
+ emits: ["update"],
31
+ setup(h, { expose: _, emit: c }) {
32
+ const { t: n } = J(), m = c, s = p(!1), a = p({}), i = p(-1), w = A(), o = E.superRefine((r, t) => {
33
+ r.name.length >= 50 && t.addIssue({
34
+ code: "custom",
35
+ message: "Name must be less than 50 characters"
36
+ });
37
+ }), l = x(() => {
38
+ const r = o.safeParse(a.value);
39
+ return r.success ? [] : r.error.errors;
40
+ });
41
+ function R() {
42
+ const r = o.safeParse(a.value);
43
+ r.success && m("update", i.value, r.data);
44
+ }
45
+ function d(r, t) {
46
+ var f;
47
+ s.value = r, r && typeof t == "number" && t >= 0 ? (i.value = t, a.value = C(
48
+ (f = w.referralProgram) == null ? void 0 : f.reward[t]
49
+ )) : (i.value = -1, a.value = {
50
+ id: (/* @__PURE__ */ new Date()).toISOString(),
51
+ name: "",
52
+ rewards: [],
53
+ rule: void 0
54
+ });
55
+ }
56
+ function g(r) {
57
+ a.value.rule = r;
58
+ }
59
+ return _({
60
+ showSheet: d,
61
+ data: a
62
+ }), (r, t) => {
63
+ const f = y("FmButton"), F = y("FmSideSheet");
64
+ return U(), G(F, {
65
+ "max-width": 1e3,
66
+ modelValue: e(s),
67
+ "onUpdate:modelValue": t[2] || (t[2] = (S) => $(s) ? s.value = S : null),
68
+ header: `${e(i) == -1 ? e(n)("connect.referral.editReferralTierSheet.create") : e(n)("connect.referral.editReferralTierSheet.edit")}`
69
+ }, {
70
+ "side-sheet-footer": b(() => [
71
+ v("div", O, [
72
+ u(f, {
73
+ label: e(n)("connect.editTierSheet.submit"),
74
+ onClick: R,
75
+ disabled: e(l).length > 0 || e(V)().isLoading,
76
+ loading: e(V)().isLoading
77
+ }, null, 8, ["label", "disabled", "loading"]),
78
+ u(f, {
79
+ label: e(n)("connect.editTierSheet.cancel"),
80
+ onClick: t[1] || (t[1] = (S) => d(!1)),
81
+ variant: "tertiary"
82
+ }, null, 8, ["label"])
83
+ ])
84
+ ]),
85
+ default: b(() => [
86
+ u(P, { json: e(a) }, null, 8, ["json"]),
87
+ u(P, { json: e(l) }, null, 8, ["json"]),
88
+ v("div", H, [
89
+ u(D, {
90
+ modelValue: e(a).name,
91
+ "onUpdate:modelValue": t[0] || (t[0] = (S) => e(a).name = S),
92
+ label: e(n)("connect.referral.editReferralTierSheet.name"),
93
+ schema: e(L).typeAtPath(e(o), "name")
94
+ }, null, 8, ["modelValue", "label", "schema"]),
95
+ v("div", M, j(e(n)("connect.referral.editReferralTierSheet.target_audience")), 1),
96
+ u(I, {
97
+ "model-value": e(a).rule,
98
+ "onUpdate:modelValue": g
99
+ }, null, 8, ["model-value"])
100
+ ])
101
+ ]),
102
+ _: 1
103
+ }, 8, ["modelValue", "header"]);
104
+ };
105
+ }
106
+ }), de = /* @__PURE__ */ T({
107
+ __name: "RewardGroup",
108
+ setup(h, { expose: _ }) {
109
+ const { minor: c } = B, n = Z(), m = A(), s = x(() => {
110
+ var o;
111
+ return ((o = m.referralProgram) == null ? void 0 : o.reward) ?? [];
112
+ }), a = p(null);
113
+ function i(o) {
114
+ var l;
115
+ (l = a.value) == null || l.showSheet(!0, o);
116
+ }
117
+ _({
118
+ onManageRewardGroup: i
119
+ });
120
+ async function w(o, l) {
121
+ var r;
122
+ const R = o == -1 ? s.value.length : o, d = C(m.referralProgram);
123
+ d.reward[R] = l;
124
+ let g = !1;
125
+ await new Promise((t) => {
126
+ n.open({
127
+ title: "Confirmation",
128
+ message: "This will change all referral settings? Would you like to update previous referral record?",
129
+ primaryActions: { text: "Update all", close: !0 },
130
+ secondaryActions: { text: "Update future only", close: !0 }
131
+ }).onPrimary(async () => {
132
+ g = !0, t();
133
+ }).onSecondary(async () => {
134
+ t();
135
+ });
136
+ }), await c(async () => {
137
+ await k.update({ ...d, updateReferralRecord: g }), await m.readReferralProgram();
138
+ }), (r = a.value) == null || r.showSheet(!1);
139
+ }
140
+ return (o, l) => (U(), G(W, {
141
+ ref_key: "editReferralTierSheetRef",
142
+ ref: a,
143
+ onUpdate: w
144
+ }, null, 512));
145
+ }
146
+ });
147
+ export {
148
+ de as _,
149
+ A as u
150
+ };