@feedmepos/mf-connect 0.1.98-beta.8 → 0.1.98-beta.80

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 (167) hide show
  1. package/dist/{App-DsB2o1oB.js → App-DievprEi.js} +853 -683
  2. package/dist/{AuditLogs-BcfgiYnJ.js → AuditLogs-DrdqOhZL.js} +16 -13
  3. package/dist/{Bin-DMr7K8Kj.js → Bin-Ci2k3z77.js} +8 -8
  4. package/dist/Broadcast-CpDMAG1o.js +306 -0
  5. package/dist/CampaignAnalytic-uRyGaLaN.js +1830 -0
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CwGoEBsW.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DtGe2Og1.js} +8 -5
  7. package/dist/Card-tb98Kyr-.js +1086 -0
  8. package/dist/{Collections-B0uGC2FE.js → Collections-P1S5WjnJ.js} +14 -13
  9. package/dist/Credit-DwK7JYf-.js +286 -0
  10. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-Cyk0iIsd.js +53 -0
  11. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-8r29jKh9.js +4432 -0
  12. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-DJLxGk7W.js → EffectSheet.vue_vue_type_style_index_0_lang-BML_-v8I.js} +36 -36
  13. package/dist/Experience-BejtRlOj.js +288 -0
  14. package/dist/{FileSaver.min-BlA0oZEC.js → FileSaver.min-C-hmBaHm.js} +1 -1
  15. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-3bH-tZAm.js +138 -0
  16. package/dist/Game-n8qL896g.js +356 -0
  17. package/dist/GiftCardSetup-Bgsfcu7N.js +736 -0
  18. package/dist/GoalPickerPanel.vue_vue_type_script_setup_true_lang-CzL68PPP.js +424 -0
  19. package/dist/Goals-BB8LJlq3.js +247 -0
  20. package/dist/{Grab-DmmwrGzk.js → Grab-COq3Ujst.js} +33 -32
  21. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-DNtLW0yQ.js → ImageInput.vue_vue_type_script_setup_true_lang-BmLclEyi.js} +1 -1
  22. package/dist/{Index-m7l4insz.js → Index-BdkIinaE.js} +10 -10
  23. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-B9sJ-M20.js → LocationPicker.vue_vue_type_script_setup_true_lang-DsWv3DVb.js} +1 -1
  24. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-Dsg2sWjF.js → LottieAnimation.vue_vue_type_script_setup_true_lang-DvOzGF8c.js} +1 -1
  25. package/dist/LoyaltyDashboard-D4Jtpw0n.js +2911 -0
  26. package/dist/MainLayout-Ca-Xm3eZ.js +143 -0
  27. package/dist/{Marketing-C9pSIdBU.js → Marketing-Cpe4s7NZ.js} +7 -6
  28. package/dist/{MarketingMaterialEdit-BEF2T9LR.js → MarketingMaterialEdit-nTeS9VVx.js} +15 -14
  29. package/dist/Member-DgGZ4Cdg.js +654 -0
  30. package/dist/MemberDetailSheet.vue_vue_type_script_setup_true_lang-_O3B-FIA.js +1281 -0
  31. package/dist/MemberImportHistory-rdlbDVWU.js +187 -0
  32. package/dist/MemberList-BC4aRJTt.js +334 -0
  33. package/dist/{MemberTransactions-CAut1TQb.js → MemberTransactions-BFfdTttp.js} +1 -1
  34. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-1AuHixPC.js → MessageInput.vue_vue_type_script_setup_true_lang-DXajAQy9.js} +5928 -5644
  35. package/dist/MetricInfoTooltip.vue_vue_type_script_setup_true_lang-8xVDzdO3.js +40 -0
  36. package/dist/Mission-BWCNKTjU.js +363 -0
  37. package/dist/Overview--Q7vzhNK.js +1316 -0
  38. package/dist/{Overview-DOJj4XvO.js → Overview-i02Wnyjn.js} +23 -20
  39. package/dist/Point-CiWxqny5.js +297 -0
  40. package/dist/Promotion-B0G9qfBm.js +426 -0
  41. package/dist/{Queue-55G2gtP5.js → Queue-YfwgYmzH.js} +16 -13
  42. package/dist/{Record-DNPI02c6.js → Record-CCuwrPKW.js} +9 -9
  43. package/dist/Review-ymsfdh7Q.js +45 -0
  44. package/dist/ReviewFacebookCallback-DyDExWvP.js +238 -0
  45. package/dist/ReviewGoogleCallback-DNyg3n2S.js +213 -0
  46. package/dist/{Reward-CnP8R2pS.js → Reward-BKIb0ezH.js} +28 -28
  47. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-BN71h9IK.js → RewardGroup.vue_vue_type_script_setup_true_lang-DPaaNgpr.js} +26 -23
  48. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CtB9Ls5-.js → RuleGroup.vue_vue_type_script_setup_true_lang-BLFLybFn.js} +198 -186
  49. package/dist/{Segment-CxiQnnyj.js → Segment-D5_pp7fh.js} +278 -276
  50. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-B1vj5f7T.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-BLLjIA-D.js} +45 -42
  51. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-cWx0G3nM.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-BRIcZwnU.js} +4 -4
  52. package/dist/Setting-CD78gIMU.js +574 -0
  53. package/dist/{SettingAdvertisements-Vt7w1WN3.js → SettingAdvertisements-C2AIT4s4.js} +12 -12
  54. package/dist/Settings-DI_tryQV.js +230 -0
  55. package/dist/Store-BV2JTRNZ.js +2615 -0
  56. package/dist/{StoreRewards-DILeipMG.js → StoreRewards-Bk55YXyO.js} +15 -15
  57. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-BZZ1fqwg.js +1331 -0
  58. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-C7lVeybl.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-BrEzWVrH.js} +2 -2
  59. package/dist/{Tier-BAZ1xuKL.js → Tier-CO2K30Ew.js} +2576 -757
  60. package/dist/{Title-CcNAt47f.js → Title-qProQh3T.js} +41 -37
  61. package/dist/Transaction-qL5L-fE_.js +45 -0
  62. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-hUjQVZ_U.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Co1BPScS.js} +26 -26
  63. package/dist/Voucher-VFD1LY9Y.js +837 -0
  64. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-CTQDxc5l.js → VoucherEditor.vue_vue_type_script_setup_true_lang-9QyTl7iq.js} +118 -124
  65. package/dist/WhatsappAccount-CxSGqm7H.js +325 -0
  66. package/dist/WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-D8L6izf0.js +96 -0
  67. package/dist/WhatsappBot-C4Oz7Xwv.js +441 -0
  68. package/dist/WhatsappBotSettings-CKqaWzwE.js +136 -0
  69. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-DuRKA4cj.js → ZodTextField.vue_vue_type_script_setup_true_lang-Bcsi94dw.js} +2 -2
  70. package/dist/{app-Z-UKRG5V.js → app-BEYzXWZO.js} +50954 -42517
  71. package/dist/app.js +1 -1
  72. package/dist/base.export-S_82Elmg.js +75 -0
  73. package/dist/browser-BSAOEeIM.js +1478 -0
  74. package/dist/{business-C7EF6cKC.js → business-DH7djUl8.js} +5 -5
  75. package/dist/campaign-DlHDgoFX.js +100 -0
  76. package/dist/campaign-k_WHxsOR.js +400 -0
  77. package/dist/{campaign.enum-BNN2gLFY.js → campaign.enum-Dx-Zo68Q.js} +1 -1
  78. package/dist/{campaign.fn-Bd34dVnx.js → campaign.fn-B-4JRzft.js} +67 -67
  79. package/dist/{collectible.enum-DO9HdJGH.js → collectible.enum-Liy2wH3s.js} +1 -1
  80. package/dist/collection.fn-zQwWDzZT.js +26 -0
  81. package/dist/currency-CQVHXBFe.js +7 -0
  82. package/dist/{duplicateCampaign-2ODeDw3a.js → duplicateCampaign-YTXMbJTj.js} +11 -11
  83. package/dist/{effect-BcB8IlTI.js → effect-CQkVLHWi.js} +1 -1
  84. package/dist/{email-addresses-BcTeU4Sh.js → email-addresses-BIoVbPGC.js} +209 -201
  85. package/dist/google-C3S8u0mT.js +4 -0
  86. package/dist/{helper-BSgrCJRv.js → helper-BCkTvF4m.js} +1 -1
  87. package/dist/{index-CoHWpylO.js → index-B-bQnb0_.js} +2115 -2557
  88. package/dist/index-BAJOC43K.js +14550 -0
  89. package/dist/{index-HXiYGO4_.js → index-BFIHEBnX.js} +6343 -7693
  90. package/dist/{index-VlFWaBrg.js → index-BJIQe3QJ.js} +1 -1
  91. package/dist/{index-BpI-BI4H.js → index-BJkRTH5T.js} +4 -4
  92. package/dist/index-BOJogkKQ.js +172 -0
  93. package/dist/{index-BoYEqLif.js → index-BRPajAkE.js} +1517 -263
  94. package/dist/{index-CsoBDon4.js → index-BTkxgos0.js} +1590 -1523
  95. package/dist/index-BUP4aHq8.js +32438 -0
  96. package/dist/index-BYvnqARr.js +902 -0
  97. package/dist/{index-hlyg-wxV.js → index-Bonq819P.js} +1 -1
  98. package/dist/{index-CIBPhxlC.js → index-C6mOI2Pp.js} +105 -123
  99. package/dist/{index-Bf6jNZit.js → index-CDIe15AY.js} +24 -9
  100. package/dist/index-CTrcdIkt.js +137 -0
  101. package/dist/index-C_H8jFYf.js +2743 -0
  102. package/dist/index-CpnchVe1.js +74 -0
  103. package/dist/index-D5AR7A5e.js +151 -0
  104. package/dist/index-D7-Q86HI.js +54 -0
  105. package/dist/index-DdOj8Hew.js +53 -0
  106. package/dist/{index-iMPtFp54.js → index-Dvqguh2B.js} +10 -9
  107. package/dist/{index-Bm0QPucw.js → index-hAKRfE-4.js} +14 -14
  108. package/dist/index-o2Ga_qaX.js +39 -0
  109. package/dist/{index.esm2017-CM7OnEyP.js → index.esm2017-D0fhMMPG.js} +128 -128
  110. package/dist/{loading-CSXr0Yqz.js → loading-C686AMVG.js} +1 -1
  111. package/dist/{lodash-Bh7XKI-R.js → lodash-CANlWUWW.js} +1 -1
  112. package/dist/member-import-UzJ6ByIS.js +188 -0
  113. package/dist/membership-DCVzFaFy.js +274 -0
  114. package/dist/{money-BZIST_m9.js → money-DuazwoX7.js} +1 -1
  115. package/dist/{number-DXLR2w95.js → number-B2HFiV0g.js} +1 -1
  116. package/dist/objectid-Bq-oVMdP.js +145 -0
  117. package/dist/onboarding-BxvNxz-9.js +131 -0
  118. package/dist/onboardingSetup-CcvKmyx8.js +17 -0
  119. package/dist/{plugins-4FlbwoES.js → plugins-C39O5j42.js} +13 -12
  120. package/dist/remy-Qz_pNsUS.js +13 -0
  121. package/dist/{reward-DUbl79bZ.js → reward-HYt-2nxt.js} +1 -1
  122. package/dist/{rule-BQUoZ4l_.js → rule-3xNIYM7z.js} +337 -275
  123. package/dist/style.css +1 -1
  124. package/dist/{template-BoiSG7G7.js → template-D37Z_b0m.js} +6 -6
  125. package/dist/timezone-JwnQgpaU.js +20 -0
  126. package/dist/transaction.fn-C5vswLI_.js +71 -0
  127. package/dist/{trigger-D5g5m6tT.js → trigger-Bc6s2cvq.js} +17 -17
  128. package/dist/useMarketingMaterialActions-DMGyAXcy.js +96 -0
  129. package/dist/{usePagination-DHePBBoR.js → usePagination-DLOOwiiY.js} +1 -1
  130. package/dist/{user-C_ToSo-g.js → user-CTIGugVF.js} +1 -1
  131. package/dist/{vue-i18n-BcYh6_51.js → vue-i18n-Dpic36zz.js} +287 -287
  132. package/dist/{xlsx-h4G1C-xj.js → xlsx-CT9_1SFr.js} +786 -786
  133. package/dist/{zod-CgigfJar.js → zod-CGVrMcDl.js} +1 -1
  134. package/package.json +10 -6
  135. package/dist/Broadcast-C9akM-TB.js +0 -266
  136. package/dist/Card-DRkIYs0M.js +0 -910
  137. package/dist/Credit-V5YA_hGx.js +0 -260
  138. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +0 -58
  139. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CYQMXARx.js +0 -3377
  140. package/dist/Experience-WTWy5yY6.js +0 -259
  141. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +0 -129
  142. package/dist/Game-BwOfTCW5.js +0 -330
  143. package/dist/LoyaltyDashboard-CJdhYiea.js +0 -1082
  144. package/dist/MainLayout-Du5kZOtA.js +0 -41
  145. package/dist/Member-DUV_vbPI.js +0 -280
  146. package/dist/MemberList-Ye4nOk-i.js +0 -1601
  147. package/dist/Mission-BBmCGpt8.js +0 -334
  148. package/dist/Point-Bzg6hi6o.js +0 -262
  149. package/dist/Promotion-BMXIp_ef.js +0 -397
  150. package/dist/Review-CYNPPxYU.js +0 -1141
  151. package/dist/ReviewFacebookCallback-0SUkKAaC.js +0 -243
  152. package/dist/ReviewGoogleCallback-BZEzx68n.js +0 -208
  153. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-C4vohf6c.js +0 -181
  154. package/dist/Setting-jHAjccod.js +0 -2047
  155. package/dist/Store-Cu-hKmVa.js +0 -1996
  156. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CGz6CTWA.js +0 -1130
  157. package/dist/Transaction-D7DO3dKQ.js +0 -39
  158. package/dist/Voucher-Cq-n1CaC.js +0 -421
  159. package/dist/campaign--MjoY1Mn.js +0 -219
  160. package/dist/campaign-DHBuP4UA.js +0 -277
  161. package/dist/export-CjB7qxZ9.js +0 -97
  162. package/dist/index-BIAjmMga.js +0 -85
  163. package/dist/index-Bv4MBLQ5.js +0 -52
  164. package/dist/index-hbyCVNa7.js +0 -30289
  165. package/dist/membership-CfredTm3.js +0 -255
  166. package/dist/objectid-Dg4ZodlT.js +0 -145
  167. package/dist/useMarketingMaterialActions-B-Jlw2Z9.js +0 -107
@@ -0,0 +1,1331 @@
1
+ import { ref as E, defineComponent as re, computed as U, h as l, resolveComponent as K, openBlock as k, createBlock as ce, unref as i, isRef as fe, withCtx as ae, createElementVNode as _, createVNode as D, createElementBlock as O, Fragment as X, renderList as ne, toDisplayString as G, createTextVNode as Re, resolveDynamicComponent as Ie, watch as ge, onBeforeMount as Fe, onMounted as De } from "vue";
2
+ import { components as T } from "@feedmepos/ui-library";
3
+ import { x as ue } from "./index-B-bQnb0_.js";
4
+ import "./index-BFIHEBnX.js";
5
+ import { T as z } from "./transaction.fn-C5vswLI_.js";
6
+ import { h as A } from "./moment-D7p2TMB-.js";
7
+ import { _ as le } from "./FilterChip.vue_vue_type_script_setup_true_lang-3bH-tZAm.js";
8
+ import { _ as ye } from "./DateRangeChip.vue_vue_type_script_setup_true_lang-Cyk0iIsd.js";
9
+ import { s as te } from "./index-CuvNtC_M.js";
10
+ import { f as W, F as Ae } from "./number-B2HFiV0g.js";
11
+ import { u as ve } from "./business-DH7djUl8.js";
12
+ import { _ as he, u as Ne } from "./usePagination-DLOOwiiY.js";
13
+ import { c as de, p as Pe } from "./plugins-C39O5j42.js";
14
+ import { g as be } from "./user-CTIGugVF.js";
15
+ import { B as xe, e as ke } from "./base.export-S_82Elmg.js";
16
+ import { u as Se } from "./campaign-DlHDgoFX.js";
17
+ import "./index-Bonq819P.js";
18
+ import "./index-BRPajAkE.js";
19
+ import "./index-BTkxgos0.js";
20
+ import "./index-BYvnqARr.js";
21
+ import "./index-Dvqguh2B.js";
22
+ import "./index-o2Ga_qaX.js";
23
+ import "./index-BOJogkKQ.js";
24
+ import { u as se } from "./vue-i18n-Dpic36zz.js";
25
+ import { o as j } from "./objectId-dwaoBfJX.js";
26
+ import { u as _e } from "./loading-C686AMVG.js";
27
+ import { w as Me } from "./xlsx-CT9_1SFr.js";
28
+ import { useRouter as Ee } from "vue-router";
29
+ import { t as H } from "./index-hAKRfE-4.js";
30
+ import { R as ee } from "./app-BEYzXWZO.js";
31
+ import { F as ie } from "./collectible.enum-Liy2wH3s.js";
32
+ import { useCoreStore as Ve } from "@feedmepos/mf-common";
33
+ import { c as Q } from "./string-Gcy5IM_H.js";
34
+ import { f as $e } from "./currency-CQVHXBFe.js";
35
+ import { m as Oe } from "./index-CDIe15AY.js";
36
+ const Be = (f) => {
37
+ if (f.startsWith("_") || f.includes("."))
38
+ return f;
39
+ for (const v of ["pf_user_", "pf_collectible_"])
40
+ if (f.startsWith(v))
41
+ return `${v.slice(0, -1)}.${f.slice(v.length).replace(new RegExp("_", "g"), ".")}`;
42
+ return f.replace(new RegExp("_", "g"), ".");
43
+ };
44
+ function ze(f, v = { key: "_id", descending: !0 }) {
45
+ const u = E({
46
+ pageCount: 1,
47
+ searchValue: "",
48
+ pageIndex: 0,
49
+ totalRows: 0,
50
+ isLoading: !1,
51
+ pageSize: 10,
52
+ hasNext: !1
53
+ }), m = E(v), C = E([]), w = E([void 0]);
54
+ function N() {
55
+ w.value = [void 0], u.value.pageIndex = 0, u.value.pageCount = 1, u.value.hasNext = !1;
56
+ }
57
+ const V = async (b = {}) => {
58
+ const p = b.pageSize ?? u.value.pageSize, a = p !== u.value.pageSize;
59
+ a && N();
60
+ const t = a ? 0 : Math.max(b.pageIndex ?? u.value.pageIndex, 0), e = t === 0 || !!w.value[t] ? t : u.value.pageIndex, n = w.value[e];
61
+ u.value.isLoading = !0, u.value.pageSize = p, C.value = [];
62
+ try {
63
+ const c = await f({
64
+ limit: p,
65
+ sortBy: m.value.key,
66
+ descending: m.value.descending,
67
+ search: u.value.searchValue,
68
+ ...n ? { cursor: n } : {}
69
+ });
70
+ C.value = c.resources, u.value.pageIndex = e, u.value.totalRows = c.resources.length, u.value.hasNext = c.meta.hasNext, u.value.pageCount = e + (c.meta.hasNext ? 2 : 1), c.meta.nextCursor ? w.value[e + 1] = c.meta.nextCursor : w.value.splice(e + 1);
71
+ } catch (c) {
72
+ console.error("Error fetching data:", c), u.value.hasNext = !1;
73
+ } finally {
74
+ u.value.isLoading = !1;
75
+ }
76
+ };
77
+ let R, g;
78
+ const h = (b) => (R && clearTimeout(R), g && g(), new Promise((p) => {
79
+ g = p, R = setTimeout(async () => {
80
+ R = void 0, g = void 0, await V(b), p();
81
+ }, 200);
82
+ }));
83
+ return {
84
+ tableMeta: u,
85
+ rowData: C,
86
+ sortBy: m,
87
+ pageCursors: w,
88
+ resetCursorState: N,
89
+ fetchData: V,
90
+ debouncedFetchData: h,
91
+ onSort: async (b) => {
92
+ b.length ? m.value = {
93
+ key: Be(b[0].id),
94
+ descending: b[0].desc
95
+ } : m.value = v, N(), await h({
96
+ pageIndex: 0,
97
+ pageSize: u.value.pageSize
98
+ });
99
+ },
100
+ onSearch: () => (N(), h({
101
+ pageIndex: 0,
102
+ pageSize: u.value.pageSize
103
+ }))
104
+ };
105
+ }
106
+ class Ue extends xe {
107
+ }
108
+ const Ye = { class: "space-y-24 pr-12" }, Le = { class: "w-full space-y-16" }, Ge = { class: "fm-typo-en-body-lg-600" }, Ke = ["onClick"], je = { class: "fm-typo-en-body-lg-600" }, We = ["onClick"], qe = { class: "flex items-center gap-8" }, He = /* @__PURE__ */ re({
109
+ __name: "TransactionDetailSheet",
110
+ setup(f, { expose: v }) {
111
+ se();
112
+ const u = E(!1), m = E(), C = Se(), w = ve();
113
+ function N(h, s) {
114
+ u.value = h, m.value = s ?? null;
115
+ }
116
+ const V = U(() => {
117
+ var h, s;
118
+ return W(
119
+ ((s = m.value) == null ? void 0 : s.expiryAmount.reduce(
120
+ (S, b) => S + b.amount,
121
+ ((h = m.value) == null ? void 0 : h.amount) ?? 0
122
+ )) ?? 0,
123
+ 2
124
+ );
125
+ }), R = U(() => {
126
+ var h, s, S, b, p;
127
+ return m.value ? [
128
+ {
129
+ label: "Transaction ID",
130
+ value: (h = m.value) == null ? void 0 : h._id
131
+ },
132
+ {
133
+ label: "Date/Time",
134
+ value: A(j(m.value._id.toString())).format(
135
+ "D MMM YYYY, hh:mmA"
136
+ )
137
+ },
138
+ {
139
+ label: "Amount",
140
+ component: () => l(
141
+ "span",
142
+ {
143
+ class: [
144
+ "pr-2",
145
+ +V.value > 0 ? "text-fm-color-system-success-300" : "text-fm-color-system-error-300"
146
+ ]
147
+ },
148
+ V.value
149
+ )
150
+ },
151
+ {
152
+ label: "Type",
153
+ value: z.formattedType(m.value)
154
+ },
155
+ {
156
+ label: "Source",
157
+ value: te(z.getReason(m.value.source))
158
+ },
159
+ {
160
+ label: "User",
161
+ value: (S = (s = m.value) == null ? void 0 : s.pf_user) == null ? void 0 : S.name
162
+ },
163
+ {
164
+ label: "Phone Number",
165
+ value: (p = (b = m.value) == null ? void 0 : b.pf_user) == null ? void 0 : p.phoneNumber
166
+ }
167
+ ] : [];
168
+ }), g = U(() => {
169
+ var p, a, t, x;
170
+ if (!m.value) return [];
171
+ const h = [], s = (p = m.value) == null ? void 0 : p.metadata, S = m.value;
172
+ if (s != null && s.campaign) {
173
+ const e = C.campaigns.all.find(
174
+ (n) => n._id === (s == null ? void 0 : s.campaign)
175
+ );
176
+ e && h.push({
177
+ label: "Campaign",
178
+ value: e.name
179
+ });
180
+ }
181
+ const b = z.formattedRemark(S);
182
+ return b && h.push({
183
+ label: "Remark",
184
+ value: b
185
+ }), (a = m.value) != null && a.ref.startsWith("bill_") && h.push({
186
+ label: "Bill Number",
187
+ value: (t = m.value) == null ? void 0 : t.ref,
188
+ copy: () => {
189
+ var e;
190
+ return de((e = m.value) == null ? void 0 : e.ref);
191
+ }
192
+ }), s != null && s.location && h.push({
193
+ label: "Location",
194
+ value: (x = w.locations.find(
195
+ (e) => e._id.toString() === (s == null ? void 0 : s.location)
196
+ )) == null ? void 0 : x.name
197
+ }), S.source === ue.enum.STORE && h.push({
198
+ label: "Store Transaction",
199
+ value: S.ref
200
+ }), s != null && s.originTransaction && h.push({
201
+ label: "Parent Transaction",
202
+ value: s.originTransaction
203
+ }), s != null && s.referral_count && h.push({
204
+ label: "Referral Count",
205
+ value: s.referral_count
206
+ }), S.refundedFrom && h.push({
207
+ label: "Refunded From",
208
+ value: S.refundedFrom
209
+ }), h;
210
+ });
211
+ return v({
212
+ showSheet: N
213
+ }), (h, s) => {
214
+ const S = K("FmButton"), b = K("FmSideSheet");
215
+ return k(), ce(b, {
216
+ "max-width": 560,
217
+ modelValue: i(u),
218
+ "onUpdate:modelValue": s[1] || (s[1] = (p) => fe(u) ? u.value = p : null),
219
+ header: "Transaction Details"
220
+ }, {
221
+ "side-sheet-footer": ae(() => [
222
+ _("div", qe, [
223
+ D(S, {
224
+ label: "Close",
225
+ onClick: s[0] || (s[0] = (p) => N(!1)),
226
+ variant: "tertiary"
227
+ })
228
+ ])
229
+ ]),
230
+ default: ae(() => [
231
+ _("div", Ye, [
232
+ _("div", Le, [
233
+ (k(!0), O(X, null, ne(i(R), (p) => (k(), O("div", {
234
+ key: p.label,
235
+ class: "flex flex-col gap-4"
236
+ }, [
237
+ _("div", Ge, G(p.label), 1),
238
+ _("div", {
239
+ class: "text-fm-color-typo-secondary fm-typo-en-body-md-400 hover:underline",
240
+ onClick: p.copy
241
+ }, [
242
+ Re(G(p.accessorFn ? p.accessorFn() : p.value) + " ", 1),
243
+ (k(), ce(Ie(p.component)))
244
+ ], 8, Ke),
245
+ s[2] || (s[2] = _("hr", { class: "mt-3" }, null, -1))
246
+ ]))), 128)),
247
+ (k(!0), O(X, null, ne(i(g), (p) => (k(), O("div", {
248
+ key: p.label,
249
+ class: "flex flex-col gap-4"
250
+ }, [
251
+ _("div", je, G(p.label), 1),
252
+ _("div", {
253
+ class: "text-fm-color-typo-secondary fm-typo-en-body-md-400 hover:underline",
254
+ onClick: p.copy
255
+ }, G(p.accessorFn ? p.accessorFn() : p.value), 9, We),
256
+ s[3] || (s[3] = _("hr", { class: "mt-3" }, null, -1))
257
+ ]))), 128))
258
+ ])
259
+ ])
260
+ ]),
261
+ _: 1
262
+ }, 8, ["modelValue"]);
263
+ };
264
+ }
265
+ }), 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" }, qt = /* @__PURE__ */ re({
266
+ __name: "CollectionTransactions",
267
+ props: {
268
+ user: {
269
+ type: String
270
+ }
271
+ },
272
+ setup(f) {
273
+ const { t: v } = se(), u = ve(), m = Se(), C = Ee(), w = f, N = E(!1), { minor: V } = _e, R = [
274
+ {
275
+ header: "Transaction ID",
276
+ accessorKey: "_id",
277
+ meta: {
278
+ maxWidth: "100px"
279
+ },
280
+ cell(o) {
281
+ return l("div", { class: "flex items-center" }, [
282
+ l(T.FmIcon, {
283
+ name: "content_copy",
284
+ outline: !0,
285
+ size: "sm",
286
+ class: "cursor-pointer mr-4",
287
+ onClick: (r) => {
288
+ r.preventDefault(), r.stopPropagation(), de(o.row.original._id.toString());
289
+ }
290
+ }),
291
+ l(
292
+ "div",
293
+ { class: "pr-2 text-ellipsis overflow-hidden" },
294
+ o.row.original._id.toString()
295
+ )
296
+ ]);
297
+ },
298
+ enableSorting: !1
299
+ },
300
+ {
301
+ header: "Created at",
302
+ accessorKey: "_id",
303
+ accessorFn: (o) => A(j(o._id.toString())),
304
+ cell: (o) => A(j(o.row.original._id.toString())).format(
305
+ "D MMM YYYY, hh:mmA"
306
+ ),
307
+ enableSorting: !0
308
+ },
309
+ {
310
+ header: "Amount",
311
+ // accessorKey: 'totalAmount',
312
+ enableSorting: !1,
313
+ cell(o) {
314
+ var y, d, M, B;
315
+ const r = W(
316
+ o.row.original.expiryAmount.reduce(
317
+ (q, Y) => q + Y.amount,
318
+ o.row.original.amount ?? 0
319
+ ),
320
+ 2
321
+ ), P = (d = (y = o.row.original.expiryAmount) == null ? void 0 : y[0]) != null && d.expiredAt ? A((B = (M = o.row.original.expiryAmount) == null ? void 0 : M[0]) == null ? void 0 : B.expiredAt).format(
322
+ "D MMM YYYY"
323
+ ) : "";
324
+ return l("div", { class: "flex items-center" }, [
325
+ l(
326
+ "div",
327
+ {
328
+ class: [
329
+ "pr-2",
330
+ +r > 0 ? "text-fm-color-system-success-300" : "text-fm-color-system-error-300"
331
+ ]
332
+ },
333
+ r
334
+ ),
335
+ l("div", { class: "flex items-center" }, [
336
+ o.row.original.expiryAmount.length > 0 ? l(
337
+ T.FmTooltip,
338
+ {
339
+ content: `Expired on ${P}`
340
+ },
341
+ [
342
+ l(T.FmIcon, {
343
+ name: "info",
344
+ outline: !0,
345
+ size: "sm"
346
+ })
347
+ ]
348
+ ) : l("div")
349
+ ])
350
+ ]);
351
+ }
352
+ },
353
+ {
354
+ header: "Type",
355
+ accessorKey: "pf_collectible.type",
356
+ accessorFn: (o) => z.formattedType(o),
357
+ meta: {
358
+ maxWidth: "200px"
359
+ },
360
+ cell(o) {
361
+ const r = z.formattedType(o.row.original);
362
+ return l("div", { class: "flex items-center" }, [
363
+ l("div", { class: "truncate text-ellipsis" }, r),
364
+ r.length > 20 ? l(
365
+ T.FmTooltip,
366
+ {
367
+ content: r
368
+ },
369
+ [
370
+ l(T.FmIcon, {
371
+ name: "info",
372
+ color: "primary",
373
+ outline: !0,
374
+ size: "sm"
375
+ })
376
+ ]
377
+ ) : null
378
+ ]);
379
+ }
380
+ },
381
+ {
382
+ header: "Source",
383
+ accessorKey: "source",
384
+ cell(o) {
385
+ var r;
386
+ return l("div", { class: "flex items-center gap-4" }, [
387
+ l(
388
+ "div",
389
+ { class: "truncate text-ellipsis" },
390
+ te(z.getReason(o.row.original.source))
391
+ ),
392
+ ...(r = o.row.original.metadata) != null && r.campaign ? [
393
+ l(
394
+ T.FmTooltip,
395
+ {
396
+ get content() {
397
+ var P;
398
+ return (P = m.campaigns.all.find(
399
+ (y) => {
400
+ var d;
401
+ return y._id === ((d = o.row.original.metadata) == null ? void 0 : d.campaign);
402
+ }
403
+ )) == null ? void 0 : P.name;
404
+ }
405
+ },
406
+ [
407
+ l(T.FmIcon, {
408
+ name: "info",
409
+ color: "primary",
410
+ size: "sm",
411
+ onClick: async (P) => {
412
+ P.preventDefault(), P.stopPropagation();
413
+ const y = m.campaigns.all.find(
414
+ (d) => {
415
+ var M;
416
+ return d._id === ((M = o.row.original.metadata) == null ? void 0 : M.campaign);
417
+ }
418
+ );
419
+ if (y)
420
+ switch (y.type) {
421
+ case "VOUCHER":
422
+ case "PROMOTION":
423
+ case "BROADCAST":
424
+ await C.push({
425
+ name: ee[`$connect-CAMPAIGN_${y.type}`]
426
+ });
427
+ break;
428
+ case "GAME":
429
+ case "CREDIT":
430
+ case "MISSION":
431
+ await C.push({
432
+ name: ee[`$connect-PROGRAM_${y.type}`]
433
+ });
434
+ break;
435
+ case "POINT":
436
+ await C.push({
437
+ name: ee["$connect-PROGRAM_EXPERIENCE"]
438
+ });
439
+ break;
440
+ case "COIN":
441
+ await C.push({
442
+ name: ee["$connect-PROGRAM_POINT"]
443
+ });
444
+ break;
445
+ }
446
+ }
447
+ })
448
+ ]
449
+ )
450
+ ] : []
451
+ ]);
452
+ }
453
+ },
454
+ {
455
+ header: "User",
456
+ accessorKey: "pf_user.name",
457
+ cell(o) {
458
+ return be(o.row.original.pf_user);
459
+ }
460
+ },
461
+ {
462
+ header: "Phone No.",
463
+ accessorKey: "pf_user.phoneNumber",
464
+ accessorFn: (o) => {
465
+ var r;
466
+ return ((r = o == null ? void 0 : o.pf_user) == null ? void 0 : r.phoneNumber) || "";
467
+ }
468
+ },
469
+ {
470
+ header: "Status",
471
+ id: "status",
472
+ enableSorting: !1,
473
+ cell(o) {
474
+ const r = !!o.row.original.refunded;
475
+ return l(T.FmChip, {
476
+ label: v(r ? "connect.transaction.refunded" : "connect.transaction.completed"),
477
+ variant: "plain",
478
+ class: r ? "text-fm-color-typo-warning bg-fm-color-system-warning-100" : "text-fm-color-typo-success bg-fm-color-system-success-100"
479
+ });
480
+ }
481
+ },
482
+ {
483
+ accessorFn: (o) => o.ref,
484
+ header: "References",
485
+ accessorKey: "ref",
486
+ cell(o) {
487
+ const r = z.formattedRemark(o.row.original);
488
+ return l("div", { class: "flex items-center justify-between gap-4" }, [
489
+ l("div", { class: "flex items-center" }, [
490
+ r ? l(
491
+ T.FmTooltip,
492
+ {
493
+ content: r
494
+ },
495
+ [
496
+ l(T.FmIcon, {
497
+ name: "info",
498
+ class: "pl-2",
499
+ outline: !0,
500
+ size: "sm"
501
+ })
502
+ ]
503
+ ) : l("div")
504
+ ]),
505
+ l("div", { class: "flex-1" }, o.row.original.ref)
506
+ ]);
507
+ }
508
+ },
509
+ {
510
+ header: "Actions",
511
+ cell(o) {
512
+ const r = o.row.original;
513
+ return l(
514
+ T.FmTooltip,
515
+ {
516
+ get content() {
517
+ return "Revert Transaction";
518
+ }
519
+ },
520
+ [
521
+ l(T.FmButton, {
522
+ variant: "tertiary",
523
+ icon: "amend",
524
+ iconColor: "neutral-gray-400",
525
+ disabled: !r.isRevertable,
526
+ onClick: (P) => {
527
+ P.stopPropagation(), n(r);
528
+ }
529
+ })
530
+ ]
531
+ );
532
+ }
533
+ }
534
+ ], g = E({
535
+ search: "",
536
+ "pf_collectible.type": [],
537
+ "metadata.location": [],
538
+ dateRange: {
539
+ startDate: A().subtract(7, "day").toISOString(),
540
+ endDate: A().endOf("day").toISOString()
541
+ },
542
+ source: []
543
+ }), h = () => ({
544
+ ...g.value,
545
+ user: w.user,
546
+ dateRange: {
547
+ start: new Date(g.value.dateRange.startDate).toISOString(),
548
+ end: new Date(g.value.dateRange.endDate).toISOString()
549
+ }
550
+ }), { tableMeta: s, rowData: S, onSort: b, debouncedFetchData: p, resetCursorState: a } = ze(async (o) => {
551
+ const r = await H.readAllCursor(
552
+ o,
553
+ h()
554
+ ), P = await Promise.all(
555
+ r.resources.map(async (y) => {
556
+ let d;
557
+ if (y.source !== ue.enum.BILL)
558
+ d = !1;
559
+ else {
560
+ const B = y.refunded || !!y.refundedFrom;
561
+ if (y.expiryAmount.reduce(
562
+ (Y, L) => Y + L.amount,
563
+ y.amount ?? 0
564
+ ) > 0) {
565
+ let Y = [];
566
+ [
567
+ ie.enum.STAMP,
568
+ ie.enum.POINT
569
+ ].includes(y.pf_collectible.type) ? d = !1 : d = !B;
570
+ } else
571
+ switch (y.pf_collectible.type) {
572
+ case ie.enum.VOUCHER:
573
+ d = y.expiryAmount.some(
574
+ (L) => !L.expiredAt || A(L.expiredAt).isAfter(A())
575
+ ) && !B;
576
+ break;
577
+ default:
578
+ d = !B;
579
+ break;
580
+ }
581
+ }
582
+ const M = t.value.find((B) => B._id === y.ref);
583
+ return {
584
+ ...y,
585
+ ref: (M == null ? void 0 : M.seqNumber) || y.ref,
586
+ isRevertable: d
587
+ };
588
+ })
589
+ );
590
+ return {
591
+ resources: r.resources.map((y) => {
592
+ const d = t.value.find((M) => M._id === y.ref);
593
+ return { ...y, ref: (d == null ? void 0 : d.seqNumber) || y.ref };
594
+ }),
595
+ meta: r.meta
596
+ };
597
+ }), t = E([]), x = ue.options.map((o) => ({ label: te(z.getReason(o)), value: o })), e = U(
598
+ () => u.locations.map((o) => ({ label: o.name, value: o._id }))
599
+ );
600
+ ge(
601
+ g,
602
+ () => {
603
+ a(), p({ pageIndex: 0 });
604
+ },
605
+ { deep: !0 }
606
+ );
607
+ async function n(o) {
608
+ V(
609
+ async () => {
610
+ await H.revertTransaction({
611
+ id: o._id.toString()
612
+ }), await p();
613
+ },
614
+ {
615
+ message: "Reverting transaction...",
616
+ successMessage: "Transaction reverted successfully"
617
+ }
618
+ );
619
+ }
620
+ async function c() {
621
+ try {
622
+ N.value = !0;
623
+ const o = new Ue(), r = h(), P = 1e3;
624
+ await V(
625
+ async () => {
626
+ var M, B, q, Y, L, pe;
627
+ let y, d = !0;
628
+ for (; d; ) {
629
+ const Z = await H.readAllCursor(
630
+ {
631
+ limit: P,
632
+ sortBy: "_id",
633
+ descending: !1,
634
+ ...y ? { cursor: y } : {}
635
+ },
636
+ r
637
+ );
638
+ if (!Z.resources.length)
639
+ break;
640
+ for (const $ of Z.resources)
641
+ o.addRecord({
642
+ TransactionID: $._id,
643
+ CreatedAt: A(j($._id.toString())).format(
644
+ "D MMM YYYY, hh:mmA"
645
+ ),
646
+ Amount: W(
647
+ $.expiryAmount.reduce(
648
+ (we, Ce) => we + Ce.amount,
649
+ $.amount ?? 0
650
+ ),
651
+ 2
652
+ ),
653
+ ExpiredAt: (B = (M = $.expiryAmount) == null ? void 0 : M[0]) != null && B.expiredAt ? A((Y = (q = $.expiryAmount) == null ? void 0 : q[0]) == null ? void 0 : Y.expiredAt).format("D MMM YYYY") : "",
654
+ Type: z.formattedType($),
655
+ Source: te(z.getReason($.source)),
656
+ User: ((L = $.pf_user) == null ? void 0 : L.name) || "",
657
+ "Phone No.": ((pe = $.pf_user) == null ? void 0 : pe.phoneNumber) || "",
658
+ References: $.ref,
659
+ Remark: z.formattedRemark($)
660
+ });
661
+ y = Z.meta.nextCursor ?? void 0, d = Z.meta.hasNext && !!y;
662
+ }
663
+ await Me(
664
+ o.buildExcel(),
665
+ `transactions-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
666
+ {
667
+ bookType: "xlsx",
668
+ bookSST: !1,
669
+ type: "array"
670
+ }
671
+ );
672
+ },
673
+ {
674
+ message: "Exporting transactions...",
675
+ successMessage: "transactions exported successfully"
676
+ }
677
+ );
678
+ } catch (o) {
679
+ console.error(o);
680
+ } finally {
681
+ N.value = !1;
682
+ }
683
+ }
684
+ const I = E(null);
685
+ function F(o) {
686
+ var r;
687
+ console.log(o), (r = I.value) == null || r.showSheet(!0, o.original);
688
+ }
689
+ return Fe(async () => {
690
+ await u.readLocations(), await m.read(), await p();
691
+ }), (o, r) => {
692
+ const P = K("FmSearch"), y = K("FmButton");
693
+ return k(), O(X, null, [
694
+ _("div", null, [
695
+ _("div", Qe, [
696
+ D(P, {
697
+ class: "hidden xs:!flex border-b border-fm-color-neutral-gray-100",
698
+ modelValue: i(g).search,
699
+ "onUpdate:modelValue": r[0] || (r[0] = (d) => i(g).search = d),
700
+ placeholder: "Search",
701
+ collapsible: ""
702
+ }, null, 8, ["modelValue"]),
703
+ D(y, {
704
+ icon: "ios_share",
705
+ variant: "tertiary",
706
+ onClick: c
707
+ })
708
+ ]),
709
+ _("div", Xe, [
710
+ _("div", Je, [
711
+ D(le, {
712
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
713
+ "right-icon": "keyboard_arrow_down",
714
+ modelValue: i(g)["metadata.location"],
715
+ "onUpdate:modelValue": r[1] || (r[1] = (d) => i(g)["metadata.location"] = d),
716
+ icon: "storefront",
717
+ "show-item-label": !0,
718
+ items: i(e)
719
+ }, null, 8, ["modelValue", "items"]),
720
+ D(le, {
721
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
722
+ "right-icon": "keyboard_arrow_down",
723
+ modelValue: i(g)["pf_collectible.type"],
724
+ "onUpdate:modelValue": r[2] || (r[2] = (d) => i(g)["pf_collectible.type"] = d),
725
+ label: "Type: ",
726
+ "show-item-label": !0,
727
+ items: [
728
+ { label: "Point", value: "COIN" },
729
+ { label: "Credit", value: "CREDIT" },
730
+ { label: "Voucher", value: "VOUCHER" },
731
+ { label: "Experience", value: "POINT" },
732
+ { label: "Tier", value: "TIER" },
733
+ { label: "Title", value: "TITLE" },
734
+ { label: "Game", value: "GAME" },
735
+ { label: "Stamp", value: "STAMP" }
736
+ ]
737
+ }, null, 8, ["modelValue"]),
738
+ D(le, {
739
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
740
+ "right-icon": "keyboard_arrow_down",
741
+ modelValue: i(g).source,
742
+ "onUpdate:modelValue": r[3] || (r[3] = (d) => i(g).source = d),
743
+ label: "Source: ",
744
+ "show-item-label": !0,
745
+ items: i(x)
746
+ }, null, 8, ["modelValue", "items"]),
747
+ D(ye, {
748
+ "model-value": {
749
+ startDate: i(g).dateRange.startDate,
750
+ endDate: i(g).dateRange.endDate
751
+ },
752
+ "onUpdate:modelValue": r[4] || (r[4] = (d) => i(g).dateRange = {
753
+ startDate: i(A)(d.startDate).startOf("d").toISOString(),
754
+ endDate: i(A)(d.endDate).endOf("d").toISOString()
755
+ })
756
+ }, null, 8, ["model-value"])
757
+ ]),
758
+ D(P, {
759
+ class: "xs:hidden",
760
+ modelValue: i(g).search,
761
+ "onUpdate:modelValue": r[5] || (r[5] = (d) => i(g).search = d),
762
+ placeholder: "Search",
763
+ collapsible: ""
764
+ }, null, 8, ["modelValue"]),
765
+ _("div", Ze, [
766
+ D(y, {
767
+ icon: "ios_share",
768
+ variant: "tertiary",
769
+ onClick: c
770
+ })
771
+ ])
772
+ ]),
773
+ D(he, {
774
+ loading: i(s).isLoading,
775
+ "row-data": i(S),
776
+ "row-count": i(s).totalRows,
777
+ "column-defs": R.filter(
778
+ (d) => !w.user || d.header !== "User" && d.header !== "Phone No."
779
+ ),
780
+ "page-count": i(s).pageCount,
781
+ "page-index": i(s).pageIndex,
782
+ "page-size": i(s).pageSize,
783
+ "shrink-at": !1,
784
+ "pagination-mode": "cursor",
785
+ "has-next": i(s).hasNext,
786
+ onSortChange: i(b),
787
+ onPageChange: r[6] || (r[6] = (d) => i(p)({
788
+ pageSize: d.pageSize,
789
+ pageIndex: d.pageIndex
790
+ })),
791
+ onRowClick: F
792
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "has-next", "onSortChange"])
793
+ ]),
794
+ D(He, {
795
+ ref_key: "transactionDetailSheet",
796
+ ref: I
797
+ }, null, 512)
798
+ ], 64);
799
+ };
800
+ }
801
+ });
802
+ class et extends xe {
803
+ }
804
+ function oe(f) {
805
+ return f.quantity ?? 1;
806
+ }
807
+ function Te(f, v) {
808
+ var u, m;
809
+ switch ((u = f.paymentType) == null ? void 0 : u.type) {
810
+ case "COIN":
811
+ return v("connect.store.paymentType.point");
812
+ case "CARD":
813
+ return v("connect.store.paymentType.cardActivation");
814
+ default:
815
+ return ((m = f.paymentType) == null ? void 0 : m.type) ?? v("connect.store.paymentType.notAvailable");
816
+ }
817
+ }
818
+ function J(f, v) {
819
+ return $e({
820
+ ...v,
821
+ amount: v.amount * oe(f)
822
+ });
823
+ }
824
+ function me(f) {
825
+ var v;
826
+ if (((v = f.paymentType) == null ? void 0 : v.type) === "COIN") {
827
+ if (f.bundle.coinPrice == null) return "N/A";
828
+ const u = f.bundle.coinPrice * oe(f);
829
+ return `${W(u, 2, !0)} points`;
830
+ }
831
+ return J(
832
+ f,
833
+ f.bundle.priceWithTaxes ?? f.bundle.price
834
+ );
835
+ }
836
+ function tt(f) {
837
+ return J(
838
+ f,
839
+ f.bundle.originalPrice ?? f.bundle.price
840
+ );
841
+ }
842
+ function at(f) {
843
+ const [v, ...u] = f.bundle.taxTotals ?? [];
844
+ if (!v) return null;
845
+ const m = u.reduce(
846
+ (C, w) => C + w.total.amount,
847
+ v.total.amount
848
+ );
849
+ return J(f, {
850
+ ...v.total,
851
+ amount: m
852
+ });
853
+ }
854
+ const nt = { class: "space-y-24 pr-12" }, ot = { class: "fm-typo-en-title-sm-800 mb-16" }, rt = {
855
+ key: 0,
856
+ class: "space-y-16"
857
+ }, st = { class: "fm-typo-en-body-lg-600" }, lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary break-words" }, it = {
858
+ key: 1,
859
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
860
+ }, ct = /* @__PURE__ */ re({
861
+ __name: "StoreTransactionDetailSheet",
862
+ setup(f, { expose: v }) {
863
+ const u = E(!1), m = E(null), { t: C } = se();
864
+ function w(a, t) {
865
+ u.value = a, m.value = t ?? null;
866
+ }
867
+ function N(a) {
868
+ if (!a.location) return "Online Store";
869
+ const t = Array.isArray(a.pf_location) ? a.pf_location[0] : a.pf_location;
870
+ return (t == null ? void 0 : t.name) ?? a.location.toString();
871
+ }
872
+ function V(a) {
873
+ return Array.isArray(a) ? a.flatMap((t) => typeof t != "object" || t === null || !("name" in t) || typeof t.name != "string" ? [] : [t.name]) : [];
874
+ }
875
+ function R(a, t, x, e) {
876
+ if (a.length === t)
877
+ return a.map((c) => x > 1 ? `${c} × ${x}` : c).join(", ");
878
+ const n = t * x;
879
+ return `${n} ${e}${n === 1 ? "" : "s"}`;
880
+ }
881
+ const g = U(() => {
882
+ var e, n, c;
883
+ const a = m.value;
884
+ if (!a) return [];
885
+ const t = a.pf_member, x = Te(a, C);
886
+ return [
887
+ { label: "Transaction ID", value: a._id.toString() },
888
+ {
889
+ label: "Date/Time",
890
+ value: A(j(a._id.toString())).format(
891
+ "D MMM YYYY, hh:mmA"
892
+ )
893
+ },
894
+ {
895
+ label: "Status",
896
+ value: Q.title(a.refund ? "REFUNDED" : a.status)
897
+ },
898
+ {
899
+ label: "Customer",
900
+ value: (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.email) ?? (t == null ? void 0 : t.phoneNumber) ?? "Unknown"
901
+ },
902
+ { label: "Location", value: N(a) },
903
+ {
904
+ label: "Payment Type",
905
+ value: ((e = a.paymentType) == null ? void 0 : e.type) === "COIN" || ((n = a.paymentType) == null ? void 0 : n.type) === "CARD" || !((c = a.paymentType) != null && c.type) ? x : Q.title(x)
906
+ },
907
+ { label: "Reference", value: a.ref || "N/A" },
908
+ ...a.paymentRef ? [{ label: "Payment Reference", value: a.paymentRef }] : [],
909
+ {
910
+ label: "Quantity",
911
+ value: oe(a).toString()
912
+ }
913
+ ];
914
+ }), h = U(() => {
915
+ const a = m.value;
916
+ return a ? [
917
+ { label: "Bundle Name", value: a.bundle.name },
918
+ {
919
+ label: "Bundle Value",
920
+ value: tt(a)
921
+ },
922
+ {
923
+ label: "Base Subtotal",
924
+ value: J(a, a.bundle.price)
925
+ },
926
+ {
927
+ label: "Selling Price",
928
+ value: me(a)
929
+ }
930
+ ] : [];
931
+ }), s = U(() => {
932
+ var n;
933
+ const a = m.value;
934
+ if (!a) return [];
935
+ const { bundle: t } = a, x = oe(a), e = [];
936
+ if (t.credit.normal > 0 && e.push({
937
+ label: "Credit",
938
+ value: `${W(
939
+ t.credit.normal * x,
940
+ 2,
941
+ !0
942
+ )} credits`
943
+ }), (n = t.credit.free) != null && n.amount) {
944
+ const c = `${t.credit.free.day} day${t.credit.free.day === 1 ? "" : "s"}`;
945
+ e.push({
946
+ label: "Free Credit",
947
+ value: `${W(
948
+ t.credit.free.amount * x,
949
+ 2,
950
+ !0
951
+ )} credits (${c})`
952
+ });
953
+ }
954
+ return t.vouchers.length > 0 && e.push({
955
+ label: "Vouchers",
956
+ value: R(
957
+ V(t.pf_vouchers),
958
+ t.vouchers.length,
959
+ x,
960
+ "voucher"
961
+ )
962
+ }), t.titles.length > 0 && e.push({
963
+ label: "Titles",
964
+ value: R(
965
+ V(t.pf_titles),
966
+ t.titles.length,
967
+ x,
968
+ "title"
969
+ )
970
+ }), e;
971
+ }), S = U(() => {
972
+ const a = m.value;
973
+ if (!a) return [];
974
+ const t = (a.bundle.taxTotals ?? []).map((e) => {
975
+ var c;
976
+ const n = (c = a.bundle._inclusiveTaxes) == null ? void 0 : c.some(
977
+ (I) => I.systemCode === e.systemCode && I.inclusive
978
+ );
979
+ return {
980
+ label: `${e.name} (${Ae(e.rate)}%, ${n ? "Inclusive" : "Exclusive"})`,
981
+ value: J(a, e.total)
982
+ };
983
+ }), x = at(a);
984
+ return x ? [...t, { label: "Tax Total", value: x }] : t;
985
+ }), b = U(() => {
986
+ var t;
987
+ const a = (t = m.value) == null ? void 0 : t.giftCard;
988
+ return a ? [
989
+ { label: "Movement", value: Q.title(a.movement) },
990
+ {
991
+ label: "Serial Number",
992
+ value: a.serialNumber ?? (a.movement === "PURCHASE" ? "Pending card issuance" : "Not available")
993
+ }
994
+ ] : [];
995
+ }), p = U(() => [
996
+ { title: "Transaction", items: g.value },
997
+ { title: "Bundle & Pricing", items: h.value },
998
+ { title: "Rewards", items: s.value, emptyText: "No rewards" },
999
+ { title: "Taxes", items: S.value, emptyText: "No taxes" },
1000
+ ...b.value.length ? [{ title: "Gift Card", items: b.value }] : []
1001
+ ]);
1002
+ return v({ showSheet: w }), (a, t) => {
1003
+ const x = K("FmButton"), e = K("FmSideSheet");
1004
+ return k(), ce(e, {
1005
+ modelValue: i(u),
1006
+ "onUpdate:modelValue": t[1] || (t[1] = (n) => fe(u) ? u.value = n : null),
1007
+ "max-width": 560,
1008
+ header: "Store Transaction Details"
1009
+ }, {
1010
+ "side-sheet-footer": ae(() => [
1011
+ D(x, {
1012
+ label: "Close",
1013
+ variant: "tertiary",
1014
+ onClick: t[0] || (t[0] = (n) => w(!1))
1015
+ })
1016
+ ]),
1017
+ default: ae(() => [
1018
+ _("div", nt, [
1019
+ (k(!0), O(X, null, ne(i(p), (n) => (k(), O("section", {
1020
+ key: n.title
1021
+ }, [
1022
+ _("h3", ot, G(n.title), 1),
1023
+ n.items.length ? (k(), O("div", rt, [
1024
+ (k(!0), O(X, null, ne(n.items, (c) => (k(), O("div", {
1025
+ key: c.label,
1026
+ class: "flex flex-col gap-4"
1027
+ }, [
1028
+ _("div", st, G(c.label), 1),
1029
+ _("div", lt, G(c.value), 1),
1030
+ t[2] || (t[2] = _("hr", { class: "mt-3 border-fm-color-neutral-gray-100" }, null, -1))
1031
+ ]))), 128))
1032
+ ])) : (k(), O("div", it, G(n.emptyText), 1))
1033
+ ]))), 128))
1034
+ ])
1035
+ ]),
1036
+ _: 1
1037
+ }, 8, ["modelValue"]);
1038
+ };
1039
+ }
1040
+ }), ut = { class: "flex items-center justify-between" }, mt = { class: "flex gap-8 items-center" }, dt = { class: "flex gap-8 items-center xs:hidden" }, Ht = /* @__PURE__ */ re({
1041
+ __name: "StoreTransactions",
1042
+ props: {
1043
+ user: {
1044
+ type: String
1045
+ }
1046
+ },
1047
+ setup(f) {
1048
+ const v = f, { minor: u } = _e, { t: m } = se();
1049
+ function C(e) {
1050
+ return Te(e, m);
1051
+ }
1052
+ function w(e) {
1053
+ return A(j(e._id.toString())).format(
1054
+ "D MMM YYYY, hh:mmA"
1055
+ );
1056
+ }
1057
+ function N(e) {
1058
+ var n, c;
1059
+ return e.location ? ((c = (n = e.pf_location) == null ? void 0 : n[0]) == null ? void 0 : c.name) ?? e.location.toString() : "Online Store";
1060
+ }
1061
+ const V = [
1062
+ {
1063
+ header: "Transaction ID",
1064
+ meta: {
1065
+ maxWidth: "150px"
1066
+ },
1067
+ cell(e) {
1068
+ return l("div", { class: "flex items-center" }, [
1069
+ l(T.FmIcon, {
1070
+ name: "content_copy",
1071
+ outline: !0,
1072
+ size: "sm",
1073
+ class: "cursor-pointer mr-4 shrink-0",
1074
+ onClick: (n) => {
1075
+ n.preventDefault(), n.stopPropagation(), de(e.row.original._id.toString());
1076
+ }
1077
+ }),
1078
+ l("div", { class: "truncate" }, e.row.original._id.toString())
1079
+ ]);
1080
+ }
1081
+ },
1082
+ {
1083
+ header: "Created at",
1084
+ accessorFn: w,
1085
+ enableSorting: !0
1086
+ },
1087
+ {
1088
+ header: "Bundle",
1089
+ accessorFn: (e) => e.bundle.name
1090
+ },
1091
+ {
1092
+ header: "Selling Price",
1093
+ cell: (e) => me(e.row.original)
1094
+ },
1095
+ {
1096
+ header: "Location",
1097
+ accessorFn: N
1098
+ },
1099
+ {
1100
+ header: "Payment Type",
1101
+ accessorFn: C,
1102
+ cell(e) {
1103
+ var n;
1104
+ return l("div", { class: "flex items-center gap-4" }, [
1105
+ l("div", { class: "flex items-center" }, [
1106
+ ((n = e.row.original.paymentType) == null ? void 0 : n.type) == "ONLINE" && e.row.original.paymentType.extra ? l(
1107
+ T.FmTooltip,
1108
+ {
1109
+ content: e.row.original.paymentType.extra
1110
+ },
1111
+ [
1112
+ l(T.FmIcon, {
1113
+ name: "info",
1114
+ outline: !0,
1115
+ size: "sm"
1116
+ })
1117
+ ]
1118
+ ) : l("div")
1119
+ ]),
1120
+ l("div", { class: "flex-1" }, C(e.row.original))
1121
+ ]);
1122
+ }
1123
+ },
1124
+ {
1125
+ header: "User",
1126
+ cell: (e) => be(e.row.original.pf_member)
1127
+ },
1128
+ {
1129
+ header: "Phone No.",
1130
+ accessorFn: (e) => e.pf_member.phoneNumber
1131
+ },
1132
+ {
1133
+ header: "Status",
1134
+ // accessorFn: (u) => u.status,
1135
+ cell(e) {
1136
+ var I, F, o, r;
1137
+ const n = e.row.original.status, c = {
1138
+ COMPLETED: "text-fm-color-typo-success bg-fm-color-system-success-100",
1139
+ REFUNDED: "text-fm-color-typo-warning bg-fm-color-system-warning-100"
1140
+ };
1141
+ return l("div", { class: "flex items-center gap-4" }, [
1142
+ l(T.FmChip, {
1143
+ label: Q.title(n),
1144
+ variant: "plain",
1145
+ class: c[n] ?? ""
1146
+ }),
1147
+ (F = (I = e.row.original) == null ? void 0 : I.refund) != null && F.reason ? l(
1148
+ T.FmTooltip,
1149
+ {
1150
+ content: (r = (o = e.row.original) == null ? void 0 : o.refund) == null ? void 0 : r.reason
1151
+ },
1152
+ [
1153
+ l(T.FmIcon, {
1154
+ name: "info",
1155
+ color: "primary",
1156
+ outline: !0,
1157
+ size: "sm"
1158
+ })
1159
+ ]
1160
+ ) : null
1161
+ ]);
1162
+ }
1163
+ },
1164
+ {
1165
+ header: "Source",
1166
+ accessorFn: (e) => e.source
1167
+ },
1168
+ {
1169
+ header: "Ref",
1170
+ accessorFn: (e) => e.ref
1171
+ },
1172
+ {
1173
+ id: "action",
1174
+ cell(e) {
1175
+ const n = e.row.original, c = n.status === "COMPLETED" && !n.refund && n.source == "ADMIN";
1176
+ return c ? l(
1177
+ T.FmMenu,
1178
+ {
1179
+ placement: "bottom-end",
1180
+ onClick: (I) => {
1181
+ I.stopPropagation();
1182
+ }
1183
+ },
1184
+ {
1185
+ "menu-button": () => l(T.FmButton, {
1186
+ icon: "settings",
1187
+ variant: "tertiary",
1188
+ if: c
1189
+ }),
1190
+ default: () => [
1191
+ l(T.FmMenuItem, {
1192
+ label: "Refund",
1193
+ sublabel: "Refund this transaction",
1194
+ onClick: async (I) => {
1195
+ I.stopPropagation(), await p(n);
1196
+ }
1197
+ })
1198
+ ]
1199
+ }
1200
+ ) : l("div");
1201
+ }
1202
+ }
1203
+ ], R = E({
1204
+ searchValue: "",
1205
+ dateRange: {
1206
+ startDate: A().subtract(7, "day").toISOString(),
1207
+ endDate: A().toISOString()
1208
+ }
1209
+ }), { tableMeta: g, rowData: h, onSort: s, debouncedFetchData: S, onSearch: b } = Ne(async (e) => {
1210
+ const n = {
1211
+ ...R.value.dateRange,
1212
+ user: v.user
1213
+ };
1214
+ return await H.readStoreTransactions(e, n);
1215
+ });
1216
+ async function p(e) {
1217
+ await Pe.confirm(
1218
+ "Are you sure you want to refund this transaction?",
1219
+ "Refund Store Transaction",
1220
+ "Confirm",
1221
+ "Cancel"
1222
+ ) && await u(
1223
+ async () => {
1224
+ var c;
1225
+ await Oe.refundStoreTransaction({
1226
+ id: e._id,
1227
+ reason: `ADMIN:${(c = Ve().sessionUser) == null ? void 0 : c.name}`
1228
+ }), await S();
1229
+ },
1230
+ {
1231
+ message: "Refunding transaction...",
1232
+ successMessage: "Transaction refunded successfully"
1233
+ }
1234
+ );
1235
+ }
1236
+ ge(
1237
+ R,
1238
+ () => {
1239
+ S();
1240
+ },
1241
+ { deep: !0 }
1242
+ ), De(async () => {
1243
+ await S();
1244
+ });
1245
+ const a = async () => ke({
1246
+ exporter: new et(),
1247
+ readFunction: (e) => H.readStoreTransactions(e, {
1248
+ ...R.value.dateRange,
1249
+ user: v.user
1250
+ }),
1251
+ transformRecord: (e) => {
1252
+ var n, c, I, F;
1253
+ return {
1254
+ "Transaction ID": e._id.toString(),
1255
+ "Created at": w(e),
1256
+ Bundle: e.bundle.name || "",
1257
+ "Selling Price": me(e),
1258
+ Location: N(e),
1259
+ "Payment Type": C(e),
1260
+ "Payment Extra": ((n = e.paymentType) == null ? void 0 : n.extra) || "",
1261
+ User: ((c = e.pf_member) == null ? void 0 : c.name) || "",
1262
+ "Phone No.": ((I = e.pf_member) == null ? void 0 : I.phoneNumber) || "",
1263
+ Status: Q.title(e.status),
1264
+ "Refund Reason": ((F = e.refund) == null ? void 0 : F.reason) || "",
1265
+ Source: e.source,
1266
+ Ref: (e == null ? void 0 : e.ref) || ""
1267
+ };
1268
+ },
1269
+ filename: "store-transactions"
1270
+ }), t = E(null);
1271
+ function x(e) {
1272
+ var n;
1273
+ (n = t.value) == null || n.showSheet(!0, e.original);
1274
+ }
1275
+ return (e, n) => {
1276
+ const c = K("FmSearch"), I = K("FmButton");
1277
+ return k(), O("div", null, [
1278
+ _("div", ut, [
1279
+ _("div", mt, [
1280
+ D(ye, {
1281
+ modelValue: i(R).dateRange,
1282
+ "onUpdate:modelValue": n[0] || (n[0] = (F) => i(R).dateRange = F)
1283
+ }, null, 8, ["modelValue"])
1284
+ ]),
1285
+ _("div", dt, [
1286
+ D(c, {
1287
+ modelValue: i(g).searchValue,
1288
+ "onUpdate:modelValue": [
1289
+ n[1] || (n[1] = (F) => i(g).searchValue = F),
1290
+ i(b)
1291
+ ],
1292
+ placeholder: "Search",
1293
+ collapsible: ""
1294
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1295
+ D(I, {
1296
+ icon: "ios_share",
1297
+ variant: "tertiary",
1298
+ onClick: a
1299
+ })
1300
+ ])
1301
+ ]),
1302
+ D(he, {
1303
+ loading: i(g).isLoading,
1304
+ "row-data": i(h),
1305
+ "row-count": i(g).totalRows,
1306
+ "column-defs": V.filter(
1307
+ (F) => !v.user || F.header !== "User" && F.header !== "Phone No."
1308
+ ),
1309
+ "page-count": i(g).pageCount,
1310
+ "page-index": i(g).pageIndex,
1311
+ "page-size": i(g).pageSize,
1312
+ "shrink-at": !1,
1313
+ onSortChange: i(s),
1314
+ onRowClick: x,
1315
+ onPageChange: n[2] || (n[2] = (F) => i(S)({
1316
+ pageSize: F.pageSize,
1317
+ pageIndex: F.pageIndex
1318
+ }))
1319
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "onSortChange"]),
1320
+ D(ct, {
1321
+ ref_key: "transactionDetailSheet",
1322
+ ref: t
1323
+ }, null, 512)
1324
+ ]);
1325
+ };
1326
+ }
1327
+ });
1328
+ export {
1329
+ qt as _,
1330
+ Ht as a
1331
+ };