@feedmepos/mf-connect 0.1.114-prod → 0.1.115-dev

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 (157) hide show
  1. package/README.md +66 -1
  2. package/dist/{App-DMYXrCc7.js → App-43mZfFAr.js} +700 -654
  3. package/dist/AuditLogs-BPpdm96t.js +2016 -0
  4. package/dist/{Bin-CHZolo56.js → Bin-CA7v180Y.js} +8 -8
  5. package/dist/Broadcast-qmdifF2Y.js +306 -0
  6. package/dist/{CampaignAnalytic-DgZvsUoF.js → CampaignAnalytic-xnrDxqaH.js} +7 -7
  7. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-C42uL_JO.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-zjk-QdtX.js} +9 -9
  8. package/dist/{Card-wRFTJwJ9.js → Card-D8icsk7L.js} +25 -24
  9. package/dist/{Collections-9G-_9Etz.js → Collections--THcD-E_.js} +197 -185
  10. package/dist/{Credit-Bl7IDMCU.js → Credit-JrbtVMBp.js} +21 -20
  11. package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-BVLJeofG.js → DateRangeChip.vue_vue_type_script_setup_true_lang-DrwKtnE5.js} +1 -1
  12. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-DgdAlHU7.js +4442 -0
  13. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-Q1f6EQW3.js → EffectSheet.vue_vue_type_style_index_0_lang-hVgqWdD0.js} +32 -32
  14. package/dist/{Experience-Cs2iViLv.js → Experience-CFeRqBoj.js} +32 -31
  15. package/dist/{FileSaver.min-B3Levdbu.js → FileSaver.min-CCXIBm58.js} +1 -1
  16. package/dist/{Game-oXURgzan.js → Game-CPxq6Ex3.js} +19 -18
  17. package/dist/{GiftCardSetup-C2Wu-dRl.js → GiftCardSetup-D0esVZDp.js} +75 -75
  18. package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-Da2e89Um.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-CJ1-vL-K.js} +7 -7
  19. package/dist/{Goals-B_xEM7gf.js → Goals-DaKI6uXt.js} +4 -4
  20. package/dist/Grab-BWzdN_cd.js +301 -0
  21. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-BRJR1heE.js → ImageInput.vue_vue_type_script_setup_true_lang-BOnL0GxM.js} +1 -1
  22. package/dist/{Index-kuT6W6R_.js → Index-2kENoaZm.js} +10 -10
  23. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-7JqHfSk-.js → LocationPicker.vue_vue_type_script_setup_true_lang-BtWnJKU_.js} +1 -1
  24. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-CI_4S7tW.js → LottieAnimation.vue_vue_type_script_setup_true_lang-CX_Sspu5.js} +1 -1
  25. package/dist/{LoyaltyDashboard-CqxHdZcm.js → LoyaltyDashboard-CB93Fz8u.js} +15 -15
  26. package/dist/MainLayout-DwnjGXh6.js +4 -0
  27. package/dist/{MainLayout-CAERFIms.js → MainLayout.vue_vue_type_script_setup_true_lang-Du8fw5v_.js} +5 -4
  28. package/dist/Marketing-DCco__2F.js +273 -0
  29. package/dist/MarketingMaterialEdit-BbgFtrYP.js +1037 -0
  30. package/dist/{Member-B8VZEn9t.js → Member-B--nYyr0.js} +7 -7
  31. package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-B31lVLKh.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-BBlzO7Db.js} +43 -50
  32. package/dist/{MemberImportHistory-D9tgHnTS.js → MemberImportHistory-D52Y4RTC.js} +7 -7
  33. package/dist/{MemberList-Hw_xQY1i.js → MemberList-13Owa1fj.js} +103 -105
  34. package/dist/{MemberTransactions-DiBO4plw.js → MemberTransactions-CpXEWNbq.js} +1 -1
  35. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-CbFt5X89.js → MessageInput.vue_vue_type_script_setup_true_lang-DlELjFM0.js} +4228 -4176
  36. package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-BE_-Ed4z.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-C_y0rM8c.js} +1 -1
  37. package/dist/{Mission-DpYei3aF.js → Mission-Ci-UzXSu.js} +22 -21
  38. package/dist/{Overview-CARquJCS.js → Overview-CKxSfAGF.js} +145 -144
  39. package/dist/{Overview-BFQMmyT6.js → Overview-CXen9Ram.js} +23 -22
  40. package/dist/{Point-Dd2ykwNv.js → Point-CR3YOaag.js} +22 -21
  41. package/dist/{Promotion-DXl-W7np.js → Promotion-tw3J4ul-.js} +137 -131
  42. package/dist/{Queue-Cd3N-4iB.js → Queue-BZGA5ZXt.js} +47 -46
  43. package/dist/{Record-C3HdDsh5.js → Record-BTevVXnT.js} +9 -9
  44. package/dist/{Review-Bif3Ub9Z.js → Review-BU7c8ZF0.js} +2 -2
  45. package/dist/ReviewFacebookCallback-BnMF6Arh.js +225 -0
  46. package/dist/{ReviewGoogleCallback-i-RNLlLm.js → ReviewGoogleCallback-xpdPHSdg.js} +5 -5
  47. package/dist/{Reward-DHxzrR_7.js → Reward-jlA_7cxz.js} +29 -29
  48. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-DcrFlcSo.js → RewardGroup.vue_vue_type_script_setup_true_lang-D3z_n42G.js} +16 -15
  49. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-CsHxqH9h.js +1923 -0
  50. package/dist/{Segment-Cjpxordk.js → Segment-C1Bwm--Q.js} +290 -291
  51. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-6u21xBu6.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-B6apgWTM.js} +31 -30
  52. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-BOXVzfer.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-B7m2F9UV.js} +4 -4
  53. package/dist/Setting-CDM4RhLW.js +574 -0
  54. package/dist/{SettingAdvertisements-aog5fz32.js → SettingAdvertisements-4XEAJzlL.js} +12 -12
  55. package/dist/Settings-D-0tvZRr.js +286 -0
  56. package/dist/{Store-Bq3kw1l2.js → Store-C56dXtc4.js} +31 -30
  57. package/dist/{StoreRewards-ZGXKEM09.js → StoreRewards-DQ1Q6WS6.js} +15 -15
  58. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-LLD91Rz6.js +1319 -0
  59. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-Bvy4NJMd.js +7007 -0
  60. package/dist/{Tier-CfgpEHY7.js → Tier-D4CPZqw7.js} +2576 -687
  61. package/dist/{Title-B2itYWeD.js → Title-DCbwhUic.js} +94 -92
  62. package/dist/{Transaction-hJ5ygIcf.js → Transaction-C5LrasXr.js} +2 -2
  63. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-8BgGlpTh.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Cl9b4mrK.js} +26 -26
  64. package/dist/{Voucher-TG47pGR3.js → Voucher-rrVbNZKR.js} +19 -19
  65. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-CjuXCTxg.js → VoucherEditor.vue_vue_type_script_setup_true_lang-BIq227nz.js} +16 -16
  66. package/dist/WhatsappAccount-oJDo5zTr.js +159 -0
  67. package/dist/WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-aCQCYFYq.js +39 -0
  68. package/dist/WhatsappBot-Cl64wG_F.js +876 -0
  69. package/dist/WhatsappBotLogs-D3uT4EiB.js +372 -0
  70. package/dist/WhatsappBotSettings-Cs1lLxh-.js +705 -0
  71. package/dist/WhatsappLayout-C639d2HP.js +21 -0
  72. package/dist/WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-DpPxWp2x.js +253 -0
  73. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-BRs-gbP0.js → ZodTextField.vue_vue_type_script_setup_true_lang-C39_95SZ.js} +2 -2
  74. package/dist/{app-tPHYkJcQ.js → app-CgimGODl.js} +10610 -8223
  75. package/dist/app.js +4 -3
  76. package/dist/{base.export-BHDVnGj2.js → base.export-D2P6HFvo.js} +2 -2
  77. package/dist/browser-BSAOEeIM.js +1478 -0
  78. package/dist/{business-HLyWfrXY.js → business-Bu5TqSA0.js} +1 -1
  79. package/dist/campaign-BFIXSgdJ.js +400 -0
  80. package/dist/{campaign-5zFgUNLw.js → campaign-zJxttSIk.js} +31 -25
  81. package/dist/{campaign.enum-BOkDnP2g.js → campaign.enum-Dx-Zo68Q.js} +3 -2
  82. package/dist/{campaign.fn-BIAoVtJj.js → campaign.fn-gvjlcEfe.js} +78 -78
  83. package/dist/{collectible.enum-BbZSAfys.js → collectible.enum-Liy2wH3s.js} +1 -1
  84. package/dist/{collection.fn-DPSgBHnz.js → collection.fn-DOm0HsSh.js} +2 -2
  85. package/dist/{currency-BVrMqU6-.js → currency-BpbQvbm8.js} +1 -1
  86. package/dist/duplicateCampaign-CvsvjRE9.js +51 -0
  87. package/dist/{effect-BBifVx76.js → effect-D-GtNB3n.js} +1 -1
  88. package/dist/{email-addresses-9C7xHTNv.js → email-addresses-BKMoAtMi.js} +2 -2
  89. package/dist/feature-flag-BJ_eyKsq.js +868 -0
  90. package/dist/feature-flag-Bo-k5sIG.js +50 -0
  91. package/dist/google-BQK68wbe.js +5 -0
  92. package/dist/{helper-C08jyQNK.js → helper-CkfjBgMM.js} +1 -1
  93. package/dist/{index-Dhyqf1s8.js → index-B6kU3PkV.js} +2700 -2613
  94. package/dist/{index-BgwZGunW.js → index-BAtUrtqM.js} +19 -6
  95. package/dist/index-BKsxIwbi.js +14571 -0
  96. package/dist/{index-DZ-q5O-V.js → index-BdEXUNoG.js} +4 -4
  97. package/dist/{index-hIUtD2eY.js → index-Bhl5IRXy.js} +11 -10
  98. package/dist/{index-kCbkOivd.js → index-BpTIulTX.js} +1 -1
  99. package/dist/index-C-iwb2Ln.js +109 -0
  100. package/dist/{index-Ciw2TZxV.js → index-CCEXSPxk.js} +8 -7
  101. package/dist/{index-CUle4c2B.js → index-CIej31pF.js} +4 -3
  102. package/dist/{index-ihw-WFCa.js → index-CQ8XFbBk.js} +2 -2
  103. package/dist/index-C_H8jFYf.js +2743 -0
  104. package/dist/{index-CEe1kJ0T.js → index-CfQuYqXn.js} +1 -1
  105. package/dist/{index-C_WoO58V.js → index-CuREApMc.js} +8 -7
  106. package/dist/{index-NJSI4wX4.js → index-D0JK99Ko.js} +693 -231
  107. package/dist/{index-DnRMNmUA.js → index-DKxN1mMS.js} +396 -232
  108. package/dist/index-DQ8JJhxs.js +74 -0
  109. package/dist/{index-D24Q28cH.js → index-DUAZOMVJ.js} +1 -1
  110. package/dist/{index-Yo0tP8KJ.js → index-DqGs6RJG.js} +683 -581
  111. package/dist/{index-B_334Y_i.js → index-DwU3fsLW.js} +29 -15
  112. package/dist/{index-hSRM1smQ.js → index-LygS9WsG.js} +8028 -10767
  113. package/dist/{index-96ZiAKj_.js → index-feCrYhi6.js} +1 -1
  114. package/dist/{index-Dk-jg0wN.js → index-zTvr2GR4.js} +2 -2
  115. package/dist/{index.esm2017-hN99SQTb.js → index.esm2017-DZi9IQPS.js} +209 -209
  116. package/dist/{loading-CVuY4vQ4.js → loading-Brid2wnu.js} +1 -1
  117. package/dist/{lodash-GFl9_FMH.js → lodash-C1epw3Kv.js} +1 -1
  118. package/dist/{member-import-CshTzabx.js → member-import-DAIxTIiu.js} +6 -5
  119. package/dist/{membership-S0KES3Ex.js → membership-BZmljFhF.js} +3 -3
  120. package/dist/{money-JxdX8ru4.js → money-cLcyGcSZ.js} +1 -1
  121. package/dist/{number-BRLwa-mB.js → number-C2jPLJr2.js} +1 -1
  122. package/dist/objectid-C-wocWKI.js +145 -0
  123. package/dist/{onboarding-BSKYeyP7.js → onboarding-oRfy_g05.js} +25 -25
  124. package/dist/{onboardingSetup-BqT52VRm.js → onboardingSetup-BLD6m8HY.js} +2 -2
  125. package/dist/{plugins-BR_wmMFJ.js → plugins-CUsr9vB0.js} +3 -3
  126. package/dist/{MarketingMaterialEdit-BvIthCHG.js → remy-icon-BhUGu2NI.js} +2 -1031
  127. package/dist/{reward-CpCGg_W2.js → reward-UOT03odb.js} +1 -1
  128. package/dist/{rule-Dbg9e8MO.js → rule-BgJnPjkI.js} +572 -492
  129. package/dist/style.css +1 -1
  130. package/dist/template-BZyFhr73.js +188 -0
  131. package/dist/{timezone-CDVa-xPr.js → timezone-BXA4wq7Y.js} +1 -1
  132. package/dist/{transaction.fn-DrTBoF9T.js → transaction.fn-CQ4fpRt3.js} +2 -2
  133. package/dist/{trigger-wqGwQfB2.js → trigger-DXJCGT0q.js} +8 -8
  134. package/dist/useMarketingMaterialActions-B-Wib5ga.js +125 -0
  135. package/dist/{usePagination-fODgpZZ8.js → usePagination-Pp4okWr8.js} +1 -1
  136. package/dist/{user-DaLUK1dk.js → user-B3gXcAIy.js} +1 -1
  137. package/dist/vue-i18n-DWGiC_vs.js +2365 -0
  138. package/dist/{xlsx-Bl4_Dtrq.js → xlsx-CCaDUTgW.js} +651 -651
  139. package/dist/{zod-CAzWyVqj.js → zod-CPwjOxvW.js} +1 -1
  140. package/package.json +12 -3
  141. package/dist/Broadcast-ByWvxVhW.js +0 -271
  142. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-DGpQfV5T.js +0 -2431
  143. package/dist/Marketing-KgcwGErU.js +0 -236
  144. package/dist/ReviewFacebookCallback-mJF54-9l.js +0 -238
  145. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-39f3I4BB.js +0 -1883
  146. package/dist/Setting-Dl9MelHz.js +0 -2036
  147. package/dist/Settings-DvCCClIP.js +0 -179
  148. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-DscLAF0p.js +0 -1264
  149. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-l_v4FHO0.js +0 -142
  150. package/dist/campaign-awCRccgX.js +0 -228
  151. package/dist/google-C3S8u0mT.js +0 -4
  152. package/dist/index-CoNJdOx7.js +0 -51
  153. package/dist/objectid-CEHN25HN.js +0 -145
  154. package/dist/rule-builder-BEIjxsE0.js +0 -102
  155. package/dist/template-CS-lExgI.js +0 -236
  156. package/dist/useMarketingMaterialActions-DC0gIyIZ.js +0 -96
  157. package/dist/vue-i18n-Dx-KXojZ.js +0 -2365
@@ -1,2431 +0,0 @@
1
- import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createVNode, unref, isRef, withCtx, createBlock, createCommentVNode, computed, createElementVNode, toDisplayString, Fragment, renderList, normalizeClass, toRefs, normalizeStyle, resolveDynamicComponent, createSlots } from "vue";
2
- import { _ } from "./lodash-GFl9_FMH.js";
3
- import { z as z$1 } from "./app-tPHYkJcQ.js";
4
- import { Z as ZodHelper } from "./zod-CAzWyVqj.js";
5
- import { F as FdoObjectId, z } from "./index-hSRM1smQ.js";
6
- import { e as FdoGroup, F as F_RUNNABLE_CAMPAIGN_TYPE, f as FdtoRunnableCampaign, g as FdoCreditLoyaltyReward, h as FdtoRandomReward, i as F_MISSION_TYPE, j as FdoThresholdCreditReward, k as FdtoThresholdReward, l as FdoMission } from "./index-DnRMNmUA.js";
7
- import { F as FdtoCollectibleConfig } from "./index-Dhyqf1s8.js";
8
- import { i as isRuleGroup, R as RuleBuilder, a as isRuleEntry } from "./rule-builder-BEIjxsE0.js";
9
- import { u as useMembershipStore } from "./membership-S0KES3Ex.js";
10
- import { u as useBusinessStore } from "./business-HLyWfrXY.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-BOkDnP2g.js";
14
- import { _ as _sfc_main$o } from "./ImageInput.vue_vue_type_script_setup_true_lang-BRJR1heE.js";
15
- import { b as _sfc_main$m, a as _sfc_main$p, _ as _sfc_main$r } from "./EffectSheet.vue_vue_type_style_index_0_lang-Q1f6EQW3.js";
16
- import { _ as _sfc_main$q } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-l_v4FHO0.js";
17
- import { _ as _sfc_main$t } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-8BgGlpTh.js";
18
- import { _ as _sfc_main$j, a as _sfc_main$k } from "./RuleGroup.vue_vue_type_script_setup_true_lang-39f3I4BB.js";
19
- import { p as prompt, f as firebaseStorage } from "./plugins-BR_wmMFJ.js";
20
- import { u as useI18n } from "./vue-i18n-Dx-KXojZ.js";
21
- import { T as TypeToTriggerOptions, _ as _sfc_main$u, b as _sfc_main$v } from "./trigger-wqGwQfB2.js";
22
- import { a as _sfc_main$s } from "./MessageInput.vue_vue_type_script_setup_true_lang-CbFt5X89.js";
23
- import { m as moment } from "./index-D24Q28cH.js";
24
- import { c as calculateNextScheduleAt, S as SummarizeRrule, R as RRule } from "./rule-Dbg9e8MO.js";
25
- import { useCoreStore } from "@feedmepos/mf-common";
26
- import { C as CountryTimezone } from "./timezone-CDVa-xPr.js";
27
- import { _ as _sfc_main$l, a as _sfc_main$n } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-CjuXCTxg.js";
28
- import "./index-Yo0tP8KJ.js";
29
- import { T as TEMPLATES } from "./index-NJSI4wX4.js";
30
- import "./index-C_WoO58V.js";
31
- import "./index-CUle4c2B.js";
32
- import { a as F_GAME_TYPE } from "./collectible.enum-BbZSAfys.js";
33
- import { u as useLoading } from "./loading-CVuY4vQ4.js";
34
- import { i as initCollectibleConfig } from "./helper-C08jyQNK.js";
35
- import { C as CollectionUtils } from "./collection.fn-DPSgBHnz.js";
36
- import { s as sentenceCase$1 } from "./index-CuvNtC_M.js";
37
- import { c as getCampaignSummaryObject } from "./campaign-awCRccgX.js";
38
- import { useDialog } from "@feedmepos/ui-library";
39
- import { u as useCampaignStore } from "./campaign-5zFgUNLw.js";
40
- import { S as SvcConfig } from "./index-Ciw2TZxV.js";
41
- import { a as cleanPF } from "./object-BYyQ0PZp.js";
42
- function campaignRefinement(e, r) {
43
- var i, m;
44
- if (!e) return;
45
- const l = e.campaign;
46
- if (!l) return;
47
- const s = l.event.rule;
48
- if (!s || !isRuleGroup(s)) {
49
- r.addIssue({
50
- code: "custom",
51
- path: ["campaign", "event", "rule"],
52
- params: {
53
- i18n: "connectZodCustom:campaign.rule_required",
54
- type: l.event.type
55
- }
56
- });
57
- return;
58
- }
59
- switch (l.type) {
60
- case "MISSION": {
61
- l.earningOption.amount > l.mission.end && r.addIssue({
62
- code: "custom",
63
- path: ["campaign", "earningOption"],
64
- params: {
65
- i18n: "connectZodCustom:campaign.earning_amount_exceed",
66
- max: l.mission.end
67
- }
68
- });
69
- break;
70
- }
71
- case "CREDIT": {
72
- const n = (i = l.config) == null ? void 0 : i.validityOption;
73
- (!n || ["validForDay", "validBefore"].every((u) => n[u] == null)) && r.addIssue({
74
- code: "custom",
75
- path: ["campaign", "config", "validityOption"],
76
- params: {
77
- i18n: "connectZodCustom:campaign.credit_validity_required"
78
- }
79
- });
80
- }
81
- }
82
- switch (l.event.type) {
83
- case "BILL_COMPLETED":
84
- l.type === "MISSION" && l.rewards.length && (l.rewards.forEach((n, o) => {
85
- (n.threshold < 0 || n.threshold > l.mission.end) && r.addIssue({
86
- code: "custom",
87
- path: ["campaign", "rewards", o, "threshold"],
88
- params: {
89
- i18n: "connectZodCustom:campaign.reward_threshold_range"
90
- }
91
- });
92
- }), (m = l.config) != null && m.validityOption.followFirstReceive || r.addIssue({
93
- code: "custom",
94
- path: ["campaign", "config", "validityOption"],
95
- params: {
96
- i18n: "connectZodCustom:campaign.mission_first_receive"
97
- }
98
- }));
99
- break;
100
- case "SCHEDULE": {
101
- if (!s.rules.g_schedule) {
102
- r.addIssue({
103
- code: "custom",
104
- path: ["campaign", "event", "rule"],
105
- params: {
106
- i18n: "connectZodCustom:campaign.schedule_period_required"
107
- },
108
- fatal: !0
109
- });
110
- return;
111
- }
112
- const n = RuleBuilder.getRules(
113
- s.rules.g_schedule
114
- ), o = [
115
- {
116
- property: "trigger.date",
117
- operator: ["_isOnDate", "_rrule"]
118
- },
119
- {
120
- property: "trigger.time",
121
- operator: ["_isOnTime"]
122
- }
123
- ];
124
- o.length == n.length && o.every((a) => n.some((f) => {
125
- const y = RuleBuilder.simplify(f);
126
- return y.property === a.property && a.operator.includes(y.operator);
127
- })) || r.addIssue({
128
- code: "custom",
129
- path: ["campaign", "event", "rule"],
130
- params: {
131
- i18n: "connectZodCustom:campaign.active_period_invalid"
132
- }
133
- });
134
- break;
135
- }
136
- default: {
137
- "earningOption" in l && l.earningOption.type != "FIXED" && r.addIssue({
138
- code: "custom",
139
- path: ["campaign", "earningOption"],
140
- params: {
141
- i18n: "connectZodCustom:campaign.fixed_earning_required"
142
- }
143
- });
144
- break;
145
- }
146
- }
147
- }
148
- function campaignTransform(e) {
149
- var l;
150
- if (e.campaign.type === "VOUCHER" && "configs" in e) {
151
- const s = e.configs;
152
- s.extras.targetLocation = e.campaign.targetLocation;
153
- const i = Math.max(
154
- e.campaign.earningOption.amount,
155
- s.options.maxUse ?? 1
156
- );
157
- e.campaign.earningOption.amount = i, s.options.maxUse = i, e.campaign.earningOption = {
158
- type: "FIXED",
159
- amount: 1
160
- };
161
- }
162
- if (e.campaign.type == "MISSION" && "configs" in e) {
163
- const s = e.configs;
164
- s.options.validityOption = (l = e.campaign.config) == null ? void 0 : l.validityOption;
165
- }
166
- const r = e.campaign.event;
167
- return r.type != "BILL_COMPLETED" && r.rule && isRuleGroup(r.rule) && (r.rule = RuleBuilder.removeEntry(r.rule, "g_bill"), e.campaign.event = r), e;
168
- }
169
- function GenerateCampaignReq(e) {
170
- const r = FdtoRunnableCampaign.optionsMap.get(e).extend({
171
- _id: FdoObjectId.optional(),
172
- collectible: z.string().nullish()
173
- });
174
- switch (e) {
175
- case "VOUCHER":
176
- return z.object({
177
- campaign: r,
178
- templateId: FdoObjectId,
179
- configs: FdtoCollectibleConfig,
180
- updateCollections: z.boolean().optional(),
181
- code: z.string().optional()
182
- });
183
- case "PROMOTION":
184
- return z.object({
185
- campaign: r,
186
- templateId: FdoObjectId
187
- });
188
- case "POINT":
189
- return z.object({
190
- campaign: r,
191
- templateId: FdoObjectId
192
- });
193
- case "CREDIT":
194
- return z.object({
195
- campaign: r,
196
- templateId: FdoObjectId
197
- });
198
- case "BROADCAST":
199
- return z.object({
200
- campaign: r,
201
- templateId: FdoObjectId
202
- });
203
- case "COIN":
204
- return z.object({
205
- campaign: r,
206
- templateId: FdoObjectId
207
- });
208
- case "REWARD_POOL":
209
- return z.object({
210
- campaign: r,
211
- templateId: FdoObjectId,
212
- updateCollections: z.boolean().optional()
213
- });
214
- case "GAME":
215
- return z.object({
216
- campaign: r,
217
- configs: FdtoCollectibleConfig,
218
- templateId: FdoObjectId,
219
- updateCollections: z.boolean().optional()
220
- });
221
- case "MISSION":
222
- return z.object({
223
- campaign: r,
224
- configs: FdtoCollectibleConfig,
225
- templateId: FdoObjectId,
226
- updateCollections: z.boolean().optional()
227
- });
228
- default:
229
- throw new Error("Not implemented");
230
- }
231
- }
232
- FdoGroup.extend({
233
- _id: FdoObjectId.optional(),
234
- name: z.string().min(1).max(300),
235
- business: FdoObjectId.optional(),
236
- campaigns: z.array(FdoObjectId).optional()
237
- });
238
- const CampaignDtos = {
239
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.VOUCHER]: GenerateCampaignReq("VOUCHER"),
240
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.PROMOTION]: GenerateCampaignReq("PROMOTION"),
241
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.POINT]: GenerateCampaignReq("POINT"),
242
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.CREDIT]: GenerateCampaignReq("CREDIT"),
243
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.BROADCAST]: GenerateCampaignReq("BROADCAST"),
244
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.COIN]: GenerateCampaignReq("COIN"),
245
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.REWARD_POOL]: GenerateCampaignReq("REWARD_POOL"),
246
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.GAME]: GenerateCampaignReq("GAME"),
247
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.MISSION]: GenerateCampaignReq("MISSION")
248
- }, _hoisted_1$g = { class: "space-y-24" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
249
- __name: "TimeRuleGroup",
250
- props: {
251
- modelValue: {
252
- type: Object,
253
- default: () => {
254
- }
255
- }
256
- },
257
- emits: ["update:model-value"],
258
- setup(e, { emit: r }) {
259
- const { t: l } = useI18n(), s = e, i = r, m = ref(
260
- !s.modelValue || !s.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(s.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
261
- );
262
- watch(m, async (o, u) => {
263
- var a;
264
- if (u == "custom" && o == "all_time" && RuleBuilder.getRules((a = s.modelValue) == null ? void 0 : a.rules.g_time).length > 0) {
265
- const f = await prompt.confirm(
266
- l("connect.template.rule.time.confirm_remove"),
267
- l("connect.common.confirm"),
268
- l("connect.common.confirm"),
269
- l("connect.common.cancel")
270
- );
271
- f && i(
272
- "update:model-value",
273
- RuleBuilder.setRuleToGroup(
274
- s.modelValue ?? RuleBuilder.scaffoldGroup(),
275
- RuleBuilder.scaffoldGroup("g_time")
276
- )
277
- ), m.value = f ? o : u;
278
- }
279
- });
280
- async function n(o) {
281
- var u;
282
- if (o == "custom" && RuleBuilder.getRules((u = s.modelValue) == null ? void 0 : u.rules.g_time).length > 0) {
283
- if (!await prompt.confirm(
284
- l("connect.template.rule.time.confirm_remove"),
285
- l("connect.common.confirm"),
286
- l("connect.common.confirm"),
287
- l("connect.common.cancel")
288
- )) {
289
- m.value = "all_time";
290
- return;
291
- }
292
- i(
293
- "update:model-value",
294
- RuleBuilder.setRuleToGroup(
295
- s.modelValue ?? RuleBuilder.scaffoldGroup(),
296
- RuleBuilder.scaffoldGroup("g_time")
297
- )
298
- );
299
- }
300
- }
301
- return (o, u) => {
302
- var y;
303
- const a = resolveComponent("FmRadio"), f = resolveComponent("FmRadioGroup");
304
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
305
- createVNode(f, {
306
- modelValue: unref(m),
307
- "onUpdate:modelValue": [
308
- u[0] || (u[0] = (v) => isRef(m) ? m.value = v : null),
309
- u[1] || (u[1] = (v) => n(v))
310
- ]
311
- }, {
312
- default: withCtx(() => [
313
- createVNode(a, {
314
- label: unref(l)("connect.template.rule.time.all_time"),
315
- value: "all_time"
316
- }, null, 8, ["label"]),
317
- createVNode(a, {
318
- label: unref(l)("connect.template.rule.time.custom"),
319
- value: "custom"
320
- }, null, 8, ["label"])
321
- ]),
322
- _: 1
323
- }, 8, ["modelValue"]),
324
- unref(m) == "custom" ? (openBlock(), createBlock(_sfc_main$j, {
325
- key: 0,
326
- class: "!mt-[0px]",
327
- "include-only": "trigger",
328
- "trigger-type": "SCHEDULE",
329
- "model-value": ((y = e.modelValue) == null ? void 0 : y.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
330
- "onUpdate:modelValue": u[2] || (u[2] = (v) => i(
331
- "update:model-value",
332
- unref(RuleBuilder).setRuleToGroup(
333
- e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
334
- v,
335
- "&&"
336
- )
337
- ))
338
- }, null, 8, ["model-value"])) : createCommentVNode("", !0)
339
- ]);
340
- };
341
- }
342
- }), _sfc_main$h = /* @__PURE__ */ defineComponent({
343
- __name: "BirthdayInput",
344
- props: {
345
- modelValue: {
346
- type: Object
347
- }
348
- },
349
- emits: ["update:model-value"],
350
- setup(e, { emit: r }) {
351
- const { t: l } = useI18n(), s = e, i = r, m = computed(() => {
352
- const { property: n, operator: o, equator: u } = RuleBuilder.simplify(
353
- s.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
354
- op: "before",
355
- x: 1
356
- })
357
- );
358
- return {
359
- property: n,
360
- operator: o,
361
- equator: u
362
- };
363
- });
364
- return (n, o) => {
365
- const u = resolveComponent("FmRadio"), a = resolveComponent("FmStepperField");
366
- return openBlock(), createElementBlock("div", null, [
367
- createVNode(u, {
368
- label: unref(l)("connect.template.rule.birthday.on_birthday"),
369
- value: "_isRange-day",
370
- "model-value": `${unref(m).operator}-${unref(m).equator.unit}`,
371
- "onUpdate:modelValue": o[0] || (o[0] = () => {
372
- i(
373
- "update:model-value",
374
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
375
- op: "this",
376
- unit: "day",
377
- ignoreYear: !0
378
- })
379
- );
380
- })
381
- }, null, 8, ["label", "model-value"]),
382
- createVNode(u, {
383
- label: unref(l)("connect.template.rule.birthday.days_before"),
384
- value: "_isDay",
385
- "model-value": unref(m).operator,
386
- "onUpdate:modelValue": o[1] || (o[1] = () => {
387
- i(
388
- "update:model-value",
389
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
390
- op: "after",
391
- x: 1,
392
- ignoreYear: !0
393
- })
394
- );
395
- })
396
- }, null, 8, ["label", "model-value"]),
397
- unref(m).operator == "_isDay" ? (openBlock(), createBlock(a, {
398
- key: 0,
399
- label: unref(l)("connect.template.rule.birthday.days_before_label"),
400
- "show-steppers": !1,
401
- "model-value": unref(m).equator.x,
402
- "onUpdate:modelValue": o[2] || (o[2] = (f) => i(
403
- "update:model-value",
404
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
405
- op: "after",
406
- x: f,
407
- ignoreYear: !0
408
- })
409
- ))
410
- }, null, 8, ["label", "model-value"])) : createCommentVNode("", !0),
411
- createVNode(u, {
412
- label: unref(l)("connect.template.rule.birthday.in_birthday_week"),
413
- value: "_isRange-week",
414
- "model-value": `${unref(m).operator}-${unref(m).equator.unit}`,
415
- "onUpdate:modelValue": o[3] || (o[3] = () => {
416
- i(
417
- "update:model-value",
418
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
419
- op: "this",
420
- unit: "week",
421
- ignoreYear: !0
422
- })
423
- );
424
- })
425
- }, null, 8, ["label", "model-value"]),
426
- createVNode(u, {
427
- label: unref(l)("connect.template.rule.birthday.in_birthday_month"),
428
- value: "_isRange-month",
429
- "model-value": `${unref(m).operator}-${unref(m).equator.unit}`,
430
- "onUpdate:modelValue": o[4] || (o[4] = () => {
431
- i(
432
- "update:model-value",
433
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
434
- op: "this",
435
- unit: "month",
436
- ignoreYear: !0
437
- })
438
- );
439
- })
440
- }, null, 8, ["label", "model-value"])
441
- ]);
442
- };
443
- }
444
- }), _hoisted_1$f = { class: "space-y-16" }, _hoisted_2$c = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$a = { class: "grid grid-cols-3 gap-16" }, _hoisted_4$9 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$6 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$g = /* @__PURE__ */ defineComponent({
445
- __name: "CampaignTriggerInput",
446
- props: {
447
- campaignType: {
448
- type: String,
449
- required: !0
450
- },
451
- modelValue: {
452
- type: String
453
- },
454
- disabled: {
455
- type: Boolean,
456
- default: !1
457
- }
458
- },
459
- emits: ["update:model-value"],
460
- setup(e, { emit: r }) {
461
- const { t: l } = useI18n(), s = e, i = r, m = computed(() => s.disabled ? TypeToTriggerOptions[s.campaignType].filter(
462
- (n) => n.value == s.modelValue
463
- ) : TypeToTriggerOptions[s.campaignType]);
464
- return (n, o) => {
465
- const u = resolveComponent("FmCard");
466
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
467
- createElementVNode("div", _hoisted_2$c, toDisplayString(unref(l)("connect.campaign.trigger.description")), 1),
468
- createElementVNode("div", _hoisted_3$a, [
469
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m), (a) => (openBlock(), createBlock(u, {
470
- variant: "outlined",
471
- disabled: s.disabled,
472
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
473
- "col-span-3": unref(m).length == 1,
474
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == a.value,
475
- "hover:bg-fm-color-opacity-sm": e.modelValue != a.value
476
- }]),
477
- onClick: () => {
478
- s.modelValue != a.value && !s.disabled && i("update:model-value", a.value);
479
- },
480
- key: a.name
481
- }, {
482
- default: withCtx(() => [
483
- createElementVNode("div", _hoisted_4$9, toDisplayString(a.name), 1),
484
- createElementVNode("div", _hoisted_5$6, toDisplayString(a.description), 1)
485
- ]),
486
- _: 2
487
- }, 1032, ["disabled", "class", "onClick"]))), 128))
488
- ])
489
- ]);
490
- };
491
- }
492
- }), _sfc_main$f = /* @__PURE__ */ defineComponent({
493
- __name: "DateInput",
494
- props: {
495
- label: {
496
- type: String,
497
- required: !1
498
- },
499
- modelValue: {
500
- type: Object,
501
- required: !1
502
- }
503
- },
504
- emits: ["update:model-value"],
505
- setup(e, { emit: r }) {
506
- const l = r;
507
- return (s, i) => {
508
- const m = resolveComponent("FmButton"), n = resolveComponent("FmField"), o = resolveComponent("FmDatePicker");
509
- return openBlock(), createBlock(o, {
510
- label: e.label,
511
- "model-value": e.modelValue || "",
512
- "onUpdate:modelValue": i[1] || (i[1] = (u) => l("update:model-value", u))
513
- }, {
514
- "trigger-button": withCtx(({ opened: u }) => [
515
- createVNode(n, {
516
- class: "flex items-center",
517
- "prepend-icon": "calendar_month",
518
- "icon-outlined": !u
519
- }, {
520
- append: withCtx(() => [
521
- e.modelValue ? (openBlock(), createBlock(m, {
522
- key: 0,
523
- variant: "tertiary",
524
- icon: "clear",
525
- onClick: i[0] || (i[0] = (a) => (a.stopPropagation(), l("update:model-value", null)))
526
- })) : createCommentVNode("", !0)
527
- ]),
528
- default: withCtx(() => [
529
- createElementVNode("div", {
530
- class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
531
- }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
532
- ]),
533
- _: 1
534
- }, 8, ["icon-outlined"])
535
- ]),
536
- _: 1
537
- }, 8, ["label", "model-value"]);
538
- };
539
- }
540
- }), _hoisted_1$e = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$b = { class: "flex-1 xs:w-full" }, _hoisted_3$9 = { class: "mt-5 xs:hidden" }, _hoisted_4$8 = { class: "flex-1 xs:w-full" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
541
- __name: "DateRangeInput",
542
- props: {
543
- modelValue: {
544
- type: Object,
545
- required: !1
546
- }
547
- },
548
- emits: ["update:model-value"],
549
- setup(e, { emit: r }) {
550
- const { t: l } = useI18n(), s = r;
551
- return (i, m) => {
552
- var n, o;
553
- return openBlock(), createElementBlock("div", _hoisted_1$e, [
554
- createElementVNode("div", _hoisted_2$b, [
555
- createVNode(_sfc_main$f, {
556
- "model-value": ((n = e.modelValue) == null ? void 0 : n.startDate) ?? null,
557
- label: unref(l)("connect.common.startDate"),
558
- "onUpdate:modelValue": m[0] || (m[0] = (u) => {
559
- var a;
560
- return s("update:model-value", {
561
- startDate: u,
562
- endDate: ((a = e.modelValue) == null ? void 0 : a.endDate) ?? null
563
- });
564
- })
565
- }, null, 8, ["model-value", "label"])
566
- ]),
567
- createElementVNode("div", _hoisted_3$9, toDisplayString(unref(l)("connect.common.to")), 1),
568
- createElementVNode("div", _hoisted_4$8, [
569
- createVNode(_sfc_main$f, {
570
- "model-value": ((o = e.modelValue) == null ? void 0 : o.endDate) ?? null,
571
- label: unref(l)("connect.common.endDate"),
572
- "onUpdate:modelValue": m[1] || (m[1] = (u) => {
573
- var a;
574
- return s("update:model-value", {
575
- startDate: ((a = e.modelValue) == null ? void 0 : a.startDate) ?? null,
576
- endDate: u
577
- });
578
- })
579
- }, null, 8, ["model-value", "label"])
580
- ])
581
- ]);
582
- };
583
- }
584
- }), _hoisted_1$d = { class: "space-y-8" }, _hoisted_2$a = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$8 = {
585
- key: 0,
586
- class: "space-y-4"
587
- }, _hoisted_4$7 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$5 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
588
- __name: "ScheduleRuleInput",
589
- props: {
590
- modelValue: {
591
- type: Object,
592
- required: !0
593
- },
594
- startDate: {
595
- type: String
596
- },
597
- endDate: {
598
- type: String
599
- }
600
- },
601
- emits: ["update:model-value"],
602
- setup(e, { emit: r }) {
603
- const { t: l } = useI18n(), s = e, i = r, m = useCoreStore(), n = computed(
604
- () => CountryTimezone[m.currentCountry.value || "MY"]
605
- );
606
- function o() {
607
- const d = RuleBuilder.getRules(s.modelValue);
608
- return d.length == 0 ? "fixed" : d.some(
609
- (c) => isRuleEntry(c) && RuleBuilder.simplify(c).operator == "_rrule"
610
- ) ? "repeating" : "fixed";
611
- }
612
- const u = ref(o()), a = ref(!1), f = computed(() => [
613
- { label: l("connect.template.rule.schedule.fixed"), value: "fixed" },
614
- { label: l("connect.template.rule.schedule.repeating"), value: "repeating" }
615
- ]), y = computed(() => {
616
- const d = RuleBuilder.getRules(s.modelValue), c = d.find(
617
- (g) => isRuleEntry(g) && RuleBuilder.simplify(g).property == "trigger.date"
618
- ), p = d.find(
619
- (g) => isRuleEntry(g) && RuleBuilder.simplify(g).property == "trigger.time"
620
- );
621
- return {
622
- date: c ? RuleBuilder.simplify(c).equator : null,
623
- time: p ? RuleBuilder.simplify(p).equator : null
624
- };
625
- }), v = computed(
626
- () => calculateNextScheduleAt(
627
- s.modelValue,
628
- /* @__PURE__ */ new Date(),
629
- s.startDate ? new Date(s.startDate) : void 0,
630
- s.endDate ? new Date(s.endDate) : void 0
631
- )
632
- );
633
- function x(d) {
634
- const c = d.value, p = c == "fixed" ? [
635
- RuleBuilder.constructEntry(
636
- "trigger.date",
637
- "_isOnDate",
638
- (/* @__PURE__ */ new Date()).toISOString()
639
- ),
640
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
641
- ] : [
642
- RuleBuilder.constructEntry(
643
- "trigger.date",
644
- "_rrule",
645
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
646
- ),
647
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
648
- ];
649
- i(
650
- "update:model-value",
651
- RuleBuilder.setRuleToGroup(
652
- RuleBuilder.scaffoldGroup("g_schedule"),
653
- p
654
- )
655
- ), u.value = c;
656
- }
657
- function b(d) {
658
- u.value == "fixed" ? i(
659
- "update:model-value",
660
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
661
- RuleBuilder.constructEntry(
662
- "trigger.date",
663
- "_isOnDate",
664
- d.date
665
- ),
666
- RuleBuilder.constructEntry(
667
- "trigger.time",
668
- "_isOnTime",
669
- d.time
670
- )
671
- ])
672
- ) : i(
673
- "update:model-value",
674
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
675
- RuleBuilder.constructEntry(
676
- "trigger.date",
677
- "_rrule",
678
- d.date
679
- ),
680
- RuleBuilder.constructEntry(
681
- "trigger.time",
682
- "_isOnTime",
683
- d.time
684
- )
685
- ])
686
- );
687
- }
688
- return (d, c) => {
689
- const p = resolveComponent("FmButtonGroup"), g = resolveComponent("FmTimePicker"), k = resolveComponent("FmIcon"), V = resolveComponent("FmTooltip"), C = resolveComponent("FmField"), B = resolveComponent("FmCard"), h = resolveComponent("FmPopover"), S = resolveComponent("FmDatePicker"), E = resolveComponent("FmHelperText");
690
- return openBlock(), createElementBlock(Fragment, null, [
691
- createVNode(p, {
692
- items: unref(f),
693
- "model-value": unref(f).find((R) => R.value === unref(u)) ?? null,
694
- "onUpdate:modelValue": x,
695
- class: "mb-8"
696
- }, null, 8, ["items", "model-value"]),
697
- createElementVNode("div", _hoisted_1$d, [
698
- createElementVNode("div", _hoisted_2$a, [
699
- createVNode(g, {
700
- label: unref(l)("connect.template.rule.schedule.notify_time"),
701
- "model-value": unref(y).time,
702
- "onUpdate:modelValue": c[0] || (c[0] = (R) => b({ date: unref(y).date, time: R })),
703
- "helper-text": unref(y).time ? void 0 : unref(l)("connect.template.rule.schedule.time_required"),
704
- "helper-state": unref(y).time ? void 0 : "error"
705
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"]),
706
- unref(u) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$8, [
707
- createElementVNode("div", _hoisted_4$7, [
708
- createElementVNode("div", null, toDisplayString(unref(l)("connect.template.rule.schedule.notify_date")), 1),
709
- unref(y).date ? (openBlock(), createBlock(V, {
710
- key: 0,
711
- "z-index": 9999,
712
- content: unref(SummarizeRrule)(unref(RRule).fromString(unref(y).date).options)
713
- }, {
714
- default: withCtx(() => [
715
- createVNode(k, {
716
- name: "info",
717
- size: "sm",
718
- outline: !0
719
- })
720
- ]),
721
- _: 1
722
- }, 8, ["content"])) : createCommentVNode("", !0)
723
- ]),
724
- createVNode(h, {
725
- "show-popover": unref(a),
726
- onPopoverChanged: c[3] || (c[3] = (R) => a.value = R)
727
- }, {
728
- "popover-button": withCtx(() => [
729
- createVNode(C, {
730
- class: "cursor-pointer",
731
- "helper-text": unref(y).date ? void 0 : unref(l)("connect.template.rule.schedule.date_required"),
732
- "helper-state": unref(y).date ? void 0 : "error"
733
- }, {
734
- default: withCtx(() => [
735
- createElementVNode("div", _hoisted_5$5, toDisplayString(unref(y).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(y).date).options) : unref(l)("connect.template.rule.schedule.set_repeating_date")), 1)
736
- ]),
737
- _: 1
738
- }, 8, ["helper-text", "helper-state"])
739
- ]),
740
- default: withCtx(() => [
741
- createVNode(B, { class: "elevated p-8 w-[450px]" }, {
742
- default: withCtx(() => [
743
- createVNode(_sfc_main$k, {
744
- "apply-button": !0,
745
- "model-value": unref(y).date || "",
746
- onCancel: c[1] || (c[1] = (R) => a.value = !1),
747
- "onUpdate:modelValue": c[2] || (c[2] = (R) => (b({ date: R, time: unref(y).time }), a.value = !1))
748
- }, null, 8, ["model-value"])
749
- ]),
750
- _: 1
751
- })
752
- ]),
753
- _: 1
754
- }, 8, ["show-popover"])
755
- ])) : (openBlock(), createBlock(S, {
756
- key: 1,
757
- label: unref(l)("connect.template.rule.schedule.notify_date"),
758
- "model-value": unref(y).date || "",
759
- "onUpdate:modelValue": c[4] || (c[4] = (R) => b({ date: R, time: unref(y).time })),
760
- "helper-text": unref(y).date ? void 0 : unref(l)("connect.template.rule.schedule.date_required"),
761
- "helper-state": unref(y).date ? void 0 : "error"
762
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"]))
763
- ]),
764
- unref(y).date && unref(y).time && unref(v) ? (openBlock(), createBlock(E, {
765
- key: 0,
766
- text: `${unref(moment)(unref(v)).isAfter(unref(moment)()) ? unref(l)("connect.template.rule.schedule.next_notification") : unref(l)("connect.template.rule.schedule.last_trigger_on")} ${unref(moment)(unref(v)).format("dddd, DD MMM YYYY")} at
767
- ${unref(moment)(unref(v)).format("hh:mmA")}(UTC${unref(moment).tz(unref(n)).format("Z")}) (${unref(moment)(unref(v)).fromNow()})`
768
- }, null, 8, ["text"])) : createCommentVNode("", !0)
769
- ])
770
- ], 64);
771
- };
772
- }
773
- }), _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: "grid grid-cols-2 gap-16" }, _hoisted_4$6 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$4 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
774
- __name: "GameTypeInput",
775
- props: {
776
- modelValue: {
777
- type: String
778
- }
779
- },
780
- emits: ["update:model-value"],
781
- setup(e, { emit: r }) {
782
- const { t: l } = useI18n(), s = e, i = r, m = computed(
783
- () => [
784
- {
785
- label: l("connect.campaign.gameType.option.FORTUNE_WHEEL.label"),
786
- description: l("connect.campaign.gameType.option.FORTUNE_WHEEL.description"),
787
- value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
788
- hidden: !1
789
- },
790
- {
791
- label: l("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.label"),
792
- description: l("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.description"),
793
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
794
- hidden: !0
795
- }
796
- ].filter((n) => !n.hidden)
797
- );
798
- return (n, o) => {
799
- const u = resolveComponent("FmCard");
800
- return openBlock(), createElementBlock("div", _hoisted_1$c, [
801
- createElementVNode("div", _hoisted_2$9, toDisplayString(unref(l)("connect.template.select_game")), 1),
802
- createElementVNode("div", _hoisted_3$7, [
803
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m), (a) => (openBlock(), createBlock(u, {
804
- variant: "outlined",
805
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
806
- "col-span-2": unref(m).length == 1,
807
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == a.value,
808
- "hover:bg-fm-color-opacity-sm": e.modelValue != a.value
809
- }]),
810
- onClick: () => {
811
- s.modelValue != a.value && i("update:model-value", a.value);
812
- },
813
- key: a.value
814
- }, {
815
- default: withCtx(() => [
816
- createElementVNode("div", _hoisted_4$6, toDisplayString(a.label), 1),
817
- createElementVNode("div", _hoisted_5$4, toDisplayString(a.description), 1)
818
- ]),
819
- _: 2
820
- }, 1032, ["class", "onClick"]))), 128))
821
- ])
822
- ]);
823
- };
824
- }
825
- }), _hoisted_1$b = {
826
- key: 0,
827
- class: "flex flex-col gap-y-24"
828
- }, _hoisted_2$8 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
829
- __name: "EditRewardPoolSheet",
830
- emits: ["update:model-value"],
831
- setup(e, { expose: r, emit: l }) {
832
- const s = useMembershipStore(), { minor: i } = useLoading, m = ref(!1), n = ref(), o = ref(), u = ref(0), a = computed(() => {
833
- var d;
834
- return ((d = s.loyaltyRewards.items.find(
835
- (c) => {
836
- var p;
837
- return c.value === ((p = n.value) == null ? void 0 : p.collectible);
838
- }
839
- )) == null ? void 0 : d.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
840
- }), f = computed(() => {
841
- const b = a.value.safeParse(n.value);
842
- return b.success ? [] : b.error.errors;
843
- });
844
- function y(b, d, c) {
845
- b && (n.value = d, u.value = c), m.value = b;
846
- }
847
- const v = l;
848
- async function x() {
849
- const b = a.value.safeParse(n.value);
850
- b.success && (await i(
851
- async () => {
852
- b.data.type === "VOUCHER" && o.value && (b.data.collectibleConfig.image = await firebaseStorage.update(
853
- b.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, o.value),
854
- o.value
855
- ));
856
- },
857
- {
858
- message: "Uploading reward image",
859
- successMessage: "Reward image updated"
860
- }
861
- ), v("update:model-value", b.data, u.value));
862
- }
863
- return r({
864
- showSheet: y
865
- }), (b, d) => {
866
- const c = resolveComponent("FmSelect"), p = resolveComponent("FmStepperField"), g = resolveComponent("FmButton"), k = resolveComponent("FmSideSheet");
867
- return openBlock(), createBlock(k, {
868
- "max-width": 560,
869
- modelValue: unref(m),
870
- "onUpdate:modelValue": [
871
- d[9] || (d[9] = (V) => isRef(m) ? m.value = V : null),
872
- d[10] || (d[10] = (V) => m.value = V)
873
- ],
874
- header: "Edit reward",
875
- "dismiss-away": ""
876
- }, {
877
- "side-sheet-footer": withCtx(() => [
878
- createElementVNode("div", _hoisted_2$8, [
879
- createVNode(g, {
880
- variant: "primary",
881
- type: "button",
882
- disabled: unref(f).length > 0,
883
- label: "Confirm",
884
- onClick: d[7] || (d[7] = (V) => x())
885
- }, null, 8, ["disabled"]),
886
- createVNode(g, {
887
- variant: "secondary",
888
- type: "button",
889
- label: "Cancel",
890
- onClick: d[8] || (d[8] = (V) => m.value = !1)
891
- })
892
- ])
893
- ]),
894
- default: withCtx(() => {
895
- var V, C, B;
896
- return [
897
- unref(n) ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
898
- createVNode(c, {
899
- label: "Reward Type",
900
- items: [
901
- { label: "No Reward", value: "NO_REWARD" },
902
- { label: "Voucher", value: "VOUCHER" },
903
- { label: "Loyalty", value: "LOYALTY" }
904
- ],
905
- "model-value": unref(n).type,
906
- "onUpdate:modelValue": d[0] || (d[0] = (h) => {
907
- h == "NO_REWARD" ? n.value = {
908
- type: "NO_REWARD",
909
- collectible: null,
910
- weight: 1
911
- } : h === "VOUCHER" ? n.value = {
912
- collectible: null,
913
- type: "VOUCHER",
914
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
915
- business: unref(useCoreStore)().currentBusiness.value._id
916
- }),
917
- earningOption: {
918
- amount: 1,
919
- type: "FIXED"
920
- },
921
- validityOption: {
922
- validForDay: 7
923
- },
924
- weight: 1
925
- } : n.value = {
926
- collectible: unref(s).loyaltyRewards.raw[0]._id,
927
- type: "LOYALTY",
928
- earningOption: {
929
- amount: 1,
930
- type: "FIXED"
931
- },
932
- validityOption: {
933
- validForDay: 7
934
- },
935
- weight: 1
936
- };
937
- })
938
- }, null, 8, ["model-value"]),
939
- unref(n).type == "LOYALTY" ? (openBlock(), createBlock(c, {
940
- key: 0,
941
- label: "Loyalty type",
942
- rules: [unref(ZodHelper).ruleAtPath(unref(a), "collectible", [unref(n).type])],
943
- items: unref(s).loyaltyRewards.items,
944
- "model-value": unref(n).collectible,
945
- "onUpdate:modelValue": d[1] || (d[1] = (h) => unref(n).collectible = h)
946
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
947
- createVNode(p, {
948
- label: "Weight",
949
- rules: [unref(ZodHelper).ruleAtPath(unref(a), "weight", [unref(n).type])],
950
- "model-value": unref(n).weight,
951
- "onUpdate:modelValue": d[2] || (d[2] = (h) => n.value = {
952
- ...unref(n),
953
- weight: h
954
- })
955
- }, null, 8, ["rules", "model-value"]),
956
- unref(n).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
957
- ((V = unref(s).loyaltyRewards.items.find(
958
- (h) => {
959
- var S;
960
- return h.value === ((S = unref(n)) == null ? void 0 : S.collectible);
961
- }
962
- )) == null ? void 0 : V.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
963
- d[11] || (d[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
964
- createVNode(_sfc_main$l, {
965
- class: "mt-[-8px]",
966
- rules: [
967
- unref(ZodHelper).ruleAtPath(unref(a), "earningOption", [unref(n).type])
968
- ],
969
- "helper-state": unref(ZodHelper).helperState(unref(f), "earningOption"),
970
- "error-text": unref(ZodHelper).helperText(unref(f), "earningOption"),
971
- "fixed-type": !0,
972
- "model-value": unref(n).earningOption,
973
- "onUpdate:modelValue": d[3] || (d[3] = (h) => n.value = {
974
- ...unref(n),
975
- earningOption: h
976
- })
977
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
978
- ], 64)) : createCommentVNode("", !0),
979
- d[12] || (d[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
980
- createVNode(_sfc_main$m, {
981
- type: unref(n).type === "LOYALTY" ? "custom" : "range",
982
- "for-credit": unref(n).type === "LOYALTY" && ((C = unref(s).loyaltyRewards.items.find(
983
- (h) => {
984
- var S;
985
- return h.value === ((S = unref(n)) == null ? void 0 : S.collectible);
986
- }
987
- )) == null ? void 0 : C.raw.type) === "CREDIT",
988
- class: "!gap-24",
989
- rules: [unref(ZodHelper).ruleAtPath(unref(a), "validityOption", [unref(n).type])],
990
- "model-value": unref(n).validityOption,
991
- "onUpdate:modelValue": d[4] || (d[4] = (h) => n.value = {
992
- ...unref(n),
993
- validityOption: h
994
- })
995
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
996
- ], 64)) : createCommentVNode("", !0),
997
- unref(n).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$n, {
998
- key: 2,
999
- "reward-image": unref(o),
1000
- "model-value": ((B = unref(n)) == null ? void 0 : B.collectibleConfig) ?? void 0,
1001
- "onUpdate:modelValue": d[5] || (d[5] = (h) => n.value = {
1002
- ...unref(n),
1003
- collectibleConfig: h
1004
- }),
1005
- "onUpdate:rewardImage": d[6] || (d[6] = (h) => o.value = h)
1006
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1007
- createVNode(JsonViewer, { json: unref(f) }, null, 8, ["json"])
1008
- ])) : createCommentVNode("", !0)
1009
- ];
1010
- }),
1011
- _: 1
1012
- }, 8, ["modelValue"]);
1013
- };
1014
- }
1015
- });
1016
- function isNullOrEmpty(e) {
1017
- return e == null || e === "";
1018
- }
1019
- const _hoisted_1$a = { class: "space-y-16" }, _hoisted_2$7 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$6 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$5 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$a = /* @__PURE__ */ defineComponent({
1020
- __name: "RewardPoolInput",
1021
- props: {
1022
- modelValue: {
1023
- type: Array,
1024
- default: () => [
1025
- {
1026
- collectible: null,
1027
- type: "NO_REWARD",
1028
- weight: 1
1029
- }
1030
- ]
1031
- }
1032
- },
1033
- emits: ["update:model-value"],
1034
- setup(e, { emit: r }) {
1035
- const l = e, s = r, i = useMembershipStore(), { t: m } = useI18n(), n = z$1.array(z$1.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), o = computed(() => l.modelValue ?? []), u = computed(() => {
1036
- const d = n.safeParse(o.value);
1037
- return d.success ? [] : d.error.errors;
1038
- }), a = ref();
1039
- function f(d, c) {
1040
- var g;
1041
- const p = [...o.value];
1042
- p[c] = d, (g = a.value) == null || g.showSheet(!1), s("update:model-value", p);
1043
- }
1044
- function y(d) {
1045
- const c = d.type == "VOUCHER" ? d.collectibleConfig : i.collectibles.find(
1046
- (k) => k._id.toString() == d.collectible
1047
- ), p = CollectionUtils.formattedType((c == null ? void 0 : c.name) || ""), g = d.weight;
1048
- return {
1049
- label: isNullOrEmpty(p) ? "NO REWARD" : p,
1050
- sublabel: `${g} (${(g / o.value.reduce((k, V) => k + V.weight, 0) * 100).toFixed(2)}%)`
1051
- };
1052
- }
1053
- function v(d) {
1054
- var p;
1055
- const c = [...o.value];
1056
- (p = a.value) == null || p.showSheet(!0, c[d], d);
1057
- }
1058
- function x(d) {
1059
- const c = [...o.value];
1060
- c.splice(d, 1), s("update:model-value", c);
1061
- }
1062
- function b() {
1063
- var d;
1064
- (d = a.value) == null || d.showSheet(
1065
- !0,
1066
- {
1067
- type: "NO_REWARD",
1068
- collectible: null,
1069
- weight: 1
1070
- },
1071
- o.value.length
1072
- );
1073
- }
1074
- return (d, c) => {
1075
- const p = resolveComponent("FmButton"), g = resolveComponent("FmCard"), k = resolveComponent("FmHelperText");
1076
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
1077
- createElementVNode("div", _hoisted_2$7, toDisplayString(unref(m)("connect.template.configure_reward_type")), 1),
1078
- createVNode(p, {
1079
- label: unref(m)("connect.campaign.rewardPool.addReward"),
1080
- onClick: c[0] || (c[0] = (V) => b()),
1081
- variant: "plain",
1082
- icon: "add"
1083
- }, null, 8, ["label"]),
1084
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (V, C) => (openBlock(), createBlock(g, {
1085
- key: C,
1086
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
1087
- variant: "outlined",
1088
- onClick: (B) => v(C)
1089
- }, {
1090
- default: withCtx(() => {
1091
- var B;
1092
- return [
1093
- createElementVNode("div", null, [
1094
- createElementVNode("div", _hoisted_3$6, toDisplayString(V.type == "LOYALTY" ? (B = V == null ? void 0 : V.earningOption) == null ? void 0 : B.amount : "") + " " + toDisplayString(y(V).label), 1),
1095
- createElementVNode("div", _hoisted_4$5, toDisplayString(y(V).sublabel), 1)
1096
- ]),
1097
- createVNode(p, {
1098
- icon: "delete",
1099
- variant: "tertiary",
1100
- onClick: (h) => (h.stopPropagation(), x(C))
1101
- }, null, 8, ["onClick"])
1102
- ];
1103
- }),
1104
- _: 2
1105
- }, 1032, ["onClick"]))), 128)),
1106
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u).filter((V) => V.path.join(".") == ""), (V) => (openBlock(), createBlock(k, {
1107
- key: V.message,
1108
- text: V.message,
1109
- state: "error"
1110
- }, null, 8, ["text"]))), 128)),
1111
- createVNode(_sfc_main$b, {
1112
- ref_key: "sheetRef",
1113
- ref: a,
1114
- "onUpdate:modelValue": f
1115
- }, null, 512)
1116
- ]);
1117
- };
1118
- }
1119
- }), _hoisted_1$9 = { class: "space-y-16" }, _hoisted_2$6 = {
1120
- key: 0,
1121
- class: "grid grid-cols-2 gap-16"
1122
- }, _hoisted_3$5 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$4 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
1123
- __name: "PromotionGameTypeInput",
1124
- props: {
1125
- modelValue: {
1126
- type: Object
1127
- }
1128
- },
1129
- emits: ["update:model-value"],
1130
- setup(e, { emit: r }) {
1131
- const { t: l } = useI18n(), s = e, i = r, m = computed(() => [
1132
- {
1133
- label: l("connect.template.promotion_game.rock_paper_scissors.label"),
1134
- description: l("connect.template.promotion_game.rock_paper_scissors.description"),
1135
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
1136
- }
1137
- ]);
1138
- return (n, o) => {
1139
- var y, v, x;
1140
- const u = resolveComponent("FmSwitch"), a = resolveComponent("FmCard"), f = resolveComponent("FmHelperText");
1141
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
1142
- createVNode(u, {
1143
- label: unref(l)("connect.template.promotion_game.enable"),
1144
- "model-value": !!((y = e.modelValue) != null && y.gameType),
1145
- "onUpdate:modelValue": o[0] || (o[0] = (b) => b ? i("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : i("update:model-value", null))
1146
- }, null, 8, ["label", "model-value"]),
1147
- ((v = e.modelValue) == null ? void 0 : v.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
1148
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m), (b) => {
1149
- var d, c;
1150
- return openBlock(), createBlock(a, {
1151
- variant: "outlined",
1152
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1153
- "col-span-2": unref(m).length == 1,
1154
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((d = e.modelValue) == null ? void 0 : d.gameType) == b.value,
1155
- "hover:bg-fm-color-opacity-sm": ((c = e.modelValue) == null ? void 0 : c.gameType) != b.value
1156
- }]),
1157
- onClick: () => {
1158
- var p;
1159
- ((p = s.modelValue) == null ? void 0 : p.gameType) != b.value && i("update:model-value", { gameType: b.value });
1160
- },
1161
- key: b.value
1162
- }, {
1163
- default: withCtx(() => [
1164
- createElementVNode("div", _hoisted_3$5, toDisplayString(b.label), 1),
1165
- createElementVNode("div", _hoisted_4$4, toDisplayString(b.description), 1)
1166
- ]),
1167
- _: 2
1168
- }, 1032, ["class", "onClick"]);
1169
- }), 128))
1170
- ])) : createCommentVNode("", !0),
1171
- ((x = e.modelValue) == null ? void 0 : x.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(f, {
1172
- key: 1,
1173
- text: unref(l)("connect.template.promotion_game.rock_paper_scissors.warning"),
1174
- state: "warning"
1175
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1176
- ]);
1177
- };
1178
- }
1179
- }), _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({
1180
- __name: "MissionTypeInput",
1181
- props: {
1182
- modelValue: {
1183
- type: String
1184
- }
1185
- },
1186
- emits: ["update:model-value"],
1187
- setup(e, { emit: r }) {
1188
- const { t: l } = useI18n(), s = e, i = r, m = computed(() => [
1189
- {
1190
- label: l("connect.campaign.mission.typeOption.STAMP.label"),
1191
- description: l("connect.campaign.mission.typeOption.STAMP.description"),
1192
- value: F_MISSION_TYPE.enum.STAMP
1193
- },
1194
- {
1195
- label: l("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
1196
- description: l("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
1197
- value: F_MISSION_TYPE.enum.PROGRESSIVE
1198
- }
1199
- ]);
1200
- return (n, o) => {
1201
- const u = resolveComponent("FmCard");
1202
- return openBlock(), createElementBlock("div", _hoisted_1$8, [
1203
- createElementVNode("div", _hoisted_2$5, toDisplayString(unref(l)("connect.template.select_game")), 1),
1204
- createElementVNode("div", _hoisted_3$4, [
1205
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m), (a) => (openBlock(), createBlock(u, {
1206
- variant: "outlined",
1207
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1208
- "col-span-2": unref(m).length == 1,
1209
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == a.value,
1210
- "hover:bg-fm-color-opacity-sm": e.modelValue != a.value
1211
- }]),
1212
- onClick: () => {
1213
- s.modelValue != a.value && i("update:model-value", a.value);
1214
- },
1215
- key: a.value
1216
- }, {
1217
- default: withCtx(() => [
1218
- createElementVNode("div", _hoisted_4$3, toDisplayString(a.label), 1),
1219
- createElementVNode("div", _hoisted_5$3, toDisplayString(a.description), 1)
1220
- ]),
1221
- _: 2
1222
- }, 1032, ["class", "onClick"]))), 128))
1223
- ])
1224
- ]);
1225
- };
1226
- }
1227
- }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
1228
- __name: "MissionEndInput",
1229
- props: {
1230
- modelValue: {
1231
- type: [String, Number]
1232
- },
1233
- helperText: {
1234
- type: String
1235
- },
1236
- helperState: {
1237
- type: String
1238
- }
1239
- },
1240
- emits: ["update:model-value"],
1241
- setup(e, { emit: r }) {
1242
- const l = r;
1243
- return (s, i) => {
1244
- const m = resolveComponent("FmStepperField");
1245
- return openBlock(), createElementBlock("div", _hoisted_1$7, [
1246
- i[1] || (i[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Input the total number of stamps needed to complete the mission ", -1)),
1247
- createVNode(m, {
1248
- label: "Maximum to collect",
1249
- "model-value": e.modelValue || null,
1250
- "onUpdate:modelValue": i[0] || (i[0] = (n) => l("update:model-value", n)),
1251
- "helper-text": e.helperText || "Set the threshold required for reward eligibility",
1252
- "helper-state": e.helperState || "none"
1253
- }, null, 8, ["model-value", "helper-text", "helper-state"])
1254
- ]);
1255
- };
1256
- }
1257
- }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
1258
- __name: "EditMissionPoolSheet",
1259
- props: {
1260
- maxThreshold: {
1261
- type: Number,
1262
- required: !0
1263
- }
1264
- },
1265
- emits: ["update:model-value"],
1266
- setup(e, { expose: r, emit: l }) {
1267
- const s = e, i = useMembershipStore(), { minor: m } = useLoading, n = ref(!1), o = ref(), u = ref(), a = ref(0), f = computed(() => {
1268
- var p;
1269
- return ((p = i.loyaltyRewards.items.find(
1270
- (g) => {
1271
- var k;
1272
- return g.value === ((k = o.value) == null ? void 0 : k.collectible);
1273
- }
1274
- )) == null ? void 0 : p.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
1275
- }), y = computed(() => {
1276
- const c = f.value.safeParse(o.value);
1277
- return c.success ? [] : c.error.errors;
1278
- });
1279
- function v(c, p, g) {
1280
- c && (o.value = p, a.value = g), n.value = c;
1281
- }
1282
- const x = l;
1283
- async function b() {
1284
- const c = f.value.safeParse(o.value);
1285
- c.success && (await m(
1286
- async () => {
1287
- c.data.type === "VOUCHER" && u.value && (c.data.collectibleConfig.image = await firebaseStorage.update(
1288
- c.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, u.value),
1289
- u.value
1290
- ));
1291
- },
1292
- {
1293
- message: "Uploading reward image",
1294
- successMessage: "Reward image updated"
1295
- }
1296
- ), x("update:model-value", c.data, a.value));
1297
- }
1298
- const d = ref();
1299
- return r({
1300
- showSheet: v
1301
- }), (c, p) => {
1302
- const g = resolveComponent("FmStepperField"), k = resolveComponent("FmSelect"), V = resolveComponent("FmForm"), C = resolveComponent("FmButton"), B = resolveComponent("FmSideSheet");
1303
- return openBlock(), createBlock(B, {
1304
- "max-width": 560,
1305
- modelValue: unref(n),
1306
- "onUpdate:modelValue": [
1307
- p[10] || (p[10] = (h) => isRef(n) ? n.value = h : null),
1308
- p[11] || (p[11] = (h) => n.value = h)
1309
- ],
1310
- header: "Edit reward",
1311
- "dismiss-away": ""
1312
- }, {
1313
- "side-sheet-footer": withCtx(() => [
1314
- createElementVNode("div", _hoisted_1$6, [
1315
- createVNode(C, {
1316
- variant: "primary",
1317
- type: "button",
1318
- label: "Confirm",
1319
- disabled: unref(y).length > 0,
1320
- onClick: p[8] || (p[8] = async () => {
1321
- var h;
1322
- return (h = unref(d)) == null ? void 0 : h.validateInputs();
1323
- })
1324
- }, null, 8, ["disabled"]),
1325
- createVNode(C, {
1326
- variant: "secondary",
1327
- type: "button",
1328
- label: "Cancel",
1329
- onClick: p[9] || (p[9] = (h) => n.value = !1)
1330
- })
1331
- ])
1332
- ]),
1333
- default: withCtx(() => [
1334
- createVNode(JsonViewer, { json: unref(o) }, null, 8, ["json"]),
1335
- unref(o) ? (openBlock(), createBlock(V, {
1336
- key: 0,
1337
- class: "flex flex-col gap-y-24",
1338
- ref_key: "formRef",
1339
- ref: d,
1340
- onValidationSuccess: p[7] || (p[7] = (h) => b())
1341
- }, {
1342
- default: withCtx(() => {
1343
- var h, S;
1344
- return [
1345
- unref(o).type ? (openBlock(), createBlock(g, {
1346
- key: 0,
1347
- label: "Threshold",
1348
- rules: [
1349
- unref(ZodHelper).toRule(
1350
- unref(z$1).number().min(1).max(
1351
- s.maxThreshold,
1352
- `Number cannot be more than ${s.maxThreshold}`
1353
- )
1354
- )
1355
- ],
1356
- "model-value": unref(o).threshold,
1357
- "onUpdate:modelValue": p[0] || (p[0] = (E) => o.value = {
1358
- ...unref(o),
1359
- threshold: E
1360
- })
1361
- }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
1362
- createVNode(k, {
1363
- label: "Reward Type",
1364
- items: [
1365
- { label: "Voucher", value: "VOUCHER" },
1366
- { label: "Loyalty", value: "LOYALTY" }
1367
- ],
1368
- "model-value": unref(o).type,
1369
- "onUpdate:modelValue": p[1] || (p[1] = (E) => {
1370
- var R, N;
1371
- E === "VOUCHER" ? o.value = {
1372
- collectible: null,
1373
- type: "VOUCHER",
1374
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
1375
- business: unref(useCoreStore)().currentBusiness.value._id
1376
- }),
1377
- earningOption: {
1378
- amount: 1,
1379
- type: "FIXED"
1380
- },
1381
- validityOption: {
1382
- validForDay: 7
1383
- },
1384
- threshold: (R = unref(o)) == null ? void 0 : R.threshold
1385
- } : o.value = {
1386
- collectible: unref(i).loyaltyRewards.raw[0]._id,
1387
- type: "LOYALTY",
1388
- earningOption: {
1389
- amount: 1,
1390
- type: "FIXED"
1391
- },
1392
- validityOption: {
1393
- validForDay: 7
1394
- },
1395
- threshold: (N = unref(o)) == null ? void 0 : N.threshold
1396
- };
1397
- })
1398
- }, null, 8, ["model-value"]),
1399
- unref(o).type == "LOYALTY" ? (openBlock(), createBlock(k, {
1400
- key: 1,
1401
- label: "Loyalty type",
1402
- rules: [unref(ZodHelper).ruleAtPath(unref(f), "collectible", [unref(o).type])],
1403
- items: unref(i).loyaltyRewards.items,
1404
- "model-value": unref(o).collectible,
1405
- "onUpdate:modelValue": p[2] || (p[2] = (E) => unref(o).collectible = E)
1406
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
1407
- unref(o).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
1408
- p[12] || (p[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
1409
- createVNode(_sfc_main$l, {
1410
- class: "mt-[-8px]",
1411
- rules: [unref(ZodHelper).ruleAtPath(unref(f), "earningOption", [unref(o).type])],
1412
- "helper-state": unref(ZodHelper).helperState(unref(y), "earningOption"),
1413
- "error-text": unref(ZodHelper).helperText(unref(y), "earningOption"),
1414
- "fixed-type": !0,
1415
- "model-value": unref(o).earningOption,
1416
- "onUpdate:modelValue": p[3] || (p[3] = (E) => o.value = {
1417
- ...unref(o),
1418
- earningOption: E
1419
- })
1420
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
1421
- createVNode(_sfc_main$m, {
1422
- class: "!gap-24",
1423
- type: unref(o).type === "LOYALTY" ? "custom" : "range",
1424
- "for-credit": unref(o).type === "LOYALTY" && ((h = unref(i).loyaltyRewards.items.find(
1425
- (E) => {
1426
- var R;
1427
- return E.value === ((R = unref(o)) == null ? void 0 : R.collectible);
1428
- }
1429
- )) == null ? void 0 : h.raw.type) === "CREDIT",
1430
- rules: [unref(ZodHelper).ruleAtPath(unref(f), "validityOption", [unref(o).type])],
1431
- "model-value": unref(o).validityOption,
1432
- "onUpdate:modelValue": p[4] || (p[4] = (E) => o.value = {
1433
- ...unref(o),
1434
- validityOption: E
1435
- })
1436
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
1437
- ], 64)) : createCommentVNode("", !0),
1438
- unref(o).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$n, {
1439
- key: 3,
1440
- "reward-image": unref(u),
1441
- "model-value": ((S = unref(o)) == null ? void 0 : S.collectibleConfig) ?? void 0,
1442
- "onUpdate:modelValue": p[5] || (p[5] = (E) => o.value = {
1443
- ...unref(o),
1444
- collectibleConfig: E
1445
- }),
1446
- "onUpdate:rewardImage": p[6] || (p[6] = (E) => u.value = E)
1447
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1448
- createVNode(JsonViewer, { json: unref(y) }, null, 8, ["json"])
1449
- ];
1450
- }),
1451
- _: 1
1452
- }, 512)) : createCommentVNode("", !0)
1453
- ]),
1454
- _: 1
1455
- }, 8, ["modelValue"]);
1456
- };
1457
- }
1458
- }), _hoisted_1$5 = {
1459
- key: 0,
1460
- class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
1461
- }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
1462
- __name: "MissionProgress",
1463
- props: {
1464
- type: {
1465
- type: String,
1466
- required: !0
1467
- },
1468
- maxRange: {
1469
- type: Number,
1470
- required: !0
1471
- },
1472
- currentRange: {
1473
- type: Number,
1474
- default: 0
1475
- },
1476
- markers: {
1477
- type: Array,
1478
- default: () => []
1479
- }
1480
- },
1481
- setup(e) {
1482
- const r = e, { maxRange: l, currentRange: s, markers: i } = toRefs(r), m = computed(
1483
- () => Math.min(s.value / l.value * 100, 100)
1484
- ), n = (o) => o / l.value * 100;
1485
- return (o, u) => {
1486
- const a = resolveComponent("FmIcon");
1487
- return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
1488
- (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(l), 40), (f) => (openBlock(), createBlock(a, {
1489
- class: normalizeClass(
1490
- unref(s) >= f ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
1491
- ),
1492
- outline: unref(s) < f,
1493
- key: f,
1494
- name: unref(i).some((y) => y === f) ? "featured_seasonal_and_gifts" : "check_circle"
1495
- }, null, 8, ["class", "outline", "name"]))), 128))
1496
- ])) : (openBlock(), createElementBlock("div", {
1497
- key: 1,
1498
- class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
1499
- }, [
1500
- createElementVNode("div", {
1501
- class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
1502
- style: normalizeStyle({ width: unref(m) + "%" })
1503
- }, null, 4),
1504
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i), (f, y) => (openBlock(), createElementBlock("div", {
1505
- key: y,
1506
- class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
1507
- style: normalizeStyle({ left: n(f) + "%" })
1508
- }, [
1509
- createElementVNode("div", _hoisted_2$4, [
1510
- createElementVNode("div", {
1511
- class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
1512
- }),
1513
- u[0] || (u[0] = createElementVNode("div", null, "🎁", -1))
1514
- ])
1515
- ], 4))), 128))
1516
- ]));
1517
- };
1518
- }
1519
- }), isObject = (e) => e !== null && typeof e == "object";
1520
- function changeKeysFactory(e) {
1521
- return function r(l, s = 1, i) {
1522
- if (s === 0 || !isObject(l))
1523
- return l;
1524
- if (Array.isArray(l))
1525
- return l.map((n) => r(n, s - 1, i));
1526
- const m = Object.create(Object.getPrototypeOf(l));
1527
- return Object.keys(l).forEach((n) => {
1528
- const o = l[n], u = e(n, i), a = r(o, s - 1, i);
1529
- m[u] = a;
1530
- }), m;
1531
- };
1532
- }
1533
- 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({
1534
- __name: "MissionPoolInput",
1535
- props: {
1536
- modelValue: {
1537
- type: Array,
1538
- default: () => []
1539
- },
1540
- mission: {
1541
- type: Object,
1542
- required: !0
1543
- }
1544
- },
1545
- emits: ["update:model-value"],
1546
- setup(e, { emit: r }) {
1547
- const { t: l } = useI18n(), s = e, i = r, m = useMembershipStore(), n = z$1.array(z$1.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), o = computed(
1548
- () => s.modelValue.sort((c, p) => c.threshold - p.threshold) ?? []
1549
- ), u = computed(() => {
1550
- const c = n.safeParse(o.value);
1551
- return c.success ? [] : c.error.errors;
1552
- }), a = ref();
1553
- function f(c, p) {
1554
- var k;
1555
- const g = [...o.value];
1556
- g[p] = c, (k = a.value) == null || k.showSheet(!1), i("update:model-value", g);
1557
- }
1558
- function y(c) {
1559
- const p = c.type == "VOUCHER" ? c.collectibleConfig : m.collectibles.find(
1560
- (V) => V._id.toString() == c.collectible
1561
- ), g = CollectionUtils.formattedType((p == null ? void 0 : p.name) || ""), k = c.earningOption.type == "FIXED" ? l("connect.template.mission_pool.reward_sublabel_fixed", {
1562
- threshold: c.threshold,
1563
- amount: c.earningOption.amount
1564
- }) : l("connect.template.mission_pool.reward_sublabel_per_spend", {
1565
- threshold: c.threshold,
1566
- amount: c.earningOption.amount,
1567
- every: c.earningOption.every
1568
- });
1569
- return {
1570
- label: isNullOrEmpty(g) ? l("connect.template.mission_pool.no_reward") : g,
1571
- sublabel: k
1572
- };
1573
- }
1574
- function v(c) {
1575
- var g;
1576
- const p = [...o.value];
1577
- (g = a.value) == null || g.showSheet(!0, p[c], c);
1578
- }
1579
- function x(c) {
1580
- const p = [...o.value];
1581
- p.splice(c, 1), i("update:model-value", p);
1582
- }
1583
- function b() {
1584
- var c;
1585
- (c = a.value) == null || c.showSheet(
1586
- !0,
1587
- {
1588
- type: "LOYALTY",
1589
- collectible: m.loyaltyRewards.items[0].value,
1590
- threshold: null,
1591
- validityOption: {
1592
- validForDay: 7
1593
- },
1594
- earningOption: {
1595
- type: "FIXED",
1596
- amount: 1
1597
- }
1598
- },
1599
- o.value.length
1600
- );
1601
- }
1602
- function d(c) {
1603
- var p, g;
1604
- return c.type == "VOUCHER" ? (p = c.collectibleConfig) == null ? void 0 : p.name : sentenceCase(
1605
- ((g = m.loyaltyRewards.items.find(
1606
- (k) => k.value == c.collectible
1607
- )) == null ? void 0 : g.label) || ""
1608
- );
1609
- }
1610
- return (c, p) => {
1611
- const g = resolveComponent("FmButton"), k = resolveComponent("FmCard"), V = resolveComponent("FmHelperText");
1612
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
1613
- createElementVNode("div", _hoisted_2$3, toDisplayString(unref(l)("connect.template.configure_reward_customer")), 1),
1614
- createVNode(g, {
1615
- label: unref(l)("connect.template.mission_pool.add_reward"),
1616
- onClick: p[0] || (p[0] = (C) => b()),
1617
- variant: "plain",
1618
- icon: "add"
1619
- }, null, 8, ["label"]),
1620
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (C, B) => (openBlock(), createBlock(k, {
1621
- key: B,
1622
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
1623
- variant: "outlined",
1624
- onClick: (h) => v(B)
1625
- }, {
1626
- default: withCtx(() => [
1627
- createElementVNode("div", null, [
1628
- createElementVNode("div", _hoisted_3$3, toDisplayString(y(C).label), 1),
1629
- createElementVNode("div", _hoisted_4$2, toDisplayString(y(C).sublabel), 1)
1630
- ]),
1631
- createVNode(g, {
1632
- icon: "delete",
1633
- variant: "tertiary",
1634
- onClick: (h) => (h.stopPropagation(), x(B))
1635
- }, null, 8, ["onClick"])
1636
- ]),
1637
- _: 2
1638
- }, 1032, ["onClick"]))), 128)),
1639
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u).filter((C) => C.path.join(".") == ""), (C) => (openBlock(), createBlock(V, {
1640
- key: C.message,
1641
- text: C.message,
1642
- state: "error"
1643
- }, null, 8, ["text"]))), 128)),
1644
- createElementVNode("div", _hoisted_5$2, toDisplayString(unref(l)("connect.template.mission_pool.preview")), 1),
1645
- (openBlock(), createBlock(k, {
1646
- key: 0,
1647
- variant: "outlined",
1648
- class: "p-24 space-y-16 w-fit"
1649
- }, {
1650
- default: withCtx(() => {
1651
- var C, B;
1652
- return [
1653
- createElementVNode("div", _hoisted_6$2, [
1654
- createElementVNode("div", null, [
1655
- createElementVNode("div", _hoisted_7$2, toDisplayString(unref(l)("connect.template.mission_pool.collect_stamps", { end: e.mission.end })) + " " + toDisplayString(((C = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : C.earningOption.amount) > 1 ? (B = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : B.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? d(e.modelValue[e.modelValue.length - 1]) : ""), 1),
1656
- createElementVNode("div", _hoisted_8$2, toDisplayString(unref(l)("connect.template.mission_pool.earn_stamp")), 1)
1657
- ])
1658
- ]),
1659
- createElementVNode("div", _hoisted_9$2, [
1660
- createVNode(_sfc_main$5, {
1661
- type: e.mission.type,
1662
- "max-range": e.mission.end,
1663
- currentRange: e.mission.end / 4,
1664
- markers: e.modelValue.map((h) => h.threshold)
1665
- }, null, 8, ["type", "max-range", "currentRange", "markers"]),
1666
- e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_10$2, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
1667
- ])
1668
- ];
1669
- }),
1670
- _: 1
1671
- })),
1672
- createVNode(_sfc_main$6, {
1673
- ref_key: "sheetRef",
1674
- ref: a,
1675
- "onUpdate:modelValue": f,
1676
- "max-threshold": e.mission.end
1677
- }, null, 8, ["max-threshold"])
1678
- ]);
1679
- };
1680
- }
1681
- }), _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({
1682
- __name: "MissionInput",
1683
- props: {
1684
- modelValue: Object
1685
- },
1686
- emits: ["update:model-value"],
1687
- setup(e, { emit: r }) {
1688
- const { t: l } = useI18n(), s = e, i = computed(() => {
1689
- const o = FdoMission.safeParse(s.modelValue);
1690
- return o.success ? [] : o.error.errors;
1691
- }), m = computed(() => [
1692
- {
1693
- label: l("connect.campaign.mission.typeOption.STAMP.label"),
1694
- description: l("connect.campaign.mission.typeOption.STAMP.description"),
1695
- value: F_MISSION_TYPE.enum.STAMP
1696
- },
1697
- {
1698
- label: l("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
1699
- description: l("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
1700
- value: F_MISSION_TYPE.enum.PROGRESSIVE
1701
- }
1702
- ]), n = r;
1703
- return (o, u) => {
1704
- var y;
1705
- const a = resolveComponent("FmCard"), f = resolveComponent("FmStepperField");
1706
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
1707
- createElementVNode("div", _hoisted_2$2, [
1708
- createElementVNode("div", _hoisted_3$2, toDisplayString(unref(l)("connect.campaign.mission.missionType")), 1),
1709
- createElementVNode("div", _hoisted_4$1, toDisplayString(unref(l)("connect.template.select_game")), 1),
1710
- createElementVNode("div", _hoisted_5$1, [
1711
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m), (v) => {
1712
- var x, b;
1713
- return openBlock(), createBlock(a, {
1714
- variant: "outlined",
1715
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1716
- "col-span-2": unref(m).length == 1,
1717
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((x = e.modelValue) == null ? void 0 : x.type) == v.value,
1718
- "hover:bg-fm-color-opacity-sm": ((b = e.modelValue) == null ? void 0 : b.type) != v.value
1719
- }]),
1720
- onClick: () => {
1721
- var d, c;
1722
- ((d = e.modelValue) == null ? void 0 : d.type) != v.value && n("update:model-value", {
1723
- ...e.modelValue,
1724
- type: v.value,
1725
- end: ((c = e.modelValue) == null ? void 0 : c.end) || 1
1726
- });
1727
- },
1728
- key: v.value
1729
- }, {
1730
- default: withCtx(() => [
1731
- createElementVNode("div", _hoisted_6$1, toDisplayString(v.label), 1),
1732
- createElementVNode("div", _hoisted_7$1, toDisplayString(v.description), 1)
1733
- ]),
1734
- _: 2
1735
- }, 1032, ["class", "onClick"]);
1736
- }), 128))
1737
- ])
1738
- ]),
1739
- createElementVNode("div", _hoisted_8$1, [
1740
- createElementVNode("div", _hoisted_9$1, toDisplayString(unref(l)("connect.campaign.mission.collectionsRequired")), 1),
1741
- createElementVNode("div", _hoisted_10$1, toDisplayString(unref(l)("connect.campaign.mission.collectionsRequiredDescription")), 1),
1742
- createVNode(f, {
1743
- label: unref(l)("connect.campaign.mission.maximumToCollect"),
1744
- "model-value": ((y = e.modelValue) == null ? void 0 : y.end) || null,
1745
- "onUpdate:modelValue": u[0] || (u[0] = (v) => {
1746
- var x;
1747
- return n("update:model-value", {
1748
- ...e.modelValue,
1749
- type: ((x = e.modelValue) == null ? void 0 : x.type) || "STAMP",
1750
- end: v
1751
- });
1752
- }),
1753
- "helper-text": unref(ZodHelper).helperText(unref(i), "end") || unref(l)("connect.campaign.mission.thresholdHelperText"),
1754
- "helper-state": unref(ZodHelper).helperState(unref(i), "end") || "none"
1755
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"])
1756
- ])
1757
- ]);
1758
- };
1759
- }
1760
- });
1761
- function useLocaleText() {
1762
- const { locale: e, t: r } = useI18n();
1763
- function l(s, i) {
1764
- return s ? s[e.value] ?? s["en-US"] ?? r(i) : r(i);
1765
- }
1766
- return { getLocaleText: l };
1767
- }
1768
- const _hoisted_1$2 = { key: 26 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
1769
- __name: "TemplateInput",
1770
- props: {
1771
- field: { type: Object, required: !0 },
1772
- modelValue: {
1773
- type: Object
1774
- },
1775
- schema: {
1776
- type: Object
1777
- },
1778
- extras: {
1779
- type: Object
1780
- },
1781
- helperText: {
1782
- type: String
1783
- },
1784
- disabled: {
1785
- type: Boolean,
1786
- default: !1
1787
- },
1788
- campaignType: {
1789
- type: String,
1790
- default: void 0
1791
- }
1792
- },
1793
- emits: ["update:model-value", "update:file"],
1794
- setup(e, { emit: r }) {
1795
- const { t: l } = useI18n(), { getLocaleText: s } = useLocaleText(), i = e, m = r;
1796
- function n(f) {
1797
- switch (i.field.type) {
1798
- case "timeframe":
1799
- const y = f.startDate ? hooks(f.startDate).startOf("day").toISOString() : void 0, v = f.endDate ? hooks(f.endDate).endOf("day").toISOString() : void 0;
1800
- m("update:model-value", {
1801
- type: "timeframe",
1802
- property: "__now",
1803
- start: y,
1804
- end: v
1805
- });
1806
- break;
1807
- case "image": {
1808
- m(
1809
- "update:file",
1810
- f,
1811
- o.value || firebaseStorage.collectibleImagePath(void 0, f)
1812
- );
1813
- break;
1814
- }
1815
- default:
1816
- m("update:model-value", f);
1817
- break;
1818
- }
1819
- }
1820
- const o = computed(() => {
1821
- switch (i.field.type) {
1822
- case "timeframe": {
1823
- const f = i.modelValue;
1824
- return {
1825
- startDate: f != null && f.start ? hooks(f == null ? void 0 : f.start).format("YYYY-MM-DD") : null,
1826
- endDate: f != null && f.end ? hooks(f == null ? void 0 : f.end).format("YYYY-MM-DD") : null
1827
- };
1828
- }
1829
- default:
1830
- return i.modelValue;
1831
- }
1832
- });
1833
- function u() {
1834
- if (!a.value.schema) return [];
1835
- const f = a.value.schema.safeParse(i.modelValue);
1836
- return f.success ? [] : f.error.errors;
1837
- }
1838
- const a = computed(() => ({
1839
- schema: i.schema,
1840
- unwrapped: i.schema ? ZodHelper.unwrap(i.schema) : void 0,
1841
- rules: i.schema ? [ZodHelper.ruleAtPath(i.schema, "")] : void 0,
1842
- labelMark: i.schema && ZodHelper.isRequired(i.schema) == !1 ? "optional" : void 0,
1843
- zodLabel: i.schema ? ZodHelper.toInputLabel(
1844
- i.schema,
1845
- s(i.field.label_locale, i.field.label ?? "")
1846
- ) : void 0
1847
- }));
1848
- return (f, y) => {
1849
- var p, g, k, V, C;
1850
- const v = resolveComponent("FmTextField"), x = resolveComponent("FmStepperField"), b = resolveComponent("FmTextarea"), d = resolveComponent("FmHelperText"), c = resolveComponent("FmSwitch");
1851
- return e.field.type === "text" ? (openBlock(), createBlock(v, {
1852
- key: 0,
1853
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
1854
- "label-mark": unref(a).labelMark,
1855
- rules: unref(a).rules,
1856
- "model-value": unref(o),
1857
- "onUpdate:modelValue": n,
1858
- "helper-state": e.helperText ? "error" : void 0,
1859
- "helper-text": e.helperText
1860
- }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1861
- createVNode(JsonViewer, {
1862
- json: { schema: unref(a).unwrapped, props: i }
1863
- }, null, 8, ["json"]),
1864
- createVNode(x, {
1865
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
1866
- "label-mark": e.field.isRuleChildren ? void 0 : unref(a).labelMark,
1867
- "model-value": unref(o),
1868
- rules: e.field.isRuleChildren ? [] : unref(a).rules,
1869
- "onUpdate:modelValue": n,
1870
- "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
1871
- "helper-text": e.field.isRuleChildren ? e.helperText : void 0
1872
- }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
1873
- ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(b, {
1874
- key: 2,
1875
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
1876
- "label-mark": unref(a).labelMark,
1877
- rules: unref(a).rules,
1878
- "model-value": unref(o),
1879
- "onUpdate:modelValue": n,
1880
- "show-word-count": "",
1881
- "max-length": (C = (V = (k = (g = (p = unref(a)) == null ? void 0 : p.unwrapped) == null ? void 0 : g._def) == null ? void 0 : k.checks) == null ? void 0 : V.find((B) => B.kind == "max")) == null ? void 0 : C.value
1882
- }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$g, {
1883
- key: 3,
1884
- "campaign-type": e.extras,
1885
- "model-value": unref(o),
1886
- disabled: e.disabled,
1887
- "onUpdate:modelValue": n
1888
- }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
1889
- createVNode(_sfc_main$e, {
1890
- "model-value": unref(o),
1891
- "onUpdate:modelValue": n
1892
- }, null, 8, ["model-value"]),
1893
- createVNode(d, {
1894
- class: "!mt-[8px]",
1895
- text: unref(ZodHelper).helperText(u(), ""),
1896
- state: unref(ZodHelper).helperState(u(), "")
1897
- }, null, 8, ["text", "state"])
1898
- ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$o, {
1899
- key: 5,
1900
- thumbnail: unref(o),
1901
- "aspect-ratio": "16 / 9",
1902
- class: "w-1/2 xs:w-2/3",
1903
- "onUpdate:file": n
1904
- }, {
1905
- label: withCtx(() => [
1906
- (openBlock(), createBlock(resolveDynamicComponent(unref(a).zodLabel)))
1907
- ]),
1908
- _: 1
1909
- }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(c, {
1910
- key: 6,
1911
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
1912
- "label-placement": "right",
1913
- sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
1914
- "label-mark": unref(a).labelMark,
1915
- rules: unref(a).rules,
1916
- "model-value": unref(o),
1917
- "onUpdate:modelValue": n
1918
- }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$p, {
1919
- key: 7,
1920
- "model-value": unref(o),
1921
- "onUpdate:modelValue": n,
1922
- "no-campaign": !1,
1923
- schema: unref(a).schema,
1924
- "is-mission": e.extras === "MISSION"
1925
- }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$q, {
1926
- key: 8,
1927
- "model-value": unref(o),
1928
- "onUpdate:modelValue": n
1929
- }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 9 }, [
1930
- createVNode(_sfc_main$r, {
1931
- "model-value": unref(o),
1932
- "onUpdate:modelValue": n,
1933
- "can-set-auto-apply": e.field.property == "campaign.effect"
1934
- }, null, 8, ["model-value", "can-set-auto-apply"]),
1935
- unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(d, {
1936
- key: 0,
1937
- class: "!mt-[8px]",
1938
- text: unref(l)("connect.campaign.common.effect_required"),
1939
- state: "error"
1940
- }, null, 8, ["text"]))
1941
- ], 64)) : e.field.type === "message" ? (openBlock(), createBlock(_sfc_main$s, {
1942
- key: 10,
1943
- "allow-email": !0,
1944
- "allow-whatsapp": !0,
1945
- "model-value": unref(o),
1946
- "onUpdate:modelValue": n,
1947
- "helper-text": unref(ZodHelper).helperText(u(), ""),
1948
- "trigger-type": e.field.extras,
1949
- "helper-state": unref(ZodHelper).helperState(u(), "")
1950
- }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"])) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$l, {
1951
- key: 11,
1952
- "model-value": unref(o),
1953
- "onUpdate:modelValue": n,
1954
- extras: e.extras,
1955
- "error-text": e.helperText
1956
- }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$m, {
1957
- key: 12,
1958
- type: "custom",
1959
- "model-value": unref(o),
1960
- "onUpdate:modelValue": n,
1961
- "helper-text": e.helperText || unref(ZodHelper).helperText(u(), ""),
1962
- "for-credit": i.campaignType === "CREDIT"
1963
- }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$c, {
1964
- key: 13,
1965
- "model-value": unref(o),
1966
- "onUpdate:modelValue": n
1967
- }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$a, {
1968
- key: 14,
1969
- "model-value": unref(o),
1970
- "onUpdate:modelValue": n
1971
- }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
1972
- key: 15,
1973
- "model-value": unref(o),
1974
- "onUpdate:modelValue": n
1975
- }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
1976
- key: 16,
1977
- "model-value": unref(o),
1978
- "onUpdate:modelValue": n
1979
- }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
1980
- key: 17,
1981
- "model-value": unref(o),
1982
- "onUpdate:modelValue": n,
1983
- "helper-text": unref(ZodHelper).helperText(u(), ""),
1984
- "helper-state": unref(ZodHelper).helperState(u(), "")
1985
- }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
1986
- key: 18,
1987
- "model-value": unref(o),
1988
- "onUpdate:modelValue": n,
1989
- mission: e.extras.mission
1990
- }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 19 }, [
1991
- createVNode(_sfc_main$d, {
1992
- "model-value": unref(o),
1993
- "onUpdate:modelValue": n,
1994
- "start-date": e.extras.start,
1995
- "end-date": e.extras.end
1996
- }, null, 8, ["model-value", "start-date", "end-date"]),
1997
- e.helperText ? (openBlock(), createBlock(d, {
1998
- key: 0,
1999
- class: "!mt-[8px]",
2000
- text: e.helperText,
2001
- state: "error"
2002
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2003
- ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 20 }, [
2004
- createVNode(_sfc_main$t, {
2005
- "model-value": unref(o),
2006
- "onUpdate:modelValue": n
2007
- }, null, 8, ["model-value"]),
2008
- e.helperText ? (openBlock(), createBlock(d, {
2009
- key: 0,
2010
- class: "!mt-[8px]",
2011
- text: e.helperText,
2012
- state: "error"
2013
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2014
- ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 21 }, [
2015
- e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(o).rules.g_time).length > 0 ? (openBlock(), createBlock(d, {
2016
- key: 0,
2017
- state: "warning",
2018
- text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
2019
- }, null, 8, ["text"])) : createCommentVNode("", !0),
2020
- createVNode(_sfc_main$i, {
2021
- "model-value": unref(o),
2022
- "onUpdate:modelValue": n
2023
- }, null, 8, ["model-value"]),
2024
- e.helperText ? (openBlock(), createBlock(d, {
2025
- key: 1,
2026
- class: "!mt-[8px]",
2027
- text: e.helperText,
2028
- state: "error"
2029
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2030
- ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
2031
- createVNode(_sfc_main$u, {
2032
- "model-value": unref(o),
2033
- "onUpdate:modelValue": n
2034
- }, null, 8, ["model-value"]),
2035
- e.helperText ? (openBlock(), createBlock(d, {
2036
- key: 0,
2037
- class: "!mt-[8px]",
2038
- text: e.helperText,
2039
- state: "error"
2040
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2041
- ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
2042
- createVNode(_sfc_main$v, {
2043
- "model-value": unref(o),
2044
- "onUpdate:modelValue": n
2045
- }, null, 8, ["model-value"]),
2046
- e.helperText ? (openBlock(), createBlock(d, {
2047
- key: 0,
2048
- class: "!mt-[8px]",
2049
- text: e.helperText,
2050
- state: "error"
2051
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2052
- ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
2053
- createVNode(_sfc_main$h, {
2054
- "model-value": unref(o),
2055
- "onUpdate:modelValue": n
2056
- }, null, 8, ["model-value"]),
2057
- e.helperText ? (openBlock(), createBlock(d, {
2058
- key: 0,
2059
- class: "!mt-[8px]",
2060
- text: e.helperText,
2061
- state: "error"
2062
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2063
- ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
2064
- createVNode(_sfc_main$9, {
2065
- "model-value": unref(o),
2066
- "onUpdate:modelValue": n
2067
- }, null, 8, ["model-value"]),
2068
- e.helperText ? (openBlock(), createBlock(d, {
2069
- key: 0,
2070
- class: "!mt-[8px]",
2071
- text: e.helperText,
2072
- state: "error"
2073
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2074
- ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(i.field), 1));
2075
- };
2076
- }
2077
- }), _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({
2078
- __name: "CampaignSummary",
2079
- props: {
2080
- data: {
2081
- type: Object,
2082
- required: !0
2083
- }
2084
- },
2085
- setup(e) {
2086
- const { t: r, te: l } = useI18n();
2087
- return (s, i) => {
2088
- const m = resolveComponent("FmCard");
2089
- return openBlock(), createBlock(m, {
2090
- variant: "outlined",
2091
- class: "p-16 space-y-8"
2092
- }, {
2093
- default: withCtx(() => [
2094
- createElementVNode("div", _hoisted_1$1, toDisplayString(unref(r)("connect.campaign.common.summary")), 1),
2095
- i[0] || (i[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
2096
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (n, o) => (openBlock(), createElementBlock("div", {
2097
- class: "space-y-4",
2098
- key: o
2099
- }, [
2100
- n ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2101
- createElementVNode("div", _hoisted_2$1, toDisplayString(unref(r)(`${o}`)), 1),
2102
- createElementVNode("div", _hoisted_3$1, toDisplayString(unref(l)(`${n}`) ? unref(r)(`${n}`) : n), 1)
2103
- ], 64)) : createCommentVNode("", !0)
2104
- ]))), 128))
2105
- ]),
2106
- _: 1
2107
- });
2108
- };
2109
- }
2110
- }), _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 = {
2111
- key: 0,
2112
- class: "max-w-6xl mx-auto"
2113
- }, _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({
2114
- __name: "EditCampaignSheet",
2115
- emits: ["submit:model-value"],
2116
- setup(__props, { expose: __expose, emit: __emit }) {
2117
- const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), { getLocaleText } = useLocaleText(), currentStep = ref(1), data = ref(), schema = ref(z$1.any()), template = ref(
2118
- TEMPLATES.VOUCHER
2119
- ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER");
2120
- async function showSheet(visible, type, campaign, selectedTemplate) {
2121
- var e, r, l;
2122
- if (sheetVisible.value = visible, campaignType.value = type, visible == !0) {
2123
- try {
2124
- isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
2125
- } catch {
2126
- } finally {
2127
- await new Promise((s) => setTimeout(s, 120)), isLoading.value = !1;
2128
- }
2129
- template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((s, i) => {
2130
- var m;
2131
- if (s.campaign.type === "VOUCHER" && s.campaign.code) {
2132
- const n = (m = s.campaign._id) == null ? void 0 : m.toString();
2133
- useCampaignStore().campaigns.voucher.some(
2134
- (o) => o.code === s.campaign.code && o._id.toString() !== n
2135
- ) && i.addIssue({
2136
- code: "custom",
2137
- message: "Code already exists, please use another code",
2138
- path: ["campaign", "code"]
2139
- });
2140
- }
2141
- })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
2142
- ...(r = template.value) == null ? void 0 : r.defaultValue
2143
- }), "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 = (l = campaign == null ? void 0 : campaign.campaign) != null && l._id ? t("connect.campaign.common.edit_campaign_title", {
2144
- typeName: t(`connect.campaign.common.typeName.${type}`)
2145
- }) : t("connect.campaign.common.create_campaign_title", {
2146
- typeName: t(`connect.campaign.common.typeName.${type}`)
2147
- });
2148
- }
2149
- }
2150
- async function hideSheet() {
2151
- Dialog.open({
2152
- title: t("connect.campaign.common.unsaved_changes"),
2153
- message: t("connect.campaign.common.unsaved_changes"),
2154
- primaryActions: {
2155
- text: t("connect.campaign.common.unsaved_changes_confirm"),
2156
- close: !0
2157
- },
2158
- secondaryActions: {
2159
- text: t("connect.campaign.common.unsaved_changes_cancel"),
2160
- close: !1
2161
- }
2162
- }).onPrimary(() => {
2163
- sheetVisible.value = !1;
2164
- }).onSecondary(() => {
2165
- Dialog.close();
2166
- });
2167
- }
2168
- const emits = __emit, errors = computed(() => {
2169
- const e = schema.value.superRefine(campaignRefinement).safeParse(data.value);
2170
- return e.success ? [] : e.error.errors;
2171
- });
2172
- function stepErrors(e = currentStep.value - 1) {
2173
- const r = template.value.steps[e].groups.flatMap(
2174
- (l) => l.fields.map((s) => s.property)
2175
- );
2176
- return errors.value.filter(
2177
- (l) => r.some((s) => l.path.join(".").includes(s))
2178
- );
2179
- }
2180
- __expose({ showSheet });
2181
- function showSummaryDialog() {
2182
- Dialog.open({
2183
- title: "",
2184
- dialogComponent: _sfc_main$1,
2185
- dialogComponentProps: {
2186
- data: data.value
2187
- }
2188
- });
2189
- }
2190
- function onUpdateProperty(e, r) {
2191
- var l, s, i, m, n, o, u, a;
2192
- if (_.set(data.value, e, r), e == "campaign.event.type") {
2193
- const y = ((m = (i = (s = (l = template.value) == null ? void 0 : l.defaultValue) == null ? void 0 : s.campaign) == null ? void 0 : i.event) == null ? void 0 : m.rule) ? _.cloneDeep({
2194
- ...(a = (u = (o = (n = template.value) == null ? void 0 : n.defaultValue) == null ? void 0 : o.campaign) == null ? void 0 : u.event) == null ? void 0 : a.rule
2195
- }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
2196
- RuleBuilder.scaffoldGroup("g_schedule"),
2197
- RuleBuilder.scaffoldGroup("g_time"),
2198
- RuleBuilder.scaffoldGroup("g_user"),
2199
- RuleBuilder.scaffoldGroup("g_bill")
2200
- ]), v = RuleBuilder.setRuleToGroup(
2201
- RuleBuilder.scaffoldGroup("g_schedule"),
2202
- [
2203
- RuleBuilder.constructEntry(
2204
- "trigger.date",
2205
- "_rrule",
2206
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
2207
- ),
2208
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2209
- ],
2210
- "&&"
2211
- );
2212
- if (r != "SCHEDULE") {
2213
- _.set(data.value, "campaign.event.rule", y);
2214
- return;
2215
- }
2216
- _.set(
2217
- data.value,
2218
- "campaign.event.rule",
2219
- RuleBuilder.setRuleToGroup(y, v)
2220
- );
2221
- }
2222
- e == "campaign.notify" && r == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
2223
- }
2224
- async function onUpdateFile(e, r) {
2225
- return e ? await minor(async () => firebaseStorage.update(r, e), {
2226
- message: `${e ? "Uploading" : "Removing"} file`,
2227
- successMessage: `File ${e ? "uploaded" : "removed"} successfully`
2228
- }) : "";
2229
- }
2230
- function isDisable(e) {
2231
- var r, l;
2232
- switch (e == null ? void 0 : e.property) {
2233
- case "campaign.event.type":
2234
- return ((l = (r = data.value) == null ? void 0 : r.campaign) == null ? void 0 : l._id) || !1;
2235
- default:
2236
- return !1;
2237
- }
2238
- }
2239
- function onSubmit() {
2240
- const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
2241
- e.success && (emits("submit:model-value", cleanPF(JSON.parse(JSON.stringify(e.data)))), sheetVisible.value = !1);
2242
- }
2243
- return (e, r) => {
2244
- const l = resolveComponent("FmButton"), s = resolveComponent("FmStep"), i = resolveComponent("FmStepper"), m = resolveComponent("FmCard"), n = resolveComponent("FmTopSheet");
2245
- return openBlock(), createBlock(n, {
2246
- "fullscreen-size": "lg",
2247
- modelValue: unref(sheetVisible),
2248
- "onUpdate:modelValue": [
2249
- r[7] || (r[7] = (o) => isRef(sheetVisible) ? sheetVisible.value = o : null),
2250
- r[8] || (r[8] = (o) => sheetVisible.value = o)
2251
- ]
2252
- }, createSlots({
2253
- "top-sheet-header": withCtx(() => [
2254
- createElementVNode("div", _hoisted_1, [
2255
- createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
2256
- createElementVNode("div", _hoisted_2, [
2257
- createVNode(l, {
2258
- onClick: r[0] || (r[0] = (o) => hideSheet()),
2259
- label: unref(t)("connect.campaign.common.cancel"),
2260
- variant: "tertiary"
2261
- }, null, 8, ["label"]),
2262
- createVNode(l, {
2263
- onClick: onSubmit,
2264
- label: unref(t)("connect.campaign.common.save"),
2265
- disabled: unref(errors).length > 0
2266
- }, null, 8, ["label", "disabled"])
2267
- ])
2268
- ])
2269
- ]),
2270
- _: 2
2271
- }, [
2272
- unref(isLoading) ? {
2273
- name: "default",
2274
- fn: withCtx(() => [
2275
- createElementVNode("div", _hoisted_9, [
2276
- createElementVNode("div", _hoisted_10, [
2277
- createElementVNode("div", _hoisted_11, [
2278
- r[9] || (r[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
2279
- createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
2280
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2281
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2282
- createElementVNode("div", { class: "space-y-3" }, [
2283
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2284
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2285
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2286
- ]),
2287
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2288
- ]),
2289
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2290
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2291
- createElementVNode("div", { class: "space-y-3" }, [
2292
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2293
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2294
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2295
- ]),
2296
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2297
- ])
2298
- ])
2299
- ], -1)),
2300
- createVNode(m, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
2301
- ])
2302
- ])
2303
- ])
2304
- ]),
2305
- key: "1"
2306
- } : {
2307
- name: "default",
2308
- fn: withCtx(() => [
2309
- unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
2310
- createVNode(i, {
2311
- modelValue: unref(currentStep),
2312
- "onUpdate:modelValue": r[1] || (r[1] = (o) => isRef(currentStep) ? currentStep.value = o : null),
2313
- orientation: "horizontal",
2314
- class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
2315
- }, {
2316
- default: withCtx(() => [
2317
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, u) => (openBlock(), createBlock(s, {
2318
- key: o.name,
2319
- title: unref(getLocaleText)(o.name_locale, o.name),
2320
- value: u + 1,
2321
- error: () => stepErrors(u).length > 0,
2322
- complete: () => u + 1 <= unref(currentStep)
2323
- }, null, 8, ["title", "value", "error", "complete"]))), 128))
2324
- ]),
2325
- _: 1
2326
- }, 8, ["modelValue"]),
2327
- createElementVNode("div", _hoisted_4, [
2328
- createVNode(l, {
2329
- icon: "close",
2330
- variant: "tertiary",
2331
- onClick: r[2] || (r[2] = (o) => sheetVisible.value = !1)
2332
- }),
2333
- createVNode(i, {
2334
- modelValue: unref(currentStep),
2335
- "onUpdate:modelValue": r[3] || (r[3] = (o) => isRef(currentStep) ? currentStep.value = o : null),
2336
- orientation: "horizontal",
2337
- class: "flex-1"
2338
- }, {
2339
- default: withCtx(() => [
2340
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, u) => (openBlock(), createBlock(s, {
2341
- key: o.name,
2342
- title: unref(sheetTitle),
2343
- description: unref(getLocaleText)(o.name_locale, o.name),
2344
- value: u + 1,
2345
- error: () => stepErrors(u).length > 0,
2346
- complete: () => u + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
2347
- }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
2348
- ]),
2349
- _: 1
2350
- }, 8, ["modelValue"]),
2351
- createVNode(l, {
2352
- icon: "info",
2353
- variant: "tertiary",
2354
- onClick: r[4] || (r[4] = () => showSummaryDialog())
2355
- })
2356
- ]),
2357
- createElementVNode("div", _hoisted_5, [
2358
- createElementVNode("div", _hoisted_6, [
2359
- createVNode(JsonViewer, {
2360
- json: {
2361
- data: unref(data),
2362
- errors: unref(errors).map(
2363
- (o) => `${o.path.join(".")} - ${o.message}`
2364
- ),
2365
- stepErrors: stepErrors().map(
2366
- (o) => `${o.path.join(".")} - ${o.message}`
2367
- ),
2368
- schema: unref(schema)
2369
- }
2370
- }, null, 8, ["json"]),
2371
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
2372
- (o) => o.fields.length && (!o.condition || (Array.isArray(o.condition) ? o.condition.every((u) => unref(_).get(unref(data), u.property) == u.value == (u.not != !0)) : unref(_).get(unref(data), o.condition.property) == o.condition.value == (o.condition.not != !0)))
2373
- ), (o, u) => (openBlock(), createElementBlock("div", {
2374
- key: u,
2375
- class: "space-y-24"
2376
- }, [
2377
- createElementVNode("div", _hoisted_7, toDisplayString(unref(getLocaleText)(o.name_locale, o.name ?? "")), 1),
2378
- (openBlock(!0), createElementBlock(Fragment, null, renderList(o.fields, (a, f) => (openBlock(), createElementBlock("div", { key: f }, [
2379
- (openBlock(), createBlock(_sfc_main$2, {
2380
- key: f,
2381
- field: a,
2382
- modelValue: unref(_).get(unref(data), a.property),
2383
- disabled: isDisable(a),
2384
- "campaign-type": unref(campaignType),
2385
- "onUpdate:modelValue": (y) => onUpdateProperty(a.property, y),
2386
- "onUpdate:file": async (y, v) => {
2387
- const x = await onUpdateFile(y, v);
2388
- onUpdateProperty(a.property, x || "");
2389
- },
2390
- schema: unref(ZodHelper).typeAtPath(
2391
- unref(schema),
2392
- a.property,
2393
- unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
2394
- ),
2395
- "helper-state": unref(ZodHelper).helperState(unref(errors), a.property),
2396
- "helper-text": unref(ZodHelper).helperText(unref(errors), a.property),
2397
- extras: a.extras != null ? a.extras == "" ? unref(data) : unref(_).get(unref(data), a.extras) : void 0
2398
- }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
2399
- ]))), 128))
2400
- ]))), 128)),
2401
- createElementVNode("div", _hoisted_8, [
2402
- createVNode(l, {
2403
- label: unref(t)("connect.common.back"),
2404
- variant: "tertiary",
2405
- disabled: unref(currentStep) == 1,
2406
- onClick: r[5] || (r[5] = (o) => currentStep.value--)
2407
- }, null, 8, ["label", "disabled"]),
2408
- createVNode(l, {
2409
- disabled: unref(currentStep) - 1 < unref(template).steps.length - 1 ? stepErrors().length > 0 : unref(errors).length > 0,
2410
- label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? unref(t)("connect.common.next") : unref(t)("connect.common.submit"),
2411
- onClick: r[6] || (r[6] = (o) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? currentStep.value++ : onSubmit())
2412
- }, null, 8, ["disabled", "label"])
2413
- ])
2414
- ]),
2415
- createVNode(_sfc_main$1, {
2416
- data: unref(data),
2417
- class: "xs:hidden"
2418
- }, null, 8, ["data"])
2419
- ])
2420
- ])) : createCommentVNode("", !0)
2421
- ]),
2422
- key: "0"
2423
- }
2424
- ]), 1032, ["modelValue"]);
2425
- };
2426
- }
2427
- });
2428
- export {
2429
- _sfc_main as _,
2430
- useLocaleText as u
2431
- };