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

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