@feedmepos/mf-connect 0.1.38-beta.52 → 0.1.38-beta.53

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 (130) hide show
  1. package/package.json +2 -2
  2. package/dist/Analytic-BU1mOMoX.js +0 -760
  3. package/dist/App-fw6iFNxW.js +0 -4638
  4. package/dist/AuditLogs-CliU8167.js +0 -1887
  5. package/dist/Bin-C49tzfas.js +0 -166
  6. package/dist/Broadcast-YZVnZTCD.js +0 -232
  7. package/dist/CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DEwsZags.js +0 -122
  8. package/dist/Card-DcQQyJl9.js +0 -911
  9. package/dist/ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js +0 -97
  10. package/dist/Collections--8lmoXWR.js +0 -540
  11. package/dist/Credit-CfkLFMei.js +0 -227
  12. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-Du7fRSZC.js +0 -128
  13. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +0 -58
  14. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-t6eac8yR.js +0 -3151
  15. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CXVOuiLI.js +0 -347
  16. package/dist/Experience-BnVVC2-L.js +0 -228
  17. package/dist/FileSaver.min-NlMItPOc.js +0 -74
  18. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +0 -129
  19. package/dist/Game-Dbz4DzY_.js +0 -297
  20. package/dist/Grab-CCqScmpp.js +0 -300
  21. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-C5irH9v6.js +0 -145
  22. package/dist/Index-DPsM9D4W.js +0 -259
  23. package/dist/JsonViewer-v8_C7l5N.js +0 -87
  24. package/dist/LottieAnimation.vue_vue_type_script_setup_true_lang-CyGJxUol.js +0 -18737
  25. package/dist/MainLayout-B1aJoR95.js +0 -41
  26. package/dist/Marketing-CFwxWdJq.js +0 -21761
  27. package/dist/Member-ZPKbf5Bk.js +0 -281
  28. package/dist/MemberList-BDs-70nG.js +0 -1607
  29. package/dist/MemberOverview-wL_ailso.js +0 -58
  30. package/dist/MemberTransactions-C-zHpuZF.js +0 -45
  31. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-B2TKmOOK.js +0 -60616
  32. package/dist/Mission-BHkb1E9m.js +0 -301
  33. package/dist/Overview-DYlcqNCX.js +0 -1079
  34. package/dist/Point-BEhNBY2_.js +0 -231
  35. package/dist/Promotion-DOXRIej4.js +0 -363
  36. package/dist/Queue-Bwa0LWhf.js +0 -260
  37. package/dist/Record-BoI8l1Qq.js +0 -341
  38. package/dist/Reward-BVQaqAYM.js +0 -442
  39. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-BC3dEiWi.js +0 -150
  40. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-HpleMvjm.js +0 -1767
  41. package/dist/Segment-Cmy7nu27.js +0 -882
  42. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-pab6X2DC.js +0 -181
  43. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-BqIh8D8O.js +0 -189
  44. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-CESoNd87.js +0 -147
  45. package/dist/Setting-DN8j_6Xv.js +0 -1993
  46. package/dist/SettingAdvertisements-qHdiaa6m.js +0 -264
  47. package/dist/Store-DfhVYCgX.js +0 -1936
  48. package/dist/StoreRewards-NYucFLJU.js +0 -535
  49. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-BGOcOAXR.js +0 -1036
  50. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-DRin8Jzw.js +0 -8093
  51. package/dist/Tier-Dl0aBuJz.js +0 -970
  52. package/dist/Title-DvO6Mira.js +0 -568
  53. package/dist/Transaction-ONVl4UZZ.js +0 -39
  54. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-FyE25D8o.js +0 -130
  55. package/dist/Voucher-BZ1feYh1.js +0 -399
  56. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-Lilql8J4.js +0 -421
  57. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-C_ZdCOPI.js +0 -56
  58. package/dist/_commonjsHelpers-BkfeUUK-.js +0 -28
  59. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +0 -9
  60. package/dist/app-B_RRkjaD.js +0 -42566
  61. package/dist/app-wDQR6dpb.js +0 -39
  62. package/dist/app.js +0 -7
  63. package/dist/business-y5qSMcd-.js +0 -82
  64. package/dist/campaign-CpzFl8Vr.js +0 -4
  65. package/dist/campaign-DHgol2Lt.js +0 -219
  66. package/dist/campaign-Drxe0zPX.js +0 -253
  67. package/dist/campaign.enum-CwAPVgPe.js +0 -21
  68. package/dist/campaign.fn-DMx5xsiK.js +0 -776
  69. package/dist/collectible.enum-Bh4jnUgP.js +0 -19
  70. package/dist/collection.fn-BpC_YBwG.js +0 -26
  71. package/dist/dto-DWkf9QOb.js +0 -222
  72. package/dist/effect-D5ZWGpNS.js +0 -78
  73. package/dist/email-addresses-DFtVESS8.js +0 -705
  74. package/dist/export-BtUy3sWU.js +0 -97
  75. package/dist/feedme.ico +0 -0
  76. package/dist/helper-DtWMZoWX.js +0 -86
  77. package/dist/index-7HXC3sH0.js +0 -56
  78. package/dist/index-BQlhmw75.js +0 -3
  79. package/dist/index-BdX7CxUg.js +0 -30076
  80. package/dist/index-BerRe0M3.js +0 -76
  81. package/dist/index-BrZ3xZzk.js +0 -146
  82. package/dist/index-CJzBpsBP.js +0 -3412
  83. package/dist/index-CQiABpeB.js +0 -32456
  84. package/dist/index-CqIWlGW3.js +0 -38
  85. package/dist/index-CsaQJMAR.js +0 -66
  86. package/dist/index-DPCDboPA.js +0 -32
  87. package/dist/index-DPaH8jaV.js +0 -8884
  88. package/dist/index-Dkce3JZ_.js +0 -54
  89. package/dist/index-DrYv_gG4.js +0 -31
  90. package/dist/index-SfJbKfWl.js +0 -2407
  91. package/dist/index-vh86FiIQ.js +0 -10
  92. package/dist/index.esm2017-CbvE5vCC.js +0 -3069
  93. package/dist/loading-BWGIK17X.js +0 -71
  94. package/dist/lodash-B5I3zXaY.js +0 -3678
  95. package/dist/membership-Zy2P6O6X.js +0 -235
  96. package/dist/moment-D7p2TMB-.js +0 -2583
  97. package/dist/money-D_fZmBbi.js +0 -15
  98. package/dist/number-C4DhXkCm.js +0 -12
  99. package/dist/object-qECH92oz.js +0 -26
  100. package/dist/objectId-dwaoBfJX.js +0 -7
  101. package/dist/objectid-C6eRcDzI.js +0 -145
  102. package/dist/plugins-DDAJav2s.js +0 -1817
  103. package/dist/reward-Dxjvmy7-.js +0 -36
  104. package/dist/rule-builder-ZkPWAiTl.js +0 -102
  105. package/dist/rule-sclqeiyk.js +0 -1951
  106. package/dist/style.css +0 -4
  107. package/dist/template-CAs0lkTY.js +0 -188
  108. package/dist/tier-BJDhpH6X.js +0 -4
  109. package/dist/tiers/tier=1.png +0 -0
  110. package/dist/tiers/tier=2.png +0 -0
  111. package/dist/tiers/tier=3.png +0 -0
  112. package/dist/tiers/tier=4.png +0 -0
  113. package/dist/timezone-5t8ki0gE.js +0 -1151
  114. package/dist/titles/type=diamond.png +0 -0
  115. package/dist/titles/type=drinks.png +0 -0
  116. package/dist/titles/type=food.png +0 -0
  117. package/dist/titles/type=heart.png +0 -0
  118. package/dist/titles/type=medal.png +0 -0
  119. package/dist/titles/type=spend.png +0 -0
  120. package/dist/titles/type=thank-you.png +0 -0
  121. package/dist/titles/type=thumbs-up.png +0 -0
  122. package/dist/titles/type=years.png +0 -0
  123. package/dist/trigger-B2fpKTfg.js +0 -213
  124. package/dist/tslib.es6-BCqqvLQ_.js +0 -44
  125. package/dist/type_drinks-D6jnpvwV.js +0 -4
  126. package/dist/usePagination-Ds-cuHop.js +0 -223
  127. package/dist/user-ORhbAsqi.js +0 -55
  128. package/dist/vue-i18n-cyOhW8mW.js +0 -2365
  129. package/dist/xlsx-4klfjFae.js +0 -15491
  130. package/dist/zod-BsHmzMQd.js +0 -91
@@ -1,3151 +0,0 @@
1
- import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, createCommentVNode, computed, onMounted, toDisplayString, createBlock, withCtx, Fragment, renderList, withModifiers, unref, isRef, createTextVNode, normalizeClass, resolveDynamicComponent, toRefs, normalizeStyle, createSlots } from "vue";
2
- import { _ } from "./lodash-B5I3zXaY.js";
3
- import { B as Bd, z } from "./app-B_RRkjaD.js";
4
- import { Z as ZodHelper } from "./zod-BsHmzMQd.js";
5
- import { c as campaignRefinement, C as CampaignDtos, a as campaignTransform } from "./dto-DWkf9QOb.js";
6
- import { u as useMembershipStore } from "./membership-Zy2P6O6X.js";
7
- import { u as useBusinessStore } from "./business-y5qSMcd-.js";
8
- import "./index-DPaH8jaV.js";
9
- import { R as RuleBuilder, a as isRuleEntry } from "./rule-builder-ZkPWAiTl.js";
10
- import { J as JsonViewer } from "./JsonViewer-v8_C7l5N.js";
11
- import { h as hooks } from "./moment-D7p2TMB-.js";
12
- import { f as featureVersionMapping } from "./campaign.enum-CwAPVgPe.js";
13
- import { _ as _sfc_main$u } from "./ImageInput.vue_vue_type_script_setup_true_lang-C5irH9v6.js";
14
- import { b as _sfc_main$s, a as _sfc_main$v, _ as _sfc_main$x } from "./EffectSheet.vue_vue_type_style_index_0_lang-CXVOuiLI.js";
15
- import { _ as _sfc_main$w } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-DRin8Jzw.js";
16
- import { c as core, S as SvcConfig } from "./index-BdX7CxUg.js";
17
- import { p as prompt, f as firebaseStorage } from "./plugins-DDAJav2s.js";
18
- import { _ as _sfc_main$o } from "./SelectItems.vue_vue_type_script_setup_true_lang-pab6X2DC.js";
19
- import { _ as _export_sfc } from "./_plugin-vue_export-helper-CHgC5LLL.js";
20
- import { _ as _sfc_main$z } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-FyE25D8o.js";
21
- import { _ as _sfc_main$p, a as _sfc_main$q } from "./RuleGroup.vue_vue_type_script_setup_true_lang-HpleMvjm.js";
22
- import { u as useI18n } from "./vue-i18n-cyOhW8mW.js";
23
- import { T as TypeToTriggerOptions, _ as _sfc_main$A, b as _sfc_main$B } from "./trigger-B2fpKTfg.js";
24
- import { _ as _sfc_main$y } from "./MessageInput.vue_vue_type_script_setup_true_lang-B2TKmOOK.js";
25
- import { C as CountryTimezone, m as moment } from "./timezone-5t8ki0gE.js";
26
- import { c as calculateNextScheduleAt, S as SummarizeRrule, R as RRule } from "./rule-sclqeiyk.js";
27
- import { useCoreStore } from "@feedmepos/mf-common";
28
- import { _ as _sfc_main$r, a as _sfc_main$t } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-Lilql8J4.js";
29
- import { T as TEMPLATES } from "./index-SfJbKfWl.js";
30
- import { v as FdoCreditLoyaltyReward, w as FdtoRandomReward, x as F_MISSION_TYPE, y as FdoThresholdCreditReward, z as FdtoThresholdReward, A as FdoMission } from "./index-CJzBpsBP.js";
31
- import "./index-CQiABpeB.js";
32
- import "./index-CqIWlGW3.js";
33
- import "./index-Dkce3JZ_.js";
34
- import { a as F_GAME_TYPE } from "./collectible.enum-Bh4jnUgP.js";
35
- import { u as useLoading } from "./loading-BWGIK17X.js";
36
- import { i as initCollectibleConfig } from "./helper-DtWMZoWX.js";
37
- import { C as CollectionUtils } from "./collection.fn-BpC_YBwG.js";
38
- import { s as sentenceCase$1 } from "./index-CsaQJMAR.js";
39
- import { d as getCampaignSummaryObject } from "./campaign-Drxe0zPX.js";
40
- import { useDialog } from "@feedmepos/ui-library";
41
- import { u as useCampaignStore } from "./campaign-DHgol2Lt.js";
42
- import { a as cleanPF } from "./object-qECH92oz.js";
43
- function summarizeGrabDiscount(e) {
44
- if (!e)
45
- return null;
46
- const m = core.Config.getCountry().currency.symbol;
47
- function a(l) {
48
- switch (l.scope.type) {
49
- case "order":
50
- return "Bill discount";
51
- case "items":
52
- return l.type.startsWith("bundle") ? u(l.type) : "Item discount";
53
- case "categories":
54
- return "Category discount";
55
- default:
56
- return "Discount";
57
- }
58
- }
59
- function u(l) {
60
- switch (l) {
61
- case "bundleSameFixPrice":
62
- return "Bundle (same item) - Fixed price";
63
- case "bundleDiffFixPrice":
64
- return "Bundle (different items) - Fixed price";
65
- case "bundleSameNet":
66
- return "Bundle (same item) - Amount off";
67
- case "bundleDiffNet":
68
- return "Bundle (different items) - Amount off";
69
- case "bundleSamePercentage":
70
- return "Bundle (same item) - Percentage off";
71
- case "bundleDiffPercentage":
72
- return "Bundle (different items) - Percentage off";
73
- default:
74
- return "Bundle discount";
75
- }
76
- }
77
- function i(l) {
78
- switch (l.type) {
79
- case "percentage":
80
- case "bundleSamePercentage":
81
- case "bundleDiffPercentage":
82
- return `${l.value}% discount`;
83
- case "net":
84
- case "bundleSameNet":
85
- case "bundleDiffNet":
86
- return `${m}${l.value} discount`;
87
- case "bundleSameFixPrice":
88
- case "bundleDiffFixPrice":
89
- return `${m}${l.value} fixed price`;
90
- case "delivery":
91
- return "Delivery fee discount";
92
- case "freeItem":
93
- return "Free item";
94
- default:
95
- return `${m}${l.value} discount`;
96
- }
97
- }
98
- function s(l) {
99
- return l.cap && l.cap > 0 ? `capped at ${m}${l.cap}` : null;
100
- }
101
- return {
102
- type: a(e),
103
- adjustment: i(e),
104
- cap: s(e)
105
- };
106
- }
107
- const _hoisted_1$l = {
108
- key: 0,
109
- class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
110
- }, _hoisted_2$h = { class: "flex items-center justify-between" }, _hoisted_3$e = { class: "flex items-center gap-8" }, _hoisted_4$d = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 p-16" }, _hoisted_5$a = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$n = /* @__PURE__ */ defineComponent({
111
- __name: "GrabItemSelectionInline",
112
- props: {
113
- visible: { type: Boolean },
114
- initialValue: {},
115
- filterItems: { type: Function }
116
- },
117
- emits: ["confirm", "cancel"],
118
- setup(e, { emit: m }) {
119
- const a = e, u = m, i = ref();
120
- watch(
121
- () => a.visible,
122
- (n) => {
123
- var r, y;
124
- !n && i.value && ((y = (r = i.value).setSelectedItems) == null || y.call(r, a.initialValue || []));
125
- }
126
- );
127
- function s() {
128
- var n;
129
- (n = i.value) == null || n.onConfirm();
130
- }
131
- function l() {
132
- u("cancel");
133
- }
134
- function o(n) {
135
- u("confirm", n);
136
- }
137
- return (n, r) => {
138
- const y = resolveComponent("FmIcon"), v = resolveComponent("FmButton");
139
- return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$l, [
140
- createElementVNode("div", _hoisted_2$h, [
141
- createElementVNode("div", _hoisted_3$e, [
142
- createVNode(y, {
143
- name: "restaurant",
144
- size: "md"
145
- }),
146
- r[0] || (r[0] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Items", -1))
147
- ]),
148
- createVNode(v, {
149
- icon: "close",
150
- variant: "tertiary",
151
- onClick: l
152
- })
153
- ]),
154
- r[1] || (r[1] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. For bundle discounts, select multiple items that can be bundled together. ", -1)),
155
- createElementVNode("div", _hoisted_4$d, [
156
- createVNode(_sfc_main$o, {
157
- ref_key: "selectItemRef",
158
- ref: i,
159
- "initial-value": e.initialValue,
160
- "filter-items": e.filterItems,
161
- "on-complete": o,
162
- "max-height": 300
163
- }, null, 8, ["initial-value", "filter-items"])
164
- ]),
165
- createElementVNode("div", _hoisted_5$a, [
166
- createVNode(v, {
167
- variant: "secondary",
168
- label: "Cancel",
169
- onClick: l
170
- }),
171
- createVNode(v, {
172
- variant: "primary",
173
- label: "Confirm Selection",
174
- onClick: s
175
- })
176
- ])
177
- ])) : createCommentVNode("", !0);
178
- };
179
- }
180
- }), _hoisted_1$k = {
181
- key: 0,
182
- class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
183
- }, _hoisted_2$g = { class: "flex items-center justify-between" }, _hoisted_3$d = { class: "flex items-center gap-8" }, _hoisted_4$c = { class: "flex gap-16 items-center flex-wrap" }, _hoisted_5$9 = { class: "flex gap-8 items-center" }, _hoisted_6$5 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_7$5 = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 max-h-[300px] overflow-y-auto" }, _hoisted_8$4 = { class: "flex items-center gap-12" }, _hoisted_9$4 = { class: "fm-typo-en-body-md-600" }, _hoisted_10$4 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_11$2 = {
184
- key: 1,
185
- class: "p-24 text-center"
186
- }, _hoisted_12$1 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_13$1 = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$m = /* @__PURE__ */ defineComponent({
187
- __name: "GrabCategorySelectionInline",
188
- props: {
189
- visible: { type: Boolean },
190
- initialValue: {}
191
- },
192
- emits: ["confirm", "cancel"],
193
- setup(e, { emit: m }) {
194
- const a = e, u = m, i = Bd(), s = ref({}), l = ref(""), o = computed(() => {
195
- const c = i.menu.value;
196
- return c ? c.modules.category.map((f) => ({
197
- id: f._id,
198
- name: f.name
199
- })) : [];
200
- }), n = computed(() => {
201
- if (!l.value) return o.value;
202
- const c = l.value.toLowerCase();
203
- return o.value.filter(
204
- (f) => f.name.toLowerCase().includes(c)
205
- );
206
- }), r = computed(() => Object.values(s.value).filter(Boolean).length);
207
- function y() {
208
- s.value = o.value.reduce(
209
- (c, f) => (c[f.id] = a.initialValue.includes(f.id), c),
210
- {}
211
- );
212
- }
213
- watch([() => a.visible, () => a.initialValue], () => {
214
- a.visible && y();
215
- }), onMounted(async () => {
216
- await i.store.getMenu(), y();
217
- });
218
- function v(c) {
219
- s.value[c] = !s.value[c];
220
- }
221
- function h() {
222
- const c = r.value === n.value.length;
223
- n.value.forEach((f) => {
224
- s.value[f.id] = !c;
225
- });
226
- }
227
- function x() {
228
- Object.keys(s.value).forEach((c) => {
229
- s.value[c] = !1;
230
- });
231
- }
232
- function k() {
233
- const c = Object.entries(s.value).filter(([, f]) => f).map(([f]) => f);
234
- u("confirm", c);
235
- }
236
- function p() {
237
- u("cancel");
238
- }
239
- const d = computed(() => n.value.length > 0 && n.value.every(
240
- (c) => s.value[c.id]
241
- ));
242
- return (c, f) => {
243
- const B = resolveComponent("FmIcon"), b = resolveComponent("FmButton"), E = resolveComponent("FmTextField"), N = resolveComponent("FmCheckbox"), C = resolveComponent("FmListItem"), R = resolveComponent("FmList");
244
- return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$k, [
245
- createElementVNode("div", _hoisted_2$g, [
246
- createElementVNode("div", _hoisted_3$d, [
247
- createVNode(B, {
248
- name: "category",
249
- size: "md"
250
- }),
251
- f[2] || (f[2] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Categories", -1))
252
- ]),
253
- createVNode(b, {
254
- icon: "close",
255
- variant: "tertiary",
256
- onClick: p
257
- })
258
- ]),
259
- f[3] || (f[3] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. The discount will be available for all items within the selected categories. ", -1)),
260
- createElementVNode("div", _hoisted_4$c, [
261
- createElementVNode("div", _hoisted_5$9, [
262
- createVNode(b, {
263
- icon: "select_all",
264
- variant: "tertiary",
265
- size: "small",
266
- label: `${d.value ? "Deselect" : "Select"} All`,
267
- onClick: h
268
- }, null, 8, ["label"]),
269
- createVNode(b, {
270
- icon: "sync",
271
- variant: "tertiary",
272
- size: "small",
273
- label: "Clear",
274
- onClick: x
275
- }),
276
- createElementVNode("span", _hoisted_6$5, toDisplayString(r.value) + " selected ", 1)
277
- ]),
278
- createVNode(E, {
279
- modelValue: l.value,
280
- "onUpdate:modelValue": f[0] || (f[0] = (S) => l.value = S),
281
- placeholder: "Search categories",
282
- "leading-icon": { name: "search", color: "" },
283
- class: "flex-1 min-w-[200px]"
284
- }, null, 8, ["modelValue"])
285
- ]),
286
- createElementVNode("div", _hoisted_7$5, [
287
- n.value.length > 0 ? (openBlock(), createBlock(R, { key: 0 }, {
288
- default: withCtx(() => [
289
- (openBlock(!0), createElementBlock(Fragment, null, renderList(n.value, (S) => (openBlock(), createBlock(C, {
290
- key: S.id,
291
- clickable: !0,
292
- onClick: ($) => v(S.id)
293
- }, {
294
- leading: withCtx(() => [
295
- createVNode(N, {
296
- "model-value": s.value[S.id] || !1,
297
- value: S.id,
298
- "onUpdate:modelValue": ($) => v(S.id),
299
- onClick: f[1] || (f[1] = withModifiers(() => {
300
- }, ["stop"]))
301
- }, null, 8, ["model-value", "value", "onUpdate:modelValue"])
302
- ]),
303
- default: withCtx(() => [
304
- createElementVNode("div", _hoisted_8$4, [
305
- createVNode(B, {
306
- name: "category",
307
- size: "sm",
308
- class: "text-fm-color-typo-secondary"
309
- }),
310
- createElementVNode("div", null, [
311
- createElementVNode("div", _hoisted_9$4, toDisplayString(S.name), 1),
312
- createElementVNode("div", _hoisted_10$4, " ID: " + toDisplayString(S.id), 1)
313
- ])
314
- ])
315
- ]),
316
- _: 2
317
- }, 1032, ["onClick"]))), 128))
318
- ]),
319
- _: 1
320
- })) : (openBlock(), createElementBlock("div", _hoisted_11$2, [
321
- createElementVNode("div", _hoisted_12$1, toDisplayString(l.value ? "No categories found matching your search." : "No categories available."), 1)
322
- ]))
323
- ]),
324
- createElementVNode("div", _hoisted_13$1, [
325
- createVNode(b, {
326
- variant: "secondary",
327
- label: "Cancel",
328
- onClick: p
329
- }),
330
- createVNode(b, {
331
- variant: "primary",
332
- label: `Confirm Selection (${r.value})`,
333
- disabled: r.value === 0,
334
- onClick: k
335
- }, null, 8, ["label", "disabled"])
336
- ])
337
- ])) : createCommentVNode("", !0);
338
- };
339
- }
340
- }), _hoisted_1$j = { class: "space-y-8" }, _hoisted_2$f = {
341
- key: 1,
342
- class: "border-1 rounded-md flex gap-16 items-center justify-between px-16 py-12"
343
- }, _hoisted_3$c = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$b = { class: "text-fm-color-typo-secondary" }, _hoisted_5$8 = { key: 0 }, _hoisted_6$4 = { class: "space-y-24" }, _hoisted_7$4 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-4" }, _hoisted_8$3 = { key: 0 }, _hoisted_9$3 = { class: "fm-typo-en-body-md-600 mb-8 block" }, _hoisted_10$3 = { key: 1 }, _hoisted_11$1 = { key: 2 }, _hoisted_12 = { key: 0 }, _hoisted_13 = { class: "space-y-8" }, _hoisted_14 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_15 = { class: "flex items-center gap-8" }, _hoisted_16 = { class: "fm-typo-en-body-md-400" }, _hoisted_17 = { key: 3 }, _hoisted_18 = { key: 0 }, _hoisted_19 = { class: "space-y-8" }, _hoisted_20 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_21 = { class: "flex items-center gap-8" }, _hoisted_22 = { class: "fm-typo-en-body-md-400" }, _hoisted_23 = {
344
- key: 0,
345
- class: "mt-16 p-12 bg-fm-color-feedback-error-light rounded-8 border border-fm-color-feedback-error-main"
346
- }, _hoisted_24 = { class: "flex items-center gap-8 mb-8 text-fm-color-system-error-300" }, _hoisted_25 = { class: "space-y-4" }, _hoisted_26 = { class: "flex gap-16" }, _sfc_main$l = /* @__PURE__ */ defineComponent({
347
- __name: "GrabEffectSheet",
348
- props: {
349
- modelValue: { type: Object }
350
- },
351
- emits: ["update:model-value"],
352
- setup(e, { emit: m }) {
353
- const a = e, u = m, i = Bd(), s = ref(!1), l = ref(!1), o = ref(!1), n = ref({
354
- type: "net",
355
- value: 0,
356
- scope: {
357
- type: "order"
358
- }
359
- });
360
- watch(
361
- () => a.modelValue,
362
- (g) => {
363
- g && (n.value = { ...g });
364
- },
365
- { immediate: !0 }
366
- ), onMounted(async () => {
367
- await i.store.getMenu();
368
- });
369
- const r = computed(() => {
370
- var g;
371
- return !(!n.value.type || !((g = n.value.scope) != null && g.type) || h(n.value.type) && (!n.value.value || n.value.value <= 0) || (n.value.scope.type === "items" || n.value.scope.type === "category") && (!n.value.scope.objectIDs || n.value.scope.objectIDs.length === 0));
372
- });
373
- async function y(g) {
374
- g.stopPropagation(), await prompt.remove("Are you sure you want to remove this discount?") && u("update:model-value", null);
375
- }
376
- function v() {
377
- var g;
378
- return B(((g = n.value.scope) == null ? void 0 : g.type) || "order");
379
- }
380
- function h(g) {
381
- return g && !["freeItem", "delivery"].includes(g);
382
- }
383
- function x(g) {
384
- return g && ["percentage", "bundleSamePercentage", "bundleDiffPercentage"].includes(
385
- g
386
- );
387
- }
388
- function k(g) {
389
- return g != null && g.includes("Percentage") ? "Discount percentage" : g != null && g.includes("FixPrice") ? "Bundle fixed price" : g === "percentage" ? "Discount percentage" : "Discount amount";
390
- }
391
- function p(g) {
392
- return g != null && g.includes("Percentage") || g === "percentage" ? "10" : "5.00";
393
- }
394
- function d(g) {
395
- return g != null && g.includes("Percentage") || g === "percentage" ? "%" : "$";
396
- }
397
- function c(g, V) {
398
- n.value = {
399
- ...n.value,
400
- [g]: V
401
- };
402
- }
403
- function f(g, V) {
404
- var D;
405
- const w = {
406
- ...n.value.scope,
407
- [g]: V
408
- };
409
- if (n.value = {
410
- ...n.value,
411
- scope: w
412
- }, g === "type") {
413
- const F = B(V);
414
- F.some(
415
- (P) => P.value === n.value.type
416
- ) || (n.value = {
417
- ...n.value,
418
- type: ((D = F[0]) == null ? void 0 : D.value) || "net",
419
- // Reset value and cap when changing to incompatible type
420
- value: 0,
421
- cap: void 0
422
- });
423
- }
424
- }
425
- function B(g) {
426
- switch (g) {
427
- case "order":
428
- return [
429
- { label: "Amount off", value: "net" },
430
- { label: "Percentage off", value: "percentage" },
431
- { label: "Delivery fee off", value: "delivery" }
432
- ];
433
- case "category":
434
- return [
435
- { label: "Amount off", value: "net" },
436
- { label: "Percentage off", value: "percentage" }
437
- ];
438
- case "items":
439
- return [
440
- { label: "Amount off", value: "net" },
441
- { label: "Percentage off", value: "percentage" },
442
- { label: "Free item", value: "freeItem" },
443
- {
444
- label: "Bundle (same item) - Fixed price",
445
- value: "bundleSameFixPrice"
446
- },
447
- { label: "Bundle (same item) - Amount off", value: "bundleSameNet" },
448
- {
449
- label: "Bundle (same item) - Percentage off",
450
- value: "bundleSamePercentage"
451
- },
452
- {
453
- label: "Bundle (different items) - Fixed price",
454
- value: "bundleDiffFixPrice"
455
- },
456
- {
457
- label: "Bundle (different items) - Amount off",
458
- value: "bundleDiffNet"
459
- },
460
- {
461
- label: "Bundle (different items) - Percentage off",
462
- value: "bundleDiffPercentage"
463
- }
464
- ];
465
- default:
466
- return [
467
- { label: "Amount off", value: "net" },
468
- { label: "Percentage off", value: "percentage" }
469
- ];
470
- }
471
- }
472
- function b(g) {
473
- switch (g) {
474
- case "order":
475
- return "Applies to entire order. Available: Amount off, Percentage off, Delivery fee discount.";
476
- case "category":
477
- return "Applies to specific item categories. Available: Amount off, Percentage off, Free item.";
478
- case "items":
479
- return "Applies to specific items. Available: Basic discounts, Bundle offers (same/different items).";
480
- default:
481
- return "Select how you want to apply the discount.";
482
- }
483
- }
484
- function E() {
485
- var g;
486
- return ((g = n.value.scope) == null ? void 0 : g.type) === "items";
487
- }
488
- function N() {
489
- var g;
490
- return ((g = n.value.scope) == null ? void 0 : g.type) === "category";
491
- }
492
- function C() {
493
- var w;
494
- const g = (w = n.value.scope) == null ? void 0 : w.objectIDs;
495
- if (!g || g.length === 0)
496
- return "No items selected";
497
- const V = i.menu.value;
498
- return V && g.length <= 3 ? g.map((F) => {
499
- const T = V.modules.item.find((P) => P._id === F);
500
- return T ? (T.name2 || T.name).trim() : `Item ${F}`;
501
- }).join(", ") : g.length === 1 ? "1 item selected" : `${g.length} items selected`;
502
- }
503
- function R() {
504
- var w;
505
- const g = (w = n.value.scope) == null ? void 0 : w.objectIDs;
506
- if (!g || g.length === 0)
507
- return "No categories selected";
508
- const V = i.menu.value;
509
- return V && g.length <= 3 ? g.map((F) => {
510
- const T = V.modules.category.find((P) => P._id === F);
511
- return T ? T.name : `Category ${F}`;
512
- }).join(", ") : g.length === 1 ? "1 category selected" : `${g.length} categories selected`;
513
- }
514
- function S() {
515
- l.value = !0;
516
- }
517
- function $() {
518
- o.value = !0;
519
- }
520
- function H(g) {
521
- f("objectIDs", g), l.value = !1;
522
- }
523
- function j(g) {
524
- f("objectIDs", g), o.value = !1;
525
- }
526
- function Y() {
527
- l.value = !1;
528
- }
529
- function G() {
530
- o.value = !1;
531
- }
532
- const M = computed(() => {
533
- var V, w, D;
534
- const g = [];
535
- return n.value.type || g.push("Discount type is required"), (V = n.value.scope) != null && V.type || g.push("Scope type is required"), h(n.value.type) && (!n.value.value || n.value.value <= 0) && g.push("Discount amount must be greater than 0"), ((w = n.value.scope) == null ? void 0 : w.type) === "items" && (!n.value.scope.objectIDs || n.value.scope.objectIDs.length === 0) && g.push("Please select at least one item"), ((D = n.value.scope) == null ? void 0 : D.type) === "category" && (!n.value.scope.objectIDs || n.value.scope.objectIDs.length === 0) && g.push("Please select at least one category"), g;
536
- });
537
- function Z() {
538
- u("update:model-value", n.value), s.value = !1;
539
- }
540
- const q = [
541
- { label: "Bill discount", value: "order" },
542
- { label: "Item discount", value: "items" },
543
- { label: "Category discount", value: "category" }
544
- ];
545
- return (g, V) => {
546
- const w = resolveComponent("FmButton"), D = resolveComponent("FmSelect"), F = resolveComponent("FmStepperField"), T = resolveComponent("FmIcon"), P = resolveComponent("FmSideSheet");
547
- return openBlock(), createBlock(P, {
548
- "max-width": 550,
549
- header: "Apply discount",
550
- modelValue: unref(s),
551
- "onUpdate:modelValue": [
552
- V[5] || (V[5] = (O) => isRef(s) ? s.value = O : null),
553
- V[6] || (V[6] = (O) => s.value = O)
554
- ]
555
- }, {
556
- "side-sheet-button": withCtx(() => {
557
- var O, U, A, L;
558
- return [
559
- createElementVNode("div", _hoisted_1$j, [
560
- V[7] || (V[7] = createElementVNode("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Configure the Grab campaign discount you want to offer your customers. ", -1)),
561
- e.modelValue ? (openBlock(), createElementBlock("div", _hoisted_2$f, [
562
- createElementVNode("div", _hoisted_3$c, [
563
- createElementVNode("div", null, toDisplayString((O = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : O.type), 1),
564
- createElementVNode("div", _hoisted_4$b, [
565
- createTextVNode(toDisplayString((U = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : U.adjustment) + " ", 1),
566
- (A = unref(summarizeGrabDiscount)(e.modelValue)) != null && A.cap ? (openBlock(), createElementBlock("span", _hoisted_5$8, toDisplayString((L = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : L.cap), 1)) : createCommentVNode("", !0)
567
- ])
568
- ]),
569
- createVNode(w, {
570
- icon: "delete",
571
- "icon-color": "neutral-gray-400",
572
- variant: "tertiary",
573
- onClick: y
574
- })
575
- ])) : (openBlock(), createBlock(w, {
576
- key: 0,
577
- label: "Apply Grab discount",
578
- icon: "add",
579
- "icon-color": "primary",
580
- variant: "secondary",
581
- class: "border-fm-color-primary text-fm-color-primary"
582
- }))
583
- ])
584
- ];
585
- }),
586
- "side-sheet-footer": withCtx(() => [
587
- createElementVNode("div", _hoisted_26, [
588
- createVNode(w, {
589
- variant: "secondary",
590
- label: "Cancel",
591
- class: "flex-1",
592
- onClick: V[4] || (V[4] = (O) => s.value = !1)
593
- }),
594
- createVNode(w, {
595
- variant: "primary",
596
- label: unref(r) ? "Confirm" : "Complete Required Fields",
597
- class: "flex-1",
598
- disabled: !unref(r),
599
- onClick: Z
600
- }, null, 8, ["label", "disabled"])
601
- ])
602
- ]),
603
- default: withCtx(() => {
604
- var O, U, A, L;
605
- return [
606
- createElementVNode("div", _hoisted_6$4, [
607
- createElementVNode("div", null, [
608
- V[8] || (V[8] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Campaign type", -1)),
609
- createVNode(D, {
610
- "model-value": ((O = unref(n).scope) == null ? void 0 : O.type) || "order",
611
- "onUpdate:modelValue": V[0] || (V[0] = (I) => f("type", I)),
612
- placeholder: "Select campaign type",
613
- items: q
614
- }, null, 8, ["model-value"]),
615
- createElementVNode("div", _hoisted_7$4, toDisplayString(b((U = unref(n).scope) == null ? void 0 : U.type)), 1)
616
- ]),
617
- createElementVNode("div", null, [
618
- V[9] || (V[9] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount type", -1)),
619
- createVNode(D, {
620
- "model-value": unref(n).type,
621
- "onUpdate:modelValue": V[1] || (V[1] = (I) => c("type", I)),
622
- placeholder: "Select discount type",
623
- items: v()
624
- }, null, 8, ["model-value", "items"])
625
- ]),
626
- h(unref(n).type) ? (openBlock(), createElementBlock("div", _hoisted_8$3, [
627
- createElementVNode("label", _hoisted_9$3, toDisplayString(k(unref(n).type)), 1),
628
- createVNode(F, {
629
- modelValue: unref(n).value,
630
- "onUpdate:modelValue": V[2] || (V[2] = (I) => unref(n).value = I),
631
- placeholder: p(unref(n).type),
632
- suffix: d(unref(n).type),
633
- type: "number"
634
- }, null, 8, ["modelValue", "placeholder", "suffix"])
635
- ])) : createCommentVNode("", !0),
636
- x(unref(n).type) ? (openBlock(), createElementBlock("div", _hoisted_10$3, [
637
- V[10] || (V[10] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount cap (optional)", -1)),
638
- createVNode(F, {
639
- modelValue: unref(n).cap,
640
- "onUpdate:modelValue": V[3] || (V[3] = (I) => unref(n).cap = I),
641
- placeholder: "Maximum discount amount",
642
- type: "number"
643
- }, null, 8, ["modelValue"])
644
- ])) : createCommentVNode("", !0),
645
- E() ? (openBlock(), createElementBlock("div", _hoisted_11$1, [
646
- unref(l) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_12, [
647
- V[12] || (V[12] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Items", -1)),
648
- createElementVNode("div", _hoisted_13, [
649
- createElementVNode("div", _hoisted_14, [
650
- createElementVNode("div", _hoisted_15, [
651
- createVNode(T, {
652
- name: "restaurant",
653
- size: "md"
654
- }),
655
- createElementVNode("span", _hoisted_16, toDisplayString(C()), 1)
656
- ]),
657
- createVNode(w, {
658
- variant: "secondary",
659
- label: "Select Items",
660
- icon: "chevron_right",
661
- onClick: S
662
- })
663
- ]),
664
- V[11] || (V[11] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. Bundle discounts require multiple items. ", -1))
665
- ])
666
- ])),
667
- createVNode(_sfc_main$n, {
668
- visible: unref(l),
669
- "initial-value": ((A = unref(n).scope) == null ? void 0 : A.objectIDs) || [],
670
- onConfirm: H,
671
- onCancel: Y
672
- }, null, 8, ["visible", "initial-value"])
673
- ])) : createCommentVNode("", !0),
674
- N() ? (openBlock(), createElementBlock("div", _hoisted_17, [
675
- unref(o) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_18, [
676
- V[14] || (V[14] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Categories", -1)),
677
- createElementVNode("div", _hoisted_19, [
678
- createElementVNode("div", _hoisted_20, [
679
- createElementVNode("div", _hoisted_21, [
680
- createVNode(T, {
681
- name: "category",
682
- size: "md"
683
- }),
684
- createElementVNode("span", _hoisted_22, toDisplayString(R()), 1)
685
- ]),
686
- createVNode(w, {
687
- variant: "secondary",
688
- label: "Select Categories",
689
- icon: "chevron_right",
690
- onClick: $
691
- })
692
- ]),
693
- V[13] || (V[13] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. ", -1))
694
- ])
695
- ])),
696
- createVNode(_sfc_main$m, {
697
- visible: unref(o),
698
- "initial-value": ((L = unref(n).scope) == null ? void 0 : L.objectIDs) || [],
699
- onConfirm: j,
700
- onCancel: G
701
- }, null, 8, ["visible", "initial-value"])
702
- ])) : createCommentVNode("", !0)
703
- ]),
704
- unref(M).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_23, [
705
- createElementVNode("div", _hoisted_24, [
706
- createVNode(T, { name: "warning" }),
707
- V[15] || (V[15] = createElementVNode("span", { class: "fm-typo-en-body-sm-600" }, "Please fix the following issues:", -1))
708
- ]),
709
- createElementVNode("ul", _hoisted_25, [
710
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(M), (I) => (openBlock(), createElementBlock("li", {
711
- key: I,
712
- class: "fm-typo-en-body-sm-400 text-fm-color-feedback-error-main flex items-start gap-8"
713
- }, [
714
- V[16] || (V[16] = createElementVNode("span", { class: "w-4 h-4 bg-fm-color-feedback-error-main rounded-full mt-6 flex-shrink-0" }, null, -1)),
715
- createTextVNode(" " + toDisplayString(I), 1)
716
- ]))), 128))
717
- ])
718
- ])) : createCommentVNode("", !0)
719
- ];
720
- }),
721
- _: 1
722
- }, 8, ["modelValue"]);
723
- };
724
- }
725
- }), GrabEffectSheet = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__scopeId", "data-v-cf604dd7"]]), _hoisted_1$i = { class: "space-y-24" }, _sfc_main$k = /* @__PURE__ */ defineComponent({
726
- __name: "TimeRuleGroup",
727
- props: {
728
- modelValue: {
729
- type: Object,
730
- default: () => {
731
- }
732
- }
733
- },
734
- emits: ["update:model-value"],
735
- setup(e, { emit: m }) {
736
- const { t: a } = useI18n(), u = e, i = m, s = ref(
737
- !u.modelValue || !u.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(u.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
738
- );
739
- watch(s, async (o, n) => {
740
- var r;
741
- if (n == "custom" && o == "all_time" && RuleBuilder.getRules((r = u.modelValue) == null ? void 0 : r.rules.g_time).length > 0) {
742
- const y = await prompt.confirm(
743
- a("connect.template.rule.time.confirm_remove"),
744
- a("connect.common.confirm"),
745
- a("connect.common.confirm"),
746
- a("connect.common.cancel")
747
- );
748
- y && i(
749
- "update:model-value",
750
- RuleBuilder.setRuleToGroup(
751
- u.modelValue ?? RuleBuilder.scaffoldGroup(),
752
- RuleBuilder.scaffoldGroup("g_time")
753
- )
754
- ), s.value = y ? o : n;
755
- }
756
- });
757
- async function l(o) {
758
- var n;
759
- if (o == "custom" && RuleBuilder.getRules((n = u.modelValue) == null ? void 0 : n.rules.g_time).length > 0) {
760
- if (!await prompt.confirm(
761
- a("connect.template.rule.time.confirm_remove"),
762
- a("connect.common.confirm"),
763
- a("connect.common.confirm"),
764
- a("connect.common.cancel")
765
- )) {
766
- s.value = "all_time";
767
- return;
768
- }
769
- i(
770
- "update:model-value",
771
- RuleBuilder.setRuleToGroup(
772
- u.modelValue ?? RuleBuilder.scaffoldGroup(),
773
- RuleBuilder.scaffoldGroup("g_time")
774
- )
775
- );
776
- }
777
- }
778
- return (o, n) => {
779
- var v;
780
- const r = resolveComponent("FmRadio"), y = resolveComponent("FmRadioGroup");
781
- return openBlock(), createElementBlock("div", _hoisted_1$i, [
782
- createVNode(y, {
783
- modelValue: unref(s),
784
- "onUpdate:modelValue": [
785
- n[0] || (n[0] = (h) => isRef(s) ? s.value = h : null),
786
- n[1] || (n[1] = (h) => l(h))
787
- ]
788
- }, {
789
- default: withCtx(() => [
790
- createVNode(r, {
791
- label: unref(a)("connect.template.rule.time.all_time"),
792
- value: "all_time"
793
- }, null, 8, ["label"]),
794
- createVNode(r, {
795
- label: unref(a)("connect.template.rule.time.custom"),
796
- value: "custom"
797
- }, null, 8, ["label"])
798
- ]),
799
- _: 1
800
- }, 8, ["modelValue"]),
801
- unref(s) == "custom" ? (openBlock(), createBlock(_sfc_main$p, {
802
- key: 0,
803
- class: "!mt-[0px]",
804
- "include-only": "trigger",
805
- "trigger-type": "SCHEDULE",
806
- "model-value": ((v = e.modelValue) == null ? void 0 : v.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
807
- "onUpdate:modelValue": n[2] || (n[2] = (h) => i(
808
- "update:model-value",
809
- unref(RuleBuilder).setRuleToGroup(
810
- e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
811
- h,
812
- "&&"
813
- )
814
- ))
815
- }, null, 8, ["model-value"])) : createCommentVNode("", !0)
816
- ]);
817
- };
818
- }
819
- }), _sfc_main$j = /* @__PURE__ */ defineComponent({
820
- __name: "BirthdayInput",
821
- props: {
822
- modelValue: {
823
- type: Object
824
- }
825
- },
826
- emits: ["update:model-value"],
827
- setup(e, { emit: m }) {
828
- const { t: a } = useI18n(), u = e, i = m, s = computed(() => {
829
- const { property: l, operator: o, equator: n } = RuleBuilder.simplify(
830
- u.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
831
- op: "before",
832
- x: 1
833
- })
834
- );
835
- return {
836
- property: l,
837
- operator: o,
838
- equator: n
839
- };
840
- });
841
- return (l, o) => {
842
- const n = resolveComponent("FmRadio"), r = resolveComponent("FmStepperField");
843
- return openBlock(), createElementBlock("div", null, [
844
- createVNode(n, {
845
- label: unref(a)("connect.template.rule.birthday.on_birthday"),
846
- value: "_isRange-day",
847
- "model-value": `${unref(s).operator}-${unref(s).equator.unit}`,
848
- "onUpdate:modelValue": o[0] || (o[0] = () => {
849
- i(
850
- "update:model-value",
851
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
852
- op: "this",
853
- unit: "day",
854
- ignoreYear: !0
855
- })
856
- );
857
- })
858
- }, null, 8, ["label", "model-value"]),
859
- createVNode(n, {
860
- label: unref(a)("connect.template.rule.birthday.days_before"),
861
- value: "_isDay",
862
- "model-value": unref(s).operator,
863
- "onUpdate:modelValue": o[1] || (o[1] = () => {
864
- i(
865
- "update:model-value",
866
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
867
- op: "after",
868
- x: 1,
869
- ignoreYear: !0
870
- })
871
- );
872
- })
873
- }, null, 8, ["label", "model-value"]),
874
- unref(s).operator == "_isDay" ? (openBlock(), createBlock(r, {
875
- key: 0,
876
- label: unref(a)("connect.template.rule.birthday.days_before_label"),
877
- "show-steppers": !1,
878
- "model-value": unref(s).equator.x,
879
- "onUpdate:modelValue": o[2] || (o[2] = (y) => i(
880
- "update:model-value",
881
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
882
- op: "after",
883
- x: y,
884
- ignoreYear: !0
885
- })
886
- ))
887
- }, null, 8, ["label", "model-value"])) : createCommentVNode("", !0),
888
- createVNode(n, {
889
- label: unref(a)("connect.template.rule.birthday.in_birthday_week"),
890
- value: "_isRange-week",
891
- "model-value": `${unref(s).operator}-${unref(s).equator.unit}`,
892
- "onUpdate:modelValue": o[3] || (o[3] = () => {
893
- i(
894
- "update:model-value",
895
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
896
- op: "this",
897
- unit: "week",
898
- ignoreYear: !0
899
- })
900
- );
901
- })
902
- }, null, 8, ["label", "model-value"]),
903
- createVNode(n, {
904
- label: unref(a)("connect.template.rule.birthday.in_birthday_month"),
905
- value: "_isRange-month",
906
- "model-value": `${unref(s).operator}-${unref(s).equator.unit}`,
907
- "onUpdate:modelValue": o[4] || (o[4] = () => {
908
- i(
909
- "update:model-value",
910
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
911
- op: "this",
912
- unit: "month",
913
- ignoreYear: !0
914
- })
915
- );
916
- })
917
- }, null, 8, ["label", "model-value"])
918
- ]);
919
- };
920
- }
921
- }), _hoisted_1$h = { class: "space-y-16" }, _hoisted_2$e = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$b = { class: "grid grid-cols-3 gap-16" }, _hoisted_4$a = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$7 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
922
- __name: "CampaignTriggerInput",
923
- props: {
924
- campaignType: {
925
- type: String,
926
- required: !0
927
- },
928
- modelValue: {
929
- type: String
930
- },
931
- disabled: {
932
- type: Boolean,
933
- default: !1
934
- }
935
- },
936
- emits: ["update:model-value"],
937
- setup(e, { emit: m }) {
938
- const { t: a } = useI18n(), u = e, i = m, s = computed(() => u.disabled ? TypeToTriggerOptions[u.campaignType].filter(
939
- (l) => l.value == u.modelValue
940
- ) : TypeToTriggerOptions[u.campaignType]);
941
- return (l, o) => {
942
- const n = resolveComponent("FmCard");
943
- return openBlock(), createElementBlock("div", _hoisted_1$h, [
944
- createElementVNode("div", _hoisted_2$e, toDisplayString(unref(a)("connect.campaign.trigger.description")), 1),
945
- createElementVNode("div", _hoisted_3$b, [
946
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (r) => (openBlock(), createBlock(n, {
947
- variant: "outlined",
948
- disabled: u.disabled,
949
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
950
- "col-span-3": unref(s).length == 1,
951
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
952
- "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
953
- }]),
954
- onClick: () => {
955
- u.modelValue != r.value && !u.disabled && i("update:model-value", r.value);
956
- },
957
- key: r.name
958
- }, {
959
- default: withCtx(() => [
960
- createElementVNode("div", _hoisted_4$a, toDisplayString(r.name), 1),
961
- createElementVNode("div", _hoisted_5$7, toDisplayString(r.description), 1)
962
- ]),
963
- _: 2
964
- }, 1032, ["disabled", "class", "onClick"]))), 128))
965
- ])
966
- ]);
967
- };
968
- }
969
- }), _sfc_main$h = /* @__PURE__ */ defineComponent({
970
- __name: "DateInput",
971
- props: {
972
- label: {
973
- type: String,
974
- required: !1
975
- },
976
- modelValue: {
977
- type: Object,
978
- required: !1
979
- }
980
- },
981
- emits: ["update:model-value"],
982
- setup(e, { emit: m }) {
983
- const a = m;
984
- return (u, i) => {
985
- const s = resolveComponent("FmButton"), l = resolveComponent("FmField"), o = resolveComponent("FmDatePicker");
986
- return openBlock(), createBlock(o, {
987
- label: e.label,
988
- "model-value": e.modelValue || "",
989
- "onUpdate:modelValue": i[1] || (i[1] = (n) => a("update:model-value", n))
990
- }, {
991
- "trigger-button": withCtx(({ opened: n }) => [
992
- createVNode(l, {
993
- class: "flex items-center",
994
- "prepend-icon": "calendar_month",
995
- "icon-outlined": !n
996
- }, {
997
- append: withCtx(() => [
998
- e.modelValue ? (openBlock(), createBlock(s, {
999
- key: 0,
1000
- variant: "tertiary",
1001
- icon: "clear",
1002
- onClick: i[0] || (i[0] = (r) => (r.stopPropagation(), a("update:model-value", null)))
1003
- })) : createCommentVNode("", !0)
1004
- ]),
1005
- default: withCtx(() => [
1006
- createElementVNode("div", {
1007
- class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
1008
- }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
1009
- ]),
1010
- _: 1
1011
- }, 8, ["icon-outlined"])
1012
- ]),
1013
- _: 1
1014
- }, 8, ["label", "model-value"]);
1015
- };
1016
- }
1017
- }), _hoisted_1$g = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$d = { class: "flex-1 xs:w-full" }, _hoisted_3$a = { class: "mt-5 xs:hidden" }, _hoisted_4$9 = { class: "flex-1 xs:w-full" }, _sfc_main$g = /* @__PURE__ */ defineComponent({
1018
- __name: "DateRangeInput",
1019
- props: {
1020
- modelValue: {
1021
- type: Object,
1022
- required: !1
1023
- }
1024
- },
1025
- emits: ["update:model-value"],
1026
- setup(e, { emit: m }) {
1027
- const { t: a } = useI18n(), u = m;
1028
- return (i, s) => {
1029
- var l, o;
1030
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
1031
- createElementVNode("div", _hoisted_2$d, [
1032
- createVNode(_sfc_main$h, {
1033
- "model-value": ((l = e.modelValue) == null ? void 0 : l.startDate) ?? null,
1034
- label: unref(a)("connect.common.startDate"),
1035
- "onUpdate:modelValue": s[0] || (s[0] = (n) => {
1036
- var r;
1037
- return u("update:model-value", {
1038
- startDate: n,
1039
- endDate: ((r = e.modelValue) == null ? void 0 : r.endDate) ?? null
1040
- });
1041
- })
1042
- }, null, 8, ["model-value", "label"])
1043
- ]),
1044
- createElementVNode("div", _hoisted_3$a, toDisplayString(unref(a)("connect.common.to")), 1),
1045
- createElementVNode("div", _hoisted_4$9, [
1046
- createVNode(_sfc_main$h, {
1047
- "model-value": ((o = e.modelValue) == null ? void 0 : o.endDate) ?? null,
1048
- label: unref(a)("connect.common.endDate"),
1049
- "onUpdate:modelValue": s[1] || (s[1] = (n) => {
1050
- var r;
1051
- return u("update:model-value", {
1052
- startDate: ((r = e.modelValue) == null ? void 0 : r.startDate) ?? null,
1053
- endDate: n
1054
- });
1055
- })
1056
- }, null, 8, ["model-value", "label"])
1057
- ])
1058
- ]);
1059
- };
1060
- }
1061
- }), _hoisted_1$f = { class: "space-y-8" }, _hoisted_2$c = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$9 = {
1062
- key: 0,
1063
- class: "space-y-4"
1064
- }, _hoisted_4$8 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$6 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$f = /* @__PURE__ */ defineComponent({
1065
- __name: "ScheduleRuleInput",
1066
- props: {
1067
- modelValue: {
1068
- type: Object,
1069
- required: !0
1070
- },
1071
- startDate: {
1072
- type: String
1073
- },
1074
- endDate: {
1075
- type: String
1076
- }
1077
- },
1078
- emits: ["update:model-value"],
1079
- setup(e, { emit: m }) {
1080
- const { t: a } = useI18n(), u = e, i = m, s = useCoreStore(), l = computed(
1081
- () => CountryTimezone[s.currentCountry.value || "MY"]
1082
- );
1083
- function o() {
1084
- const p = RuleBuilder.getRules(u.modelValue);
1085
- return p.length == 0 ? "fixed" : p.some(
1086
- (d) => isRuleEntry(d) && RuleBuilder.simplify(d).operator == "_rrule"
1087
- ) ? "repeating" : "fixed";
1088
- }
1089
- const n = ref(o()), r = ref(!1), y = computed(() => [
1090
- { label: a("connect.template.rule.schedule.fixed"), value: "fixed" },
1091
- { label: a("connect.template.rule.schedule.repeating"), value: "repeating" }
1092
- ]), v = computed(() => {
1093
- const p = RuleBuilder.getRules(u.modelValue), d = p.find(
1094
- (f) => isRuleEntry(f) && RuleBuilder.simplify(f).property == "trigger.date"
1095
- ), c = p.find(
1096
- (f) => isRuleEntry(f) && RuleBuilder.simplify(f).property == "trigger.time"
1097
- );
1098
- return {
1099
- date: d ? RuleBuilder.simplify(d).equator : null,
1100
- time: c ? RuleBuilder.simplify(c).equator : null
1101
- };
1102
- }), h = computed(
1103
- () => calculateNextScheduleAt(
1104
- u.modelValue,
1105
- /* @__PURE__ */ new Date(),
1106
- u.startDate ? new Date(u.startDate) : void 0,
1107
- u.endDate ? new Date(u.endDate) : void 0
1108
- )
1109
- );
1110
- function x(p) {
1111
- const d = p.value, c = d == "fixed" ? [
1112
- RuleBuilder.constructEntry(
1113
- "trigger.date",
1114
- "_isOnDate",
1115
- (/* @__PURE__ */ new Date()).toISOString()
1116
- ),
1117
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1118
- ] : [
1119
- RuleBuilder.constructEntry(
1120
- "trigger.date",
1121
- "_rrule",
1122
- new RRule({
1123
- dtstart: u.startDate ? new Date(u.startDate) : /* @__PURE__ */ new Date(),
1124
- freq: RRule.DAILY,
1125
- interval: 1,
1126
- byhour: 0,
1127
- byminute: 0,
1128
- bysecond: 0,
1129
- wkst: RRule.SU
1130
- }).toString()
1131
- ),
1132
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1133
- ];
1134
- i(
1135
- "update:model-value",
1136
- RuleBuilder.setRuleToGroup(
1137
- RuleBuilder.scaffoldGroup("g_schedule"),
1138
- c
1139
- )
1140
- ), n.value = d;
1141
- }
1142
- function k(p) {
1143
- n.value == "fixed" ? i(
1144
- "update:model-value",
1145
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1146
- RuleBuilder.constructEntry(
1147
- "trigger.date",
1148
- "_isOnDate",
1149
- p.date
1150
- ),
1151
- RuleBuilder.constructEntry(
1152
- "trigger.time",
1153
- "_isOnTime",
1154
- p.time
1155
- )
1156
- ])
1157
- ) : i(
1158
- "update:model-value",
1159
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1160
- RuleBuilder.constructEntry(
1161
- "trigger.date",
1162
- "_rrule",
1163
- p.date
1164
- ),
1165
- RuleBuilder.constructEntry(
1166
- "trigger.time",
1167
- "_isOnTime",
1168
- p.time
1169
- )
1170
- ])
1171
- );
1172
- }
1173
- return (p, d) => {
1174
- const c = resolveComponent("FmButtonGroup"), f = resolveComponent("FmTimePicker"), B = resolveComponent("FmIcon"), b = resolveComponent("FmTooltip"), E = resolveComponent("FmField"), N = resolveComponent("FmCard"), C = resolveComponent("FmPopover"), R = resolveComponent("FmDatePicker"), S = resolveComponent("FmHelperText");
1175
- return openBlock(), createElementBlock(Fragment, null, [
1176
- createVNode(c, {
1177
- items: unref(y),
1178
- "model-value": unref(y).find(($) => $.value === unref(n)) ?? null,
1179
- "onUpdate:modelValue": x,
1180
- class: "mb-8"
1181
- }, null, 8, ["items", "model-value"]),
1182
- createElementVNode("div", _hoisted_1$f, [
1183
- createElementVNode("div", _hoisted_2$c, [
1184
- createVNode(f, {
1185
- label: unref(a)("connect.template.rule.schedule.notify_time"),
1186
- "model-value": unref(v).time,
1187
- "onUpdate:modelValue": d[0] || (d[0] = ($) => k({ date: unref(v).date, time: $ })),
1188
- "helper-text": unref(v).time ? void 0 : unref(a)("connect.template.rule.schedule.time_required"),
1189
- "helper-state": unref(v).time ? void 0 : "error"
1190
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"]),
1191
- unref(n) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
1192
- createElementVNode("div", _hoisted_4$8, [
1193
- createElementVNode("div", null, toDisplayString(unref(a)("connect.template.rule.schedule.notify_date")), 1),
1194
- unref(v).date ? (openBlock(), createBlock(b, {
1195
- key: 0,
1196
- "z-index": 9999,
1197
- content: unref(SummarizeRrule)(unref(RRule).fromString(unref(v).date).options)
1198
- }, {
1199
- default: withCtx(() => [
1200
- createVNode(B, {
1201
- name: "info",
1202
- size: "sm",
1203
- outline: !0
1204
- })
1205
- ]),
1206
- _: 1
1207
- }, 8, ["content"])) : createCommentVNode("", !0)
1208
- ]),
1209
- createVNode(C, {
1210
- "show-popover": unref(r),
1211
- onPopoverChanged: d[3] || (d[3] = ($) => r.value = $)
1212
- }, {
1213
- "popover-button": withCtx(() => [
1214
- createVNode(E, {
1215
- class: "cursor-pointer",
1216
- "helper-text": unref(v).date ? void 0 : unref(a)("connect.template.rule.schedule.date_required"),
1217
- "helper-state": unref(v).date ? void 0 : "error"
1218
- }, {
1219
- default: withCtx(() => [
1220
- createElementVNode("div", _hoisted_5$6, toDisplayString(unref(v).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(v).date).options) : unref(a)("connect.template.rule.schedule.set_repeating_date")), 1)
1221
- ]),
1222
- _: 1
1223
- }, 8, ["helper-text", "helper-state"])
1224
- ]),
1225
- default: withCtx(() => [
1226
- createVNode(N, { class: "elevated p-8 w-[450px]" }, {
1227
- default: withCtx(() => [
1228
- createVNode(_sfc_main$q, {
1229
- "apply-button": !0,
1230
- "model-value": unref(v).date || "",
1231
- "start-date": e.startDate ? new Date(e.startDate) : void 0,
1232
- onCancel: d[1] || (d[1] = ($) => r.value = !1),
1233
- "onUpdate:modelValue": d[2] || (d[2] = ($) => (k({ date: $, time: unref(v).time }), r.value = !1))
1234
- }, null, 8, ["model-value", "start-date"])
1235
- ]),
1236
- _: 1
1237
- })
1238
- ]),
1239
- _: 1
1240
- }, 8, ["show-popover"])
1241
- ])) : (openBlock(), createBlock(R, {
1242
- key: 1,
1243
- label: unref(a)("connect.template.rule.schedule.notify_date"),
1244
- "model-value": unref(v).date || "",
1245
- "onUpdate:modelValue": d[4] || (d[4] = ($) => k({ date: $, time: unref(v).time })),
1246
- "helper-text": unref(v).date ? void 0 : unref(a)("connect.template.rule.schedule.date_required"),
1247
- "helper-state": unref(v).date ? void 0 : "error"
1248
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"]))
1249
- ]),
1250
- unref(v).date && unref(v).time && unref(h) ? (openBlock(), createBlock(S, {
1251
- key: 0,
1252
- text: `${unref(moment)(unref(h)).isAfter(unref(moment)()) ? unref(a)("connect.template.rule.schedule.next_notification") : unref(a)("connect.template.rule.schedule.last_trigger_on")} ${unref(moment)(unref(h)).format("dddd, DD MMM YYYY")} at
1253
- ${unref(moment)(unref(h)).format("hh:mmA")}(UTC${unref(moment).tz(unref(l)).format("Z")}) (${unref(moment)(unref(h)).fromNow()})`
1254
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1255
- ])
1256
- ], 64);
1257
- };
1258
- }
1259
- }), _hoisted_1$e = { class: "space-y-16" }, _hoisted_2$b = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$8 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$7 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
1260
- __name: "GameTypeInput",
1261
- props: {
1262
- modelValue: {
1263
- type: String
1264
- }
1265
- },
1266
- emits: ["update:model-value"],
1267
- setup(e, { emit: m }) {
1268
- const { t: a } = useI18n(), u = e, i = m, s = computed(
1269
- () => [
1270
- {
1271
- label: a("connect.campaign.gameType.option.FORTUNE_WHEEL.label"),
1272
- description: a("connect.campaign.gameType.option.FORTUNE_WHEEL.description"),
1273
- value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
1274
- hidden: !1
1275
- },
1276
- {
1277
- label: a("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.label"),
1278
- description: a("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.description"),
1279
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
1280
- hidden: !0
1281
- }
1282
- ].filter((l) => !l.hidden)
1283
- );
1284
- return (l, o) => {
1285
- const n = resolveComponent("FmCard");
1286
- return openBlock(), createElementBlock("div", _hoisted_1$e, [
1287
- createElementVNode("div", _hoisted_2$b, toDisplayString(unref(a)("connect.template.select_game")), 1),
1288
- createElementVNode("div", _hoisted_3$8, [
1289
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (r) => (openBlock(), createBlock(n, {
1290
- variant: "outlined",
1291
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1292
- "col-span-2": unref(s).length == 1,
1293
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
1294
- "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
1295
- }]),
1296
- onClick: () => {
1297
- u.modelValue != r.value && i("update:model-value", r.value);
1298
- },
1299
- key: r.value
1300
- }, {
1301
- default: withCtx(() => [
1302
- createElementVNode("div", _hoisted_4$7, toDisplayString(r.label), 1),
1303
- createElementVNode("div", _hoisted_5$5, toDisplayString(r.description), 1)
1304
- ]),
1305
- _: 2
1306
- }, 1032, ["class", "onClick"]))), 128))
1307
- ])
1308
- ]);
1309
- };
1310
- }
1311
- }), _hoisted_1$d = {
1312
- key: 0,
1313
- class: "flex flex-col gap-y-24"
1314
- }, _hoisted_2$a = { class: "flex gap-8 items-center justify-start" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
1315
- __name: "EditRewardPoolSheet",
1316
- emits: ["update:model-value"],
1317
- setup(e, { expose: m, emit: a }) {
1318
- const u = useMembershipStore(), { minor: i } = useLoading, s = ref(!1), l = ref(), o = ref(), n = ref(0), r = computed(() => {
1319
- var p;
1320
- return ((p = u.loyaltyRewards.items.find(
1321
- (d) => {
1322
- var c;
1323
- return d.value === ((c = l.value) == null ? void 0 : c.collectible);
1324
- }
1325
- )) == null ? void 0 : p.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
1326
- }), y = computed(() => {
1327
- const k = r.value.safeParse(l.value);
1328
- return k.success ? [] : k.error.errors;
1329
- });
1330
- function v(k, p, d) {
1331
- k && (l.value = p, n.value = d), s.value = k;
1332
- }
1333
- const h = a;
1334
- async function x() {
1335
- const k = r.value.safeParse(l.value);
1336
- k.success && (await i(
1337
- async () => {
1338
- k.data.type === "VOUCHER" && o.value && (k.data.collectibleConfig.image = await firebaseStorage.update(
1339
- k.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, o.value),
1340
- o.value
1341
- ));
1342
- },
1343
- {
1344
- message: "Uploading reward image",
1345
- successMessage: "Reward image updated"
1346
- }
1347
- ), h("update:model-value", k.data, n.value));
1348
- }
1349
- return m({
1350
- showSheet: v
1351
- }), (k, p) => {
1352
- const d = resolveComponent("FmSelect"), c = resolveComponent("FmStepperField"), f = resolveComponent("FmButton"), B = resolveComponent("FmSideSheet");
1353
- return openBlock(), createBlock(B, {
1354
- "max-width": 560,
1355
- modelValue: unref(s),
1356
- "onUpdate:modelValue": [
1357
- p[9] || (p[9] = (b) => isRef(s) ? s.value = b : null),
1358
- p[10] || (p[10] = (b) => s.value = b)
1359
- ],
1360
- header: "Edit reward",
1361
- "dismiss-away": ""
1362
- }, {
1363
- "side-sheet-footer": withCtx(() => [
1364
- createElementVNode("div", _hoisted_2$a, [
1365
- createVNode(f, {
1366
- variant: "primary",
1367
- type: "button",
1368
- disabled: unref(y).length > 0,
1369
- label: "Confirm",
1370
- onClick: p[7] || (p[7] = (b) => x())
1371
- }, null, 8, ["disabled"]),
1372
- createVNode(f, {
1373
- variant: "secondary",
1374
- type: "button",
1375
- label: "Cancel",
1376
- onClick: p[8] || (p[8] = (b) => s.value = !1)
1377
- })
1378
- ])
1379
- ]),
1380
- default: withCtx(() => {
1381
- var b, E, N;
1382
- return [
1383
- unref(l) ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
1384
- createVNode(d, {
1385
- label: "Reward Type",
1386
- items: [
1387
- { label: "No Reward", value: "NO_REWARD" },
1388
- { label: "Voucher", value: "VOUCHER" },
1389
- { label: "Loyalty", value: "LOYALTY" }
1390
- ],
1391
- "model-value": unref(l).type,
1392
- "onUpdate:modelValue": p[0] || (p[0] = (C) => {
1393
- C == "NO_REWARD" ? l.value = {
1394
- type: "NO_REWARD",
1395
- collectible: null,
1396
- weight: 1
1397
- } : C === "VOUCHER" ? l.value = {
1398
- collectible: null,
1399
- type: "VOUCHER",
1400
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
1401
- business: unref(useCoreStore)().currentBusiness.value._id
1402
- }),
1403
- earningOption: {
1404
- amount: 1,
1405
- type: "FIXED"
1406
- },
1407
- validityOption: {
1408
- validForDay: 7
1409
- },
1410
- weight: 1
1411
- } : l.value = {
1412
- collectible: unref(u).loyaltyRewards.raw[0]._id,
1413
- type: "LOYALTY",
1414
- earningOption: {
1415
- amount: 1,
1416
- type: "FIXED"
1417
- },
1418
- validityOption: {
1419
- validForDay: 7
1420
- },
1421
- weight: 1
1422
- };
1423
- })
1424
- }, null, 8, ["model-value"]),
1425
- unref(l).type == "LOYALTY" ? (openBlock(), createBlock(d, {
1426
- key: 0,
1427
- label: "Loyalty type",
1428
- rules: [unref(ZodHelper).ruleAtPath(unref(r), "collectible", [unref(l).type])],
1429
- items: unref(u).loyaltyRewards.items,
1430
- "model-value": unref(l).collectible,
1431
- "onUpdate:modelValue": p[1] || (p[1] = (C) => unref(l).collectible = C)
1432
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
1433
- createVNode(c, {
1434
- label: "Weight",
1435
- rules: [unref(ZodHelper).ruleAtPath(unref(r), "weight", [unref(l).type])],
1436
- "model-value": unref(l).weight,
1437
- "onUpdate:modelValue": p[2] || (p[2] = (C) => l.value = {
1438
- ...unref(l),
1439
- weight: C
1440
- })
1441
- }, null, 8, ["rules", "model-value"]),
1442
- unref(l).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1443
- ((b = unref(u).loyaltyRewards.items.find(
1444
- (C) => {
1445
- var R;
1446
- return C.value === ((R = unref(l)) == null ? void 0 : R.collectible);
1447
- }
1448
- )) == null ? void 0 : b.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1449
- p[11] || (p[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
1450
- createVNode(_sfc_main$r, {
1451
- class: "mt-[-8px]",
1452
- rules: [
1453
- unref(ZodHelper).ruleAtPath(unref(r), "earningOption", [unref(l).type])
1454
- ],
1455
- "helper-state": unref(ZodHelper).helperState(unref(y), "earningOption"),
1456
- "error-text": unref(ZodHelper).helperText(unref(y), "earningOption"),
1457
- "fixed-type": !0,
1458
- "model-value": unref(l).earningOption,
1459
- "onUpdate:modelValue": p[3] || (p[3] = (C) => l.value = {
1460
- ...unref(l),
1461
- earningOption: C
1462
- })
1463
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
1464
- ], 64)) : createCommentVNode("", !0),
1465
- p[12] || (p[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
1466
- createVNode(_sfc_main$s, {
1467
- type: unref(l).type === "LOYALTY" ? "custom" : "range",
1468
- "for-credit": unref(l).type === "LOYALTY" && ((E = unref(u).loyaltyRewards.items.find(
1469
- (C) => {
1470
- var R;
1471
- return C.value === ((R = unref(l)) == null ? void 0 : R.collectible);
1472
- }
1473
- )) == null ? void 0 : E.raw.type) === "CREDIT",
1474
- class: "!gap-24",
1475
- rules: [unref(ZodHelper).ruleAtPath(unref(r), "validityOption", [unref(l).type])],
1476
- "model-value": unref(l).validityOption,
1477
- "onUpdate:modelValue": p[4] || (p[4] = (C) => l.value = {
1478
- ...unref(l),
1479
- validityOption: C
1480
- })
1481
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
1482
- ], 64)) : createCommentVNode("", !0),
1483
- unref(l).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$t, {
1484
- key: 2,
1485
- "reward-image": unref(o),
1486
- "model-value": ((N = unref(l)) == null ? void 0 : N.collectibleConfig) ?? void 0,
1487
- "onUpdate:modelValue": p[5] || (p[5] = (C) => l.value = {
1488
- ...unref(l),
1489
- collectibleConfig: C
1490
- }),
1491
- "onUpdate:rewardImage": p[6] || (p[6] = (C) => o.value = C)
1492
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1493
- createVNode(JsonViewer, { json: unref(y) }, null, 8, ["json"])
1494
- ])) : createCommentVNode("", !0)
1495
- ];
1496
- }),
1497
- _: 1
1498
- }, 8, ["modelValue"]);
1499
- };
1500
- }
1501
- });
1502
- function isNullOrEmpty(e) {
1503
- return e == null || e === "";
1504
- }
1505
- const _hoisted_1$c = { class: "space-y-16" }, _hoisted_2$9 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$7 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$6 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
1506
- __name: "RewardPoolInput",
1507
- props: {
1508
- modelValue: {
1509
- type: Array,
1510
- default: () => [
1511
- {
1512
- collectible: null,
1513
- type: "NO_REWARD",
1514
- weight: 1
1515
- }
1516
- ]
1517
- }
1518
- },
1519
- emits: ["update:model-value"],
1520
- setup(e, { emit: m }) {
1521
- const a = e, u = m, i = useMembershipStore(), { t: s } = useI18n(), l = z.array(z.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), o = computed(() => a.modelValue ?? []), n = computed(() => {
1522
- const p = l.safeParse(o.value);
1523
- return p.success ? [] : p.error.errors;
1524
- }), r = ref();
1525
- function y(p, d) {
1526
- var f;
1527
- const c = [...o.value];
1528
- c[d] = p, (f = r.value) == null || f.showSheet(!1), u("update:model-value", c);
1529
- }
1530
- function v(p) {
1531
- const d = p.type == "VOUCHER" ? p.collectibleConfig : i.collectibles.find(
1532
- (B) => B._id.toString() == p.collectible
1533
- ), c = CollectionUtils.formattedType((d == null ? void 0 : d.name) || ""), f = p.weight;
1534
- return {
1535
- label: isNullOrEmpty(c) ? "NO REWARD" : c,
1536
- sublabel: `${f} (${(f / o.value.reduce((B, b) => B + b.weight, 0) * 100).toFixed(2)}%)`
1537
- };
1538
- }
1539
- function h(p) {
1540
- var c;
1541
- const d = [...o.value];
1542
- (c = r.value) == null || c.showSheet(!0, d[p], p);
1543
- }
1544
- function x(p) {
1545
- const d = [...o.value];
1546
- d.splice(p, 1), u("update:model-value", d);
1547
- }
1548
- function k() {
1549
- var p;
1550
- (p = r.value) == null || p.showSheet(
1551
- !0,
1552
- {
1553
- type: "NO_REWARD",
1554
- collectible: null,
1555
- weight: 1
1556
- },
1557
- o.value.length
1558
- );
1559
- }
1560
- return (p, d) => {
1561
- const c = resolveComponent("FmButton"), f = resolveComponent("FmCard"), B = resolveComponent("FmHelperText");
1562
- return openBlock(), createElementBlock("div", _hoisted_1$c, [
1563
- createElementVNode("div", _hoisted_2$9, toDisplayString(unref(s)("connect.template.configure_reward_type")), 1),
1564
- createVNode(c, {
1565
- label: unref(s)("connect.campaign.rewardPool.addReward"),
1566
- onClick: d[0] || (d[0] = (b) => k()),
1567
- variant: "plain",
1568
- icon: "add"
1569
- }, null, 8, ["label"]),
1570
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (b, E) => (openBlock(), createBlock(f, {
1571
- key: E,
1572
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
1573
- variant: "outlined",
1574
- onClick: (N) => h(E)
1575
- }, {
1576
- default: withCtx(() => {
1577
- var N;
1578
- return [
1579
- createElementVNode("div", null, [
1580
- createElementVNode("div", _hoisted_3$7, toDisplayString(b.type == "LOYALTY" ? (N = b == null ? void 0 : b.earningOption) == null ? void 0 : N.amount : "") + " " + toDisplayString(v(b).label), 1),
1581
- createElementVNode("div", _hoisted_4$6, toDisplayString(v(b).sublabel), 1)
1582
- ]),
1583
- createVNode(c, {
1584
- icon: "delete",
1585
- variant: "tertiary",
1586
- onClick: (C) => (C.stopPropagation(), x(E))
1587
- }, null, 8, ["onClick"])
1588
- ];
1589
- }),
1590
- _: 2
1591
- }, 1032, ["onClick"]))), 128)),
1592
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filter((b) => b.path.join(".") == ""), (b) => (openBlock(), createBlock(B, {
1593
- key: b.message,
1594
- text: b.message,
1595
- state: "error"
1596
- }, null, 8, ["text"]))), 128)),
1597
- createVNode(_sfc_main$d, {
1598
- ref_key: "sheetRef",
1599
- ref: r,
1600
- "onUpdate:modelValue": y
1601
- }, null, 512)
1602
- ]);
1603
- };
1604
- }
1605
- }), _hoisted_1$b = { class: "space-y-16" }, _hoisted_2$8 = {
1606
- key: 0,
1607
- class: "grid grid-cols-2 gap-16"
1608
- }, _hoisted_3$6 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
1609
- __name: "PromotionGameTypeInput",
1610
- props: {
1611
- modelValue: {
1612
- type: Object
1613
- }
1614
- },
1615
- emits: ["update:model-value"],
1616
- setup(e, { emit: m }) {
1617
- const { t: a } = useI18n(), u = e, i = m, s = computed(() => [
1618
- {
1619
- label: a("connect.template.promotion_game.rock_paper_scissors.label"),
1620
- description: a("connect.template.promotion_game.rock_paper_scissors.description"),
1621
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
1622
- }
1623
- ]);
1624
- return (l, o) => {
1625
- var v, h, x;
1626
- const n = resolveComponent("FmSwitch"), r = resolveComponent("FmCard"), y = resolveComponent("FmHelperText");
1627
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
1628
- createVNode(n, {
1629
- label: unref(a)("connect.template.promotion_game.enable"),
1630
- "model-value": !!((v = e.modelValue) != null && v.gameType),
1631
- "onUpdate:modelValue": o[0] || (o[0] = (k) => k ? i("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : i("update:model-value", null))
1632
- }, null, 8, ["label", "model-value"]),
1633
- ((h = e.modelValue) == null ? void 0 : h.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
1634
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (k) => {
1635
- var p, d;
1636
- return openBlock(), createBlock(r, {
1637
- variant: "outlined",
1638
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1639
- "col-span-2": unref(s).length == 1,
1640
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((p = e.modelValue) == null ? void 0 : p.gameType) == k.value,
1641
- "hover:bg-fm-color-opacity-sm": ((d = e.modelValue) == null ? void 0 : d.gameType) != k.value
1642
- }]),
1643
- onClick: () => {
1644
- var c;
1645
- ((c = u.modelValue) == null ? void 0 : c.gameType) != k.value && i("update:model-value", { gameType: k.value });
1646
- },
1647
- key: k.value
1648
- }, {
1649
- default: withCtx(() => [
1650
- createElementVNode("div", _hoisted_3$6, toDisplayString(k.label), 1),
1651
- createElementVNode("div", _hoisted_4$5, toDisplayString(k.description), 1)
1652
- ]),
1653
- _: 2
1654
- }, 1032, ["class", "onClick"]);
1655
- }), 128))
1656
- ])) : createCommentVNode("", !0),
1657
- ((x = e.modelValue) == null ? void 0 : x.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(y, {
1658
- key: 1,
1659
- text: unref(a)("connect.template.promotion_game.rock_paper_scissors.warning"),
1660
- state: "warning"
1661
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1662
- ]);
1663
- };
1664
- }
1665
- }), _hoisted_1$a = { class: "space-y-8" }, _hoisted_2$7 = { class: "grid gap-16 grid-cols-2" }, _hoisted_3$5 = { class: "space-y-6" }, _hoisted_4$4 = { class: "space-y-8" }, _hoisted_5$4 = { class: "fm-typo-en-body-lg-600" }, _hoisted_6$3 = { class: "flex items-center space-x-3" }, _hoisted_7$3 = {
1666
- key: 0,
1667
- class: "ml-6 space-y-2"
1668
- }, _sfc_main$a = /* @__PURE__ */ defineComponent({
1669
- __name: "GrabConditionsInput",
1670
- props: {
1671
- modelValue: {
1672
- type: Object
1673
- },
1674
- schema: {
1675
- type: Object,
1676
- default: () => z.any()
1677
- }
1678
- },
1679
- emits: ["update:model-value"],
1680
- setup(e, { emit: m }) {
1681
- const { t: a } = useI18n(), u = e, i = m, s = ref(u.modelValue ?? {}), l = ref(
1682
- (() => {
1683
- const v = {};
1684
- return s.value.workingHour && Object.keys(s.value.workingHour).forEach((h) => {
1685
- const x = s.value.workingHour[h];
1686
- x && "periods" in x && Array.isArray(x.periods) ? v[h] = x.periods : Array.isArray(x) && (v[h] = x);
1687
- }), v;
1688
- })()
1689
- ), o = [
1690
- { key: "mon", label: "Monday" },
1691
- { key: "tue", label: "Tuesday" },
1692
- { key: "wed", label: "Wednesday" },
1693
- { key: "thu", label: "Thursday" },
1694
- { key: "fri", label: "Friday" },
1695
- { key: "sat", label: "Saturday" },
1696
- { key: "sun", label: "Sunday" }
1697
- ], n = (v) => {
1698
- l.value[v] || (l.value[v] = []), l.value[v].push({
1699
- startTime: "00:00",
1700
- endTime: "23:59"
1701
- }), y();
1702
- }, r = (v, h) => {
1703
- l.value[v] && l.value[v].length > h && (l.value[v].splice(h, 1), l.value[v].length === 0 && delete l.value[v], y());
1704
- }, y = () => {
1705
- const v = Object.keys(l.value).reduce(
1706
- (h, x) => (l.value[x] && l.value[x].length > 0 && (h[x] = {
1707
- periods: l.value[x]
1708
- }), h),
1709
- {}
1710
- );
1711
- s.value.workingHour = Object.keys(v).length > 0 ? v : void 0;
1712
- };
1713
- return watch(s, () => i("update:model-value", s.value), { deep: !0 }), watch(l, y, { deep: !0 }), (v, h) => {
1714
- const x = resolveComponent("FmSelect"), k = resolveComponent("FmStepperField"), p = resolveComponent("FmCheckbox"), d = resolveComponent("FmTimePicker"), c = resolveComponent("FmButton");
1715
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
1716
- createElementVNode("div", _hoisted_2$7, [
1717
- createVNode(x, {
1718
- label: unref(a)("connect.template.eaterType"),
1719
- modelValue: unref(s).eaterType,
1720
- "onUpdate:modelValue": h[0] || (h[0] = (f) => unref(s).eaterType = f),
1721
- items: [
1722
- { label: unref(a)("connect.template.allEaters"), value: "all" },
1723
- { label: unref(a)("connect.template.newEatersOnly"), value: "new" },
1724
- {
1725
- label: unref(a)("connect.template.existingEatersOnly"),
1726
- value: "existing"
1727
- }
1728
- ],
1729
- rules: [unref(ZodHelper).ruleAtPath(e.schema, "eaterType")]
1730
- }, null, 8, ["label", "modelValue", "items", "rules"]),
1731
- createVNode(k, {
1732
- modelValue: unref(s).minBasketAmount,
1733
- "onUpdate:modelValue": h[1] || (h[1] = (f) => unref(s).minBasketAmount = f),
1734
- "show-steppers": !1,
1735
- rules: [unref(ZodHelper).ruleAtPath(e.schema, "minBasketAmount")]
1736
- }, {
1737
- label: withCtx(() => [
1738
- (openBlock(), createBlock(resolveDynamicComponent(
1739
- unref(ZodHelper).toInputLabel(
1740
- unref(ZodHelper).typeAtPath(e.schema, "minBasketAmount"),
1741
- unref(a)("connect.template.minBasketAmount")
1742
- )
1743
- )))
1744
- ]),
1745
- _: 1
1746
- }, 8, ["modelValue", "rules"]),
1747
- createVNode(k, {
1748
- modelValue: unref(s).bundleQuantity,
1749
- "onUpdate:modelValue": h[2] || (h[2] = (f) => unref(s).bundleQuantity = f),
1750
- "show-steppers": !1,
1751
- rules: [unref(ZodHelper).ruleAtPath(e.schema, "bundleQuantity")]
1752
- }, {
1753
- label: withCtx(() => [
1754
- (openBlock(), createBlock(resolveDynamicComponent(
1755
- unref(ZodHelper).toInputLabel(
1756
- unref(ZodHelper).typeAtPath(e.schema, "bundleQuantity"),
1757
- unref(a)("connect.template.bundleQuantity")
1758
- )
1759
- )))
1760
- ]),
1761
- _: 1
1762
- }, 8, ["modelValue", "rules"])
1763
- ]),
1764
- createElementVNode("div", _hoisted_3$5, [
1765
- createElementVNode("div", _hoisted_4$4, [
1766
- createElementVNode("div", _hoisted_5$4, toDisplayString(unref(a)("connect.template.operationHours")), 1),
1767
- (openBlock(), createElementBlock(Fragment, null, renderList(o, (f) => createElementVNode("div", {
1768
- key: f.key,
1769
- class: "space-y-2"
1770
- }, [
1771
- createElementVNode("div", _hoisted_6$3, [
1772
- createVNode(p, {
1773
- label: f.label,
1774
- "model-value": !!(unref(l)[f.key] && unref(l)[f.key].length > 0),
1775
- "onUpdate:modelValue": (B) => {
1776
- B ? n(f.key) : (unref(l)[f.key] = [], delete unref(l)[f.key], y());
1777
- }
1778
- }, null, 8, ["label", "model-value", "onUpdate:modelValue"])
1779
- ]),
1780
- unref(l)[f.key] && unref(l)[f.key].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_7$3, [
1781
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(l)[f.key] || [], (B, b) => (openBlock(), createElementBlock("div", {
1782
- key: b,
1783
- class: "flex items-center space-x-2 w-100"
1784
- }, [
1785
- createVNode(d, {
1786
- "model-value": B.startTime || "",
1787
- "onUpdate:modelValue": (E) => {
1788
- unref(l)[f.key] && unref(l)[f.key][b] && (unref(l)[f.key][b].startTime = E || "", y());
1789
- }
1790
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
1791
- h[3] || (h[3] = createElementVNode("span", null, "to", -1)),
1792
- createVNode(d, {
1793
- "model-value": B.endTime || "",
1794
- "onUpdate:modelValue": (E) => {
1795
- unref(l)[f.key] && unref(l)[f.key][b] && (unref(l)[f.key][b].endTime = E || "", y());
1796
- }
1797
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
1798
- createVNode(c, {
1799
- variant: "tertiary",
1800
- size: "sm",
1801
- onClick: (E) => r(f.key, b),
1802
- icon: "close"
1803
- }, null, 8, ["onClick"]),
1804
- b === 0 ? (openBlock(), createBlock(c, {
1805
- key: 0,
1806
- onClick: (E) => n(f.key),
1807
- icon: "add",
1808
- variant: "plain"
1809
- }, null, 8, ["onClick"])) : createCommentVNode("", !0)
1810
- ]))), 128))
1811
- ])) : createCommentVNode("", !0)
1812
- ])), 64))
1813
- ])
1814
- ])
1815
- ]);
1816
- };
1817
- }
1818
- }), GrabConditionsInput = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-7f17ebe8"]]), _hoisted_1$9 = { class: "space-y-8" }, _hoisted_2$6 = { class: "grid gap-16 grid-cols-2" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
1819
- __name: "GrabQuotaInput",
1820
- props: {
1821
- modelValue: {
1822
- type: Object
1823
- },
1824
- schema: {
1825
- type: Object,
1826
- default: () => z.any()
1827
- }
1828
- },
1829
- emits: ["update:model-value"],
1830
- setup(e, { emit: m }) {
1831
- const { t: a } = useI18n(), u = e, i = m, s = ref(u.modelValue ?? {});
1832
- return watch(s, () => i("update:model-value", s.value)), (l, o) => {
1833
- const n = resolveComponent("FmStepperField");
1834
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
1835
- createElementVNode("div", _hoisted_2$6, [
1836
- createVNode(n, {
1837
- modelValue: unref(s).totalCount,
1838
- "onUpdate:modelValue": o[0] || (o[0] = (r) => unref(s).totalCount = r),
1839
- "show-steppers": !1,
1840
- rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCount")]
1841
- }, {
1842
- label: withCtx(() => [
1843
- (openBlock(), createBlock(resolveDynamicComponent(
1844
- unref(ZodHelper).toInputLabel(
1845
- unref(ZodHelper).typeAtPath(e.schema, "totalCount"),
1846
- unref(a)("connect.template.totalCount")
1847
- )
1848
- )))
1849
- ]),
1850
- _: 1
1851
- }, 8, ["modelValue", "rules"]),
1852
- createVNode(n, {
1853
- modelValue: unref(s).totalCountPerUser,
1854
- "onUpdate:modelValue": o[1] || (o[1] = (r) => unref(s).totalCountPerUser = r),
1855
- "show-steppers": !1,
1856
- rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCountPerUser")]
1857
- }, {
1858
- label: withCtx(() => [
1859
- (openBlock(), createBlock(resolveDynamicComponent(
1860
- unref(ZodHelper).toInputLabel(
1861
- unref(ZodHelper).typeAtPath(e.schema, "totalCountPerUser"),
1862
- unref(a)("connect.template.totalCountPerUser")
1863
- )
1864
- )))
1865
- ]),
1866
- _: 1
1867
- }, 8, ["modelValue", "rules"])
1868
- ])
1869
- ]);
1870
- };
1871
- }
1872
- }), _hoisted_1$8 = { class: "space-y-16" }, _hoisted_2$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$4 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$3 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$8 = /* @__PURE__ */ defineComponent({
1873
- __name: "MissionTypeInput",
1874
- props: {
1875
- modelValue: {
1876
- type: String
1877
- }
1878
- },
1879
- emits: ["update:model-value"],
1880
- setup(e, { emit: m }) {
1881
- const { t: a } = useI18n(), u = e, i = m, s = computed(() => [
1882
- {
1883
- label: a("connect.campaign.mission.typeOption.STAMP.label"),
1884
- description: a("connect.campaign.mission.typeOption.STAMP.description"),
1885
- value: F_MISSION_TYPE.enum.STAMP
1886
- },
1887
- {
1888
- label: a("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
1889
- description: a("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
1890
- value: F_MISSION_TYPE.enum.PROGRESSIVE
1891
- }
1892
- ]);
1893
- return (l, o) => {
1894
- const n = resolveComponent("FmCard");
1895
- return openBlock(), createElementBlock("div", _hoisted_1$8, [
1896
- createElementVNode("div", _hoisted_2$5, toDisplayString(unref(a)("connect.template.select_game")), 1),
1897
- createElementVNode("div", _hoisted_3$4, [
1898
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (r) => (openBlock(), createBlock(n, {
1899
- variant: "outlined",
1900
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1901
- "col-span-2": unref(s).length == 1,
1902
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
1903
- "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
1904
- }]),
1905
- onClick: () => {
1906
- u.modelValue != r.value && i("update:model-value", r.value);
1907
- },
1908
- key: r.value
1909
- }, {
1910
- default: withCtx(() => [
1911
- createElementVNode("div", _hoisted_4$3, toDisplayString(r.label), 1),
1912
- createElementVNode("div", _hoisted_5$3, toDisplayString(r.description), 1)
1913
- ]),
1914
- _: 2
1915
- }, 1032, ["class", "onClick"]))), 128))
1916
- ])
1917
- ]);
1918
- };
1919
- }
1920
- }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
1921
- __name: "MissionEndInput",
1922
- props: {
1923
- modelValue: {
1924
- type: [String, Number]
1925
- },
1926
- helperText: {
1927
- type: String
1928
- },
1929
- helperState: {
1930
- type: String
1931
- }
1932
- },
1933
- emits: ["update:model-value"],
1934
- setup(e, { emit: m }) {
1935
- const a = m;
1936
- return (u, i) => {
1937
- const s = resolveComponent("FmStepperField");
1938
- return openBlock(), createElementBlock("div", _hoisted_1$7, [
1939
- i[1] || (i[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)),
1940
- createVNode(s, {
1941
- label: "Maximum to collect",
1942
- "model-value": e.modelValue || null,
1943
- "onUpdate:modelValue": i[0] || (i[0] = (l) => a("update:model-value", l)),
1944
- "helper-text": e.helperText || "Set the threshold required for reward eligibility",
1945
- "helper-state": e.helperState || "none"
1946
- }, null, 8, ["model-value", "helper-text", "helper-state"])
1947
- ]);
1948
- };
1949
- }
1950
- }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
1951
- __name: "EditMissionPoolSheet",
1952
- props: {
1953
- maxThreshold: {
1954
- type: Number,
1955
- required: !0
1956
- }
1957
- },
1958
- emits: ["update:model-value"],
1959
- setup(e, { expose: m, emit: a }) {
1960
- const u = e, i = useMembershipStore(), { minor: s } = useLoading, l = ref(!1), o = ref(), n = ref(), r = ref(0), y = computed(() => {
1961
- var c;
1962
- return ((c = i.loyaltyRewards.items.find(
1963
- (f) => {
1964
- var B;
1965
- return f.value === ((B = o.value) == null ? void 0 : B.collectible);
1966
- }
1967
- )) == null ? void 0 : c.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
1968
- }), v = computed(() => {
1969
- const d = y.value.safeParse(o.value);
1970
- return d.success ? [] : d.error.errors;
1971
- });
1972
- function h(d, c, f) {
1973
- d && (o.value = c, r.value = f), l.value = d;
1974
- }
1975
- const x = a;
1976
- async function k() {
1977
- const d = y.value.safeParse(o.value);
1978
- d.success && (await s(
1979
- async () => {
1980
- d.data.type === "VOUCHER" && n.value && (d.data.collectibleConfig.image = await firebaseStorage.update(
1981
- d.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
1982
- n.value
1983
- ));
1984
- },
1985
- {
1986
- message: "Uploading reward image",
1987
- successMessage: "Reward image updated"
1988
- }
1989
- ), x("update:model-value", d.data, r.value));
1990
- }
1991
- const p = ref();
1992
- return m({
1993
- showSheet: h
1994
- }), (d, c) => {
1995
- const f = resolveComponent("FmStepperField"), B = resolveComponent("FmSelect"), b = resolveComponent("FmForm"), E = resolveComponent("FmButton"), N = resolveComponent("FmSideSheet");
1996
- return openBlock(), createBlock(N, {
1997
- "max-width": 560,
1998
- modelValue: unref(l),
1999
- "onUpdate:modelValue": [
2000
- c[10] || (c[10] = (C) => isRef(l) ? l.value = C : null),
2001
- c[11] || (c[11] = (C) => l.value = C)
2002
- ],
2003
- header: "Edit reward",
2004
- "dismiss-away": ""
2005
- }, {
2006
- "side-sheet-footer": withCtx(() => [
2007
- createElementVNode("div", _hoisted_1$6, [
2008
- createVNode(E, {
2009
- variant: "primary",
2010
- type: "button",
2011
- label: "Confirm",
2012
- disabled: unref(v).length > 0,
2013
- onClick: c[8] || (c[8] = async () => {
2014
- var C;
2015
- return (C = unref(p)) == null ? void 0 : C.validateInputs();
2016
- })
2017
- }, null, 8, ["disabled"]),
2018
- createVNode(E, {
2019
- variant: "secondary",
2020
- type: "button",
2021
- label: "Cancel",
2022
- onClick: c[9] || (c[9] = (C) => l.value = !1)
2023
- })
2024
- ])
2025
- ]),
2026
- default: withCtx(() => [
2027
- createVNode(JsonViewer, { json: unref(o) }, null, 8, ["json"]),
2028
- unref(o) ? (openBlock(), createBlock(b, {
2029
- key: 0,
2030
- class: "flex flex-col gap-y-24",
2031
- ref_key: "formRef",
2032
- ref: p,
2033
- onValidationSuccess: c[7] || (c[7] = (C) => k())
2034
- }, {
2035
- default: withCtx(() => {
2036
- var C, R;
2037
- return [
2038
- unref(o).type ? (openBlock(), createBlock(f, {
2039
- key: 0,
2040
- label: "Threshold",
2041
- rules: [
2042
- unref(ZodHelper).toRule(
2043
- unref(z).number().min(1).max(
2044
- u.maxThreshold,
2045
- `Number cannot be more than ${u.maxThreshold}`
2046
- )
2047
- )
2048
- ],
2049
- "model-value": unref(o).threshold,
2050
- "onUpdate:modelValue": c[0] || (c[0] = (S) => o.value = {
2051
- ...unref(o),
2052
- threshold: S
2053
- })
2054
- }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
2055
- createVNode(B, {
2056
- label: "Reward Type",
2057
- items: [
2058
- { label: "Voucher", value: "VOUCHER" },
2059
- { label: "Loyalty", value: "LOYALTY" }
2060
- ],
2061
- "model-value": unref(o).type,
2062
- "onUpdate:modelValue": c[1] || (c[1] = (S) => {
2063
- var $, H;
2064
- S === "VOUCHER" ? o.value = {
2065
- collectible: null,
2066
- type: "VOUCHER",
2067
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
2068
- business: unref(useCoreStore)().currentBusiness.value._id
2069
- }),
2070
- earningOption: {
2071
- amount: 1,
2072
- type: "FIXED"
2073
- },
2074
- validityOption: {
2075
- validForDay: 7
2076
- },
2077
- threshold: ($ = unref(o)) == null ? void 0 : $.threshold
2078
- } : o.value = {
2079
- collectible: unref(i).loyaltyRewards.raw[0]._id,
2080
- type: "LOYALTY",
2081
- earningOption: {
2082
- amount: 1,
2083
- type: "FIXED"
2084
- },
2085
- validityOption: {
2086
- validForDay: 7
2087
- },
2088
- threshold: (H = unref(o)) == null ? void 0 : H.threshold
2089
- };
2090
- })
2091
- }, null, 8, ["model-value"]),
2092
- unref(o).type == "LOYALTY" ? (openBlock(), createBlock(B, {
2093
- key: 1,
2094
- label: "Loyalty type",
2095
- rules: [unref(ZodHelper).ruleAtPath(unref(y), "collectible", [unref(o).type])],
2096
- items: unref(i).loyaltyRewards.items,
2097
- "model-value": unref(o).collectible,
2098
- "onUpdate:modelValue": c[2] || (c[2] = (S) => unref(o).collectible = S)
2099
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
2100
- unref(o).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2101
- c[12] || (c[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
2102
- createVNode(_sfc_main$r, {
2103
- class: "mt-[-8px]",
2104
- rules: [unref(ZodHelper).ruleAtPath(unref(y), "earningOption", [unref(o).type])],
2105
- "helper-state": unref(ZodHelper).helperState(unref(v), "earningOption"),
2106
- "error-text": unref(ZodHelper).helperText(unref(v), "earningOption"),
2107
- "fixed-type": !0,
2108
- "model-value": unref(o).earningOption,
2109
- "onUpdate:modelValue": c[3] || (c[3] = (S) => o.value = {
2110
- ...unref(o),
2111
- earningOption: S
2112
- })
2113
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
2114
- createVNode(_sfc_main$s, {
2115
- class: "!gap-24",
2116
- type: unref(o).type === "LOYALTY" ? "custom" : "range",
2117
- "for-credit": unref(o).type === "LOYALTY" && ((C = unref(i).loyaltyRewards.items.find(
2118
- (S) => {
2119
- var $;
2120
- return S.value === (($ = unref(o)) == null ? void 0 : $.collectible);
2121
- }
2122
- )) == null ? void 0 : C.raw.type) === "CREDIT",
2123
- rules: [unref(ZodHelper).ruleAtPath(unref(y), "validityOption", [unref(o).type])],
2124
- "model-value": unref(o).validityOption,
2125
- "onUpdate:modelValue": c[4] || (c[4] = (S) => o.value = {
2126
- ...unref(o),
2127
- validityOption: S
2128
- })
2129
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
2130
- ], 64)) : createCommentVNode("", !0),
2131
- unref(o).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$t, {
2132
- key: 3,
2133
- "reward-image": unref(n),
2134
- "model-value": ((R = unref(o)) == null ? void 0 : R.collectibleConfig) ?? void 0,
2135
- "onUpdate:modelValue": c[5] || (c[5] = (S) => o.value = {
2136
- ...unref(o),
2137
- collectibleConfig: S
2138
- }),
2139
- "onUpdate:rewardImage": c[6] || (c[6] = (S) => n.value = S)
2140
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
2141
- createVNode(JsonViewer, { json: unref(v) }, null, 8, ["json"])
2142
- ];
2143
- }),
2144
- _: 1
2145
- }, 512)) : createCommentVNode("", !0)
2146
- ]),
2147
- _: 1
2148
- }, 8, ["modelValue"]);
2149
- };
2150
- }
2151
- }), _hoisted_1$5 = {
2152
- key: 0,
2153
- class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
2154
- }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
2155
- __name: "MissionProgress",
2156
- props: {
2157
- type: {
2158
- type: String,
2159
- required: !0
2160
- },
2161
- maxRange: {
2162
- type: Number,
2163
- required: !0
2164
- },
2165
- currentRange: {
2166
- type: Number,
2167
- default: 0
2168
- },
2169
- markers: {
2170
- type: Array,
2171
- default: () => []
2172
- }
2173
- },
2174
- setup(e) {
2175
- const m = e, { maxRange: a, currentRange: u, markers: i } = toRefs(m), s = computed(
2176
- () => Math.min(u.value / a.value * 100, 100)
2177
- ), l = (o) => o / a.value * 100;
2178
- return (o, n) => {
2179
- const r = resolveComponent("FmIcon");
2180
- return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
2181
- (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(a), 40), (y) => (openBlock(), createBlock(r, {
2182
- class: normalizeClass(
2183
- unref(u) >= y ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
2184
- ),
2185
- outline: unref(u) < y,
2186
- key: y,
2187
- name: unref(i).some((v) => v === y) ? "featured_seasonal_and_gifts" : "check_circle"
2188
- }, null, 8, ["class", "outline", "name"]))), 128))
2189
- ])) : (openBlock(), createElementBlock("div", {
2190
- key: 1,
2191
- class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
2192
- }, [
2193
- createElementVNode("div", {
2194
- class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
2195
- style: normalizeStyle({ width: unref(s) + "%" })
2196
- }, null, 4),
2197
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i), (y, v) => (openBlock(), createElementBlock("div", {
2198
- key: v,
2199
- class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
2200
- style: normalizeStyle({ left: l(y) + "%" })
2201
- }, [
2202
- createElementVNode("div", _hoisted_2$4, [
2203
- createElementVNode("div", {
2204
- class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
2205
- }),
2206
- n[0] || (n[0] = createElementVNode("div", null, "🎁", -1))
2207
- ])
2208
- ], 4))), 128))
2209
- ]));
2210
- };
2211
- }
2212
- }), isObject = (e) => e !== null && typeof e == "object";
2213
- function changeKeysFactory(e) {
2214
- return function m(a, u = 1, i) {
2215
- if (u === 0 || !isObject(a))
2216
- return a;
2217
- if (Array.isArray(a))
2218
- return a.map((l) => m(l, u - 1, i));
2219
- const s = Object.create(Object.getPrototypeOf(a));
2220
- return Object.keys(a).forEach((l) => {
2221
- const o = a[l], n = e(l, i), r = m(o, u - 1, i);
2222
- s[n] = r;
2223
- }), s;
2224
- };
2225
- }
2226
- const sentenceCase = changeKeysFactory(sentenceCase$1), _hoisted_1$4 = { class: "space-y-16" }, _hoisted_2$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$3 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$2 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$2 = { class: "fm-typo-en-title-sm-800" }, _hoisted_6$2 = { class: "flex items-center gap-4" }, _hoisted_7$2 = { class: "fm-typo-en-body-lg-600" }, _hoisted_8$2 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_9$2 = { class: "flex items-center gap-16" }, _hoisted_10$2 = { key: 0 }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
2227
- __name: "MissionPoolInput",
2228
- props: {
2229
- modelValue: {
2230
- type: Array,
2231
- default: () => []
2232
- },
2233
- mission: {
2234
- type: Object,
2235
- required: !0
2236
- }
2237
- },
2238
- emits: ["update:model-value"],
2239
- setup(e, { emit: m }) {
2240
- const { t: a } = useI18n(), u = e, i = m, s = useMembershipStore(), l = z.array(z.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), o = computed(
2241
- () => u.modelValue.sort((d, c) => d.threshold - c.threshold) ?? []
2242
- ), n = computed(() => {
2243
- const d = l.safeParse(o.value);
2244
- return d.success ? [] : d.error.errors;
2245
- }), r = ref();
2246
- function y(d, c) {
2247
- var B;
2248
- const f = [...o.value];
2249
- f[c] = d, (B = r.value) == null || B.showSheet(!1), i("update:model-value", f);
2250
- }
2251
- function v(d) {
2252
- const c = d.type == "VOUCHER" ? d.collectibleConfig : s.collectibles.find(
2253
- (b) => b._id.toString() == d.collectible
2254
- ), f = CollectionUtils.formattedType((c == null ? void 0 : c.name) || ""), B = d.earningOption.type == "FIXED" ? a("connect.template.mission_pool.reward_sublabel_fixed", {
2255
- threshold: d.threshold,
2256
- amount: d.earningOption.amount
2257
- }) : a("connect.template.mission_pool.reward_sublabel_per_spend", {
2258
- threshold: d.threshold,
2259
- amount: d.earningOption.amount,
2260
- every: d.earningOption.every
2261
- });
2262
- return {
2263
- label: isNullOrEmpty(f) ? a("connect.template.mission_pool.no_reward") : f,
2264
- sublabel: B
2265
- };
2266
- }
2267
- function h(d) {
2268
- var f;
2269
- const c = [...o.value];
2270
- (f = r.value) == null || f.showSheet(!0, c[d], d);
2271
- }
2272
- function x(d) {
2273
- const c = [...o.value];
2274
- c.splice(d, 1), i("update:model-value", c);
2275
- }
2276
- function k() {
2277
- var d;
2278
- (d = r.value) == null || d.showSheet(
2279
- !0,
2280
- {
2281
- type: "LOYALTY",
2282
- collectible: s.loyaltyRewards.items[0].value,
2283
- threshold: null,
2284
- validityOption: {
2285
- validForDay: 7
2286
- },
2287
- earningOption: {
2288
- type: "FIXED",
2289
- amount: 1
2290
- }
2291
- },
2292
- o.value.length
2293
- );
2294
- }
2295
- function p(d) {
2296
- var c, f;
2297
- return d.type == "VOUCHER" ? (c = d.collectibleConfig) == null ? void 0 : c.name : sentenceCase(
2298
- ((f = s.loyaltyRewards.items.find(
2299
- (B) => B.value == d.collectible
2300
- )) == null ? void 0 : f.label) || ""
2301
- );
2302
- }
2303
- return (d, c) => {
2304
- const f = resolveComponent("FmButton"), B = resolveComponent("FmCard"), b = resolveComponent("FmHelperText");
2305
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
2306
- createElementVNode("div", _hoisted_2$3, toDisplayString(unref(a)("connect.template.configure_reward_customer")), 1),
2307
- createVNode(f, {
2308
- label: unref(a)("connect.template.mission_pool.add_reward"),
2309
- onClick: c[0] || (c[0] = (E) => k()),
2310
- variant: "plain",
2311
- icon: "add"
2312
- }, null, 8, ["label"]),
2313
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (E, N) => (openBlock(), createBlock(B, {
2314
- key: N,
2315
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2316
- variant: "outlined",
2317
- onClick: (C) => h(N)
2318
- }, {
2319
- default: withCtx(() => [
2320
- createElementVNode("div", null, [
2321
- createElementVNode("div", _hoisted_3$3, toDisplayString(v(E).label), 1),
2322
- createElementVNode("div", _hoisted_4$2, toDisplayString(v(E).sublabel), 1)
2323
- ]),
2324
- createVNode(f, {
2325
- icon: "delete",
2326
- variant: "tertiary",
2327
- onClick: (C) => (C.stopPropagation(), x(N))
2328
- }, null, 8, ["onClick"])
2329
- ]),
2330
- _: 2
2331
- }, 1032, ["onClick"]))), 128)),
2332
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filter((E) => E.path.join(".") == ""), (E) => (openBlock(), createBlock(b, {
2333
- key: E.message,
2334
- text: E.message,
2335
- state: "error"
2336
- }, null, 8, ["text"]))), 128)),
2337
- createElementVNode("div", _hoisted_5$2, toDisplayString(unref(a)("connect.template.mission_pool.preview")), 1),
2338
- (openBlock(), createBlock(B, {
2339
- key: 0,
2340
- variant: "outlined",
2341
- class: "p-24 space-y-16 w-fit"
2342
- }, {
2343
- default: withCtx(() => {
2344
- var E, N;
2345
- return [
2346
- createElementVNode("div", _hoisted_6$2, [
2347
- createElementVNode("div", null, [
2348
- createElementVNode("div", _hoisted_7$2, toDisplayString(unref(a)("connect.template.mission_pool.collect_stamps", { end: e.mission.end })) + " " + toDisplayString(((E = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : E.earningOption.amount) > 1 ? (N = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : N.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? p(e.modelValue[e.modelValue.length - 1]) : ""), 1),
2349
- createElementVNode("div", _hoisted_8$2, toDisplayString(unref(a)("connect.template.mission_pool.earn_stamp")), 1)
2350
- ])
2351
- ]),
2352
- createElementVNode("div", _hoisted_9$2, [
2353
- createVNode(_sfc_main$5, {
2354
- type: e.mission.type,
2355
- "max-range": e.mission.end,
2356
- currentRange: e.mission.end / 4,
2357
- markers: e.modelValue.map((C) => C.threshold)
2358
- }, null, 8, ["type", "max-range", "currentRange", "markers"]),
2359
- e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_10$2, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
2360
- ])
2361
- ];
2362
- }),
2363
- _: 1
2364
- })),
2365
- createVNode(_sfc_main$6, {
2366
- ref_key: "sheetRef",
2367
- ref: r,
2368
- "onUpdate:modelValue": y,
2369
- "max-threshold": e.mission.end
2370
- }, null, 8, ["max-threshold"])
2371
- ]);
2372
- };
2373
- }
2374
- }), _hoisted_1$3 = { class: "space-y-16" }, _hoisted_2$2 = { class: "space-y-8" }, _hoisted_3$2 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_5$1 = { class: "grid grid-cols-2 gap-16" }, _hoisted_6$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_7$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_8$1 = { class: "space-y-8" }, _hoisted_9$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_10$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
2375
- __name: "MissionInput",
2376
- props: {
2377
- modelValue: Object
2378
- },
2379
- emits: ["update:model-value"],
2380
- setup(e, { emit: m }) {
2381
- const { t: a } = useI18n(), u = e, i = computed(() => {
2382
- const o = FdoMission.safeParse(u.modelValue);
2383
- return o.success ? [] : o.error.errors;
2384
- }), s = computed(() => [
2385
- {
2386
- label: a("connect.campaign.mission.typeOption.STAMP.label"),
2387
- description: a("connect.campaign.mission.typeOption.STAMP.description"),
2388
- value: F_MISSION_TYPE.enum.STAMP
2389
- },
2390
- {
2391
- label: a("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
2392
- description: a("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
2393
- value: F_MISSION_TYPE.enum.PROGRESSIVE
2394
- }
2395
- ]), l = m;
2396
- return (o, n) => {
2397
- var v;
2398
- const r = resolveComponent("FmCard"), y = resolveComponent("FmStepperField");
2399
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
2400
- createElementVNode("div", _hoisted_2$2, [
2401
- createElementVNode("div", _hoisted_3$2, toDisplayString(unref(a)("connect.campaign.mission.missionType")), 1),
2402
- createElementVNode("div", _hoisted_4$1, toDisplayString(unref(a)("connect.template.select_game")), 1),
2403
- createElementVNode("div", _hoisted_5$1, [
2404
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (h) => {
2405
- var x, k;
2406
- return openBlock(), createBlock(r, {
2407
- variant: "outlined",
2408
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2409
- "col-span-2": unref(s).length == 1,
2410
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((x = e.modelValue) == null ? void 0 : x.type) == h.value,
2411
- "hover:bg-fm-color-opacity-sm": ((k = e.modelValue) == null ? void 0 : k.type) != h.value
2412
- }]),
2413
- onClick: () => {
2414
- var p, d;
2415
- ((p = e.modelValue) == null ? void 0 : p.type) != h.value && l("update:model-value", {
2416
- ...e.modelValue,
2417
- type: h.value,
2418
- end: ((d = e.modelValue) == null ? void 0 : d.end) || 1
2419
- });
2420
- },
2421
- key: h.value
2422
- }, {
2423
- default: withCtx(() => [
2424
- createElementVNode("div", _hoisted_6$1, toDisplayString(h.label), 1),
2425
- createElementVNode("div", _hoisted_7$1, toDisplayString(h.description), 1)
2426
- ]),
2427
- _: 2
2428
- }, 1032, ["class", "onClick"]);
2429
- }), 128))
2430
- ])
2431
- ]),
2432
- createElementVNode("div", _hoisted_8$1, [
2433
- createElementVNode("div", _hoisted_9$1, toDisplayString(unref(a)("connect.campaign.mission.collectionsRequired")), 1),
2434
- createElementVNode("div", _hoisted_10$1, toDisplayString(unref(a)("connect.campaign.mission.collectionsRequiredDescription")), 1),
2435
- createVNode(y, {
2436
- label: unref(a)("connect.campaign.mission.maximumToCollect"),
2437
- "model-value": ((v = e.modelValue) == null ? void 0 : v.end) || null,
2438
- "onUpdate:modelValue": n[0] || (n[0] = (h) => {
2439
- var x;
2440
- return l("update:model-value", {
2441
- ...e.modelValue,
2442
- type: ((x = e.modelValue) == null ? void 0 : x.type) || "STAMP",
2443
- end: h
2444
- });
2445
- }),
2446
- "helper-text": unref(ZodHelper).helperText(unref(i), "end") || unref(a)("connect.campaign.mission.thresholdHelperText"),
2447
- "helper-state": unref(ZodHelper).helperState(unref(i), "end") || "none"
2448
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"])
2449
- ])
2450
- ]);
2451
- };
2452
- }
2453
- });
2454
- function useLocaleText() {
2455
- const { locale: e, t: m } = useI18n();
2456
- function a(u, i) {
2457
- return u ? u[e.value] ?? u["en-US"] ?? m(i) : m(i);
2458
- }
2459
- return { getLocaleText: a };
2460
- }
2461
- const _hoisted_1$2 = { key: 29 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
2462
- __name: "TemplateInput",
2463
- props: {
2464
- field: { type: Object, required: !0 },
2465
- modelValue: {
2466
- type: Object
2467
- },
2468
- schema: {
2469
- type: Object
2470
- },
2471
- extras: {
2472
- type: Object
2473
- },
2474
- helperText: {
2475
- type: String
2476
- },
2477
- disabled: {
2478
- type: Boolean,
2479
- default: !1
2480
- },
2481
- campaignType: {
2482
- type: String,
2483
- default: void 0
2484
- }
2485
- },
2486
- emits: ["update:model-value", "update:file"],
2487
- setup(e, { emit: m }) {
2488
- const { t: a } = useI18n(), { getLocaleText: u } = useLocaleText(), i = e, s = m;
2489
- function l(y) {
2490
- switch (i.field.type) {
2491
- case "timeframe":
2492
- const v = y.startDate ? hooks(y.startDate).startOf("day").toISOString() : void 0, h = y.endDate ? hooks(y.endDate).endOf("day").toISOString() : void 0;
2493
- s("update:model-value", {
2494
- type: "timeframe",
2495
- property: "__now",
2496
- start: v,
2497
- end: h
2498
- });
2499
- break;
2500
- case "image": {
2501
- s(
2502
- "update:file",
2503
- y,
2504
- o.value || firebaseStorage.collectibleImagePath(void 0, y)
2505
- );
2506
- break;
2507
- }
2508
- default:
2509
- s("update:model-value", y);
2510
- break;
2511
- }
2512
- }
2513
- const o = computed(() => {
2514
- switch (i.field.type) {
2515
- case "timeframe": {
2516
- const y = i.modelValue;
2517
- return {
2518
- startDate: y != null && y.start ? hooks(y == null ? void 0 : y.start).format("YYYY-MM-DD") : null,
2519
- endDate: y != null && y.end ? hooks(y == null ? void 0 : y.end).format("YYYY-MM-DD") : null
2520
- };
2521
- }
2522
- default:
2523
- return i.modelValue;
2524
- }
2525
- });
2526
- function n() {
2527
- if (!r.value.schema) return [];
2528
- const y = r.value.schema.safeParse(i.modelValue);
2529
- return y.success ? [] : y.error.errors;
2530
- }
2531
- const r = computed(() => ({
2532
- schema: i.schema,
2533
- unwrapped: i.schema ? ZodHelper.unwrap(i.schema) : void 0,
2534
- rules: i.schema ? [ZodHelper.ruleAtPath(i.schema, "")] : void 0,
2535
- labelMark: i.schema && ZodHelper.isRequired(i.schema) == !1 ? "optional" : void 0,
2536
- zodLabel: i.schema ? ZodHelper.toInputLabel(
2537
- i.schema,
2538
- u(i.field.label_locale, i.field.label ?? "")
2539
- ) : void 0
2540
- }));
2541
- return (y, v) => {
2542
- var c, f, B, b, E;
2543
- const h = resolveComponent("FmTextField"), x = resolveComponent("FmStepperField"), k = resolveComponent("FmTextarea"), p = resolveComponent("FmHelperText"), d = resolveComponent("FmSwitch");
2544
- return e.field.type === "text" ? (openBlock(), createBlock(h, {
2545
- key: 0,
2546
- label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2547
- "label-mark": unref(r).labelMark,
2548
- rules: unref(r).rules,
2549
- "model-value": unref(o),
2550
- "onUpdate:modelValue": l,
2551
- "helper-state": e.helperText ? "error" : void 0,
2552
- "helper-text": e.helperText
2553
- }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2554
- createVNode(JsonViewer, {
2555
- json: { schema: unref(r).unwrapped, props: i }
2556
- }, null, 8, ["json"]),
2557
- createVNode(x, {
2558
- label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2559
- "label-mark": e.field.isRuleChildren ? void 0 : unref(r).labelMark,
2560
- "model-value": unref(o),
2561
- rules: e.field.isRuleChildren ? [] : unref(r).rules,
2562
- "onUpdate:modelValue": l,
2563
- "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
2564
- "helper-text": e.field.isRuleChildren ? e.helperText : void 0
2565
- }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
2566
- ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(k, {
2567
- key: 2,
2568
- label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2569
- "label-mark": unref(r).labelMark,
2570
- rules: unref(r).rules,
2571
- "model-value": unref(o),
2572
- "onUpdate:modelValue": l,
2573
- "show-word-count": "",
2574
- "max-length": (E = (b = (B = (f = (c = unref(r)) == null ? void 0 : c.unwrapped) == null ? void 0 : f._def) == null ? void 0 : B.checks) == null ? void 0 : b.find((N) => N.kind == "max")) == null ? void 0 : E.value
2575
- }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$i, {
2576
- key: 3,
2577
- "campaign-type": e.extras,
2578
- "model-value": unref(o),
2579
- disabled: e.disabled,
2580
- "onUpdate:modelValue": l
2581
- }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
2582
- createVNode(_sfc_main$g, {
2583
- "model-value": unref(o),
2584
- "onUpdate:modelValue": l
2585
- }, null, 8, ["model-value"]),
2586
- createVNode(p, {
2587
- class: "!mt-[8px]",
2588
- text: unref(ZodHelper).helperText(n(), ""),
2589
- state: unref(ZodHelper).helperState(n(), "")
2590
- }, null, 8, ["text", "state"])
2591
- ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$u, {
2592
- key: 5,
2593
- thumbnail: unref(o),
2594
- "aspect-ratio": "16 / 9",
2595
- class: "w-1/2 xs:w-2/3",
2596
- "onUpdate:file": l
2597
- }, {
2598
- label: withCtx(() => [
2599
- (openBlock(), createBlock(resolveDynamicComponent(unref(r).zodLabel)))
2600
- ]),
2601
- _: 1
2602
- }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(d, {
2603
- key: 6,
2604
- label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2605
- "label-placement": "right",
2606
- sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
2607
- "label-mark": unref(r).labelMark,
2608
- rules: unref(r).rules,
2609
- "model-value": unref(o),
2610
- "onUpdate:modelValue": l
2611
- }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$v, {
2612
- key: 7,
2613
- "model-value": unref(o),
2614
- "onUpdate:modelValue": l,
2615
- "no-campaign": !1,
2616
- schema: unref(r).schema,
2617
- "is-mission": e.extras === "MISSION"
2618
- }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "grab_conditions" ? (openBlock(), createBlock(GrabConditionsInput, {
2619
- key: 8,
2620
- "model-value": unref(o),
2621
- "onUpdate:modelValue": l,
2622
- schema: unref(r).schema
2623
- }, null, 8, ["model-value", "schema"])) : e.field.type === "grab_quota" ? (openBlock(), createBlock(_sfc_main$9, {
2624
- key: 9,
2625
- "model-value": unref(o),
2626
- "onUpdate:modelValue": l,
2627
- schema: unref(r).schema
2628
- }, null, 8, ["model-value", "schema"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$w, {
2629
- key: 10,
2630
- "model-value": unref(o),
2631
- "onUpdate:modelValue": l
2632
- }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 11 }, [
2633
- createVNode(_sfc_main$x, {
2634
- "model-value": unref(o),
2635
- "onUpdate:modelValue": l,
2636
- "can-set-auto-apply": e.field.property == "campaign.effect"
2637
- }, null, 8, ["model-value", "can-set-auto-apply"]),
2638
- unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(p, {
2639
- key: 0,
2640
- class: "!mt-[8px]",
2641
- text: unref(a)("connect.campaign.common.effect_required"),
2642
- state: "error"
2643
- }, null, 8, ["text"]))
2644
- ], 64)) : e.field.type == "grab_effect" ? (openBlock(), createElementBlock(Fragment, { key: 12 }, [
2645
- createVNode(GrabEffectSheet, {
2646
- "model-value": unref(o),
2647
- "onUpdate:modelValue": l
2648
- }, null, 8, ["model-value"]),
2649
- unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(p, {
2650
- key: 0,
2651
- class: "!mt-[8px]",
2652
- text: unref(a)("connect.campaign.common.effect_required"),
2653
- state: "error"
2654
- }, null, 8, ["text"]))
2655
- ], 64)) : e.field.type === "message" ? (openBlock(), createBlock(_sfc_main$y, {
2656
- key: 13,
2657
- "allow-email": !0,
2658
- "allow-whatsapp": !0,
2659
- "model-value": unref(o),
2660
- "onUpdate:modelValue": l,
2661
- "helper-text": unref(ZodHelper).helperText(n(), ""),
2662
- "trigger-type": e.field.extras,
2663
- "helper-state": unref(ZodHelper).helperState(n(), "")
2664
- }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"])) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$r, {
2665
- key: 14,
2666
- "model-value": unref(o),
2667
- "onUpdate:modelValue": l,
2668
- extras: e.extras,
2669
- "error-text": e.helperText
2670
- }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$s, {
2671
- key: 15,
2672
- type: "custom",
2673
- "model-value": unref(o),
2674
- "onUpdate:modelValue": l,
2675
- "helper-text": e.helperText || unref(ZodHelper).helperText(n(), ""),
2676
- "for-credit": i.campaignType === "CREDIT"
2677
- }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$e, {
2678
- key: 16,
2679
- "model-value": unref(o),
2680
- "onUpdate:modelValue": l
2681
- }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$c, {
2682
- key: 17,
2683
- "model-value": unref(o),
2684
- "onUpdate:modelValue": l
2685
- }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
2686
- key: 18,
2687
- "model-value": unref(o),
2688
- "onUpdate:modelValue": l
2689
- }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
2690
- key: 19,
2691
- "model-value": unref(o),
2692
- "onUpdate:modelValue": l
2693
- }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
2694
- key: 20,
2695
- "model-value": unref(o),
2696
- "onUpdate:modelValue": l,
2697
- "helper-text": unref(ZodHelper).helperText(n(), ""),
2698
- "helper-state": unref(ZodHelper).helperState(n(), "")
2699
- }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
2700
- key: 21,
2701
- "model-value": unref(o),
2702
- "onUpdate:modelValue": l,
2703
- mission: e.extras.mission
2704
- }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
2705
- createVNode(_sfc_main$f, {
2706
- "model-value": unref(o),
2707
- "onUpdate:modelValue": l,
2708
- "start-date": e.extras.start,
2709
- "end-date": e.extras.end
2710
- }, null, 8, ["model-value", "start-date", "end-date"]),
2711
- e.helperText ? (openBlock(), createBlock(p, {
2712
- key: 0,
2713
- class: "!mt-[8px]",
2714
- text: e.helperText,
2715
- state: "error"
2716
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2717
- ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
2718
- createVNode(_sfc_main$z, {
2719
- "model-value": unref(o),
2720
- "onUpdate:modelValue": l
2721
- }, null, 8, ["model-value"]),
2722
- e.helperText ? (openBlock(), createBlock(p, {
2723
- key: 0,
2724
- class: "!mt-[8px]",
2725
- text: e.helperText,
2726
- state: "error"
2727
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2728
- ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
2729
- e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(o).rules.g_time).length > 0 ? (openBlock(), createBlock(p, {
2730
- key: 0,
2731
- state: "warning",
2732
- text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
2733
- }, null, 8, ["text"])) : createCommentVNode("", !0),
2734
- createVNode(_sfc_main$k, {
2735
- "model-value": unref(o),
2736
- "onUpdate:modelValue": l
2737
- }, null, 8, ["model-value"]),
2738
- e.helperText ? (openBlock(), createBlock(p, {
2739
- key: 1,
2740
- class: "!mt-[8px]",
2741
- text: e.helperText,
2742
- state: "error"
2743
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2744
- ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
2745
- createVNode(_sfc_main$A, {
2746
- "model-value": unref(o),
2747
- "onUpdate:modelValue": l
2748
- }, null, 8, ["model-value"]),
2749
- e.helperText ? (openBlock(), createBlock(p, {
2750
- key: 0,
2751
- class: "!mt-[8px]",
2752
- text: e.helperText,
2753
- state: "error"
2754
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2755
- ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 26 }, [
2756
- createVNode(_sfc_main$B, {
2757
- "model-value": unref(o),
2758
- "onUpdate:modelValue": l
2759
- }, null, 8, ["model-value"]),
2760
- e.helperText ? (openBlock(), createBlock(p, {
2761
- key: 0,
2762
- class: "!mt-[8px]",
2763
- text: e.helperText,
2764
- state: "error"
2765
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2766
- ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 27 }, [
2767
- createVNode(_sfc_main$j, {
2768
- "model-value": unref(o),
2769
- "onUpdate:modelValue": l
2770
- }, null, 8, ["model-value"]),
2771
- e.helperText ? (openBlock(), createBlock(p, {
2772
- key: 0,
2773
- class: "!mt-[8px]",
2774
- text: e.helperText,
2775
- state: "error"
2776
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2777
- ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 28 }, [
2778
- createVNode(_sfc_main$b, {
2779
- "model-value": unref(o),
2780
- "onUpdate:modelValue": l
2781
- }, null, 8, ["model-value"]),
2782
- e.helperText ? (openBlock(), createBlock(p, {
2783
- key: 0,
2784
- class: "!mt-[8px]",
2785
- text: e.helperText,
2786
- state: "error"
2787
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2788
- ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(i.field), 1));
2789
- };
2790
- }
2791
- }), _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({
2792
- __name: "CampaignSummary",
2793
- props: {
2794
- data: {
2795
- type: Object,
2796
- required: !0
2797
- }
2798
- },
2799
- setup(e) {
2800
- const { t: m, te: a } = useI18n();
2801
- return (u, i) => {
2802
- const s = resolveComponent("FmCard");
2803
- return openBlock(), createBlock(s, {
2804
- variant: "outlined",
2805
- class: "p-16 space-y-8"
2806
- }, {
2807
- default: withCtx(() => [
2808
- createElementVNode("div", _hoisted_1$1, toDisplayString(unref(m)("connect.campaign.common.summary")), 1),
2809
- i[0] || (i[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
2810
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (l, o) => (openBlock(), createElementBlock("div", {
2811
- class: "space-y-4",
2812
- key: o
2813
- }, [
2814
- l ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2815
- createElementVNode("div", _hoisted_2$1, toDisplayString(unref(m)(`${o}`)), 1),
2816
- createElementVNode("div", _hoisted_3$1, toDisplayString(unref(a)(`${l}`) ? unref(m)(`${l}`) : l), 1)
2817
- ], 64)) : createCommentVNode("", !0)
2818
- ]))), 128))
2819
- ]),
2820
- _: 1
2821
- });
2822
- };
2823
- }
2824
- }), _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 = {
2825
- key: 0,
2826
- class: "max-w-6xl mx-auto"
2827
- }, _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({
2828
- __name: "EditCampaignSheet",
2829
- emits: ["submit:model-value"],
2830
- setup(__props, { expose: __expose, emit: __emit }) {
2831
- const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), { getLocaleText } = useLocaleText(), currentStep = ref(1), data = ref(), schema = ref(z.any()), template = ref(
2832
- TEMPLATES.VOUCHER
2833
- ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER");
2834
- async function showSheet(visible, type, campaign, selectedTemplate) {
2835
- var e, m;
2836
- if (sheetVisible.value = visible, campaignType.value = type, visible == !0) {
2837
- try {
2838
- isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
2839
- } catch {
2840
- } finally {
2841
- await new Promise((a) => setTimeout(a, 120)), isLoading.value = !1;
2842
- }
2843
- console.log(
2844
- TEMPLATES[type],
2845
- "base template"
2846
- ), template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((a, u) => {
2847
- a.campaign.type === "VOUCHER" && a.campaign.code && useCampaignStore().campaigns.voucher.some(
2848
- (i) => i.code === a.campaign.code && i._id.toString() !== a.campaign._id.toString()
2849
- ) && u.addIssue({
2850
- code: "custom",
2851
- message: "Code already exists, please use another code",
2852
- path: ["campaign", "code"]
2853
- });
2854
- })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
2855
- ...(m = template.value) == null ? void 0 : m.defaultValue
2856
- }), "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 ? t("connect.campaign.common.edit_campaign_title", {
2857
- typeName: t(`connect.campaign.common.typeName.${type}`)
2858
- }) : t("connect.campaign.common.create_campaign_title", {
2859
- typeName: t(`connect.campaign.common.typeName.${type}`)
2860
- });
2861
- }
2862
- }
2863
- async function hideSheet() {
2864
- Dialog.open({
2865
- title: t("connect.campaign.common.unsaved_changes"),
2866
- message: t("connect.campaign.common.unsaved_changes"),
2867
- primaryActions: {
2868
- text: t("connect.campaign.common.unsaved_changes_confirm"),
2869
- close: !0
2870
- },
2871
- secondaryActions: {
2872
- text: t("connect.campaign.common.unsaved_changes_cancel"),
2873
- close: !1
2874
- }
2875
- }).onPrimary(() => {
2876
- sheetVisible.value = !1;
2877
- }).onSecondary(() => {
2878
- Dialog.close();
2879
- });
2880
- }
2881
- const emits = __emit, errors = computed(() => {
2882
- const e = schema.value.superRefine(campaignRefinement).safeParse(data.value);
2883
- return e.success ? [] : e.error.errors;
2884
- });
2885
- function stepErrors(e = currentStep.value - 1) {
2886
- const m = template.value.steps[e].groups.flatMap(
2887
- (a) => a.fields.map((u) => u.property)
2888
- );
2889
- return errors.value.filter(
2890
- (a) => m.some((u) => a.path.join(".").includes(u))
2891
- );
2892
- }
2893
- __expose({ showSheet });
2894
- function showSummaryDialog() {
2895
- Dialog.open({
2896
- title: "",
2897
- dialogComponent: _sfc_main$1,
2898
- dialogComponentProps: {
2899
- data: data.value
2900
- }
2901
- });
2902
- }
2903
- function onUpdateProperty(e, m) {
2904
- var a, u, i, s, l, o, n, r;
2905
- if (_.set(data.value, e, m), e == "campaign.event.type") {
2906
- const v = ((s = (i = (u = (a = template.value) == null ? void 0 : a.defaultValue) == null ? void 0 : u.campaign) == null ? void 0 : i.event) == null ? void 0 : s.rule) ? _.cloneDeep({
2907
- ...(r = (n = (o = (l = template.value) == null ? void 0 : l.defaultValue) == null ? void 0 : o.campaign) == null ? void 0 : n.event) == null ? void 0 : r.rule
2908
- }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
2909
- RuleBuilder.scaffoldGroup("g_schedule"),
2910
- RuleBuilder.scaffoldGroup("g_time"),
2911
- RuleBuilder.scaffoldGroup("g_user"),
2912
- RuleBuilder.scaffoldGroup("g_bill")
2913
- ]), h = RuleBuilder.setRuleToGroup(
2914
- RuleBuilder.scaffoldGroup("g_schedule"),
2915
- [
2916
- RuleBuilder.constructEntry(
2917
- "trigger.date",
2918
- "_rrule",
2919
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
2920
- ),
2921
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2922
- ],
2923
- "&&"
2924
- );
2925
- if (m != "SCHEDULE") {
2926
- _.set(data.value, "campaign.event.rule", v);
2927
- return;
2928
- }
2929
- _.set(
2930
- data.value,
2931
- "campaign.event.rule",
2932
- RuleBuilder.setRuleToGroup(v, h)
2933
- );
2934
- }
2935
- e == "campaign.notify" && m == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
2936
- }
2937
- async function onUpdateFile(e, m) {
2938
- return e ? await minor(async () => firebaseStorage.update(m, e), {
2939
- message: `${e ? "Uploading" : "Removing"} file`,
2940
- successMessage: `File ${e ? "uploaded" : "removed"} successfully`
2941
- }) : "";
2942
- }
2943
- function isDisable(e) {
2944
- var m, a;
2945
- switch (e == null ? void 0 : e.property) {
2946
- case "campaign.event.type":
2947
- return ((a = (m = data.value) == null ? void 0 : m.campaign) == null ? void 0 : a._id) || !1;
2948
- default:
2949
- return !1;
2950
- }
2951
- }
2952
- async function onSubmit() {
2953
- const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
2954
- if (!e.success)
2955
- return;
2956
- const m = await emits(
2957
- "submit:model-value",
2958
- cleanPF(JSON.parse(JSON.stringify(e.data)))
2959
- );
2960
- (m || m === void 0) && (sheetVisible.value = !1);
2961
- }
2962
- return (e, m) => {
2963
- const a = resolveComponent("FmButton"), u = resolveComponent("FmStep"), i = resolveComponent("FmStepper"), s = resolveComponent("FmCard"), l = resolveComponent("FmTopSheet");
2964
- return openBlock(), createBlock(l, {
2965
- "fullscreen-size": "lg",
2966
- modelValue: unref(sheetVisible),
2967
- "onUpdate:modelValue": [
2968
- m[7] || (m[7] = (o) => isRef(sheetVisible) ? sheetVisible.value = o : null),
2969
- m[8] || (m[8] = (o) => sheetVisible.value = o)
2970
- ]
2971
- }, createSlots({
2972
- "top-sheet-header": withCtx(() => [
2973
- createElementVNode("div", _hoisted_1, [
2974
- createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
2975
- createElementVNode("div", _hoisted_2, [
2976
- createVNode(a, {
2977
- onClick: m[0] || (m[0] = (o) => hideSheet()),
2978
- label: unref(t)("connect.campaign.common.cancel"),
2979
- variant: "tertiary"
2980
- }, null, 8, ["label"]),
2981
- createVNode(a, {
2982
- onClick: onSubmit,
2983
- label: unref(t)("connect.campaign.common.save"),
2984
- disabled: unref(errors).length > 0
2985
- }, null, 8, ["label", "disabled"])
2986
- ])
2987
- ])
2988
- ]),
2989
- _: 2
2990
- }, [
2991
- unref(isLoading) ? {
2992
- name: "default",
2993
- fn: withCtx(() => [
2994
- createElementVNode("div", _hoisted_9, [
2995
- createElementVNode("div", _hoisted_10, [
2996
- createElementVNode("div", _hoisted_11, [
2997
- m[9] || (m[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
2998
- createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
2999
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
3000
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
3001
- createElementVNode("div", { class: "space-y-3" }, [
3002
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
3003
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
3004
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3005
- ]),
3006
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3007
- ]),
3008
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
3009
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
3010
- createElementVNode("div", { class: "space-y-3" }, [
3011
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
3012
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
3013
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3014
- ]),
3015
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3016
- ])
3017
- ])
3018
- ], -1)),
3019
- createVNode(s, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
3020
- ])
3021
- ])
3022
- ])
3023
- ]),
3024
- key: "1"
3025
- } : {
3026
- name: "default",
3027
- fn: withCtx(() => [
3028
- unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
3029
- createVNode(i, {
3030
- modelValue: unref(currentStep),
3031
- "onUpdate:modelValue": m[1] || (m[1] = (o) => isRef(currentStep) ? currentStep.value = o : null),
3032
- orientation: "horizontal",
3033
- class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
3034
- }, {
3035
- default: withCtx(() => [
3036
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, n) => (openBlock(), createBlock(u, {
3037
- key: o.name,
3038
- title: unref(getLocaleText)(o.name_locale, o.name),
3039
- value: n + 1,
3040
- error: () => stepErrors(n).length > 0,
3041
- complete: () => n + 1 <= unref(currentStep)
3042
- }, null, 8, ["title", "value", "error", "complete"]))), 128))
3043
- ]),
3044
- _: 1
3045
- }, 8, ["modelValue"]),
3046
- createElementVNode("div", _hoisted_4, [
3047
- createVNode(a, {
3048
- icon: "close",
3049
- variant: "tertiary",
3050
- onClick: m[2] || (m[2] = (o) => sheetVisible.value = !1)
3051
- }),
3052
- createVNode(i, {
3053
- modelValue: unref(currentStep),
3054
- "onUpdate:modelValue": m[3] || (m[3] = (o) => isRef(currentStep) ? currentStep.value = o : null),
3055
- orientation: "horizontal",
3056
- class: "flex-1"
3057
- }, {
3058
- default: withCtx(() => [
3059
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, n) => (openBlock(), createBlock(u, {
3060
- key: o.name,
3061
- title: unref(sheetTitle),
3062
- description: unref(getLocaleText)(o.name_locale, o.name),
3063
- value: n + 1,
3064
- error: () => stepErrors(n).length > 0,
3065
- complete: () => n + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
3066
- }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
3067
- ]),
3068
- _: 1
3069
- }, 8, ["modelValue"]),
3070
- createVNode(a, {
3071
- icon: "info",
3072
- variant: "tertiary",
3073
- onClick: m[4] || (m[4] = () => showSummaryDialog())
3074
- })
3075
- ]),
3076
- createElementVNode("div", _hoisted_5, [
3077
- createElementVNode("div", _hoisted_6, [
3078
- createVNode(JsonViewer, {
3079
- json: {
3080
- data: unref(data),
3081
- errors: unref(errors).map(
3082
- (o) => `${o.path.join(".")} - ${o.message}`
3083
- ),
3084
- stepErrors: stepErrors().map(
3085
- (o) => `${o.path.join(".")} - ${o.message}`
3086
- ),
3087
- schema: unref(schema)
3088
- }
3089
- }, null, 8, ["json"]),
3090
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
3091
- (o) => o.fields.length && (!o.condition || (Array.isArray(o.condition) ? o.condition.every((n) => unref(_).get(unref(data), n.property) == n.value == (n.not != !0)) : unref(_).get(unref(data), o.condition.property) == o.condition.value == (o.condition.not != !0)))
3092
- ), (o, n) => (openBlock(), createElementBlock("div", {
3093
- key: n,
3094
- class: "space-y-24"
3095
- }, [
3096
- createElementVNode("div", _hoisted_7, toDisplayString(unref(getLocaleText)(o.name_locale, o.name ?? "")), 1),
3097
- (openBlock(!0), createElementBlock(Fragment, null, renderList(o.fields, (r, y) => (openBlock(), createElementBlock("div", { key: y }, [
3098
- (openBlock(), createBlock(_sfc_main$2, {
3099
- key: y,
3100
- field: r,
3101
- modelValue: unref(_).get(unref(data), r.property),
3102
- disabled: isDisable(r),
3103
- "campaign-type": unref(campaignType),
3104
- "onUpdate:modelValue": (v) => onUpdateProperty(r.property, v),
3105
- "onUpdate:file": async (v, h) => {
3106
- const x = await onUpdateFile(v, h);
3107
- onUpdateProperty(r.property, x || "");
3108
- },
3109
- schema: unref(ZodHelper).typeAtPath(
3110
- unref(schema),
3111
- r.property,
3112
- unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
3113
- ),
3114
- "helper-state": unref(ZodHelper).helperState(unref(errors), r.property),
3115
- "helper-text": unref(ZodHelper).helperText(unref(errors), r.property),
3116
- extras: r.extras != null ? r.extras == "" ? unref(data) : unref(_).get(unref(data), r.extras) : void 0
3117
- }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
3118
- ]))), 128))
3119
- ]))), 128)),
3120
- createElementVNode("div", _hoisted_8, [
3121
- createVNode(a, {
3122
- label: unref(t)("connect.common.back"),
3123
- variant: "tertiary",
3124
- disabled: unref(currentStep) == 1,
3125
- onClick: m[5] || (m[5] = (o) => currentStep.value--)
3126
- }, null, 8, ["label", "disabled"]),
3127
- createVNode(a, {
3128
- disabled: unref(currentStep) - 1 < unref(template).steps.length - 1 ? stepErrors().length > 0 : unref(errors).length > 0,
3129
- label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? unref(t)("connect.common.next") : unref(t)("connect.common.submit"),
3130
- onClick: m[6] || (m[6] = (o) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? currentStep.value++ : onSubmit())
3131
- }, null, 8, ["disabled", "label"])
3132
- ])
3133
- ]),
3134
- createVNode(_sfc_main$1, {
3135
- data: unref(data),
3136
- class: "xs:hidden"
3137
- }, null, 8, ["data"])
3138
- ])
3139
- ])) : createCommentVNode("", !0)
3140
- ]),
3141
- key: "0"
3142
- }
3143
- ]), 1032, ["modelValue"]);
3144
- };
3145
- }
3146
- });
3147
- export {
3148
- _sfc_main as _,
3149
- summarizeGrabDiscount as s,
3150
- useLocaleText as u
3151
- };