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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +66 -1
  2. package/dist/{App-2J4yDonr.js → App-CIWTDYuZ.js} +700 -654
  3. package/dist/AuditLogs-BluLDXu9.js +2016 -0
  4. package/dist/{Bin-BU_hVuxJ.js → Bin-jS6pM4L3.js} +8 -8
  5. package/dist/Broadcast-DBqsSZ0S.js +306 -0
  6. package/dist/{CampaignAnalytic-DUUmFMvy.js → CampaignAnalytic-DJrjXD4H.js} +7 -7
  7. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BZirReIy.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CzwigRLi.js} +9 -9
  8. package/dist/{Card-DS2K_LFv.js → Card-B10nLilL.js} +25 -24
  9. package/dist/{Collections-BFdRdPHR.js → Collections-BN42A73p.js} +197 -185
  10. package/dist/{Credit-CODfiox3.js → Credit-0SS26HGE.js} +21 -20
  11. package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-B2T5G1hZ.js → DateRangeChip.vue_vue_type_script_setup_true_lang-B3wozBFs.js} +1 -1
  12. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-BRd5RVYe.js +4442 -0
  13. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-KvZebiOu.js → EffectSheet.vue_vue_type_style_index_0_lang-zV9dLCWp.js} +32 -32
  14. package/dist/{Experience-BGBWc8Ep.js → Experience-D7qPzsrc.js} +32 -31
  15. package/dist/{FileSaver.min-DJAN3Eu0.js → FileSaver.min-BKWoklMK.js} +1 -1
  16. package/dist/{Game-6yyn0uAd.js → Game-BoYMwfog.js} +19 -18
  17. package/dist/{GiftCardSetup-B096bTm0.js → GiftCardSetup-B87O0xzo.js} +75 -75
  18. package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-ChvUXdF-.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-B3uGbEFY.js} +7 -7
  19. package/dist/{Goals-Db2mwbRo.js → Goals-CVxf3xCA.js} +4 -4
  20. package/dist/Grab-mGL1Mue_.js +301 -0
  21. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-xdEzwMcS.js → ImageInput.vue_vue_type_script_setup_true_lang-HipBZ1_T.js} +1 -1
  22. package/dist/{Index-580WNkG2.js → Index-Dptuy-6c.js} +10 -10
  23. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-BkAQXKNJ.js → LocationPicker.vue_vue_type_script_setup_true_lang-Cjc4UeKz.js} +1 -1
  24. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-CR6sSnx4.js → LottieAnimation.vue_vue_type_script_setup_true_lang-Bh0ari3f.js} +1 -1
  25. package/dist/{LoyaltyDashboard-Clr2aiUP.js → LoyaltyDashboard-BxhI6RAE.js} +15 -15
  26. package/dist/MainLayout-YfDxvZXl.js +4 -0
  27. package/dist/{MainLayout-_iCyT5mw.js → MainLayout.vue_vue_type_script_setup_true_lang-BgXpznbi.js} +5 -4
  28. package/dist/{Marketing-fq1wxANq.js → Marketing-C2cVJacf.js} +4 -4
  29. package/dist/MarketingMaterialEdit-DkOEy_L-.js +1037 -0
  30. package/dist/{Member-BfRy196y.js → Member-DufbKDOh.js} +7 -7
  31. package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-BAR44Qcp.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-CU8EmBxy.js} +43 -50
  32. package/dist/{MemberImportHistory-C4622Ivs.js → MemberImportHistory-DlFN-uQl.js} +7 -7
  33. package/dist/{MemberList-DqtsMN_N.js → MemberList-B344n8I4.js} +103 -105
  34. package/dist/{MemberTransactions-DsUoFg3z.js → MemberTransactions-BS7H640M.js} +1 -1
  35. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-CzFMUgXM.js → MessageInput.vue_vue_type_script_setup_true_lang-CxDtXvwd.js} +4228 -4176
  36. package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-CVQYcuQ6.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-lY0jlyOG.js} +1 -1
  37. package/dist/{Mission-B0GO4LiM.js → Mission-D2ed_oKn.js} +22 -21
  38. package/dist/{Overview-XpJJmHqs.js → Overview-CLh_T6YY.js} +145 -144
  39. package/dist/{Overview-CVITimwN.js → Overview-DJa-hXDC.js} +23 -22
  40. package/dist/{Point-B7aCrMkI.js → Point-DAPeg1VD.js} +22 -21
  41. package/dist/{Promotion-DfVcuXHy.js → Promotion-CPPCMMFl.js} +137 -131
  42. package/dist/{Queue-BT7O2cvj.js → Queue-BcPwCRcM.js} +47 -46
  43. package/dist/{Record-CAc030dz.js → Record-C5XKn--g.js} +9 -9
  44. package/dist/{Review-CyXo4GTY.js → Review-Cc51luIv.js} +2 -2
  45. package/dist/ReviewFacebookCallback-BSGInFB8.js +225 -0
  46. package/dist/{ReviewGoogleCallback-BxiFOl0B.js → ReviewGoogleCallback-C1gY4vcP.js} +5 -5
  47. package/dist/{Reward-ChfNtdwX.js → Reward-k1R3hLiF.js} +29 -29
  48. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-CpQu_QBQ.js → RewardGroup.vue_vue_type_script_setup_true_lang-BGbbGVK4.js} +16 -15
  49. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Coh3L11L.js +1923 -0
  50. package/dist/{Segment-H2zBDZeh.js → Segment-DsBnIvje.js} +290 -291
  51. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-B0jCJ-Xq.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-CMKpvXN-.js} +31 -30
  52. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-DW_ViNZM.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-LyAtRMs8.js} +4 -4
  53. package/dist/Setting-BRueNgc4.js +574 -0
  54. package/dist/{SettingAdvertisements-DPQHP3-B.js → SettingAdvertisements-BrVcQyhF.js} +12 -12
  55. package/dist/Settings-fOvXd29Z.js +286 -0
  56. package/dist/{Store-B2f5HVQc.js → Store-rrh2pIHH.js} +661 -654
  57. package/dist/{StoreRewards-QxfaEt9f.js → StoreRewards-D-jivVKr.js} +15 -15
  58. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CvQXsZbH.js +1319 -0
  59. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-DbnY9VE9.js +7007 -0
  60. package/dist/{Tier-BSk4rBm8.js → Tier-DJiLtw3M.js} +2576 -687
  61. package/dist/{Title-CIzpB8TT.js → Title-s0bzA7yZ.js} +94 -92
  62. package/dist/{Transaction-BjxxNEHa.js → Transaction-CQ-CJ_eh.js} +2 -2
  63. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-BMutYxOU.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Bfy8SZH1.js} +26 -26
  64. package/dist/{Voucher-B2lFq21Y.js → Voucher-9vydRET7.js} +19 -19
  65. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-BWV631It.js → VoucherEditor.vue_vue_type_script_setup_true_lang-Dq7veRL5.js} +16 -16
  66. package/dist/WhatsappAccount-D12Hvzfl.js +159 -0
  67. package/dist/WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-BrZEDi6O.js +39 -0
  68. package/dist/WhatsappBot-o5b_0CnB.js +629 -0
  69. package/dist/WhatsappBotLogs-CK_V_iT5.js +372 -0
  70. package/dist/WhatsappBotSettings-BooibLUg.js +694 -0
  71. package/dist/WhatsappLayout-bOyNHGUI.js +21 -0
  72. package/dist/WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-Cytrffdh.js +253 -0
  73. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-BCoB0Fsa.js → ZodTextField.vue_vue_type_script_setup_true_lang-96t_eUzk.js} +2 -2
  74. package/dist/{app-DgFVWdhA.js → app-DV3e2LkD.js} +10610 -8223
  75. package/dist/app.js +4 -3
  76. package/dist/{base.export-B6Rojjek.js → base.export-DQUUtGmy.js} +2 -2
  77. package/dist/browser-BSAOEeIM.js +1478 -0
  78. package/dist/{business-C6ID0exl.js → business-BZ0boE-5.js} +1 -1
  79. package/dist/campaign-CsfFq2S-.js +400 -0
  80. package/dist/{campaign-BgSJXWdU.js → campaign-DMrtYWcs.js} +31 -25
  81. package/dist/{campaign.enum-CVvm0LMm.js → campaign.enum-Dx-Zo68Q.js} +3 -2
  82. package/dist/campaign.fn-C-CdNNdR.js +776 -0
  83. package/dist/{collectible.enum-DGQVW464.js → collectible.enum-Liy2wH3s.js} +1 -1
  84. package/dist/{collection.fn-dV4F8R-j.js → collection.fn-C-rryKSc.js} +2 -2
  85. package/dist/{currency-DlHi_3WN.js → currency-BOd9iVZV.js} +1 -1
  86. package/dist/duplicateCampaign-ey_rW0Bz.js +51 -0
  87. package/dist/{effect-BJgmiWY4.js → effect-BP6Hkxmj.js} +1 -1
  88. package/dist/{email-addresses-3GTx_xTh.js → email-addresses-CO61QAq0.js} +2 -2
  89. package/dist/feature-flag-Bq1SgbYC.js +868 -0
  90. package/dist/feature-flag-lvPP0ED-.js +50 -0
  91. package/dist/google-BQK68wbe.js +5 -0
  92. package/dist/{helper-BX0JQP06.js → helper-BRpts-M-.js} +1 -1
  93. package/dist/{index-BIpAzktM.js → index-03WIXl-H.js} +8 -7
  94. package/dist/{index-BeCKw7Y3.js → index-B0RavybO.js} +19 -6
  95. package/dist/{index-DeNbsrQx.js → index-BDNkoALK.js} +1 -1
  96. package/dist/{index-Bl5aHABH.js → index-BV5aPSYo.js} +11 -10
  97. package/dist/{index-Cnw0B8Lc.js → index-Bk20uvPY.js} +1 -1
  98. package/dist/index-Bn19rfby.js +14571 -0
  99. package/dist/index-C_H8jFYf.js +2743 -0
  100. package/dist/{index-nmw7_9ZE.js → index-Cj-eugzc.js} +1 -1
  101. package/dist/{index-uXgPJlic.js → index-CoROn5OA.js} +2700 -2613
  102. package/dist/{index-DdMVrWZy.js → index-CrBhcMaL.js} +8028 -10767
  103. package/dist/{index-2xed2K8D.js → index-CsBjAM3E.js} +4 -3
  104. package/dist/{index-CiFReW-F.js → index-D1t4_KaG.js} +1 -1
  105. package/dist/{index-DRNdJ_KC.js → index-D3wGTCWf.js} +8 -7
  106. package/dist/{index-CtBLnWVG.js → index-D41kjcrZ.js} +683 -581
  107. package/dist/{index-CNULhBPM.js → index-DIZLkVe0.js} +691 -230
  108. package/dist/{index-QaWLGgEC.js → index-DucKyzrD.js} +2 -2
  109. package/dist/{index-o2OQljHs.js → index-R5WS21OL.js} +4 -4
  110. package/dist/index-RwNlbTO8.js +115 -0
  111. package/dist/{index-R0qlOO6J.js → index-VYI0zWNC.js} +29 -15
  112. package/dist/index-ZRE89TKq.js +80 -0
  113. package/dist/{index-BHT6cvWA.js → index-_Cj-bsd_.js} +396 -232
  114. package/dist/{index-Y2Pu1YkB.js → index-mToWKHVs.js} +2 -2
  115. package/dist/{index.esm2017-Dum0onrS.js → index.esm2017-B_Sag8Pg.js} +209 -209
  116. package/dist/{loading-B2mSdkfy.js → loading-C5fVI0ry.js} +1 -1
  117. package/dist/{lodash-DtOypaKt.js → lodash-COo8_xCU.js} +1 -1
  118. package/dist/{member-import-C2pLnh44.js → member-import-I_pKwUfF.js} +6 -5
  119. package/dist/{membership-BWyBGF4n.js → membership-BgfH9Kva.js} +3 -3
  120. package/dist/{money-3lCCVCeP.js → money-Cr07YDlV.js} +1 -1
  121. package/dist/{number-zlqy2MLG.js → number-DFsj0dkh.js} +1 -1
  122. package/dist/objectid-Cu89BzwI.js +145 -0
  123. package/dist/{onboarding-BqD3B4M1.js → onboarding-DlkJCm-5.js} +25 -25
  124. package/dist/{onboardingSetup-CCQ90jg7.js → onboardingSetup-BEhVj613.js} +2 -2
  125. package/dist/{plugins-Bj3npYnL.js → plugins-CPTtiKqf.js} +3 -3
  126. package/dist/{MarketingMaterialEdit-0h7E0n5e.js → remy-icon-BhUGu2NI.js} +2 -1031
  127. package/dist/{reward-5dDuZEb7.js → reward-DqY0mQ_5.js} +1 -1
  128. package/dist/{rule-NqLeSyoO.js → rule-mJJ48eKw.js} +572 -492
  129. package/dist/style.css +1 -1
  130. package/dist/template-C1QftpDG.js +188 -0
  131. package/dist/{timezone-B0lkgvh-.js → timezone-BBgBHels.js} +1 -1
  132. package/dist/{transaction.fn-CACuVUBe.js → transaction.fn-Sr0hj3kY.js} +2 -2
  133. package/dist/{trigger-BKJwKTJx.js → trigger-PUP0mwKM.js} +8 -8
  134. package/dist/{useMarketingMaterialActions-DERvOmen.js → useMarketingMaterialActions-faslwaHd.js} +3 -3
  135. package/dist/{usePagination-FkjroUq2.js → usePagination-Be6nIQ9y.js} +1 -1
  136. package/dist/{user-H9MnsLbu.js → user-DBSYzG_9.js} +1 -1
  137. package/dist/vue-i18n-C6c2jsH3.js +2365 -0
  138. package/dist/{xlsx-BVmtIl_i.js → xlsx-Bfo19lFv.js} +786 -786
  139. package/dist/{zod-DI7OBdxu.js → zod-CihbDg3N.js} +1 -1
  140. package/package.json +12 -3
  141. package/dist/Broadcast-CoirZUyr.js +0 -271
  142. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-DyIOw_HH.js +0 -2431
  143. package/dist/ReviewFacebookCallback--IcyheQA.js +0 -238
  144. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang--5K-qagY.js +0 -1883
  145. package/dist/Setting-D4XOHSHT.js +0 -2036
  146. package/dist/Settings-Dt_oLoGl.js +0 -179
  147. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Db2cd6ny.js +0 -1264
  148. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-D9L-AayN.js +0 -142
  149. package/dist/campaign-DDfFBFye.js +0 -228
  150. package/dist/campaign.fn-DRabv93K.js +0 -776
  151. package/dist/google-C3S8u0mT.js +0 -4
  152. package/dist/index-CmhDYsk6.js +0 -51
  153. package/dist/objectid-b2KGvMA7.js +0 -145
  154. package/dist/rule-builder-BzYwbbj4.js +0 -102
  155. package/dist/template-fjUz6xrU.js +0 -236
  156. package/dist/vue-i18n-DbJO6sZW.js +0 -2365
@@ -0,0 +1,1319 @@
1
+ import { ref as k, defineComponent as oe, computed as B, h as i, resolveComponent as Y, openBlock as P, createBlock as le, unref as c, isRef as de, withCtx as te, createElementVNode as w, createVNode as A, createElementBlock as E, Fragment as q, renderList as ae, toDisplayString as U, createTextVNode as Re, resolveDynamicComponent as Ie, watch as pe, onBeforeMount as Fe, onMounted as De } from "vue";
2
+ import { components as T } from "@feedmepos/ui-library";
3
+ import { s as fe } from "./index-D41kjcrZ.js";
4
+ import "./index-CrBhcMaL.js";
5
+ import { T as O } from "./transaction.fn-Sr0hj3kY.js";
6
+ import { h as M } from "./moment-D7p2TMB-.js";
7
+ import { _ as se } from "./FilterChip.vue_vue_type_script_setup_true_lang-3bH-tZAm.js";
8
+ import { _ as ge } from "./DateRangeChip.vue_vue_type_script_setup_true_lang-B3wozBFs.js";
9
+ import { s as ee } from "./index-CuvNtC_M.js";
10
+ import { f as G, F as Ae } from "./number-DFsj0dkh.js";
11
+ import { u as ye } from "./business-BZ0boE-5.js";
12
+ import { _ as ve, u as Ne } from "./usePagination-Be6nIQ9y.js";
13
+ import { c as ce, p as he } from "./plugins-CPTtiKqf.js";
14
+ import { g as be } from "./user-DBSYzG_9.js";
15
+ import { B as xe, e as Pe } from "./base.export-DQUUtGmy.js";
16
+ import { u as Se } from "./campaign-DMrtYWcs.js";
17
+ import "./index-BDNkoALK.js";
18
+ import "./index-DIZLkVe0.js";
19
+ import "./index-CoROn5OA.js";
20
+ import "./index-_Cj-bsd_.js";
21
+ import "./index-D3wGTCWf.js";
22
+ import "./index-RwNlbTO8.js";
23
+ import "./index-CsBjAM3E.js";
24
+ import { u as re } from "./vue-i18n-C6c2jsH3.js";
25
+ import { o as L } from "./objectId-dwaoBfJX.js";
26
+ import { u as _e } from "./loading-C5fVI0ry.js";
27
+ import { w as Me } from "./xlsx-Bfo19lFv.js";
28
+ import { useRouter as ke } from "vue-router";
29
+ import { t as j } from "./index-VYI0zWNC.js";
30
+ import { R as Z } from "./app-DV3e2LkD.js";
31
+ import { useCoreStore as $e } from "@feedmepos/mf-common";
32
+ import { c as W } from "./string-Gcy5IM_H.js";
33
+ import { f as Ve } from "./currency-BOd9iVZV.js";
34
+ import { m as Ee } from "./index-B0RavybO.js";
35
+ const Oe = (l) => {
36
+ if (l.startsWith("_") || l.includes("."))
37
+ return l;
38
+ for (const y of ["pf_user_", "pf_collectible_"])
39
+ if (l.startsWith(y))
40
+ return `${y.slice(0, -1)}.${l.slice(y.length).replace(new RegExp("_", "g"), ".")}`;
41
+ return l.replace(new RegExp("_", "g"), ".");
42
+ };
43
+ function Be(l, y = { key: "_id", descending: !0 }) {
44
+ const u = k({
45
+ pageCount: 1,
46
+ searchValue: "",
47
+ pageIndex: 0,
48
+ totalRows: 0,
49
+ isLoading: !1,
50
+ pageSize: 10,
51
+ hasNext: !1
52
+ }), m = k(y), R = k([]), C = k([void 0]);
53
+ function N() {
54
+ C.value = [void 0], u.value.pageIndex = 0, u.value.pageCount = 1, u.value.hasNext = !1;
55
+ }
56
+ const $ = async (b = {}) => {
57
+ const p = b.pageSize ?? u.value.pageSize, t = p !== u.value.pageSize;
58
+ t && N();
59
+ const a = t ? 0 : Math.max(b.pageIndex ?? u.value.pageIndex, 0), e = a === 0 || !!C.value[a] ? a : u.value.pageIndex, o = C.value[e];
60
+ u.value.isLoading = !0, u.value.pageSize = p, R.value = [];
61
+ try {
62
+ const d = await l({
63
+ limit: p,
64
+ sortBy: m.value.key,
65
+ descending: m.value.descending,
66
+ search: u.value.searchValue,
67
+ ...o ? { cursor: o } : {}
68
+ });
69
+ R.value = d.resources, u.value.pageIndex = e, u.value.totalRows = d.resources.length, u.value.hasNext = d.meta.hasNext, u.value.pageCount = e + (d.meta.hasNext ? 2 : 1), d.meta.nextCursor ? C.value[e + 1] = d.meta.nextCursor : C.value.splice(e + 1);
70
+ } catch (d) {
71
+ console.error("Error fetching data:", d), u.value.hasNext = !1;
72
+ } finally {
73
+ u.value.isLoading = !1;
74
+ }
75
+ };
76
+ let I, g;
77
+ const v = (b) => (I && clearTimeout(I), g && g(), new Promise((p) => {
78
+ g = p, I = setTimeout(async () => {
79
+ I = void 0, g = void 0, await $(b), p();
80
+ }, 200);
81
+ }));
82
+ return {
83
+ tableMeta: u,
84
+ rowData: R,
85
+ sortBy: m,
86
+ pageCursors: C,
87
+ resetCursorState: N,
88
+ fetchData: $,
89
+ debouncedFetchData: v,
90
+ onSort: async (b) => {
91
+ b.length ? m.value = {
92
+ key: Oe(b[0].id),
93
+ descending: b[0].desc
94
+ } : m.value = y, N(), await v({
95
+ pageIndex: 0,
96
+ pageSize: u.value.pageSize
97
+ });
98
+ },
99
+ onSearch: () => (N(), v({
100
+ pageIndex: 0,
101
+ pageSize: u.value.pageSize
102
+ }))
103
+ };
104
+ }
105
+ class ze extends xe {
106
+ }
107
+ const Ue = { class: "space-y-24 pr-12" }, Ye = { class: "w-full space-y-16" }, Le = { class: "fm-typo-en-body-lg-600" }, Ge = ["onClick"], Ke = { class: "fm-typo-en-body-lg-600" }, je = ["onClick"], We = { class: "flex items-center gap-8" }, qe = /* @__PURE__ */ oe({
108
+ __name: "TransactionDetailSheet",
109
+ setup(l, { expose: y }) {
110
+ re();
111
+ const u = k(!1), m = k(), R = Se(), C = ye();
112
+ function N(v, s) {
113
+ u.value = v, m.value = s ?? null;
114
+ }
115
+ const $ = B(() => {
116
+ var v, s;
117
+ return G(
118
+ ((s = m.value) == null ? void 0 : s.expiryAmount.reduce(
119
+ (_, b) => _ + b.amount,
120
+ ((v = m.value) == null ? void 0 : v.amount) ?? 0
121
+ )) ?? 0,
122
+ 2
123
+ );
124
+ }), I = B(() => {
125
+ var v, s, _, b, p;
126
+ return m.value ? [
127
+ {
128
+ label: "Transaction ID",
129
+ value: (v = m.value) == null ? void 0 : v._id
130
+ },
131
+ {
132
+ label: "Date/Time",
133
+ value: M(L(m.value._id.toString())).format(
134
+ "D MMM YYYY, hh:mmA"
135
+ )
136
+ },
137
+ {
138
+ label: "Amount",
139
+ component: () => i(
140
+ "span",
141
+ {
142
+ class: [
143
+ "pr-2",
144
+ +$.value > 0 ? "text-fm-color-system-success-300" : "text-fm-color-system-error-300"
145
+ ]
146
+ },
147
+ $.value
148
+ )
149
+ },
150
+ {
151
+ label: "Type",
152
+ value: O.formattedType(m.value)
153
+ },
154
+ {
155
+ label: "Source",
156
+ value: ee(O.getReason(m.value.source))
157
+ },
158
+ {
159
+ label: "User",
160
+ value: (_ = (s = m.value) == null ? void 0 : s.pf_user) == null ? void 0 : _.name
161
+ },
162
+ {
163
+ label: "Phone Number",
164
+ value: (p = (b = m.value) == null ? void 0 : b.pf_user) == null ? void 0 : p.phoneNumber
165
+ }
166
+ ] : [];
167
+ }), g = B(() => {
168
+ var p, t, a, x;
169
+ if (!m.value) return [];
170
+ const v = [], s = (p = m.value) == null ? void 0 : p.metadata, _ = m.value;
171
+ if (s != null && s.campaign) {
172
+ const e = R.campaigns.all.find(
173
+ (o) => o._id === (s == null ? void 0 : s.campaign)
174
+ );
175
+ e && v.push({
176
+ label: "Campaign",
177
+ value: e.name
178
+ });
179
+ }
180
+ const b = O.formattedRemark(_);
181
+ return b && v.push({
182
+ label: "Remark",
183
+ value: b
184
+ }), (t = m.value) != null && t.ref.startsWith("bill_") && v.push({
185
+ label: "Bill Number",
186
+ value: (a = m.value) == null ? void 0 : a.ref,
187
+ copy: () => {
188
+ var e;
189
+ return ce((e = m.value) == null ? void 0 : e.ref);
190
+ }
191
+ }), s != null && s.location && v.push({
192
+ label: "Location",
193
+ value: (x = C.locations.find(
194
+ (e) => e._id.toString() === (s == null ? void 0 : s.location)
195
+ )) == null ? void 0 : x.name
196
+ }), _.source === fe.enum.STORE && v.push({
197
+ label: "Store Transaction",
198
+ value: _.ref
199
+ }), s != null && s.originTransaction && v.push({
200
+ label: "Parent Transaction",
201
+ value: s.originTransaction
202
+ }), s != null && s.referral_count && v.push({
203
+ label: "Referral Count",
204
+ value: s.referral_count
205
+ }), _.refundedFrom && v.push({
206
+ label: "Refunded From",
207
+ value: _.refundedFrom
208
+ }), v;
209
+ });
210
+ return y({
211
+ showSheet: N
212
+ }), (v, s) => {
213
+ const _ = Y("FmButton"), b = Y("FmSideSheet");
214
+ return P(), le(b, {
215
+ "max-width": 560,
216
+ modelValue: c(u),
217
+ "onUpdate:modelValue": s[1] || (s[1] = (p) => de(u) ? u.value = p : null),
218
+ header: "Transaction Details"
219
+ }, {
220
+ "side-sheet-footer": te(() => [
221
+ w("div", We, [
222
+ A(_, {
223
+ label: "Close",
224
+ onClick: s[0] || (s[0] = (p) => N(!1)),
225
+ variant: "tertiary"
226
+ })
227
+ ])
228
+ ]),
229
+ default: te(() => [
230
+ w("div", Ue, [
231
+ w("div", Ye, [
232
+ (P(!0), E(q, null, ae(c(I), (p) => (P(), E("div", {
233
+ key: p.label,
234
+ class: "flex flex-col gap-4"
235
+ }, [
236
+ w("div", Le, U(p.label), 1),
237
+ w("div", {
238
+ class: "text-fm-color-typo-secondary fm-typo-en-body-md-400 hover:underline",
239
+ onClick: p.copy
240
+ }, [
241
+ Re(U(p.accessorFn ? p.accessorFn() : p.value) + " ", 1),
242
+ (P(), le(Ie(p.component)))
243
+ ], 8, Ge),
244
+ s[2] || (s[2] = w("hr", { class: "mt-3" }, null, -1))
245
+ ]))), 128)),
246
+ (P(!0), E(q, null, ae(c(g), (p) => (P(), E("div", {
247
+ key: p.label,
248
+ class: "flex flex-col gap-4"
249
+ }, [
250
+ w("div", Ke, U(p.label), 1),
251
+ w("div", {
252
+ class: "text-fm-color-typo-secondary fm-typo-en-body-md-400 hover:underline",
253
+ onClick: p.copy
254
+ }, U(p.accessorFn ? p.accessorFn() : p.value), 9, je),
255
+ s[3] || (s[3] = w("hr", { class: "mt-3" }, null, -1))
256
+ ]))), 128))
257
+ ])
258
+ ])
259
+ ]),
260
+ _: 1
261
+ }, 8, ["modelValue"]);
262
+ };
263
+ }
264
+ });
265
+ function He(l) {
266
+ if (l.source !== "BILL")
267
+ return "Only bill transactions can be reversed";
268
+ if (l.refundedFrom) return "Reversal entries cannot be reversed";
269
+ if (l.refunded) return "Transaction already reversed or replaced";
270
+ if (l.expiryAmount.reduce(
271
+ (u, m) => u + m.amount,
272
+ l.amount
273
+ ) === 0) return "Transaction has no reward amount";
274
+ }
275
+ const Qe = { class: "hidden xs:!flex items-center justify-end" }, Xe = { class: "flex items-center justify-between" }, Je = { class: "flex gap-8 items-center w-full overflow-x-scroll" }, Ze = { class: "xs:hidden" }, Wt = /* @__PURE__ */ oe({
276
+ __name: "CollectionTransactions",
277
+ props: {
278
+ user: {
279
+ type: String
280
+ }
281
+ },
282
+ setup(l) {
283
+ const { t: y } = re(), u = ye(), m = Se(), R = ke(), C = l, N = k(!1), { minor: $ } = _e, I = [
284
+ {
285
+ header: "Transaction ID",
286
+ accessorKey: "_id",
287
+ meta: {
288
+ maxWidth: "100px"
289
+ },
290
+ cell(r) {
291
+ return i("div", { class: "flex items-center" }, [
292
+ i(T.FmIcon, {
293
+ name: "content_copy",
294
+ outline: !0,
295
+ size: "sm",
296
+ class: "cursor-pointer mr-4",
297
+ onClick: (n) => {
298
+ n.preventDefault(), n.stopPropagation(), ce(r.row.original._id.toString());
299
+ }
300
+ }),
301
+ i(
302
+ "div",
303
+ { class: "pr-2 text-ellipsis overflow-hidden" },
304
+ r.row.original._id.toString()
305
+ )
306
+ ]);
307
+ },
308
+ enableSorting: !1
309
+ },
310
+ {
311
+ header: "Created at",
312
+ accessorKey: "_id",
313
+ accessorFn: (r) => M(L(r._id.toString())),
314
+ cell: (r) => M(L(r.row.original._id.toString())).format(
315
+ "D MMM YYYY, hh:mmA"
316
+ ),
317
+ enableSorting: !0
318
+ },
319
+ {
320
+ header: "Amount",
321
+ // accessorKey: 'totalAmount',
322
+ enableSorting: !1,
323
+ cell(r) {
324
+ var h, f, z, K;
325
+ const n = G(
326
+ r.row.original.expiryAmount.reduce(
327
+ (Q, X) => Q + X.amount,
328
+ r.row.original.amount ?? 0
329
+ ),
330
+ 2
331
+ ), S = (f = (h = r.row.original.expiryAmount) == null ? void 0 : h[0]) != null && f.expiredAt ? M((K = (z = r.row.original.expiryAmount) == null ? void 0 : z[0]) == null ? void 0 : K.expiredAt).format(
332
+ "D MMM YYYY"
333
+ ) : "";
334
+ return i("div", { class: "flex items-center" }, [
335
+ i(
336
+ "div",
337
+ {
338
+ class: [
339
+ "pr-2",
340
+ +n > 0 ? "text-fm-color-system-success-300" : "text-fm-color-system-error-300"
341
+ ]
342
+ },
343
+ n
344
+ ),
345
+ i("div", { class: "flex items-center" }, [
346
+ r.row.original.expiryAmount.length > 0 ? i(
347
+ T.FmTooltip,
348
+ {
349
+ content: `Expired on ${S}`
350
+ },
351
+ [
352
+ i(T.FmIcon, {
353
+ name: "info",
354
+ outline: !0,
355
+ size: "sm"
356
+ })
357
+ ]
358
+ ) : i("div")
359
+ ])
360
+ ]);
361
+ }
362
+ },
363
+ {
364
+ header: "Type",
365
+ accessorKey: "pf_collectible.type",
366
+ accessorFn: (r) => O.formattedType(r),
367
+ meta: {
368
+ maxWidth: "200px"
369
+ },
370
+ cell(r) {
371
+ const n = O.formattedType(r.row.original);
372
+ return i("div", { class: "flex items-center" }, [
373
+ i("div", { class: "truncate text-ellipsis" }, n),
374
+ n.length > 20 ? i(
375
+ T.FmTooltip,
376
+ {
377
+ content: n
378
+ },
379
+ [
380
+ i(T.FmIcon, {
381
+ name: "info",
382
+ color: "primary",
383
+ outline: !0,
384
+ size: "sm"
385
+ })
386
+ ]
387
+ ) : null
388
+ ]);
389
+ }
390
+ },
391
+ {
392
+ header: "Source",
393
+ accessorKey: "source",
394
+ cell(r) {
395
+ var n;
396
+ return i("div", { class: "flex items-center gap-4" }, [
397
+ i(
398
+ "div",
399
+ { class: "truncate text-ellipsis" },
400
+ ee(O.getReason(r.row.original.source))
401
+ ),
402
+ ...(n = r.row.original.metadata) != null && n.campaign ? [
403
+ i(
404
+ T.FmTooltip,
405
+ {
406
+ get content() {
407
+ var S;
408
+ return (S = m.campaigns.all.find(
409
+ (h) => {
410
+ var f;
411
+ return h._id === ((f = r.row.original.metadata) == null ? void 0 : f.campaign);
412
+ }
413
+ )) == null ? void 0 : S.name;
414
+ }
415
+ },
416
+ [
417
+ i(T.FmIcon, {
418
+ name: "info",
419
+ color: "primary",
420
+ size: "sm",
421
+ onClick: async (S) => {
422
+ S.preventDefault(), S.stopPropagation();
423
+ const h = m.campaigns.all.find(
424
+ (f) => {
425
+ var z;
426
+ return f._id === ((z = r.row.original.metadata) == null ? void 0 : z.campaign);
427
+ }
428
+ );
429
+ if (h)
430
+ switch (h.type) {
431
+ case "VOUCHER":
432
+ case "PROMOTION":
433
+ case "BROADCAST":
434
+ await R.push({
435
+ name: Z[`$connect-CAMPAIGN_${h.type}`]
436
+ });
437
+ break;
438
+ case "GAME":
439
+ case "CREDIT":
440
+ case "MISSION":
441
+ await R.push({
442
+ name: Z[`$connect-PROGRAM_${h.type}`]
443
+ });
444
+ break;
445
+ case "POINT":
446
+ await R.push({
447
+ name: Z["$connect-PROGRAM_EXPERIENCE"]
448
+ });
449
+ break;
450
+ case "COIN":
451
+ await R.push({
452
+ name: Z["$connect-PROGRAM_POINT"]
453
+ });
454
+ break;
455
+ }
456
+ }
457
+ })
458
+ ]
459
+ )
460
+ ] : []
461
+ ]);
462
+ }
463
+ },
464
+ {
465
+ header: "User",
466
+ accessorKey: "pf_user.name",
467
+ cell(r) {
468
+ return be(r.row.original.pf_user);
469
+ }
470
+ },
471
+ {
472
+ header: "Phone No.",
473
+ accessorKey: "pf_user.phoneNumber",
474
+ accessorFn: (r) => {
475
+ var n;
476
+ return ((n = r == null ? void 0 : r.pf_user) == null ? void 0 : n.phoneNumber) || "";
477
+ }
478
+ },
479
+ {
480
+ header: "Status",
481
+ id: "status",
482
+ enableSorting: !1,
483
+ cell(r) {
484
+ const n = !!r.row.original.refunded;
485
+ return i(T.FmChip, {
486
+ label: y(n ? "connect.transaction.refunded" : "connect.transaction.completed"),
487
+ variant: "plain",
488
+ class: n ? "text-fm-color-typo-warning bg-fm-color-system-warning-100" : "text-fm-color-typo-success bg-fm-color-system-success-100"
489
+ });
490
+ }
491
+ },
492
+ {
493
+ accessorFn: (r) => r.ref,
494
+ header: "References",
495
+ accessorKey: "ref",
496
+ cell(r) {
497
+ const n = O.formattedRemark(r.row.original);
498
+ return i("div", { class: "flex items-center justify-between gap-4" }, [
499
+ i("div", { class: "flex items-center" }, [
500
+ n ? i(
501
+ T.FmTooltip,
502
+ {
503
+ content: n
504
+ },
505
+ [
506
+ i(T.FmIcon, {
507
+ name: "info",
508
+ class: "pl-2",
509
+ outline: !0,
510
+ size: "sm"
511
+ })
512
+ ]
513
+ ) : i("div")
514
+ ]),
515
+ i("div", { class: "flex-1" }, r.row.original.ref)
516
+ ]);
517
+ }
518
+ },
519
+ {
520
+ header: "Actions",
521
+ cell(r) {
522
+ var h;
523
+ const n = r.row.original, S = He(n);
524
+ return i(
525
+ T.FmTooltip,
526
+ {
527
+ get content() {
528
+ var f;
529
+ return S || (((f = n.pf_collectible) == null ? void 0 : f.type) === "STAMP" ? "Recalculate mission rewards" : "Revert transaction");
530
+ }
531
+ },
532
+ [
533
+ i(T.FmButton, {
534
+ variant: "tertiary",
535
+ icon: "amend",
536
+ iconColor: "neutral-gray-400",
537
+ "aria-label": S ? `Cannot reverse transaction ${n._id}: ${S}` : ((h = n.pf_collectible) == null ? void 0 : h.type) === "STAMP" ? `Recalculate mission rewards for transaction ${n._id}` : `Reverse transaction ${n._id}`,
538
+ disabled: !!S,
539
+ onClick: (f) => {
540
+ f.stopPropagation(), o(n);
541
+ }
542
+ })
543
+ ]
544
+ );
545
+ }
546
+ }
547
+ ], g = k({
548
+ search: "",
549
+ "pf_collectible.type": [],
550
+ "metadata.location": [],
551
+ dateRange: {
552
+ startDate: M().subtract(7, "day").toISOString(),
553
+ endDate: M().endOf("day").toISOString()
554
+ },
555
+ source: []
556
+ }), v = () => ({
557
+ ...g.value,
558
+ user: C.user,
559
+ dateRange: {
560
+ start: new Date(g.value.dateRange.startDate).toISOString(),
561
+ end: new Date(g.value.dateRange.endDate).toISOString()
562
+ }
563
+ }), { tableMeta: s, rowData: _, onSort: b, debouncedFetchData: p, resetCursorState: t } = Be(async (r) => {
564
+ const n = await j.readAllCursor(
565
+ r,
566
+ v()
567
+ );
568
+ return {
569
+ resources: n.resources.map((S) => {
570
+ const h = a.value.find((f) => f._id === S.ref);
571
+ return {
572
+ ...S,
573
+ ref: (h == null ? void 0 : h.seqNumber) || S.ref
574
+ };
575
+ }),
576
+ meta: n.meta
577
+ };
578
+ }), a = k([]), x = fe.options.map((r) => ({ label: ee(O.getReason(r)), value: r })), e = B(
579
+ () => u.locations.map((r) => ({ label: r.name, value: r._id }))
580
+ );
581
+ pe(
582
+ g,
583
+ () => {
584
+ t(), p({ pageIndex: 0 });
585
+ },
586
+ { deep: !0 }
587
+ );
588
+ async function o(r) {
589
+ var h;
590
+ const n = ((h = r.pf_collectible) == null ? void 0 : h.type) === "STAMP";
591
+ await he.confirm(
592
+ n ? "This will remove this transaction's mission progress, revoke affected rewards, and recalculate later mission earnings. Continue?" : "Are you sure you want to revert this transaction?",
593
+ n ? "Recalculate Mission Rewards" : "Revert Transaction",
594
+ "Confirm",
595
+ "Cancel"
596
+ ) && await $(
597
+ async () => {
598
+ await j.revertTransaction({
599
+ id: r._id.toString()
600
+ }), await p();
601
+ },
602
+ {
603
+ message: n ? "Recalculating mission rewards..." : "Reverting transaction...",
604
+ successMessage: n ? "Mission rewards recalculated successfully" : "Transaction reverted successfully"
605
+ }
606
+ );
607
+ }
608
+ async function d() {
609
+ try {
610
+ N.value = !0;
611
+ const r = new ze(), n = v(), S = 1e3;
612
+ await $(
613
+ async () => {
614
+ var z, K, Q, X, ue, me;
615
+ let h, f = !0;
616
+ for (; f; ) {
617
+ const J = await j.readAllCursor(
618
+ {
619
+ limit: S,
620
+ sortBy: "_id",
621
+ descending: !1,
622
+ ...h ? { cursor: h } : {}
623
+ },
624
+ n
625
+ );
626
+ if (!J.resources.length)
627
+ break;
628
+ for (const V of J.resources)
629
+ r.addRecord({
630
+ TransactionID: V._id,
631
+ CreatedAt: M(L(V._id.toString())).format(
632
+ "D MMM YYYY, hh:mmA"
633
+ ),
634
+ Amount: G(
635
+ V.expiryAmount.reduce(
636
+ (Te, Ce) => Te + Ce.amount,
637
+ V.amount ?? 0
638
+ ),
639
+ 2
640
+ ),
641
+ ExpiredAt: (K = (z = V.expiryAmount) == null ? void 0 : z[0]) != null && K.expiredAt ? M((X = (Q = V.expiryAmount) == null ? void 0 : Q[0]) == null ? void 0 : X.expiredAt).format("D MMM YYYY") : "",
642
+ Type: O.formattedType(V),
643
+ Source: ee(O.getReason(V.source)),
644
+ User: ((ue = V.pf_user) == null ? void 0 : ue.name) || "",
645
+ "Phone No.": ((me = V.pf_user) == null ? void 0 : me.phoneNumber) || "",
646
+ References: V.ref,
647
+ Remark: O.formattedRemark(V)
648
+ });
649
+ h = J.meta.nextCursor ?? void 0, f = J.meta.hasNext && !!h;
650
+ }
651
+ await Me(
652
+ r.buildExcel(),
653
+ `transactions-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
654
+ {
655
+ bookType: "xlsx",
656
+ bookSST: !1,
657
+ type: "array"
658
+ }
659
+ );
660
+ },
661
+ {
662
+ message: "Exporting transactions...",
663
+ successMessage: "transactions exported successfully"
664
+ }
665
+ );
666
+ } catch (r) {
667
+ console.error(r);
668
+ } finally {
669
+ N.value = !1;
670
+ }
671
+ }
672
+ const F = k(null);
673
+ function D(r) {
674
+ var n;
675
+ console.log(r), (n = F.value) == null || n.showSheet(!0, r.original);
676
+ }
677
+ return Fe(async () => {
678
+ await u.readLocations(), await m.read(), await p();
679
+ }), (r, n) => {
680
+ const S = Y("FmSearch"), h = Y("FmButton");
681
+ return P(), E(q, null, [
682
+ w("div", null, [
683
+ w("div", Qe, [
684
+ A(S, {
685
+ class: "hidden xs:!flex border-b border-fm-color-neutral-gray-100",
686
+ modelValue: c(g).search,
687
+ "onUpdate:modelValue": n[0] || (n[0] = (f) => c(g).search = f),
688
+ placeholder: "Search",
689
+ collapsible: ""
690
+ }, null, 8, ["modelValue"]),
691
+ A(h, {
692
+ icon: "ios_share",
693
+ variant: "tertiary",
694
+ onClick: d
695
+ })
696
+ ]),
697
+ w("div", Xe, [
698
+ w("div", Je, [
699
+ A(se, {
700
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
701
+ "right-icon": "keyboard_arrow_down",
702
+ modelValue: c(g)["metadata.location"],
703
+ "onUpdate:modelValue": n[1] || (n[1] = (f) => c(g)["metadata.location"] = f),
704
+ icon: "storefront",
705
+ "show-item-label": !0,
706
+ items: c(e)
707
+ }, null, 8, ["modelValue", "items"]),
708
+ A(se, {
709
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
710
+ "right-icon": "keyboard_arrow_down",
711
+ modelValue: c(g)["pf_collectible.type"],
712
+ "onUpdate:modelValue": n[2] || (n[2] = (f) => c(g)["pf_collectible.type"] = f),
713
+ label: "Type: ",
714
+ "show-item-label": !0,
715
+ items: [
716
+ { label: "Point", value: "COIN" },
717
+ { label: "Credit", value: "CREDIT" },
718
+ { label: "Voucher", value: "VOUCHER" },
719
+ { label: "Experience", value: "POINT" },
720
+ { label: "Tier", value: "TIER" },
721
+ { label: "Title", value: "TITLE" },
722
+ { label: "Game", value: "GAME" },
723
+ { label: "Stamp", value: "STAMP" }
724
+ ]
725
+ }, null, 8, ["modelValue"]),
726
+ A(se, {
727
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
728
+ "right-icon": "keyboard_arrow_down",
729
+ modelValue: c(g).source,
730
+ "onUpdate:modelValue": n[3] || (n[3] = (f) => c(g).source = f),
731
+ label: "Source: ",
732
+ "show-item-label": !0,
733
+ items: c(x)
734
+ }, null, 8, ["modelValue", "items"]),
735
+ A(ge, {
736
+ "model-value": {
737
+ startDate: c(g).dateRange.startDate,
738
+ endDate: c(g).dateRange.endDate
739
+ },
740
+ "onUpdate:modelValue": n[4] || (n[4] = (f) => c(g).dateRange = {
741
+ startDate: c(M)(f.startDate).startOf("d").toISOString(),
742
+ endDate: c(M)(f.endDate).endOf("d").toISOString()
743
+ })
744
+ }, null, 8, ["model-value"])
745
+ ]),
746
+ A(S, {
747
+ class: "xs:hidden",
748
+ modelValue: c(g).search,
749
+ "onUpdate:modelValue": n[5] || (n[5] = (f) => c(g).search = f),
750
+ placeholder: "Search",
751
+ collapsible: ""
752
+ }, null, 8, ["modelValue"]),
753
+ w("div", Ze, [
754
+ A(h, {
755
+ icon: "ios_share",
756
+ variant: "tertiary",
757
+ onClick: d
758
+ })
759
+ ])
760
+ ]),
761
+ A(ve, {
762
+ loading: c(s).isLoading,
763
+ "row-data": c(_),
764
+ "row-count": c(s).totalRows,
765
+ "column-defs": I.filter(
766
+ (f) => !C.user || f.header !== "User" && f.header !== "Phone No."
767
+ ),
768
+ "page-count": c(s).pageCount,
769
+ "page-index": c(s).pageIndex,
770
+ "page-size": c(s).pageSize,
771
+ "shrink-at": !1,
772
+ "pagination-mode": "cursor",
773
+ "has-next": c(s).hasNext,
774
+ onSortChange: c(b),
775
+ onPageChange: n[6] || (n[6] = (f) => c(p)({
776
+ pageSize: f.pageSize,
777
+ pageIndex: f.pageIndex
778
+ })),
779
+ onRowClick: D
780
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "has-next", "onSortChange"])
781
+ ]),
782
+ A(qe, {
783
+ ref_key: "transactionDetailSheet",
784
+ ref: F
785
+ }, null, 512)
786
+ ], 64);
787
+ };
788
+ }
789
+ });
790
+ class et extends xe {
791
+ }
792
+ function ne(l) {
793
+ return l.quantity ?? 1;
794
+ }
795
+ function we(l, y) {
796
+ var u, m;
797
+ switch ((u = l.paymentType) == null ? void 0 : u.type) {
798
+ case "COIN":
799
+ return y("connect.store.paymentType.point");
800
+ case "CARD":
801
+ return y("connect.store.paymentType.cardActivation");
802
+ default:
803
+ return ((m = l.paymentType) == null ? void 0 : m.type) ?? y("connect.store.paymentType.notAvailable");
804
+ }
805
+ }
806
+ function H(l, y) {
807
+ return Ve({
808
+ ...y,
809
+ amount: y.amount * ne(l)
810
+ });
811
+ }
812
+ function ie(l) {
813
+ var y;
814
+ if (((y = l.paymentType) == null ? void 0 : y.type) === "COIN") {
815
+ if (l.bundle.coinPrice == null) return "N/A";
816
+ const u = l.bundle.coinPrice * ne(l);
817
+ return `${G(u, 2, !0)} points`;
818
+ }
819
+ return H(
820
+ l,
821
+ l.bundle.priceWithTaxes ?? l.bundle.price
822
+ );
823
+ }
824
+ function tt(l) {
825
+ return H(
826
+ l,
827
+ l.bundle.originalPrice ?? l.bundle.price
828
+ );
829
+ }
830
+ function at(l) {
831
+ const [y, ...u] = l.bundle.taxTotals ?? [];
832
+ if (!y) return null;
833
+ const m = u.reduce(
834
+ (R, C) => R + C.total.amount,
835
+ y.total.amount
836
+ );
837
+ return H(l, {
838
+ ...y.total,
839
+ amount: m
840
+ });
841
+ }
842
+ const nt = { class: "space-y-24 pr-12" }, ot = { class: "fm-typo-en-title-sm-800 mb-16" }, rt = {
843
+ key: 0,
844
+ class: "space-y-16"
845
+ }, st = { class: "fm-typo-en-body-lg-600" }, lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary break-words" }, it = {
846
+ key: 1,
847
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
848
+ }, ct = /* @__PURE__ */ oe({
849
+ __name: "StoreTransactionDetailSheet",
850
+ setup(l, { expose: y }) {
851
+ const u = k(!1), m = k(null), { t: R } = re();
852
+ function C(t, a) {
853
+ u.value = t, m.value = a ?? null;
854
+ }
855
+ function N(t) {
856
+ if (!t.location) return "Online Store";
857
+ const a = Array.isArray(t.pf_location) ? t.pf_location[0] : t.pf_location;
858
+ return (a == null ? void 0 : a.name) ?? t.location.toString();
859
+ }
860
+ function $(t) {
861
+ return Array.isArray(t) ? t.flatMap((a) => typeof a != "object" || a === null || !("name" in a) || typeof a.name != "string" ? [] : [a.name]) : [];
862
+ }
863
+ function I(t, a, x, e) {
864
+ if (t.length === a)
865
+ return t.map((d) => x > 1 ? `${d} × ${x}` : d).join(", ");
866
+ const o = a * x;
867
+ return `${o} ${e}${o === 1 ? "" : "s"}`;
868
+ }
869
+ const g = B(() => {
870
+ var e, o, d;
871
+ const t = m.value;
872
+ if (!t) return [];
873
+ const a = t.pf_member, x = we(t, R);
874
+ return [
875
+ { label: "Transaction ID", value: t._id.toString() },
876
+ {
877
+ label: "Date/Time",
878
+ value: M(L(t._id.toString())).format(
879
+ "D MMM YYYY, hh:mmA"
880
+ )
881
+ },
882
+ {
883
+ label: "Status",
884
+ value: W.title(t.refund ? "REFUNDED" : t.status)
885
+ },
886
+ {
887
+ label: "Customer",
888
+ value: (a == null ? void 0 : a.name) ?? (a == null ? void 0 : a.email) ?? (a == null ? void 0 : a.phoneNumber) ?? "Unknown"
889
+ },
890
+ { label: "Location", value: N(t) },
891
+ {
892
+ label: "Payment Type",
893
+ value: ((e = t.paymentType) == null ? void 0 : e.type) === "COIN" || ((o = t.paymentType) == null ? void 0 : o.type) === "CARD" || !((d = t.paymentType) != null && d.type) ? x : W.title(x)
894
+ },
895
+ { label: "Reference", value: t.ref || "N/A" },
896
+ ...t.paymentRef ? [{ label: "Payment Reference", value: t.paymentRef }] : [],
897
+ {
898
+ label: "Quantity",
899
+ value: ne(t).toString()
900
+ }
901
+ ];
902
+ }), v = B(() => {
903
+ const t = m.value;
904
+ return t ? [
905
+ { label: "Bundle Name", value: t.bundle.name },
906
+ {
907
+ label: "Bundle Value",
908
+ value: tt(t)
909
+ },
910
+ {
911
+ label: "Base Subtotal",
912
+ value: H(t, t.bundle.price)
913
+ },
914
+ {
915
+ label: "Selling Price",
916
+ value: ie(t)
917
+ }
918
+ ] : [];
919
+ }), s = B(() => {
920
+ var o;
921
+ const t = m.value;
922
+ if (!t) return [];
923
+ const { bundle: a } = t, x = ne(t), e = [];
924
+ if (a.credit.normal > 0 && e.push({
925
+ label: "Credit",
926
+ value: `${G(
927
+ a.credit.normal * x,
928
+ 2,
929
+ !0
930
+ )} credits`
931
+ }), (o = a.credit.free) != null && o.amount) {
932
+ const d = `${a.credit.free.day} day${a.credit.free.day === 1 ? "" : "s"}`;
933
+ e.push({
934
+ label: "Free Credit",
935
+ value: `${G(
936
+ a.credit.free.amount * x,
937
+ 2,
938
+ !0
939
+ )} credits (${d})`
940
+ });
941
+ }
942
+ return a.vouchers.length > 0 && e.push({
943
+ label: "Vouchers",
944
+ value: I(
945
+ $(a.pf_vouchers),
946
+ a.vouchers.length,
947
+ x,
948
+ "voucher"
949
+ )
950
+ }), a.titles.length > 0 && e.push({
951
+ label: "Titles",
952
+ value: I(
953
+ $(a.pf_titles),
954
+ a.titles.length,
955
+ x,
956
+ "title"
957
+ )
958
+ }), e;
959
+ }), _ = B(() => {
960
+ const t = m.value;
961
+ if (!t) return [];
962
+ const a = (t.bundle.taxTotals ?? []).map((e) => {
963
+ var d;
964
+ const o = (d = t.bundle._inclusiveTaxes) == null ? void 0 : d.some(
965
+ (F) => F.systemCode === e.systemCode && F.inclusive
966
+ );
967
+ return {
968
+ label: `${e.name} (${Ae(e.rate)}%, ${o ? "Inclusive" : "Exclusive"})`,
969
+ value: H(t, e.total)
970
+ };
971
+ }), x = at(t);
972
+ return x ? [...a, { label: "Tax Total", value: x }] : a;
973
+ }), b = B(() => {
974
+ var a;
975
+ const t = (a = m.value) == null ? void 0 : a.giftCard;
976
+ return t ? [
977
+ { label: "Movement", value: W.title(t.movement) },
978
+ {
979
+ label: "Serial Number",
980
+ value: t.serialNumber ?? (t.movement === "PURCHASE" ? "Pending card issuance" : "Not available")
981
+ }
982
+ ] : [];
983
+ }), p = B(() => [
984
+ { title: "Transaction", items: g.value },
985
+ { title: "Bundle & Pricing", items: v.value },
986
+ { title: "Rewards", items: s.value, emptyText: "No rewards" },
987
+ { title: "Taxes", items: _.value, emptyText: "No taxes" },
988
+ ...b.value.length ? [{ title: "Gift Card", items: b.value }] : []
989
+ ]);
990
+ return y({ showSheet: C }), (t, a) => {
991
+ const x = Y("FmButton"), e = Y("FmSideSheet");
992
+ return P(), le(e, {
993
+ modelValue: c(u),
994
+ "onUpdate:modelValue": a[1] || (a[1] = (o) => de(u) ? u.value = o : null),
995
+ "max-width": 560,
996
+ header: "Store Transaction Details"
997
+ }, {
998
+ "side-sheet-footer": te(() => [
999
+ A(x, {
1000
+ label: "Close",
1001
+ variant: "tertiary",
1002
+ onClick: a[0] || (a[0] = (o) => C(!1))
1003
+ })
1004
+ ]),
1005
+ default: te(() => [
1006
+ w("div", nt, [
1007
+ (P(!0), E(q, null, ae(c(p), (o) => (P(), E("section", {
1008
+ key: o.title
1009
+ }, [
1010
+ w("h3", ot, U(o.title), 1),
1011
+ o.items.length ? (P(), E("div", rt, [
1012
+ (P(!0), E(q, null, ae(o.items, (d) => (P(), E("div", {
1013
+ key: d.label,
1014
+ class: "flex flex-col gap-4"
1015
+ }, [
1016
+ w("div", st, U(d.label), 1),
1017
+ w("div", lt, U(d.value), 1),
1018
+ a[2] || (a[2] = w("hr", { class: "mt-3 border-fm-color-neutral-gray-100" }, null, -1))
1019
+ ]))), 128))
1020
+ ])) : (P(), E("div", it, U(o.emptyText), 1))
1021
+ ]))), 128))
1022
+ ])
1023
+ ]),
1024
+ _: 1
1025
+ }, 8, ["modelValue"]);
1026
+ };
1027
+ }
1028
+ }), ut = { class: "flex items-center justify-between" }, mt = { class: "flex gap-8 items-center" }, dt = { class: "flex gap-8 items-center xs:hidden" }, qt = /* @__PURE__ */ oe({
1029
+ __name: "StoreTransactions",
1030
+ props: {
1031
+ user: {
1032
+ type: String
1033
+ }
1034
+ },
1035
+ setup(l) {
1036
+ const y = l, { minor: u } = _e, { t: m } = re();
1037
+ function R(e) {
1038
+ return we(e, m);
1039
+ }
1040
+ function C(e) {
1041
+ return M(L(e._id.toString())).format(
1042
+ "D MMM YYYY, hh:mmA"
1043
+ );
1044
+ }
1045
+ function N(e) {
1046
+ var o, d;
1047
+ return e.location ? ((d = (o = e.pf_location) == null ? void 0 : o[0]) == null ? void 0 : d.name) ?? e.location.toString() : "Online Store";
1048
+ }
1049
+ const $ = [
1050
+ {
1051
+ header: "Transaction ID",
1052
+ meta: {
1053
+ maxWidth: "150px"
1054
+ },
1055
+ cell(e) {
1056
+ return i("div", { class: "flex items-center" }, [
1057
+ i(T.FmIcon, {
1058
+ name: "content_copy",
1059
+ outline: !0,
1060
+ size: "sm",
1061
+ class: "cursor-pointer mr-4 shrink-0",
1062
+ onClick: (o) => {
1063
+ o.preventDefault(), o.stopPropagation(), ce(e.row.original._id.toString());
1064
+ }
1065
+ }),
1066
+ i("div", { class: "truncate" }, e.row.original._id.toString())
1067
+ ]);
1068
+ }
1069
+ },
1070
+ {
1071
+ header: "Created at",
1072
+ accessorFn: C,
1073
+ enableSorting: !0
1074
+ },
1075
+ {
1076
+ header: "Bundle",
1077
+ accessorFn: (e) => e.bundle.name
1078
+ },
1079
+ {
1080
+ header: "Selling Price",
1081
+ cell: (e) => ie(e.row.original)
1082
+ },
1083
+ {
1084
+ header: "Location",
1085
+ accessorFn: N
1086
+ },
1087
+ {
1088
+ header: "Payment Type",
1089
+ accessorFn: R,
1090
+ cell(e) {
1091
+ var o;
1092
+ return i("div", { class: "flex items-center gap-4" }, [
1093
+ i("div", { class: "flex items-center" }, [
1094
+ ((o = e.row.original.paymentType) == null ? void 0 : o.type) == "ONLINE" && e.row.original.paymentType.extra ? i(
1095
+ T.FmTooltip,
1096
+ {
1097
+ content: e.row.original.paymentType.extra
1098
+ },
1099
+ [
1100
+ i(T.FmIcon, {
1101
+ name: "info",
1102
+ outline: !0,
1103
+ size: "sm"
1104
+ })
1105
+ ]
1106
+ ) : i("div")
1107
+ ]),
1108
+ i("div", { class: "flex-1" }, R(e.row.original))
1109
+ ]);
1110
+ }
1111
+ },
1112
+ {
1113
+ header: "User",
1114
+ cell: (e) => be(e.row.original.pf_member)
1115
+ },
1116
+ {
1117
+ header: "Phone No.",
1118
+ accessorFn: (e) => e.pf_member.phoneNumber
1119
+ },
1120
+ {
1121
+ header: "Status",
1122
+ // accessorFn: (u) => u.status,
1123
+ cell(e) {
1124
+ var F, D, r, n;
1125
+ const o = e.row.original.status, d = {
1126
+ COMPLETED: "text-fm-color-typo-success bg-fm-color-system-success-100",
1127
+ REFUNDED: "text-fm-color-typo-warning bg-fm-color-system-warning-100"
1128
+ };
1129
+ return i("div", { class: "flex items-center gap-4" }, [
1130
+ i(T.FmChip, {
1131
+ label: W.title(o),
1132
+ variant: "plain",
1133
+ class: d[o] ?? ""
1134
+ }),
1135
+ (D = (F = e.row.original) == null ? void 0 : F.refund) != null && D.reason ? i(
1136
+ T.FmTooltip,
1137
+ {
1138
+ content: (n = (r = e.row.original) == null ? void 0 : r.refund) == null ? void 0 : n.reason
1139
+ },
1140
+ [
1141
+ i(T.FmIcon, {
1142
+ name: "info",
1143
+ color: "primary",
1144
+ outline: !0,
1145
+ size: "sm"
1146
+ })
1147
+ ]
1148
+ ) : null
1149
+ ]);
1150
+ }
1151
+ },
1152
+ {
1153
+ header: "Source",
1154
+ accessorFn: (e) => e.source
1155
+ },
1156
+ {
1157
+ header: "Ref",
1158
+ accessorFn: (e) => e.ref
1159
+ },
1160
+ {
1161
+ id: "action",
1162
+ cell(e) {
1163
+ const o = e.row.original, d = o.status === "COMPLETED" && !o.refund && o.source == "ADMIN";
1164
+ return d ? i(
1165
+ T.FmMenu,
1166
+ {
1167
+ placement: "bottom-end",
1168
+ onClick: (F) => {
1169
+ F.stopPropagation();
1170
+ }
1171
+ },
1172
+ {
1173
+ "menu-button": () => i(T.FmButton, {
1174
+ icon: "settings",
1175
+ variant: "tertiary",
1176
+ if: d
1177
+ }),
1178
+ default: () => [
1179
+ i(T.FmMenuItem, {
1180
+ label: "Refund",
1181
+ sublabel: "Refund this transaction",
1182
+ onClick: async (F) => {
1183
+ F.stopPropagation(), await p(o);
1184
+ }
1185
+ })
1186
+ ]
1187
+ }
1188
+ ) : i("div");
1189
+ }
1190
+ }
1191
+ ], I = k({
1192
+ searchValue: "",
1193
+ dateRange: {
1194
+ startDate: M().subtract(7, "day").toISOString(),
1195
+ endDate: M().toISOString()
1196
+ }
1197
+ }), { tableMeta: g, rowData: v, onSort: s, debouncedFetchData: _, onSearch: b } = Ne(async (e) => {
1198
+ const o = {
1199
+ ...I.value.dateRange,
1200
+ user: y.user
1201
+ };
1202
+ return await j.readStoreTransactions(e, o);
1203
+ });
1204
+ async function p(e) {
1205
+ await he.confirm(
1206
+ "Are you sure you want to refund this transaction?",
1207
+ "Refund Store Transaction",
1208
+ "Confirm",
1209
+ "Cancel"
1210
+ ) && await u(
1211
+ async () => {
1212
+ var d;
1213
+ await Ee.refundStoreTransaction({
1214
+ id: e._id,
1215
+ reason: `ADMIN:${(d = $e().sessionUser) == null ? void 0 : d.name}`
1216
+ }), await _();
1217
+ },
1218
+ {
1219
+ message: "Refunding transaction...",
1220
+ successMessage: "Transaction refunded successfully"
1221
+ }
1222
+ );
1223
+ }
1224
+ pe(
1225
+ I,
1226
+ () => {
1227
+ _();
1228
+ },
1229
+ { deep: !0 }
1230
+ ), De(async () => {
1231
+ await _();
1232
+ });
1233
+ const t = async () => Pe({
1234
+ exporter: new et(),
1235
+ readFunction: (e) => j.readStoreTransactions(e, {
1236
+ ...I.value.dateRange,
1237
+ user: y.user
1238
+ }),
1239
+ transformRecord: (e) => {
1240
+ var o, d, F, D;
1241
+ return {
1242
+ "Transaction ID": e._id.toString(),
1243
+ "Created at": C(e),
1244
+ Bundle: e.bundle.name || "",
1245
+ "Selling Price": ie(e),
1246
+ Location: N(e),
1247
+ "Payment Type": R(e),
1248
+ "Payment Extra": ((o = e.paymentType) == null ? void 0 : o.extra) || "",
1249
+ User: ((d = e.pf_member) == null ? void 0 : d.name) || "",
1250
+ "Phone No.": ((F = e.pf_member) == null ? void 0 : F.phoneNumber) || "",
1251
+ Status: W.title(e.status),
1252
+ "Refund Reason": ((D = e.refund) == null ? void 0 : D.reason) || "",
1253
+ Source: e.source,
1254
+ Ref: (e == null ? void 0 : e.ref) || ""
1255
+ };
1256
+ },
1257
+ filename: "store-transactions"
1258
+ }), a = k(null);
1259
+ function x(e) {
1260
+ var o;
1261
+ (o = a.value) == null || o.showSheet(!0, e.original);
1262
+ }
1263
+ return (e, o) => {
1264
+ const d = Y("FmSearch"), F = Y("FmButton");
1265
+ return P(), E("div", null, [
1266
+ w("div", ut, [
1267
+ w("div", mt, [
1268
+ A(ge, {
1269
+ modelValue: c(I).dateRange,
1270
+ "onUpdate:modelValue": o[0] || (o[0] = (D) => c(I).dateRange = D)
1271
+ }, null, 8, ["modelValue"])
1272
+ ]),
1273
+ w("div", dt, [
1274
+ A(d, {
1275
+ modelValue: c(g).searchValue,
1276
+ "onUpdate:modelValue": [
1277
+ o[1] || (o[1] = (D) => c(g).searchValue = D),
1278
+ c(b)
1279
+ ],
1280
+ placeholder: "Search",
1281
+ collapsible: ""
1282
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1283
+ A(F, {
1284
+ icon: "ios_share",
1285
+ variant: "tertiary",
1286
+ onClick: t
1287
+ })
1288
+ ])
1289
+ ]),
1290
+ A(ve, {
1291
+ loading: c(g).isLoading,
1292
+ "row-data": c(v),
1293
+ "row-count": c(g).totalRows,
1294
+ "column-defs": $.filter(
1295
+ (D) => !y.user || D.header !== "User" && D.header !== "Phone No."
1296
+ ),
1297
+ "page-count": c(g).pageCount,
1298
+ "page-index": c(g).pageIndex,
1299
+ "page-size": c(g).pageSize,
1300
+ "shrink-at": !1,
1301
+ onSortChange: c(s),
1302
+ onRowClick: x,
1303
+ onPageChange: o[2] || (o[2] = (D) => c(_)({
1304
+ pageSize: D.pageSize,
1305
+ pageIndex: D.pageIndex
1306
+ }))
1307
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "onSortChange"]),
1308
+ A(ct, {
1309
+ ref_key: "transactionDetailSheet",
1310
+ ref: a
1311
+ }, null, 512)
1312
+ ]);
1313
+ };
1314
+ }
1315
+ });
1316
+ export {
1317
+ Wt as _,
1318
+ qt as a
1319
+ };