@feedmepos/mf-connect 0.1.38-beta.70 → 0.1.38-beta.72

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