@feedmepos/mf-connect 0.1.111-prod → 0.1.113-beta.3

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