@feedmepos/mf-connect 0.1.38-beta.21 → 0.1.38-beta.23

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 (94) hide show
  1. package/dist/{Analytic-CEd_WApy.js → Analytic-xMxbAEul.js} +13 -13
  2. package/dist/{App-ulCtuU5o.js → App-DkBJoQa2.js} +303 -307
  3. package/dist/{AuditLogs-BM1Np61K.js → AuditLogs-CkpffM8N.js} +9 -9
  4. package/dist/{Bin-icbjnKXw.js → Bin-D3JHC66F.js} +8 -8
  5. package/dist/{Broadcast-COQ3E8vI.js → Broadcast-eCxNA0EG.js} +9 -9
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BbXEYOFK.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BMrLc0hX.js} +6 -6
  7. package/dist/{Card-Cwh3GXi0.js → Card-CaOvpWvL.js} +16 -16
  8. package/dist/{Collections-EuOjzpkL.js → Collections-CxScAHZl.js} +6 -6
  9. package/dist/{Credit-BY2Fpdhh.js → Credit-BnPpMq8q.js} +9 -9
  10. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-BEnaGmCW.js +3109 -0
  11. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BLw3-hI1.js → EffectSheet.vue_vue_type_style_index_0_lang-DJhtUAk_.js} +6 -6
  12. package/dist/{Experience-rAH7zk71.js → Experience-nMxubr1P.js} +9 -9
  13. package/dist/{Game-DlI0yNF0.js → Game-C8pHAp1o.js} +10 -10
  14. package/dist/Grab-DjTma0rb.js +282 -0
  15. package/dist/{Index-DemXFS3d.js → Index-COHMtBIi.js} +10 -10
  16. package/dist/{Marketing-shNBO9Rc.js → Marketing-C3R9Rw4y.js} +7112 -5424
  17. package/dist/{Member-C19ZgpaL.js → Member-gjwH9kPr.js} +10 -10
  18. package/dist/{MemberList-B2tNB4yg.js → MemberList-Bg_zsGbz.js} +25 -25
  19. package/dist/{MemberTransactions-BN3qaTVY.js → MemberTransactions-7aZsIeZL.js} +1 -1
  20. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-BY3j1h72.js → MessageInput.vue_vue_type_script_setup_true_lang-DtPV3l4w.js} +2285 -2219
  21. package/dist/{Mission-j1KI0-hJ.js → Mission-DqAahrB0.js} +10 -10
  22. package/dist/{Overview-BN2Vdu8Q.js → Overview-_b_4mLBe.js} +18 -18
  23. package/dist/{Point-8zy7QcTk.js → Point-CsMZA2do.js} +9 -9
  24. package/dist/{Promotion-mcUcylXB.js → Promotion-j4_gUzqi.js} +10 -10
  25. package/dist/{Queue-BsNv4P8u.js → Queue-MOdvEl5u.js} +10 -10
  26. package/dist/{Record-VA6Bdlnz.js → Record-BQIQBdc6.js} +8 -8
  27. package/dist/{Reward-CVyO3Ga1.js → Reward-DABAfCmo.js} +15 -15
  28. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-BR9_a9bJ.js → RewardGroup.vue_vue_type_script_setup_true_lang-D-BK8GZ4.js} +11 -11
  29. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-Dhs2whAH.js → RuleGroup.vue_vue_type_script_setup_true_lang-ClwtUvs9.js} +13 -13
  30. package/dist/{Segment-BMgcdIIS.js → Segment-DSpcce-q.js} +22 -22
  31. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-CKRpWcn_.js → SelectItems.vue_vue_type_script_setup_true_lang-CZu-7I-8.js} +2 -2
  32. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-DZCNcdVW.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-D5Oc0pqy.js} +11 -11
  33. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-BESF672g.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-7NWmWQjo.js} +3 -3
  34. package/dist/{Setting-BMKKkZTD.js → Setting-DTFpHJd7.js} +11 -11
  35. package/dist/{Store-DdxMDtfL.js → Store-mAraPykq.js} +19 -19
  36. package/dist/{StoreRewards-CRyeHEMF.js → StoreRewards-C1Cw1Nij.js} +13 -13
  37. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-DS6-9WP9.js → StoreTransactions.vue_vue_type_script_setup_true_lang-C_igl8vi.js} +20 -20
  38. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BTKpclKX.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-D3c0qO9i.js} +1 -1
  39. package/dist/{Tier-D5Xmp5vV.js → Tier-B7AUECOs.js} +20 -20
  40. package/dist/{Title-CsK2crqD.js → Title-DWw4-4cE.js} +19 -19
  41. package/dist/{Transaction-Dvfc9x4f.js → Transaction-ClZvbeDP.js} +2 -2
  42. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-CqCxWltm.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Cen_yXF7.js} +6 -6
  43. package/dist/{Voucher-CPN7TMho.js → Voucher-BBYDF1GX.js} +13 -13
  44. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-DMye9MS3.js → VoucherEditor.vue_vue_type_script_setup_true_lang-Vscwqd3r.js} +10 -10
  45. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-CnaQAEKo.js → ZodTextField.vue_vue_type_script_setup_true_lang-C2yUE0Cq.js} +1 -1
  46. package/dist/{app-DRBevJsF.js → app-9boJd9tw.js} +1 -1
  47. package/dist/{app-DteFjR9L.js → app-DLdolyB3.js} +740 -676
  48. package/dist/app.js +1 -1
  49. package/dist/{business-BqV9jK-p.js → business-D900a5Tb.js} +1 -1
  50. package/dist/{campaign-CsWoG6e_.js → campaign-DXo7F7aH.js} +29 -25
  51. package/dist/{campaign-BHDq-yx-.js → campaign-D_F3xj3O.js} +27 -14
  52. package/dist/{campaign.enum-Dfa96W5V.js → campaign.enum-CG0IjpL0.js} +3 -2
  53. package/dist/{campaign.fn-pLrwyHA_.js → campaign.fn-B6f4zAed.js} +37 -37
  54. package/dist/{collectible.enum-BYTYWPsR.js → collectible.enum-0jg7mZtz.js} +1 -1
  55. package/dist/{collection.fn-CYLIQJig.js → collection.fn-BDcZoQfR.js} +2 -2
  56. package/dist/{dto-DBfDbpyb.js → dto-Diu2Xl3e.js} +51 -39
  57. package/dist/{effect-D9pD5RCk.js → effect-DvIk5Cg6.js} +1 -1
  58. package/dist/{email-addresses-BApvdLkQ.js → email-addresses-DQf3ZdZP.js} +1 -1
  59. package/dist/{export--EfmCiw0.js → export-WSVAzeqR.js} +3 -3
  60. package/dist/{helper-BHiK3pLT.js → helper-CzsKE573.js} +1 -1
  61. package/dist/{index-CD2bkLo_.js → index-1-H1oqKb.js} +1 -1
  62. package/dist/{index-B9_Tn8si.js → index-B6Kbxgky.js} +1 -1
  63. package/dist/{index-DXM3o6kl.js → index-B6KkRHaV.js} +1 -1
  64. package/dist/{index-DYgdunxw.js → index-Bej-AJUB.js} +3 -3
  65. package/dist/{index-C1Vrltkc.js → index-CErvxcDp.js} +1 -1
  66. package/dist/{index-Bqc7PV3K.js → index-D-VZHYyP.js} +1 -1
  67. package/dist/{index-CVxruvVB.js → index-D1fzmeG6.js} +3 -3
  68. package/dist/{index-Pd9RCQxn.js → index-D3wppWii.js} +1 -1
  69. package/dist/{index-COiVJ9pA.js → index-DMg2pJLu.js} +1 -1
  70. package/dist/{index-qd_dvZcw.js → index-DPyNXHg6.js} +16 -16
  71. package/dist/{index-Cc80pBYX.js → index-DWN3abQr.js} +573 -573
  72. package/dist/{index-CDLBLuYq.js → index-DlwPVNEv.js} +845 -708
  73. package/dist/{index-2dknXEFJ.js → index-__X1c_dR.js} +184 -15
  74. package/dist/{index-BSQXDDQY.js → index-uJ-YdKV1.js} +3 -3
  75. package/dist/{index.esm2017-DAWS_ALH.js → index.esm2017-shNT9EQF.js} +1 -1
  76. package/dist/{loading-BVUeda4s.js → loading-CBKMbqM5.js} +1 -1
  77. package/dist/{membership-BL_43RJR.js → membership-DQa8yaY2.js} +3 -3
  78. package/dist/{money-Cd8hLiNc.js → money-IYgOL6F1.js} +1 -1
  79. package/dist/{number-DVb8PSrj.js → number-DXdhRp2S.js} +1 -1
  80. package/dist/{objectid-D33s3gxp.js → objectid-DABStWGB.js} +5 -5
  81. package/dist/{plugins-BKtBkC9Q.js → plugins-DXwZ_v63.js} +2 -2
  82. package/dist/{reward-f41dJcaL.js → reward-DYiYZcJC.js} +1 -1
  83. package/dist/{rule-Cbux1-fC.js → rule-Beum_Zy5.js} +3 -3
  84. package/dist/{rule-builder-BrZeF45Z.js → rule-builder-BLNgIsjE.js} +12 -10
  85. package/dist/style.css +1 -1
  86. package/dist/{template-tqhgmIdT.js → template-C5PTDFfm.js} +4 -4
  87. package/dist/{timezone-DaTVH4y0.js → timezone-PLVeOMdC.js} +1 -1
  88. package/dist/{trigger-C34RfwrT.js → trigger-B0u2ZuY-.js} +4 -4
  89. package/dist/{user-DgKhDLYr.js → user-BlM3HCwC.js} +1 -1
  90. package/dist/{vue-i18n-xo56wiwi.js → vue-i18n-CwrnHMwQ.js} +246 -246
  91. package/dist/{xlsx-D8ZZRjtf.js → xlsx-BAbyCaI0.js} +1 -1
  92. package/package.json +1 -1
  93. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-BbsLgUMQ.js +0 -2188
  94. package/dist/remy-vue-client-Cpppk9h-.js +0 -1693
@@ -1,2188 +0,0 @@
1
- import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createVNode, unref, isRef, withCtx, createBlock, createCommentVNode, computed, createElementVNode, Fragment, renderList, normalizeClass, toDisplayString, toRefs, normalizeStyle, resolveDynamicComponent, createSlots } from "vue";
2
- import { _ } from "./lodash-B5I3zXaY.js";
3
- import { z } from "./app-DteFjR9L.js";
4
- import { Z as ZodHelper } from "./zod-Bg2FbC-D.js";
5
- import { c as getCampaignSummaryObject, C as CampaignOptions } from "./campaign-BHDq-yx-.js";
6
- import { c as campaignRefinement, C as CampaignDtos, a as campaignTransform } from "./dto-DBfDbpyb.js";
7
- import { u as useMembershipStore } from "./membership-BL_43RJR.js";
8
- import { u as useBusinessStore } from "./business-BqV9jK-p.js";
9
- import "./index-qd_dvZcw.js";
10
- import { R as RuleBuilder, a as isRuleEntry } from "./rule-builder-BrZeF45Z.js";
11
- import { J as JsonViewer } from "./JsonViewer-v8_C7l5N.js";
12
- import { h as hooks } from "./moment-D7p2TMB-.js";
13
- import { f as featureVersionMapping } from "./campaign.enum-Dfa96W5V.js";
14
- import { _ as _sfc_main$o } from "./ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js";
15
- import { b as _sfc_main$m, a as _sfc_main$p, _ as _sfc_main$r } from "./EffectSheet.vue_vue_type_style_index_0_lang-BLw3-hI1.js";
16
- import { _ as _sfc_main$q } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-BTKpclKX.js";
17
- import { _ as _sfc_main$t } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-CqCxWltm.js";
18
- import { _ as _sfc_main$j, a as _sfc_main$k } from "./RuleGroup.vue_vue_type_script_setup_true_lang-Dhs2whAH.js";
19
- import { p as prompt, c as cases, f as firebaseStorage } from "./plugins-BKtBkC9Q.js";
20
- import { u as useI18n } from "./vue-i18n-xo56wiwi.js";
21
- import { T as TypeToTriggerOptions, _ as _sfc_main$u, b as _sfc_main$v } from "./trigger-C34RfwrT.js";
22
- import { _ as _sfc_main$s } from "./MessageInput.vue_vue_type_script_setup_true_lang-BY3j1h72.js";
23
- import { C as CountryTimezone, m as moment } from "./timezone-DaTVH4y0.js";
24
- import { c as calculateNextScheduleAt, S as SummarizeRrule, R as RRule } from "./rule-Cbux1-fC.js";
25
- import { useCoreStore } from "@feedmepos/mf-common";
26
- import { _ as _sfc_main$l, a as _sfc_main$n } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-DMye9MS3.js";
27
- import { T as TEMPLATES } from "./index-2dknXEFJ.js";
28
- import { t as FdoCreditLoyaltyReward, u as FdtoRandomReward, v as F_MISSION_TYPE, w as FdoThresholdCreditReward, x as FdtoThresholdReward, y as FdoMission } from "./index-CDLBLuYq.js";
29
- import "./index-C1Vrltkc.js";
30
- import "./index-DYgdunxw.js";
31
- import { a as F_GAME_TYPE } from "./collectible.enum-BYTYWPsR.js";
32
- import { u as useLoading } from "./loading-BVUeda4s.js";
33
- import { i as initCollectibleConfig } from "./helper-BHiK3pLT.js";
34
- import { C as CollectionUtils } from "./collection.fn-CYLIQJig.js";
35
- import { s as sentenceCase$1 } from "./index-CsaQJMAR.js";
36
- import "./index-Cc80pBYX.js";
37
- import { useDialog } from "@feedmepos/ui-library";
38
- import { u as useCampaignStore } from "./campaign-CsWoG6e_.js";
39
- import { S as SvcConfig } from "./index-BSQXDDQY.js";
40
- import { a as cleanPF } from "./object-qECH92oz.js";
41
- const _hoisted_1$g = { class: "space-y-24" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
42
- __name: "TimeRuleGroup",
43
- props: {
44
- modelValue: {
45
- type: Object,
46
- default: () => {
47
- }
48
- }
49
- },
50
- emits: ["update:model-value"],
51
- setup(e, { emit: m }) {
52
- const { t: a } = useI18n(), i = e, u = m, d = ref(
53
- !i.modelValue || !i.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(i.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
54
- );
55
- watch(d, async (o, n) => {
56
- var s;
57
- if (n == "custom" && o == "all_time" && RuleBuilder.getRules((s = i.modelValue) == null ? void 0 : s.rules.g_time).length > 0) {
58
- const y = await prompt.confirm(
59
- a("connect.template.rule.time.confirm_remove"),
60
- a("connect.common.confirm"),
61
- a("connect.common.confirm"),
62
- a("connect.common.cancel")
63
- );
64
- y && u(
65
- "update:model-value",
66
- RuleBuilder.setRuleToGroup(
67
- i.modelValue ?? RuleBuilder.scaffoldGroup(),
68
- RuleBuilder.scaffoldGroup("g_time")
69
- )
70
- ), d.value = y ? o : n;
71
- }
72
- });
73
- async function l(o) {
74
- var n;
75
- if (o == "custom" && RuleBuilder.getRules((n = i.modelValue) == null ? void 0 : n.rules.g_time).length > 0) {
76
- if (!await prompt.confirm(
77
- a("connect.template.rule.time.confirm_remove"),
78
- a("connect.common.confirm"),
79
- a("connect.common.confirm"),
80
- a("connect.common.cancel")
81
- )) {
82
- d.value = "all_time";
83
- return;
84
- }
85
- u(
86
- "update:model-value",
87
- RuleBuilder.setRuleToGroup(
88
- i.modelValue ?? RuleBuilder.scaffoldGroup(),
89
- RuleBuilder.scaffoldGroup("g_time")
90
- )
91
- );
92
- }
93
- }
94
- return (o, n) => {
95
- var v;
96
- const s = resolveComponent("FmRadio"), y = resolveComponent("FmRadioGroup");
97
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
98
- createVNode(y, {
99
- modelValue: unref(d),
100
- "onUpdate:modelValue": [
101
- n[0] || (n[0] = (h) => isRef(d) ? d.value = h : null),
102
- n[1] || (n[1] = (h) => l(h))
103
- ]
104
- }, {
105
- default: withCtx(() => [
106
- createVNode(s, {
107
- label: unref(a)("connect.template.rule.time.all_time"),
108
- value: "all_time"
109
- }, null, 8, ["label"]),
110
- createVNode(s, {
111
- label: unref(a)("connect.template.rule.time.custom"),
112
- value: "custom"
113
- }, null, 8, ["label"])
114
- ]),
115
- _: 1
116
- }, 8, ["modelValue"]),
117
- unref(d) == "custom" ? (openBlock(), createBlock(_sfc_main$j, {
118
- key: 0,
119
- class: "!mt-[0px]",
120
- "include-only": "trigger",
121
- "trigger-type": "SCHEDULE",
122
- "model-value": ((v = e.modelValue) == null ? void 0 : v.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
123
- "onUpdate:modelValue": n[2] || (n[2] = (h) => u(
124
- "update:model-value",
125
- unref(RuleBuilder).setRuleToGroup(
126
- e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
127
- h,
128
- "&&"
129
- )
130
- ))
131
- }, null, 8, ["model-value"])) : createCommentVNode("", !0)
132
- ]);
133
- };
134
- }
135
- }), _sfc_main$h = /* @__PURE__ */ defineComponent({
136
- __name: "BirthdayInput",
137
- props: {
138
- modelValue: {
139
- type: Object
140
- }
141
- },
142
- emits: ["update:model-value"],
143
- setup(e, { emit: m }) {
144
- const a = e, i = m, u = computed(() => {
145
- const { property: d, operator: l, equator: o } = RuleBuilder.simplify(
146
- a.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
147
- op: "before",
148
- x: 1
149
- })
150
- );
151
- return {
152
- property: d,
153
- operator: l,
154
- equator: o
155
- };
156
- });
157
- return (d, l) => {
158
- const o = resolveComponent("FmRadio"), n = resolveComponent("FmStepperField");
159
- return openBlock(), createElementBlock("div", null, [
160
- createVNode(o, {
161
- label: "On birthday",
162
- value: "_isRange-day",
163
- "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
164
- "onUpdate:modelValue": l[0] || (l[0] = () => {
165
- i(
166
- "update:model-value",
167
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
168
- op: "this",
169
- unit: "day",
170
- ignoreYear: !0
171
- })
172
- );
173
- })
174
- }, null, 8, ["model-value"]),
175
- createVNode(o, {
176
- label: "N days before birthday",
177
- value: "_isDay",
178
- "model-value": unref(u).operator,
179
- "onUpdate:modelValue": l[1] || (l[1] = () => {
180
- i(
181
- "update:model-value",
182
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
183
- op: "after",
184
- x: 1,
185
- ignoreYear: !0
186
- })
187
- );
188
- })
189
- }, null, 8, ["model-value"]),
190
- unref(u).operator == "_isDay" ? (openBlock(), createBlock(n, {
191
- key: 0,
192
- label: "Days before birthday",
193
- "show-steppers": !1,
194
- "model-value": unref(u).equator.x,
195
- "onUpdate:modelValue": l[2] || (l[2] = (s) => i(
196
- "update:model-value",
197
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
198
- op: "after",
199
- x: s,
200
- ignoreYear: !0
201
- })
202
- ))
203
- }, null, 8, ["model-value"])) : createCommentVNode("", !0),
204
- createVNode(o, {
205
- label: "In birthday week",
206
- value: "_isRange-week",
207
- "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
208
- "onUpdate:modelValue": l[3] || (l[3] = () => {
209
- i(
210
- "update:model-value",
211
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
212
- op: "this",
213
- unit: "week",
214
- ignoreYear: !0
215
- })
216
- );
217
- })
218
- }, null, 8, ["model-value"]),
219
- createVNode(o, {
220
- label: "In birthday month",
221
- value: "_isRange-month",
222
- "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
223
- "onUpdate:modelValue": l[4] || (l[4] = () => {
224
- i(
225
- "update:model-value",
226
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
227
- op: "this",
228
- unit: "month",
229
- ignoreYear: !0
230
- })
231
- );
232
- })
233
- }, null, 8, ["model-value"])
234
- ]);
235
- };
236
- }
237
- }), _hoisted_1$f = { class: "space-y-16" }, _hoisted_2$c = { class: "grid grid-cols-3 gap-16" }, _hoisted_3$a = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$7 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$g = /* @__PURE__ */ defineComponent({
238
- __name: "CampaignTriggerInput",
239
- props: {
240
- campaignType: {
241
- type: String,
242
- required: !0
243
- },
244
- modelValue: {
245
- type: String
246
- },
247
- disabled: {
248
- type: Boolean,
249
- default: !1
250
- }
251
- },
252
- emits: ["update:model-value"],
253
- setup(e, { emit: m }) {
254
- const a = e, i = m, u = computed(() => a.disabled ? TypeToTriggerOptions[a.campaignType].filter(
255
- (d) => d.value == a.modelValue
256
- ) : TypeToTriggerOptions[a.campaignType]);
257
- return (d, l) => {
258
- const o = resolveComponent("FmCard");
259
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
260
- l[0] || (l[0] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Define the conditions that must be met to activate a reward. ", -1)),
261
- createElementVNode("div", _hoisted_2$c, [
262
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (n) => (openBlock(), createBlock(o, {
263
- variant: "outlined",
264
- disabled: a.disabled,
265
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
266
- "col-span-3": unref(u).length == 1,
267
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == n.value,
268
- "hover:bg-fm-color-opacity-sm": e.modelValue != n.value
269
- }]),
270
- onClick: () => {
271
- a.modelValue != n.value && !a.disabled && i("update:model-value", n.value);
272
- },
273
- key: n.name
274
- }, {
275
- default: withCtx(() => [
276
- createElementVNode("div", _hoisted_3$a, toDisplayString(n.name), 1),
277
- createElementVNode("div", _hoisted_4$7, toDisplayString(n.description), 1)
278
- ]),
279
- _: 2
280
- }, 1032, ["disabled", "class", "onClick"]))), 128))
281
- ])
282
- ]);
283
- };
284
- }
285
- }), _sfc_main$f = /* @__PURE__ */ defineComponent({
286
- __name: "DateInput",
287
- props: {
288
- label: {
289
- type: String,
290
- required: !1
291
- },
292
- modelValue: {
293
- type: Object,
294
- required: !1
295
- }
296
- },
297
- emits: ["update:model-value"],
298
- setup(e, { emit: m }) {
299
- const a = m;
300
- return (i, u) => {
301
- const d = resolveComponent("FmButton"), l = resolveComponent("FmField"), o = resolveComponent("FmDatePicker");
302
- return openBlock(), createBlock(o, {
303
- label: e.label,
304
- "model-value": e.modelValue || "",
305
- "onUpdate:modelValue": u[1] || (u[1] = (n) => a("update:model-value", n))
306
- }, {
307
- "trigger-button": withCtx(({ opened: n }) => [
308
- createVNode(l, {
309
- class: "flex items-center",
310
- "prepend-icon": "calendar_month",
311
- "icon-outlined": !n
312
- }, {
313
- append: withCtx(() => [
314
- e.modelValue ? (openBlock(), createBlock(d, {
315
- key: 0,
316
- variant: "tertiary",
317
- icon: "clear",
318
- onClick: u[0] || (u[0] = (s) => (s.stopPropagation(), a("update:model-value", null)))
319
- })) : createCommentVNode("", !0)
320
- ]),
321
- default: withCtx(() => [
322
- createElementVNode("div", {
323
- class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
324
- }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
325
- ]),
326
- _: 2
327
- }, 1032, ["icon-outlined"])
328
- ]),
329
- _: 1
330
- }, 8, ["label", "model-value"]);
331
- };
332
- }
333
- }), _hoisted_1$e = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$b = { class: "flex-1 xs:w-full" }, _hoisted_3$9 = { class: "flex-1 xs:w-full" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
334
- __name: "DateRangeInput",
335
- props: {
336
- modelValue: {
337
- type: Object,
338
- required: !1
339
- }
340
- },
341
- emits: ["update:model-value"],
342
- setup(e, { emit: m }) {
343
- const a = m;
344
- return (i, u) => {
345
- var d, l;
346
- return openBlock(), createElementBlock("div", _hoisted_1$e, [
347
- createElementVNode("div", _hoisted_2$b, [
348
- createVNode(_sfc_main$f, {
349
- "model-value": ((d = e.modelValue) == null ? void 0 : d.startDate) ?? null,
350
- label: "Start date",
351
- "onUpdate:modelValue": u[0] || (u[0] = (o) => {
352
- var n;
353
- return a("update:model-value", {
354
- startDate: o,
355
- endDate: ((n = e.modelValue) == null ? void 0 : n.endDate) ?? null
356
- });
357
- })
358
- }, null, 8, ["model-value"])
359
- ]),
360
- u[2] || (u[2] = createElementVNode("div", { class: "mt-5 xs:hidden" }, "to", -1)),
361
- createElementVNode("div", _hoisted_3$9, [
362
- createVNode(_sfc_main$f, {
363
- "model-value": ((l = e.modelValue) == null ? void 0 : l.endDate) ?? null,
364
- label: "End date",
365
- "onUpdate:modelValue": u[1] || (u[1] = (o) => {
366
- var n;
367
- return a("update:model-value", {
368
- startDate: ((n = e.modelValue) == null ? void 0 : n.startDate) ?? null,
369
- endDate: o
370
- });
371
- })
372
- }, null, 8, ["model-value"])
373
- ])
374
- ]);
375
- };
376
- }
377
- }), _hoisted_1$d = { class: "space-y-8" }, _hoisted_2$a = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$8 = {
378
- key: 0,
379
- class: "space-y-4"
380
- }, _hoisted_4$6 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$3 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
381
- __name: "ScheduleRuleInput",
382
- props: {
383
- modelValue: {
384
- type: Object,
385
- required: !0
386
- },
387
- startDate: {
388
- type: String
389
- },
390
- endDate: {
391
- type: String
392
- }
393
- },
394
- emits: ["update:model-value"],
395
- setup(e, { emit: m }) {
396
- const a = e, i = m, u = useCoreStore(), d = computed(
397
- () => CountryTimezone[u.currentCountry.value || "MY"]
398
- );
399
- function l() {
400
- const g = RuleBuilder.getRules(a.modelValue);
401
- return g.length == 0 ? "fixed" : g.some(
402
- (c) => isRuleEntry(c) && RuleBuilder.simplify(c).operator == "_rrule"
403
- ) ? "repeating" : "fixed";
404
- }
405
- const o = ref(l()), n = ref(!1), s = computed(() => {
406
- const g = RuleBuilder.getRules(a.modelValue), c = g.find(
407
- (p) => isRuleEntry(p) && RuleBuilder.simplify(p).property == "trigger.date"
408
- ), r = g.find(
409
- (p) => isRuleEntry(p) && RuleBuilder.simplify(p).property == "trigger.time"
410
- );
411
- return {
412
- date: c ? RuleBuilder.simplify(c).equator : null,
413
- time: r ? RuleBuilder.simplify(r).equator : null
414
- };
415
- }), y = computed(
416
- () => calculateNextScheduleAt(
417
- a.modelValue,
418
- /* @__PURE__ */ new Date(),
419
- a.startDate ? new Date(a.startDate) : void 0,
420
- a.endDate ? new Date(a.endDate) : void 0
421
- )
422
- );
423
- function v(g) {
424
- const c = g.label.toLowerCase(), r = c == "fixed" ? [
425
- RuleBuilder.constructEntry(
426
- "trigger.date",
427
- "_isOnDate",
428
- (/* @__PURE__ */ new Date()).toISOString()
429
- ),
430
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
431
- ] : [
432
- RuleBuilder.constructEntry(
433
- "trigger.date",
434
- "_rrule",
435
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
436
- ),
437
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
438
- ];
439
- i(
440
- "update:model-value",
441
- RuleBuilder.setRuleToGroup(
442
- RuleBuilder.scaffoldGroup("g_schedule"),
443
- r
444
- )
445
- ), o.value = c;
446
- }
447
- function h(g) {
448
- o.value == "fixed" ? i(
449
- "update:model-value",
450
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
451
- RuleBuilder.constructEntry(
452
- "trigger.date",
453
- "_isOnDate",
454
- g.date
455
- ),
456
- RuleBuilder.constructEntry(
457
- "trigger.time",
458
- "_isOnTime",
459
- g.time
460
- )
461
- ])
462
- ) : i(
463
- "update:model-value",
464
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
465
- RuleBuilder.constructEntry(
466
- "trigger.date",
467
- "_rrule",
468
- g.date
469
- ),
470
- RuleBuilder.constructEntry(
471
- "trigger.time",
472
- "_isOnTime",
473
- g.time
474
- )
475
- ])
476
- );
477
- }
478
- return (g, c) => {
479
- const r = resolveComponent("FmButtonGroup"), p = resolveComponent("FmTimePicker"), f = resolveComponent("FmIcon"), b = resolveComponent("FmTooltip"), C = resolveComponent("FmField"), V = resolveComponent("FmCard"), x = resolveComponent("FmPopover"), R = resolveComponent("FmDatePicker"), k = resolveComponent("FmHelperText");
480
- return openBlock(), createElementBlock(Fragment, null, [
481
- createVNode(r, {
482
- items: [{ label: "Fixed" }, { label: "Repeating" }],
483
- "model-value": { label: unref(cases).title(unref(o)) },
484
- "onUpdate:modelValue": v,
485
- class: "mb-8"
486
- }, null, 8, ["model-value"]),
487
- createElementVNode("div", _hoisted_1$d, [
488
- createElementVNode("div", _hoisted_2$a, [
489
- createVNode(p, {
490
- label: "Notify time",
491
- "model-value": unref(s).time,
492
- "onUpdate:modelValue": c[0] || (c[0] = (B) => h({ date: unref(s).date, time: B })),
493
- "helper-text": unref(s).time ? void 0 : "Time is required",
494
- "helper-state": unref(s).time ? void 0 : "error"
495
- }, null, 8, ["model-value", "helper-text", "helper-state"]),
496
- unref(o) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$8, [
497
- createElementVNode("div", _hoisted_4$6, [
498
- c[5] || (c[5] = createElementVNode("div", null, "Notify date", -1)),
499
- unref(s).date ? (openBlock(), createBlock(b, {
500
- key: 0,
501
- "z-index": 9999,
502
- content: unref(SummarizeRrule)(unref(RRule).fromString(unref(s).date).options)
503
- }, {
504
- default: withCtx(() => [
505
- createVNode(f, {
506
- name: "info",
507
- size: "sm",
508
- outline: !0
509
- })
510
- ]),
511
- _: 1
512
- }, 8, ["content"])) : createCommentVNode("", !0)
513
- ]),
514
- createVNode(x, {
515
- "show-popover": unref(n),
516
- onPopoverChanged: c[3] || (c[3] = (B) => n.value = B)
517
- }, {
518
- "popover-button": withCtx(() => [
519
- createVNode(C, {
520
- class: "cursor-pointer",
521
- "helper-text": unref(s).date ? void 0 : "Date is required",
522
- "helper-state": unref(s).date ? void 0 : "error"
523
- }, {
524
- default: withCtx(() => [
525
- createElementVNode("div", _hoisted_5$3, toDisplayString(unref(s).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(s).date).options) : "Set a repeating date"), 1)
526
- ]),
527
- _: 1
528
- }, 8, ["helper-text", "helper-state"])
529
- ]),
530
- default: withCtx(() => [
531
- createVNode(V, { class: "elevated p-8 w-[450px]" }, {
532
- default: withCtx(() => [
533
- createVNode(_sfc_main$k, {
534
- "apply-button": !0,
535
- "model-value": unref(s).date || "",
536
- onCancel: c[1] || (c[1] = (B) => n.value = !1),
537
- "onUpdate:modelValue": c[2] || (c[2] = (B) => (h({ date: B, time: unref(s).time }), n.value = !1))
538
- }, null, 8, ["model-value"])
539
- ]),
540
- _: 1
541
- })
542
- ]),
543
- _: 1
544
- }, 8, ["show-popover"])
545
- ])) : (openBlock(), createBlock(R, {
546
- key: 1,
547
- label: "Notify date",
548
- "model-value": unref(s).date || "",
549
- "onUpdate:modelValue": c[4] || (c[4] = (B) => h({ date: B, time: unref(s).time })),
550
- "helper-text": unref(s).date ? void 0 : "Date is required",
551
- "helper-state": unref(s).date ? void 0 : "error"
552
- }, null, 8, ["model-value", "helper-text", "helper-state"]))
553
- ]),
554
- unref(s).date && unref(s).time && unref(y) ? (openBlock(), createBlock(k, {
555
- key: 0,
556
- text: `${unref(moment)(unref(y)).isAfter(unref(moment)()) ? "The next notification will be sent on " : "Last trigger is on "} ${unref(moment)(unref(y)).format("dddd, DD MMM YYYY")} at
557
- ${unref(moment)(unref(y)).format("hh:mmA")}(UTC${unref(moment).tz(unref(d)).format("Z")}) (${unref(moment)(unref(y)).fromNow()})`
558
- }, null, 8, ["text"])) : createCommentVNode("", !0)
559
- ])
560
- ], 64);
561
- };
562
- }
563
- }), _hoisted_1$c = { class: "space-y-16" }, _hoisted_2$9 = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$7 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
564
- __name: "GameTypeInput",
565
- props: {
566
- modelValue: {
567
- type: String
568
- }
569
- },
570
- emits: ["update:model-value"],
571
- setup(e, { emit: m }) {
572
- const a = e, i = m, u = computed(
573
- () => [
574
- {
575
- label: "Fortune Wheel",
576
- description: "Allow customers to spin the Fortune Wheel to win various rewards.",
577
- value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
578
- hidden: !1
579
- },
580
- {
581
- label: "Rock paper scissor",
582
- description: "Customers play a game of Rock Paper Scissors against the cashier.",
583
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
584
- hidden: !0
585
- }
586
- ].filter((d) => !d.hidden)
587
- );
588
- return (d, l) => {
589
- const o = resolveComponent("FmCard");
590
- return openBlock(), createElementBlock("div", _hoisted_1$c, [
591
- l[0] || (l[0] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Select a game where you want your customer to play. ", -1)),
592
- createElementVNode("div", _hoisted_2$9, [
593
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (n) => (openBlock(), createBlock(o, {
594
- variant: "outlined",
595
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
596
- "col-span-2": unref(u).length == 1,
597
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == n.value,
598
- "hover:bg-fm-color-opacity-sm": e.modelValue != n.value
599
- }]),
600
- onClick: () => {
601
- a.modelValue != n.value && i("update:model-value", n.value);
602
- },
603
- key: n.value
604
- }, {
605
- default: withCtx(() => [
606
- createElementVNode("div", _hoisted_3$7, toDisplayString(n.label), 1),
607
- createElementVNode("div", _hoisted_4$5, toDisplayString(n.description), 1)
608
- ]),
609
- _: 2
610
- }, 1032, ["class", "onClick"]))), 128))
611
- ])
612
- ]);
613
- };
614
- }
615
- }), _hoisted_1$b = {
616
- key: 0,
617
- class: "flex flex-col gap-y-24"
618
- }, _hoisted_2$8 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
619
- __name: "EditRewardPoolSheet",
620
- emits: ["update:model-value"],
621
- setup(e, { expose: m, emit: a }) {
622
- const i = useMembershipStore(), { minor: u } = useLoading, d = ref(!1), l = ref(), o = ref(), n = ref(0), s = computed(() => {
623
- var r;
624
- return ((r = i.loyaltyRewards.items.find(
625
- (p) => {
626
- var f;
627
- return p.value === ((f = l.value) == null ? void 0 : f.collectible);
628
- }
629
- )) == null ? void 0 : r.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
630
- }), y = computed(() => {
631
- const c = s.value.safeParse(l.value);
632
- return c.success ? [] : c.error.errors;
633
- });
634
- function v(c, r, p) {
635
- c && (l.value = r, n.value = p), d.value = c;
636
- }
637
- const h = a;
638
- async function g() {
639
- const c = s.value.safeParse(l.value);
640
- c.success && (await u(
641
- async () => {
642
- c.data.type === "VOUCHER" && o.value && (c.data.collectibleConfig.image = await firebaseStorage.update(
643
- c.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, o.value),
644
- o.value
645
- ));
646
- },
647
- {
648
- message: "Uploading reward image",
649
- successMessage: "Reward image updated"
650
- }
651
- ), h("update:model-value", c.data, n.value));
652
- }
653
- return m({
654
- showSheet: v
655
- }), (c, r) => {
656
- const p = resolveComponent("FmSelect"), f = resolveComponent("FmStepperField"), b = resolveComponent("FmButton"), C = resolveComponent("FmSideSheet");
657
- return openBlock(), createBlock(C, {
658
- "max-width": 560,
659
- modelValue: unref(d),
660
- "onUpdate:modelValue": [
661
- r[9] || (r[9] = (V) => isRef(d) ? d.value = V : null),
662
- r[10] || (r[10] = (V) => d.value = V)
663
- ],
664
- header: "Edit reward",
665
- "dismiss-away": ""
666
- }, {
667
- "side-sheet-footer": withCtx(() => [
668
- createElementVNode("div", _hoisted_2$8, [
669
- createVNode(b, {
670
- variant: "primary",
671
- type: "button",
672
- disabled: unref(y).length > 0,
673
- label: "Confirm",
674
- onClick: r[7] || (r[7] = (V) => g())
675
- }, null, 8, ["disabled"]),
676
- createVNode(b, {
677
- variant: "secondary",
678
- type: "button",
679
- label: "Cancel",
680
- onClick: r[8] || (r[8] = (V) => d.value = !1)
681
- })
682
- ])
683
- ]),
684
- default: withCtx(() => {
685
- var V, x, R;
686
- return [
687
- unref(l) ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
688
- createVNode(p, {
689
- label: "Reward Type",
690
- items: [
691
- { label: "No Reward", value: "NO_REWARD" },
692
- { label: "Voucher", value: "VOUCHER" },
693
- { label: "Loyalty", value: "LOYALTY" }
694
- ],
695
- "model-value": unref(l).type,
696
- "onUpdate:modelValue": r[0] || (r[0] = (k) => {
697
- k == "NO_REWARD" ? l.value = {
698
- type: "NO_REWARD",
699
- collectible: null,
700
- weight: 1
701
- } : k === "VOUCHER" ? l.value = {
702
- collectible: null,
703
- type: "VOUCHER",
704
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
705
- business: unref(useCoreStore)().currentBusiness.value._id
706
- }),
707
- earningOption: {
708
- amount: 1,
709
- type: "FIXED"
710
- },
711
- validityOption: {
712
- validForDay: 7
713
- },
714
- weight: 1
715
- } : l.value = {
716
- collectible: unref(i).loyaltyRewards.raw[0]._id,
717
- type: "LOYALTY",
718
- earningOption: {
719
- amount: 1,
720
- type: "FIXED"
721
- },
722
- validityOption: {
723
- validForDay: 7
724
- },
725
- weight: 1
726
- };
727
- })
728
- }, null, 8, ["model-value"]),
729
- unref(l).type == "LOYALTY" ? (openBlock(), createBlock(p, {
730
- key: 0,
731
- label: "Loyalty type",
732
- rules: [unref(ZodHelper).ruleAtPath(unref(s), "collectible", [unref(l).type])],
733
- items: unref(i).loyaltyRewards.items,
734
- "model-value": unref(l).collectible,
735
- "onUpdate:modelValue": r[1] || (r[1] = (k) => unref(l).collectible = k)
736
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
737
- createVNode(f, {
738
- label: "Weight",
739
- rules: [unref(ZodHelper).ruleAtPath(unref(s), "weight", [unref(l).type])],
740
- "model-value": unref(l).weight,
741
- "onUpdate:modelValue": r[2] || (r[2] = (k) => l.value = {
742
- ...unref(l),
743
- weight: k
744
- })
745
- }, null, 8, ["rules", "model-value"]),
746
- unref(l).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
747
- ((V = unref(i).loyaltyRewards.items.find(
748
- (k) => {
749
- var B;
750
- return k.value === ((B = unref(l)) == null ? void 0 : B.collectible);
751
- }
752
- )) == null ? void 0 : V.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
753
- r[11] || (r[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
754
- createVNode(_sfc_main$l, {
755
- class: "mt-[-8px]",
756
- rules: [
757
- unref(ZodHelper).ruleAtPath(unref(s), "earningOption", [unref(l).type])
758
- ],
759
- "helper-state": unref(ZodHelper).helperState(unref(y), "earningOption"),
760
- "error-text": unref(ZodHelper).helperText(unref(y), "earningOption"),
761
- "fixed-type": !0,
762
- "model-value": unref(l).earningOption,
763
- "onUpdate:modelValue": r[3] || (r[3] = (k) => l.value = {
764
- ...unref(l),
765
- earningOption: k
766
- })
767
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
768
- ], 64)) : createCommentVNode("", !0),
769
- r[12] || (r[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
770
- createVNode(_sfc_main$m, {
771
- type: unref(l).type === "LOYALTY" ? "custom" : "range",
772
- "for-credit": unref(l).type === "LOYALTY" && ((x = unref(i).loyaltyRewards.items.find(
773
- (k) => {
774
- var B;
775
- return k.value === ((B = unref(l)) == null ? void 0 : B.collectible);
776
- }
777
- )) == null ? void 0 : x.raw.type) === "CREDIT",
778
- class: "!gap-24",
779
- rules: [unref(ZodHelper).ruleAtPath(unref(s), "validityOption", [unref(l).type])],
780
- "model-value": unref(l).validityOption,
781
- "onUpdate:modelValue": r[4] || (r[4] = (k) => l.value = {
782
- ...unref(l),
783
- validityOption: k
784
- })
785
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
786
- ], 64)) : createCommentVNode("", !0),
787
- unref(l).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$n, {
788
- key: 2,
789
- "reward-image": unref(o),
790
- "model-value": ((R = unref(l)) == null ? void 0 : R.collectibleConfig) ?? void 0,
791
- "onUpdate:modelValue": r[5] || (r[5] = (k) => l.value = {
792
- ...unref(l),
793
- collectibleConfig: k
794
- }),
795
- "onUpdate:rewardImage": r[6] || (r[6] = (k) => o.value = k)
796
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
797
- createVNode(JsonViewer, { json: unref(y) }, null, 8, ["json"])
798
- ])) : createCommentVNode("", !0)
799
- ];
800
- }),
801
- _: 1
802
- }, 8, ["modelValue"]);
803
- };
804
- }
805
- });
806
- function isNullOrEmpty(e) {
807
- return e == null || e === "";
808
- }
809
- const _hoisted_1$a = { class: "space-y-16" }, _hoisted_2$7 = { class: "fm-typo-en-body-lg-400" }, _hoisted_3$6 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$a = /* @__PURE__ */ defineComponent({
810
- __name: "RewardPoolInput",
811
- props: {
812
- modelValue: {
813
- type: Array,
814
- default: () => [
815
- {
816
- collectible: null,
817
- type: "NO_REWARD",
818
- weight: 1
819
- }
820
- ]
821
- }
822
- },
823
- emits: ["update:model-value"],
824
- setup(e, { emit: m }) {
825
- const a = e, i = m, u = useMembershipStore(), d = z.array(z.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), l = computed(() => a.modelValue ?? []), o = computed(() => {
826
- const c = d.safeParse(l.value);
827
- return c.success ? [] : c.error.errors;
828
- }), n = ref();
829
- function s(c, r) {
830
- var f;
831
- const p = [...l.value];
832
- p[r] = c, (f = n.value) == null || f.showSheet(!1), i("update:model-value", p);
833
- }
834
- function y(c) {
835
- const r = c.type == "VOUCHER" ? c.collectibleConfig : u.collectibles.find(
836
- (b) => b._id.toString() == c.collectible
837
- ), p = CollectionUtils.formattedType((r == null ? void 0 : r.name) || ""), f = c.weight;
838
- return {
839
- label: isNullOrEmpty(p) ? "NO REWARD" : p,
840
- sublabel: `${f} (${(f / l.value.reduce((b, C) => b + C.weight, 0) * 100).toFixed(2)}%)`
841
- };
842
- }
843
- function v(c) {
844
- var p;
845
- const r = [...l.value];
846
- (p = n.value) == null || p.showSheet(!0, r[c], c);
847
- }
848
- function h(c) {
849
- const r = [...l.value];
850
- r.splice(c, 1), i("update:model-value", r);
851
- }
852
- function g() {
853
- var c;
854
- (c = n.value) == null || c.showSheet(
855
- !0,
856
- {
857
- type: "NO_REWARD",
858
- collectible: null,
859
- weight: 1
860
- },
861
- l.value.length
862
- );
863
- }
864
- return (c, r) => {
865
- const p = resolveComponent("FmButton"), f = resolveComponent("FmCard"), b = resolveComponent("FmHelperText");
866
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
867
- r[1] || (r[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Configure the reward type and weightage given to your customer. ", -1)),
868
- createVNode(p, {
869
- label: "Add Reward",
870
- onClick: r[0] || (r[0] = (C) => g()),
871
- variant: "plain",
872
- icon: "add"
873
- }),
874
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(l), (C, V) => (openBlock(), createBlock(f, {
875
- key: V,
876
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
877
- variant: "outlined",
878
- onClick: (x) => v(V)
879
- }, {
880
- default: withCtx(() => {
881
- var x;
882
- return [
883
- createElementVNode("div", null, [
884
- createElementVNode("div", _hoisted_2$7, toDisplayString(C.type == "LOYALTY" ? (x = C == null ? void 0 : C.earningOption) == null ? void 0 : x.amount : "") + " " + toDisplayString(y(C).label), 1),
885
- createElementVNode("div", _hoisted_3$6, toDisplayString(y(C).sublabel), 1)
886
- ]),
887
- createVNode(p, {
888
- icon: "delete",
889
- variant: "tertiary",
890
- onClick: (R) => (R.stopPropagation(), h(V))
891
- }, null, 8, ["onClick"])
892
- ];
893
- }),
894
- _: 2
895
- }, 1032, ["onClick"]))), 128)),
896
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o).filter((C) => C.path.join(".") == ""), (C) => (openBlock(), createBlock(b, {
897
- key: C.message,
898
- text: C.message,
899
- state: "error"
900
- }, null, 8, ["text"]))), 128)),
901
- createVNode(_sfc_main$b, {
902
- ref_key: "sheetRef",
903
- ref: n,
904
- "onUpdate:modelValue": s
905
- }, null, 512)
906
- ]);
907
- };
908
- }
909
- }), _hoisted_1$9 = { class: "space-y-16" }, _hoisted_2$6 = {
910
- key: 0,
911
- class: "grid grid-cols-2 gap-16"
912
- }, _hoisted_3$5 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$4 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
913
- __name: "PromotionGameTypeInput",
914
- props: {
915
- modelValue: {
916
- type: Object
917
- }
918
- },
919
- emits: ["update:model-value"],
920
- setup(e, { emit: m }) {
921
- const a = e, i = m, u = computed(() => [
922
- {
923
- label: "Rock paper scissor",
924
- description: "Customers play 3 rounds of Rock Paper Scissors against the cashier. If customer won 2 rounds, they will get a discount.",
925
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
926
- }
927
- ]);
928
- return (d, l) => {
929
- var y, v, h;
930
- const o = resolveComponent("FmSwitch"), n = resolveComponent("FmCard"), s = resolveComponent("FmHelperText");
931
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
932
- createVNode(o, {
933
- label: "Enable game",
934
- "model-value": !!((y = e.modelValue) != null && y.gameType),
935
- "onUpdate:modelValue": l[0] || (l[0] = (g) => g ? i("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : i("update:model-value", null))
936
- }, null, 8, ["model-value"]),
937
- ((v = e.modelValue) == null ? void 0 : v.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
938
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (g) => {
939
- var c, r;
940
- return openBlock(), createBlock(n, {
941
- variant: "outlined",
942
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
943
- "col-span-2": unref(u).length == 1,
944
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((c = e.modelValue) == null ? void 0 : c.gameType) == g.value,
945
- "hover:bg-fm-color-opacity-sm": ((r = e.modelValue) == null ? void 0 : r.gameType) != g.value
946
- }]),
947
- onClick: () => {
948
- var p;
949
- ((p = a.modelValue) == null ? void 0 : p.gameType) != g.value && i("update:model-value", { gameType: g.value });
950
- },
951
- key: g.value
952
- }, {
953
- default: withCtx(() => [
954
- createElementVNode("div", _hoisted_3$5, toDisplayString(g.label), 1),
955
- createElementVNode("div", _hoisted_4$4, toDisplayString(g.description), 1)
956
- ]),
957
- _: 2
958
- }, 1032, ["class", "onClick"]);
959
- }), 128))
960
- ])) : createCommentVNode("", !0),
961
- ((h = e.modelValue) == null ? void 0 : h.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(s, {
962
- key: 1,
963
- text: "Rock paper scissors is only available for POS >= 7.7.4 with dual screen on android devices (Sunmi D3 Pro and Sunmi T3 Pro)",
964
- state: "warning"
965
- })) : createCommentVNode("", !0)
966
- ]);
967
- };
968
- }
969
- }), _hoisted_1$8 = { class: "space-y-16" }, _hoisted_2$5 = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$4 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$8 = /* @__PURE__ */ defineComponent({
970
- __name: "MissionTypeInput",
971
- props: {
972
- modelValue: {
973
- type: String
974
- }
975
- },
976
- emits: ["update:model-value"],
977
- setup(e, { emit: m }) {
978
- const a = e, i = m, u = computed(() => [
979
- {
980
- label: "Stamp",
981
- description: "Award stamps for purchases, redeemable after reaching set milestones.",
982
- value: F_MISSION_TYPE.enum.STAMP
983
- },
984
- {
985
- label: "Progress",
986
- description: "Reward customers when they reach a cumulative spending goal.",
987
- value: F_MISSION_TYPE.enum.PROGRESSIVE
988
- }
989
- ]);
990
- return (d, l) => {
991
- const o = resolveComponent("FmCard");
992
- return openBlock(), createElementBlock("div", _hoisted_1$8, [
993
- l[0] || (l[0] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Select a game where you want your customer to play. ", -1)),
994
- createElementVNode("div", _hoisted_2$5, [
995
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (n) => (openBlock(), createBlock(o, {
996
- variant: "outlined",
997
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
998
- "col-span-2": unref(u).length == 1,
999
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == n.value,
1000
- "hover:bg-fm-color-opacity-sm": e.modelValue != n.value
1001
- }]),
1002
- onClick: () => {
1003
- a.modelValue != n.value && i("update:model-value", n.value);
1004
- },
1005
- key: n.value
1006
- }, {
1007
- default: withCtx(() => [
1008
- createElementVNode("div", _hoisted_3$4, toDisplayString(n.label), 1),
1009
- createElementVNode("div", _hoisted_4$3, toDisplayString(n.description), 1)
1010
- ]),
1011
- _: 2
1012
- }, 1032, ["class", "onClick"]))), 128))
1013
- ])
1014
- ]);
1015
- };
1016
- }
1017
- }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
1018
- __name: "MissionEndInput",
1019
- props: {
1020
- modelValue: {
1021
- type: [String, Number]
1022
- },
1023
- helperText: {
1024
- type: String
1025
- },
1026
- helperState: {
1027
- type: String
1028
- }
1029
- },
1030
- emits: ["update:model-value"],
1031
- setup(e, { emit: m }) {
1032
- const a = m;
1033
- return (i, u) => {
1034
- const d = resolveComponent("FmStepperField");
1035
- return openBlock(), createElementBlock("div", _hoisted_1$7, [
1036
- u[1] || (u[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Input the total number of stamps needed to complete the mission ", -1)),
1037
- createVNode(d, {
1038
- label: "Maximum to collect",
1039
- "model-value": e.modelValue || null,
1040
- "onUpdate:modelValue": u[0] || (u[0] = (l) => a("update:model-value", l)),
1041
- "helper-text": e.helperText || "Set the threshold required for reward eligibility",
1042
- "helper-state": e.helperState || "none"
1043
- }, null, 8, ["model-value", "helper-text", "helper-state"])
1044
- ]);
1045
- };
1046
- }
1047
- }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
1048
- __name: "EditMissionPoolSheet",
1049
- props: {
1050
- maxThreshold: {
1051
- type: Number,
1052
- required: !0
1053
- }
1054
- },
1055
- emits: ["update:model-value"],
1056
- setup(e, { expose: m, emit: a }) {
1057
- const i = e, u = useMembershipStore(), { minor: d } = useLoading, l = ref(!1), o = ref(), n = ref(), s = ref(0), y = computed(() => {
1058
- var f;
1059
- return ((f = u.loyaltyRewards.items.find(
1060
- (b) => {
1061
- var C;
1062
- return b.value === ((C = o.value) == null ? void 0 : C.collectible);
1063
- }
1064
- )) == null ? void 0 : f.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
1065
- }), v = computed(() => {
1066
- const p = y.value.safeParse(o.value);
1067
- return p.success ? [] : p.error.errors;
1068
- });
1069
- function h(p, f, b) {
1070
- p && (o.value = f, s.value = b), l.value = p;
1071
- }
1072
- const g = a;
1073
- async function c() {
1074
- const p = y.value.safeParse(o.value);
1075
- p.success && (await d(
1076
- async () => {
1077
- p.data.type === "VOUCHER" && n.value && (p.data.collectibleConfig.image = await firebaseStorage.update(
1078
- p.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
1079
- n.value
1080
- ));
1081
- },
1082
- {
1083
- message: "Uploading reward image",
1084
- successMessage: "Reward image updated"
1085
- }
1086
- ), g("update:model-value", p.data, s.value));
1087
- }
1088
- const r = ref();
1089
- return m({
1090
- showSheet: h
1091
- }), (p, f) => {
1092
- const b = resolveComponent("FmStepperField"), C = resolveComponent("FmSelect"), V = resolveComponent("FmForm"), x = resolveComponent("FmButton"), R = resolveComponent("FmSideSheet");
1093
- return openBlock(), createBlock(R, {
1094
- "max-width": 560,
1095
- modelValue: unref(l),
1096
- "onUpdate:modelValue": [
1097
- f[10] || (f[10] = (k) => isRef(l) ? l.value = k : null),
1098
- f[11] || (f[11] = (k) => l.value = k)
1099
- ],
1100
- header: "Edit reward",
1101
- "dismiss-away": ""
1102
- }, {
1103
- "side-sheet-footer": withCtx(() => [
1104
- createElementVNode("div", _hoisted_1$6, [
1105
- createVNode(x, {
1106
- variant: "primary",
1107
- type: "button",
1108
- label: "Confirm",
1109
- disabled: unref(v).length > 0,
1110
- onClick: f[8] || (f[8] = async () => {
1111
- var k;
1112
- return (k = unref(r)) == null ? void 0 : k.validateInputs();
1113
- })
1114
- }, null, 8, ["disabled"]),
1115
- createVNode(x, {
1116
- variant: "secondary",
1117
- type: "button",
1118
- label: "Cancel",
1119
- onClick: f[9] || (f[9] = (k) => l.value = !1)
1120
- })
1121
- ])
1122
- ]),
1123
- default: withCtx(() => [
1124
- createVNode(JsonViewer, { json: unref(o) }, null, 8, ["json"]),
1125
- unref(o) ? (openBlock(), createBlock(V, {
1126
- key: 0,
1127
- class: "flex flex-col gap-y-24",
1128
- ref_key: "formRef",
1129
- ref: r,
1130
- onValidationSuccess: f[7] || (f[7] = (k) => c())
1131
- }, {
1132
- default: withCtx(() => {
1133
- var k, B;
1134
- return [
1135
- unref(o).type ? (openBlock(), createBlock(b, {
1136
- key: 0,
1137
- label: "Threshold",
1138
- rules: [
1139
- unref(ZodHelper).toRule(
1140
- unref(z).number().min(1).max(
1141
- i.maxThreshold,
1142
- `Number cannot be more than ${i.maxThreshold}`
1143
- )
1144
- )
1145
- ],
1146
- "model-value": unref(o).threshold,
1147
- "onUpdate:modelValue": f[0] || (f[0] = (E) => o.value = {
1148
- ...unref(o),
1149
- threshold: E
1150
- })
1151
- }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
1152
- createVNode(C, {
1153
- label: "Reward Type",
1154
- items: [
1155
- { label: "Voucher", value: "VOUCHER" },
1156
- { label: "Loyalty", value: "LOYALTY" }
1157
- ],
1158
- "model-value": unref(o).type,
1159
- "onUpdate:modelValue": f[1] || (f[1] = (E) => {
1160
- var S, w;
1161
- E === "VOUCHER" ? o.value = {
1162
- collectible: null,
1163
- type: "VOUCHER",
1164
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
1165
- business: unref(useCoreStore)().currentBusiness.value._id
1166
- }),
1167
- earningOption: {
1168
- amount: 1,
1169
- type: "FIXED"
1170
- },
1171
- validityOption: {
1172
- validForDay: 7
1173
- },
1174
- threshold: (S = unref(o)) == null ? void 0 : S.threshold
1175
- } : o.value = {
1176
- collectible: unref(u).loyaltyRewards.raw[0]._id,
1177
- type: "LOYALTY",
1178
- earningOption: {
1179
- amount: 1,
1180
- type: "FIXED"
1181
- },
1182
- validityOption: {
1183
- validForDay: 7
1184
- },
1185
- threshold: (w = unref(o)) == null ? void 0 : w.threshold
1186
- };
1187
- })
1188
- }, null, 8, ["model-value"]),
1189
- unref(o).type == "LOYALTY" ? (openBlock(), createBlock(C, {
1190
- key: 1,
1191
- label: "Loyalty type",
1192
- rules: [unref(ZodHelper).ruleAtPath(unref(y), "collectible", [unref(o).type])],
1193
- items: unref(u).loyaltyRewards.items,
1194
- "model-value": unref(o).collectible,
1195
- "onUpdate:modelValue": f[2] || (f[2] = (E) => unref(o).collectible = E)
1196
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
1197
- unref(o).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
1198
- f[12] || (f[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
1199
- createVNode(_sfc_main$l, {
1200
- class: "mt-[-8px]",
1201
- rules: [unref(ZodHelper).ruleAtPath(unref(y), "earningOption", [unref(o).type])],
1202
- "helper-state": unref(ZodHelper).helperState(unref(v), "earningOption"),
1203
- "error-text": unref(ZodHelper).helperText(unref(v), "earningOption"),
1204
- "fixed-type": !0,
1205
- "model-value": unref(o).earningOption,
1206
- "onUpdate:modelValue": f[3] || (f[3] = (E) => o.value = {
1207
- ...unref(o),
1208
- earningOption: E
1209
- })
1210
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
1211
- createVNode(_sfc_main$m, {
1212
- class: "!gap-24",
1213
- type: unref(o).type === "LOYALTY" ? "custom" : "range",
1214
- "for-credit": unref(o).type === "LOYALTY" && ((k = unref(u).loyaltyRewards.items.find(
1215
- (E) => {
1216
- var S;
1217
- return E.value === ((S = unref(o)) == null ? void 0 : S.collectible);
1218
- }
1219
- )) == null ? void 0 : k.raw.type) === "CREDIT",
1220
- rules: [unref(ZodHelper).ruleAtPath(unref(y), "validityOption", [unref(o).type])],
1221
- "model-value": unref(o).validityOption,
1222
- "onUpdate:modelValue": f[4] || (f[4] = (E) => o.value = {
1223
- ...unref(o),
1224
- validityOption: E
1225
- })
1226
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
1227
- ], 64)) : createCommentVNode("", !0),
1228
- unref(o).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$n, {
1229
- key: 3,
1230
- "reward-image": unref(n),
1231
- "model-value": ((B = unref(o)) == null ? void 0 : B.collectibleConfig) ?? void 0,
1232
- "onUpdate:modelValue": f[5] || (f[5] = (E) => o.value = {
1233
- ...unref(o),
1234
- collectibleConfig: E
1235
- }),
1236
- "onUpdate:rewardImage": f[6] || (f[6] = (E) => n.value = E)
1237
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1238
- createVNode(JsonViewer, { json: unref(v) }, null, 8, ["json"])
1239
- ];
1240
- }),
1241
- _: 1
1242
- }, 512)) : createCommentVNode("", !0)
1243
- ]),
1244
- _: 1
1245
- }, 8, ["modelValue"]);
1246
- };
1247
- }
1248
- }), _hoisted_1$5 = {
1249
- key: 0,
1250
- class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
1251
- }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
1252
- __name: "MissionProgress",
1253
- props: {
1254
- type: {
1255
- type: String,
1256
- required: !0
1257
- },
1258
- maxRange: {
1259
- type: Number,
1260
- required: !0
1261
- },
1262
- currentRange: {
1263
- type: Number,
1264
- default: 0
1265
- },
1266
- markers: {
1267
- type: Array,
1268
- default: () => []
1269
- }
1270
- },
1271
- setup(e) {
1272
- const m = e, { maxRange: a, currentRange: i, markers: u } = toRefs(m), d = computed(
1273
- () => Math.min(i.value / a.value * 100, 100)
1274
- ), l = (o) => o / a.value * 100;
1275
- return (o, n) => {
1276
- const s = resolveComponent("FmIcon");
1277
- return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
1278
- (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(a), 40), (y) => (openBlock(), createBlock(s, {
1279
- class: normalizeClass(
1280
- unref(i) >= y ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
1281
- ),
1282
- outline: unref(i) < y,
1283
- key: y,
1284
- name: unref(u).some((v) => v === y) ? "featured_seasonal_and_gifts" : "check_circle"
1285
- }, null, 8, ["class", "outline", "name"]))), 128))
1286
- ])) : (openBlock(), createElementBlock("div", {
1287
- key: 1,
1288
- class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
1289
- }, [
1290
- createElementVNode("div", {
1291
- class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
1292
- style: normalizeStyle({ width: unref(d) + "%" })
1293
- }, null, 4),
1294
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (y, v) => (openBlock(), createElementBlock("div", {
1295
- key: v,
1296
- class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
1297
- style: normalizeStyle({ left: l(y) + "%" })
1298
- }, [
1299
- createElementVNode("div", _hoisted_2$4, [
1300
- createElementVNode("div", {
1301
- class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
1302
- }),
1303
- n[0] || (n[0] = createElementVNode("div", null, "🎁", -1))
1304
- ])
1305
- ], 4))), 128))
1306
- ]));
1307
- };
1308
- }
1309
- }), isObject = (e) => e !== null && typeof e == "object";
1310
- function changeKeysFactory(e) {
1311
- return function m(a, i = 1, u) {
1312
- if (i === 0 || !isObject(a))
1313
- return a;
1314
- if (Array.isArray(a))
1315
- return a.map((l) => m(l, i - 1, u));
1316
- const d = Object.create(Object.getPrototypeOf(a));
1317
- return Object.keys(a).forEach((l) => {
1318
- const o = a[l], n = e(l, u), s = m(o, i - 1, u);
1319
- d[n] = s;
1320
- }), d;
1321
- };
1322
- }
1323
- const sentenceCase = changeKeysFactory(sentenceCase$1), _hoisted_1$4 = { class: "space-y-16" }, _hoisted_2$3 = { class: "fm-typo-en-body-lg-400" }, _hoisted_3$3 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_4$2 = { class: "flex items-center gap-4" }, _hoisted_5$2 = { class: "fm-typo-en-body-lg-600" }, _hoisted_6$2 = { class: "flex items-center gap-16" }, _hoisted_7$1 = { key: 0 }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
1324
- __name: "MissionPoolInput",
1325
- props: {
1326
- modelValue: {
1327
- type: Array,
1328
- default: () => []
1329
- },
1330
- mission: {
1331
- type: Object,
1332
- required: !0
1333
- }
1334
- },
1335
- emits: ["update:model-value"],
1336
- setup(e, { emit: m }) {
1337
- const a = e, i = m, u = useMembershipStore(), d = z.array(z.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), l = computed(
1338
- () => a.modelValue.sort((r, p) => r.threshold - p.threshold) ?? []
1339
- ), o = computed(() => {
1340
- const r = d.safeParse(l.value);
1341
- return r.success ? [] : r.error.errors;
1342
- }), n = ref();
1343
- function s(r, p) {
1344
- var b;
1345
- const f = [...l.value];
1346
- f[p] = r, (b = n.value) == null || b.showSheet(!1), i("update:model-value", f);
1347
- }
1348
- function y(r) {
1349
- const p = r.type == "VOUCHER" ? r.collectibleConfig : u.collectibles.find(
1350
- (b) => b._id.toString() == r.collectible
1351
- ), f = CollectionUtils.formattedType((p == null ? void 0 : p.name) || "");
1352
- return {
1353
- label: isNullOrEmpty(f) ? "NO REWARD" : f,
1354
- sublabel: `Reward at ${r.threshold} | Amount: ${r.earningOption.type == "FIXED" ? r.earningOption.amount : `${r.earningOption.amount} for every RM${r.earningOption.every} spent`} `
1355
- };
1356
- }
1357
- function v(r) {
1358
- var f;
1359
- const p = [...l.value];
1360
- (f = n.value) == null || f.showSheet(!0, p[r], r);
1361
- }
1362
- function h(r) {
1363
- const p = [...l.value];
1364
- p.splice(r, 1), i("update:model-value", p);
1365
- }
1366
- function g() {
1367
- var r;
1368
- (r = n.value) == null || r.showSheet(
1369
- !0,
1370
- {
1371
- type: "LOYALTY",
1372
- collectible: u.loyaltyRewards.items[0].value,
1373
- threshold: null,
1374
- validityOption: {
1375
- validForDay: 7
1376
- },
1377
- earningOption: {
1378
- type: "FIXED",
1379
- amount: 1
1380
- }
1381
- },
1382
- l.value.length
1383
- );
1384
- }
1385
- function c(r) {
1386
- var p, f;
1387
- return r.type == "VOUCHER" ? (p = r.collectibleConfig) == null ? void 0 : p.name : sentenceCase(
1388
- ((f = u.loyaltyRewards.items.find(
1389
- (b) => b.value == r.collectible
1390
- )) == null ? void 0 : f.label) || ""
1391
- );
1392
- }
1393
- return (r, p) => {
1394
- const f = resolveComponent("FmButton"), b = resolveComponent("FmCard"), C = resolveComponent("FmHelperText");
1395
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
1396
- p[2] || (p[2] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Configure the reward type given to your customer. ", -1)),
1397
- createVNode(f, {
1398
- label: "Add Reward",
1399
- onClick: p[0] || (p[0] = (V) => g()),
1400
- variant: "plain",
1401
- icon: "add"
1402
- }),
1403
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(l), (V, x) => (openBlock(), createBlock(b, {
1404
- key: x,
1405
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
1406
- variant: "outlined",
1407
- onClick: (R) => v(x)
1408
- }, {
1409
- default: withCtx(() => [
1410
- createElementVNode("div", null, [
1411
- createElementVNode("div", _hoisted_2$3, toDisplayString(y(V).label), 1),
1412
- createElementVNode("div", _hoisted_3$3, toDisplayString(y(V).sublabel), 1)
1413
- ]),
1414
- createVNode(f, {
1415
- icon: "delete",
1416
- variant: "tertiary",
1417
- onClick: (R) => (R.stopPropagation(), h(x))
1418
- }, null, 8, ["onClick"])
1419
- ]),
1420
- _: 2
1421
- }, 1032, ["onClick"]))), 128)),
1422
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o).filter((V) => V.path.join(".") == ""), (V) => (openBlock(), createBlock(C, {
1423
- key: V.message,
1424
- text: V.message,
1425
- state: "error"
1426
- }, null, 8, ["text"]))), 128)),
1427
- p[3] || (p[3] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Mission Preview", -1)),
1428
- (openBlock(), createBlock(b, {
1429
- key: 0,
1430
- variant: "outlined",
1431
- class: "p-24 space-y-16 w-fit"
1432
- }, {
1433
- default: withCtx(() => {
1434
- var V, x;
1435
- return [
1436
- createElementVNode("div", _hoisted_4$2, [
1437
- createElementVNode("div", null, [
1438
- createElementVNode("div", _hoisted_5$2, " Collect " + toDisplayString(e.mission.end) + " stamps to get " + toDisplayString(((V = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : V.earningOption.amount) > 1 ? (x = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : x.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? c(e.modelValue[e.modelValue.length - 1]) : ""), 1),
1439
- p[1] || (p[1] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Earn a stamp! ", -1))
1440
- ])
1441
- ]),
1442
- createElementVNode("div", _hoisted_6$2, [
1443
- createVNode(_sfc_main$5, {
1444
- type: e.mission.type,
1445
- "max-range": e.mission.end,
1446
- currentRange: e.mission.end / 4,
1447
- markers: e.modelValue.map((R) => R.threshold)
1448
- }, null, 8, ["type", "max-range", "currentRange", "markers"]),
1449
- e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_7$1, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
1450
- ])
1451
- ];
1452
- }),
1453
- _: 1
1454
- })),
1455
- createVNode(_sfc_main$6, {
1456
- ref_key: "sheetRef",
1457
- ref: n,
1458
- "onUpdate:modelValue": s,
1459
- "max-threshold": e.mission.end
1460
- }, null, 8, ["max-threshold"])
1461
- ]);
1462
- };
1463
- }
1464
- }), _hoisted_1$3 = { class: "space-y-16" }, _hoisted_2$2 = { class: "space-y-8" }, _hoisted_3$2 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_6$1 = { class: "space-y-8" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
1465
- __name: "MissionInput",
1466
- props: {
1467
- modelValue: Object
1468
- },
1469
- emits: ["update:model-value"],
1470
- setup(e, { emit: m }) {
1471
- const a = e, i = computed(() => {
1472
- const l = FdoMission.safeParse(a.modelValue);
1473
- return l.success ? [] : l.error.errors;
1474
- }), u = computed(() => [
1475
- {
1476
- label: "Stamp",
1477
- description: "Award stamps for purchases, redeemable after reaching set milestones.",
1478
- value: F_MISSION_TYPE.enum.STAMP
1479
- },
1480
- {
1481
- label: "Progress",
1482
- description: "Reward customers when they reach a cumulative spending goal.",
1483
- value: F_MISSION_TYPE.enum.PROGRESSIVE
1484
- }
1485
- ]), d = m;
1486
- return (l, o) => {
1487
- var y;
1488
- const n = resolveComponent("FmCard"), s = resolveComponent("FmStepperField");
1489
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
1490
- createElementVNode("div", _hoisted_2$2, [
1491
- o[1] || (o[1] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Mission Type", -1)),
1492
- o[2] || (o[2] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Select a game where you want your customer to play. ", -1)),
1493
- createElementVNode("div", _hoisted_3$2, [
1494
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (v) => {
1495
- var h, g;
1496
- return openBlock(), createBlock(n, {
1497
- variant: "outlined",
1498
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1499
- "col-span-2": unref(u).length == 1,
1500
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((h = e.modelValue) == null ? void 0 : h.type) == v.value,
1501
- "hover:bg-fm-color-opacity-sm": ((g = e.modelValue) == null ? void 0 : g.type) != v.value
1502
- }]),
1503
- onClick: () => {
1504
- var c, r;
1505
- ((c = e.modelValue) == null ? void 0 : c.type) != v.value && d("update:model-value", {
1506
- ...e.modelValue,
1507
- type: v.value,
1508
- end: ((r = e.modelValue) == null ? void 0 : r.end) || 1
1509
- });
1510
- },
1511
- key: v.value
1512
- }, {
1513
- default: withCtx(() => [
1514
- createElementVNode("div", _hoisted_4$1, toDisplayString(v.label), 1),
1515
- createElementVNode("div", _hoisted_5$1, toDisplayString(v.description), 1)
1516
- ]),
1517
- _: 2
1518
- }, 1032, ["class", "onClick"]);
1519
- }), 128))
1520
- ])
1521
- ]),
1522
- createElementVNode("div", _hoisted_6$1, [
1523
- o[3] || (o[3] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Collections required", -1)),
1524
- o[4] || (o[4] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Input the total number of stamps needed to complete the mission ", -1)),
1525
- createVNode(s, {
1526
- label: "Maximum to collect",
1527
- "model-value": ((y = e.modelValue) == null ? void 0 : y.end) || null,
1528
- "onUpdate:modelValue": o[0] || (o[0] = (v) => {
1529
- var h;
1530
- return d("update:model-value", {
1531
- ...e.modelValue,
1532
- type: ((h = e.modelValue) == null ? void 0 : h.type) || "STAMP",
1533
- end: v
1534
- });
1535
- }),
1536
- "helper-text": unref(ZodHelper).helperText(unref(i), "end") || "Set the threshold required for reward eligibility",
1537
- "helper-state": unref(ZodHelper).helperState(unref(i), "end") || "none"
1538
- }, null, 8, ["model-value", "helper-text", "helper-state"])
1539
- ])
1540
- ]);
1541
- };
1542
- }
1543
- }), _hoisted_1$2 = { key: 26 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
1544
- __name: "TemplateInput",
1545
- props: {
1546
- field: { type: Object, required: !0 },
1547
- modelValue: {
1548
- type: Object
1549
- },
1550
- schema: {
1551
- type: Object
1552
- },
1553
- extras: {
1554
- type: Object
1555
- },
1556
- helperText: {
1557
- type: String
1558
- },
1559
- disabled: {
1560
- type: Boolean,
1561
- default: !1
1562
- }
1563
- },
1564
- emits: ["update:model-value", "update:file"],
1565
- setup(e, { emit: m }) {
1566
- const { t: a } = useI18n(), i = e, u = m;
1567
- function d(s) {
1568
- switch (i.field.type) {
1569
- case "timeframe":
1570
- const y = s.startDate ? hooks(s.startDate).startOf("day").toISOString() : void 0, v = s.endDate ? hooks(s.endDate).endOf("day").toISOString() : void 0;
1571
- u("update:model-value", {
1572
- type: "timeframe",
1573
- property: "__now",
1574
- start: y,
1575
- end: v
1576
- });
1577
- break;
1578
- case "image": {
1579
- u(
1580
- "update:file",
1581
- s,
1582
- l.value || firebaseStorage.collectibleImagePath(void 0, s)
1583
- );
1584
- break;
1585
- }
1586
- default:
1587
- u("update:model-value", s);
1588
- break;
1589
- }
1590
- }
1591
- const l = computed(() => {
1592
- switch (i.field.type) {
1593
- case "timeframe": {
1594
- const s = i.modelValue;
1595
- return {
1596
- startDate: s != null && s.start ? hooks(s == null ? void 0 : s.start).format("YYYY-MM-DD") : null,
1597
- endDate: s != null && s.end ? hooks(s == null ? void 0 : s.end).format("YYYY-MM-DD") : null
1598
- };
1599
- }
1600
- default:
1601
- return i.modelValue;
1602
- }
1603
- });
1604
- function o() {
1605
- if (!n.value.schema) return [];
1606
- const s = n.value.schema.safeParse(i.modelValue);
1607
- return s.success ? [] : s.error.errors;
1608
- }
1609
- const n = computed(() => ({
1610
- schema: i.schema,
1611
- unwrapped: i.schema ? ZodHelper.unwrap(i.schema) : void 0,
1612
- rules: i.schema ? [ZodHelper.ruleAtPath(i.schema, "")] : void 0,
1613
- labelMark: i.schema && ZodHelper.isRequired(i.schema) == !1 ? "optional" : void 0,
1614
- zodLabel: i.schema ? ZodHelper.toInputLabel(i.schema, i.field.label) : void 0
1615
- }));
1616
- return (s, y) => {
1617
- var p, f, b, C, V;
1618
- const v = resolveComponent("FmTextField"), h = resolveComponent("FmStepperField"), g = resolveComponent("FmTextarea"), c = resolveComponent("FmHelperText"), r = resolveComponent("FmSwitch");
1619
- return e.field.type === "text" ? (openBlock(), createBlock(v, {
1620
- key: 0,
1621
- label: unref(a)(e.field.label),
1622
- "label-mark": unref(n).labelMark,
1623
- rules: unref(n).rules,
1624
- "model-value": unref(l),
1625
- "onUpdate:modelValue": d,
1626
- "helper-state": e.helperText ? "error" : void 0,
1627
- "helper-text": e.helperText
1628
- }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1629
- createVNode(JsonViewer, {
1630
- json: { schema: unref(n).unwrapped, props: i }
1631
- }, null, 8, ["json"]),
1632
- createVNode(h, {
1633
- label: unref(a)(e.field.label),
1634
- "label-mark": e.field.isRuleChildren ? void 0 : unref(n).labelMark,
1635
- "model-value": unref(l),
1636
- rules: e.field.isRuleChildren ? [] : unref(n).rules,
1637
- "onUpdate:modelValue": d,
1638
- "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
1639
- "helper-text": e.field.isRuleChildren ? e.helperText : void 0
1640
- }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
1641
- ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(g, {
1642
- key: 2,
1643
- label: unref(a)(e.field.label),
1644
- "label-mark": unref(n).labelMark,
1645
- rules: unref(n).rules,
1646
- "model-value": unref(l),
1647
- "onUpdate:modelValue": d,
1648
- "show-word-count": "",
1649
- "max-length": (V = (C = (b = (f = (p = unref(n)) == null ? void 0 : p.unwrapped) == null ? void 0 : f._def) == null ? void 0 : b.checks) == null ? void 0 : C.find((x) => x.kind == "max")) == null ? void 0 : V.value
1650
- }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$g, {
1651
- key: 3,
1652
- "campaign-type": e.extras,
1653
- "model-value": unref(l),
1654
- disabled: e.disabled,
1655
- "onUpdate:modelValue": d
1656
- }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
1657
- createVNode(_sfc_main$e, {
1658
- "model-value": unref(l),
1659
- "onUpdate:modelValue": d
1660
- }, null, 8, ["model-value"]),
1661
- createVNode(c, {
1662
- class: "!mt-[8px]",
1663
- text: unref(ZodHelper).helperText(o(), ""),
1664
- state: unref(ZodHelper).helperState(o(), "")
1665
- }, null, 8, ["text", "state"])
1666
- ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$o, {
1667
- key: 5,
1668
- thumbnail: unref(l),
1669
- "aspect-ratio": "16 / 9",
1670
- class: "w-1/2 xs:w-2/3",
1671
- "onUpdate:file": d
1672
- }, {
1673
- label: withCtx(() => [
1674
- (openBlock(), createBlock(resolveDynamicComponent(unref(n).zodLabel)))
1675
- ]),
1676
- _: 1
1677
- }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(r, {
1678
- key: 6,
1679
- label: unref(a)(e.field.label),
1680
- "label-placement": "right",
1681
- sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
1682
- "label-mark": unref(n).labelMark,
1683
- rules: unref(n).rules,
1684
- "model-value": unref(l),
1685
- "onUpdate:modelValue": d
1686
- }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$p, {
1687
- key: 7,
1688
- "model-value": unref(l),
1689
- "onUpdate:modelValue": d,
1690
- "no-campaign": !1,
1691
- schema: unref(n).schema,
1692
- "is-mission": e.extras === "MISSION"
1693
- }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$q, {
1694
- key: 8,
1695
- "model-value": unref(l),
1696
- "onUpdate:modelValue": d
1697
- }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 9 }, [
1698
- createVNode(_sfc_main$r, {
1699
- "model-value": unref(l),
1700
- "onUpdate:modelValue": d,
1701
- "can-set-auto-apply": e.field.property == "campaign.effect"
1702
- }, null, 8, ["model-value", "can-set-auto-apply"]),
1703
- unref(l) ? createCommentVNode("", !0) : (openBlock(), createBlock(c, {
1704
- key: 0,
1705
- class: "!mt-[8px]",
1706
- text: unref(a)("connect.campaign.common.effect_required"),
1707
- state: "error"
1708
- }, null, 8, ["text"]))
1709
- ], 64)) : e.field.type === "message" ? (openBlock(), createBlock(_sfc_main$s, {
1710
- key: 10,
1711
- "allow-email": !0,
1712
- "allow-whatsapp": !0,
1713
- "model-value": unref(l),
1714
- "onUpdate:modelValue": d,
1715
- "helper-text": unref(ZodHelper).helperText(o(), ""),
1716
- "trigger-type": e.field.extras,
1717
- "helper-state": unref(ZodHelper).helperState(o(), "")
1718
- }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"])) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$l, {
1719
- key: 11,
1720
- "model-value": unref(l),
1721
- "onUpdate:modelValue": d,
1722
- extras: e.extras,
1723
- "error-text": e.helperText
1724
- }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$m, {
1725
- key: 12,
1726
- type: "custom",
1727
- "model-value": unref(l),
1728
- "onUpdate:modelValue": d,
1729
- "helper-text": e.helperText || unref(ZodHelper).helperText(o(), "")
1730
- }, null, 8, ["model-value", "helper-text"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$c, {
1731
- key: 13,
1732
- "model-value": unref(l),
1733
- "onUpdate:modelValue": d
1734
- }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$a, {
1735
- key: 14,
1736
- "model-value": unref(l),
1737
- "onUpdate:modelValue": d
1738
- }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
1739
- key: 15,
1740
- "model-value": unref(l),
1741
- "onUpdate:modelValue": d
1742
- }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
1743
- key: 16,
1744
- "model-value": unref(l),
1745
- "onUpdate:modelValue": d
1746
- }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
1747
- key: 17,
1748
- "model-value": unref(l),
1749
- "onUpdate:modelValue": d,
1750
- "helper-text": unref(ZodHelper).helperText(o(), ""),
1751
- "helper-state": unref(ZodHelper).helperState(o(), "")
1752
- }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
1753
- key: 18,
1754
- "model-value": unref(l),
1755
- "onUpdate:modelValue": d,
1756
- mission: e.extras.mission
1757
- }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 19 }, [
1758
- createVNode(_sfc_main$d, {
1759
- "model-value": unref(l),
1760
- "onUpdate:modelValue": d,
1761
- "start-date": e.extras.start,
1762
- "end-date": e.extras.end
1763
- }, null, 8, ["model-value", "start-date", "end-date"]),
1764
- e.helperText ? (openBlock(), createBlock(c, {
1765
- key: 0,
1766
- class: "!mt-[8px]",
1767
- text: e.helperText,
1768
- state: "error"
1769
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1770
- ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 20 }, [
1771
- createVNode(_sfc_main$t, {
1772
- "model-value": unref(l),
1773
- "onUpdate:modelValue": d
1774
- }, null, 8, ["model-value"]),
1775
- e.helperText ? (openBlock(), createBlock(c, {
1776
- key: 0,
1777
- class: "!mt-[8px]",
1778
- text: e.helperText,
1779
- state: "error"
1780
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1781
- ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 21 }, [
1782
- e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(l).rules.g_time).length > 0 ? (openBlock(), createBlock(c, {
1783
- key: 0,
1784
- state: "warning",
1785
- text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
1786
- }, null, 8, ["text"])) : createCommentVNode("", !0),
1787
- createVNode(_sfc_main$i, {
1788
- "model-value": unref(l),
1789
- "onUpdate:modelValue": d
1790
- }, null, 8, ["model-value"]),
1791
- e.helperText ? (openBlock(), createBlock(c, {
1792
- key: 1,
1793
- class: "!mt-[8px]",
1794
- text: e.helperText,
1795
- state: "error"
1796
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1797
- ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
1798
- createVNode(_sfc_main$u, {
1799
- "model-value": unref(l),
1800
- "onUpdate:modelValue": d
1801
- }, null, 8, ["model-value"]),
1802
- e.helperText ? (openBlock(), createBlock(c, {
1803
- key: 0,
1804
- class: "!mt-[8px]",
1805
- text: e.helperText,
1806
- state: "error"
1807
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1808
- ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
1809
- createVNode(_sfc_main$v, {
1810
- "model-value": unref(l),
1811
- "onUpdate:modelValue": d
1812
- }, null, 8, ["model-value"]),
1813
- e.helperText ? (openBlock(), createBlock(c, {
1814
- key: 0,
1815
- class: "!mt-[8px]",
1816
- text: e.helperText,
1817
- state: "error"
1818
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1819
- ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
1820
- createVNode(_sfc_main$h, {
1821
- "model-value": unref(l),
1822
- "onUpdate:modelValue": d
1823
- }, null, 8, ["model-value"]),
1824
- e.helperText ? (openBlock(), createBlock(c, {
1825
- key: 0,
1826
- class: "!mt-[8px]",
1827
- text: e.helperText,
1828
- state: "error"
1829
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1830
- ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
1831
- createVNode(_sfc_main$9, {
1832
- "model-value": unref(l),
1833
- "onUpdate:modelValue": d
1834
- }, null, 8, ["model-value"]),
1835
- e.helperText ? (openBlock(), createBlock(c, {
1836
- key: 0,
1837
- class: "!mt-[8px]",
1838
- text: e.helperText,
1839
- state: "error"
1840
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1841
- ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(i.field), 1));
1842
- };
1843
- }
1844
- }), _hoisted_1$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_2$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$1 = { class: "fm-typo-en-body-lg-600" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
1845
- __name: "CampaignSummary",
1846
- props: {
1847
- data: {
1848
- type: Object,
1849
- required: !0
1850
- }
1851
- },
1852
- setup(e) {
1853
- const { t: m, te: a } = useI18n();
1854
- return (i, u) => {
1855
- const d = resolveComponent("FmCard");
1856
- return openBlock(), createBlock(d, {
1857
- variant: "outlined",
1858
- class: "p-16 space-y-8"
1859
- }, {
1860
- default: withCtx(() => [
1861
- createElementVNode("div", _hoisted_1$1, toDisplayString(unref(m)("connect.campaign.common.summary")), 1),
1862
- u[0] || (u[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
1863
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (l, o) => (openBlock(), createElementBlock("div", {
1864
- class: "space-y-4",
1865
- key: o
1866
- }, [
1867
- l ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1868
- createElementVNode("div", _hoisted_2$1, toDisplayString(unref(m)(`${o}`)), 1),
1869
- createElementVNode("div", _hoisted_3$1, toDisplayString(unref(a)(`${l}`) ? unref(m)(`${l}`) : l), 1)
1870
- ], 64)) : createCommentVNode("", !0)
1871
- ]))), 128))
1872
- ]),
1873
- _: 1
1874
- });
1875
- };
1876
- }
1877
- }), _hoisted_1 = { class: "xs:hidden px-24 pb-[14px] pt-[22px] flex items-center justify-between w-full border-b" }, _hoisted_2 = { class: "flex items-center gap-8" }, _hoisted_3 = {
1878
- key: 0,
1879
- class: "max-w-6xl mx-auto"
1880
- }, _hoisted_4 = { class: "hidden xs:flex gap-8 items-center w-full px-16 py-8 border-b border-fm-color-neutral-gray-100" }, _hoisted_5 = { class: "grid grid-cols-3 gap-40" }, _hoisted_6 = { class: "col-span-2 space-y-40 xs:col-span-3 xs:px-16 xs:pt-16" }, _hoisted_7 = { class: "fm-typo-en-title-sm-800 !mb-[-8px]" }, _hoisted_8 = { class: "w-full flex items-center justify-end gap-8 pb-24" }, _hoisted_9 = { class: "max-w-6xl mx-auto rounded-md p-4 w-full" }, _hoisted_10 = { class: "animate-pulse flex space-x-4 pt-16" }, _hoisted_11 = { class: "grid grid-cols-3 w-full gap-40" }, _sfc_main = /* @__PURE__ */ defineComponent({
1881
- __name: "EditCampaignSheet",
1882
- emits: ["submit:model-value"],
1883
- setup(__props, { expose: __expose, emit: __emit }) {
1884
- const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), currentStep = ref(1), data = ref(), schema = ref(z.any()), template = ref(
1885
- TEMPLATES.VOUCHER
1886
- ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign");
1887
- async function showSheet(visible, type, campaign, selectedTemplate) {
1888
- var e, m;
1889
- if (sheetVisible.value = visible, visible == !0) {
1890
- try {
1891
- isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
1892
- } catch {
1893
- } finally {
1894
- await new Promise((a) => setTimeout(a, 120)), isLoading.value = !1;
1895
- }
1896
- template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((a, i) => {
1897
- a.campaign.type === "VOUCHER" && a.campaign.code && useCampaignStore().campaigns.voucher.some(
1898
- (u) => u.code === a.campaign.code && u._id.toString() !== a.campaign._id.toString()
1899
- ) && i.addIssue({
1900
- code: "custom",
1901
- message: "Code already exists, please use another code",
1902
- path: ["campaign", "code"]
1903
- });
1904
- })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
1905
- ...(m = template.value) == null ? void 0 : m.defaultValue
1906
- }), "configs" in data.value && typeof data.value.configs == "string" && (data.value.configs = eval(data.value.configs)), data.value = cleanPF(data.value), data.value.templateId = SvcConfig.getBusinessId(), data.value.campaign.business = SvcConfig.getBusinessId(), data.value.campaign.templateId = SvcConfig.getBusinessId(), "configs" in data.value && (data.value.configs.business = SvcConfig.getBusinessId()), currentStep.value = 1, sheetTitle.value = campaign ? `Edit ${CampaignOptions[type].name} Campaign` : `Create ${CampaignOptions[type].name} Campaign`;
1907
- }
1908
- }
1909
- async function hideSheet() {
1910
- Dialog.open({
1911
- title: t("connect.campaign.common.unsaved_changes"),
1912
- message: t("connect.campaign.common.unsaved_changes"),
1913
- primaryActions: {
1914
- text: t("connect.campaign.common.unsaved_changes_confirm"),
1915
- close: !0
1916
- },
1917
- secondaryActions: {
1918
- text: t("connect.campaign.common.unsaved_changes_cancel"),
1919
- close: !1
1920
- }
1921
- }).onPrimary(() => {
1922
- sheetVisible.value = !1;
1923
- }).onSecondary(() => {
1924
- Dialog.close();
1925
- });
1926
- }
1927
- const emits = __emit, errors = computed(() => {
1928
- const e = schema.value.superRefine(campaignRefinement).safeParse(data.value);
1929
- return e.success ? [] : e.error.errors;
1930
- });
1931
- function stepErrors(e = currentStep.value - 1) {
1932
- const m = template.value.steps[e].groups.flatMap(
1933
- (a) => a.fields.map((i) => i.property)
1934
- );
1935
- return errors.value.filter(
1936
- (a) => m.some((i) => a.path.join(".").includes(i))
1937
- );
1938
- }
1939
- __expose({ showSheet });
1940
- function showSummaryDialog() {
1941
- Dialog.open({
1942
- title: "",
1943
- dialogComponent: _sfc_main$1,
1944
- dialogComponentProps: {
1945
- data: data.value
1946
- }
1947
- });
1948
- }
1949
- function onUpdateProperty(e, m) {
1950
- var a, i, u, d, l, o, n, s;
1951
- if (_.set(data.value, e, m), e == "campaign.event.type") {
1952
- const v = ((d = (u = (i = (a = template.value) == null ? void 0 : a.defaultValue) == null ? void 0 : i.campaign) == null ? void 0 : u.event) == null ? void 0 : d.rule) ? _.cloneDeep({
1953
- ...(s = (n = (o = (l = template.value) == null ? void 0 : l.defaultValue) == null ? void 0 : o.campaign) == null ? void 0 : n.event) == null ? void 0 : s.rule
1954
- }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
1955
- RuleBuilder.scaffoldGroup("g_schedule"),
1956
- RuleBuilder.scaffoldGroup("g_time"),
1957
- RuleBuilder.scaffoldGroup("g_user"),
1958
- RuleBuilder.scaffoldGroup("g_bill")
1959
- ]), h = RuleBuilder.setRuleToGroup(
1960
- RuleBuilder.scaffoldGroup("g_schedule"),
1961
- [
1962
- RuleBuilder.constructEntry(
1963
- "trigger.date",
1964
- "_rrule",
1965
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
1966
- ),
1967
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1968
- ],
1969
- "&&"
1970
- );
1971
- if (m != "SCHEDULE") {
1972
- _.set(data.value, "campaign.event.rule", v);
1973
- return;
1974
- }
1975
- _.set(
1976
- data.value,
1977
- "campaign.event.rule",
1978
- RuleBuilder.setRuleToGroup(v, h)
1979
- );
1980
- }
1981
- e == "campaign.notify" && m == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
1982
- }
1983
- async function onUpdateFile(e, m) {
1984
- return e ? await minor(async () => firebaseStorage.update(m, e), {
1985
- message: `${e ? "Uploading" : "Removing"} file`,
1986
- successMessage: `File ${e ? "uploaded" : "removed"} successfully`
1987
- }) : "";
1988
- }
1989
- function isDisable(e) {
1990
- var m, a;
1991
- switch (e == null ? void 0 : e.property) {
1992
- case "campaign.event.type":
1993
- return ((a = (m = data.value) == null ? void 0 : m.campaign) == null ? void 0 : a._id) || !1;
1994
- default:
1995
- return !1;
1996
- }
1997
- }
1998
- function onSubmit() {
1999
- const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
2000
- e.success && (emits("submit:model-value", cleanPF(JSON.parse(JSON.stringify(e.data)))), sheetVisible.value = !1);
2001
- }
2002
- return (e, m) => {
2003
- const a = resolveComponent("FmButton"), i = resolveComponent("FmStep"), u = resolveComponent("FmStepper"), d = resolveComponent("FmCard"), l = resolveComponent("FmTopSheet");
2004
- return openBlock(), createBlock(l, {
2005
- "fullscreen-size": "lg",
2006
- modelValue: unref(sheetVisible),
2007
- "onUpdate:modelValue": [
2008
- m[7] || (m[7] = (o) => isRef(sheetVisible) ? sheetVisible.value = o : null),
2009
- m[8] || (m[8] = (o) => sheetVisible.value = o)
2010
- ]
2011
- }, createSlots({
2012
- "top-sheet-header": withCtx(() => [
2013
- createElementVNode("div", _hoisted_1, [
2014
- createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
2015
- createElementVNode("div", _hoisted_2, [
2016
- createVNode(a, {
2017
- onClick: m[0] || (m[0] = (o) => hideSheet()),
2018
- label: unref(t)("connect.campaign.common.cancel"),
2019
- variant: "tertiary"
2020
- }, null, 8, ["label"]),
2021
- createVNode(a, {
2022
- onClick: onSubmit,
2023
- label: unref(t)("connect.campaign.common.save"),
2024
- disabled: unref(errors).length > 0
2025
- }, null, 8, ["label", "disabled"])
2026
- ])
2027
- ])
2028
- ]),
2029
- _: 2
2030
- }, [
2031
- unref(isLoading) ? {
2032
- name: "default",
2033
- fn: withCtx(() => [
2034
- createElementVNode("div", _hoisted_9, [
2035
- createElementVNode("div", _hoisted_10, [
2036
- createElementVNode("div", _hoisted_11, [
2037
- m[9] || (m[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
2038
- createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
2039
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2040
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2041
- createElementVNode("div", { class: "space-y-3" }, [
2042
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2043
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2044
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2045
- ]),
2046
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2047
- ]),
2048
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2049
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2050
- createElementVNode("div", { class: "space-y-3" }, [
2051
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2052
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2053
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2054
- ]),
2055
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2056
- ])
2057
- ])
2058
- ], -1)),
2059
- createVNode(d, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
2060
- ])
2061
- ])
2062
- ])
2063
- ]),
2064
- key: "1"
2065
- } : {
2066
- name: "default",
2067
- fn: withCtx(() => [
2068
- unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
2069
- createVNode(u, {
2070
- modelValue: unref(currentStep),
2071
- "onUpdate:modelValue": m[1] || (m[1] = (o) => isRef(currentStep) ? currentStep.value = o : null),
2072
- orientation: "horizontal",
2073
- class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
2074
- }, {
2075
- default: withCtx(() => [
2076
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, n) => (openBlock(), createBlock(i, {
2077
- key: o.name,
2078
- title: unref(t)(o.name),
2079
- value: n + 1,
2080
- error: () => stepErrors(n).length > 0,
2081
- complete: () => n + 1 <= unref(currentStep)
2082
- }, null, 8, ["title", "value", "error", "complete"]))), 128))
2083
- ]),
2084
- _: 1
2085
- }, 8, ["modelValue"]),
2086
- createElementVNode("div", _hoisted_4, [
2087
- createVNode(a, {
2088
- icon: "close",
2089
- variant: "tertiary",
2090
- onClick: m[2] || (m[2] = (o) => sheetVisible.value = !1)
2091
- }),
2092
- createVNode(u, {
2093
- modelValue: unref(currentStep),
2094
- "onUpdate:modelValue": m[3] || (m[3] = (o) => isRef(currentStep) ? currentStep.value = o : null),
2095
- orientation: "horizontal",
2096
- class: "flex-1"
2097
- }, {
2098
- default: withCtx(() => [
2099
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, n) => (openBlock(), createBlock(i, {
2100
- key: o.name,
2101
- title: unref(sheetTitle),
2102
- description: unref(t)(o.name),
2103
- value: n + 1,
2104
- error: () => stepErrors(n).length > 0,
2105
- complete: () => n + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
2106
- }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
2107
- ]),
2108
- _: 1
2109
- }, 8, ["modelValue"]),
2110
- createVNode(a, {
2111
- icon: "info",
2112
- variant: "tertiary",
2113
- onClick: m[4] || (m[4] = () => showSummaryDialog())
2114
- })
2115
- ]),
2116
- createElementVNode("div", _hoisted_5, [
2117
- createElementVNode("div", _hoisted_6, [
2118
- createVNode(JsonViewer, {
2119
- json: {
2120
- data: unref(data),
2121
- errors: unref(errors).map(
2122
- (o) => `${o.path.join(".")} - ${o.message}`
2123
- ),
2124
- stepErrors: stepErrors().map(
2125
- (o) => `${o.path.join(".")} - ${o.message}`
2126
- ),
2127
- schema: unref(schema)
2128
- }
2129
- }, null, 8, ["json"]),
2130
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
2131
- (o) => o.fields.length && (!o.condition || unref(_).get(unref(data), o.condition.property) == o.condition.value == (o.condition.not != !0))
2132
- ), (o, n) => (openBlock(), createElementBlock("div", {
2133
- key: n,
2134
- class: "space-y-24"
2135
- }, [
2136
- createElementVNode("div", _hoisted_7, toDisplayString(o.name ? unref(t)(o.name) : ""), 1),
2137
- (openBlock(!0), createElementBlock(Fragment, null, renderList(o.fields, (s, y) => (openBlock(), createElementBlock("div", { key: y }, [
2138
- (openBlock(), createBlock(_sfc_main$2, {
2139
- key: y,
2140
- field: s,
2141
- modelValue: unref(_).get(unref(data), s.property),
2142
- disabled: isDisable(s),
2143
- "onUpdate:modelValue": (v) => onUpdateProperty(s.property, v),
2144
- "onUpdate:file": async (v, h) => {
2145
- const g = await onUpdateFile(v, h);
2146
- onUpdateProperty(s.property, g || "");
2147
- },
2148
- schema: unref(ZodHelper).typeAtPath(
2149
- unref(schema),
2150
- s.property,
2151
- unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
2152
- ),
2153
- "helper-state": unref(ZodHelper).helperState(unref(errors), s.property),
2154
- "helper-text": unref(ZodHelper).helperText(unref(errors), s.property),
2155
- extras: s.extras != null ? s.extras == "" ? unref(data) : unref(_).get(unref(data), s.extras) : void 0
2156
- }, null, 8, ["field", "modelValue", "disabled", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
2157
- ]))), 128))
2158
- ]))), 128)),
2159
- createElementVNode("div", _hoisted_8, [
2160
- createVNode(a, {
2161
- label: "Back",
2162
- variant: "tertiary",
2163
- disabled: unref(currentStep) == 1,
2164
- onClick: m[5] || (m[5] = (o) => currentStep.value--)
2165
- }, null, 8, ["disabled"]),
2166
- createVNode(a, {
2167
- disabled: unref(currentStep) - 1 < unref(template).steps.length - 1 ? stepErrors().length > 0 : unref(errors).length > 0,
2168
- label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? "Next" : "Submit",
2169
- onClick: m[6] || (m[6] = (o) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? currentStep.value++ : onSubmit())
2170
- }, null, 8, ["disabled", "label"])
2171
- ])
2172
- ]),
2173
- createVNode(_sfc_main$1, {
2174
- data: unref(data),
2175
- class: "xs:hidden"
2176
- }, null, 8, ["data"])
2177
- ])
2178
- ])) : createCommentVNode("", !0)
2179
- ]),
2180
- key: "0"
2181
- }
2182
- ]), 1032, ["modelValue"]);
2183
- };
2184
- }
2185
- });
2186
- export {
2187
- _sfc_main as _
2188
- };