@feedmepos/mf-connect 0.1.98-beta.14 → 0.1.98-beta.15

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