@feedmepos/mf-connect 0.1.98-beta.7 → 0.1.98-beta.71

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 (152) hide show
  1. package/dist/{App-BonFFUVJ.js → App-B-Onur9k.js} +812 -666
  2. package/dist/{AuditLogs-CaQisyMC.js → AuditLogs-BnEeKG1C.js} +14 -13
  3. package/dist/{Bin-Mu8gAiHw.js → Bin-BH9_nATR.js} +8 -8
  4. package/dist/Broadcast-Gt2ZLLpZ.js +302 -0
  5. package/dist/CampaignAnalytic-BT6zTgNk.js +1830 -0
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BoLZVrCU.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-nNLLEzii.js} +6 -5
  7. package/dist/Card-dD52oor7.js +1084 -0
  8. package/dist/{Collections-CByXxRW_.js → Collections-7bwYNl3M.js} +14 -13
  9. package/dist/Credit-qZdlqXqR.js +286 -0
  10. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-DeNn_k19.js +53 -0
  11. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-C09W9Qja.js +4213 -0
  12. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BXsAX1Xa.js → EffectSheet.vue_vue_type_style_index_0_lang-Bz1HRBMa.js} +35 -35
  13. package/dist/{Experience-B7J-aqPK.js → Experience-CAaWgWXP.js} +112 -86
  14. package/dist/{FileSaver.min-D_F_MSZt.js → FileSaver.min-BpfY6VnX.js} +1 -1
  15. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-3bH-tZAm.js +138 -0
  16. package/dist/Game-fhrbFb_5.js +356 -0
  17. package/dist/GiftCardSetup-CTwmNKim.js +736 -0
  18. package/dist/{Grab-C45MmlD9.js → Grab-BnPfb92x.js} +33 -32
  19. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-CPPcB3PC.js → ImageInput.vue_vue_type_script_setup_true_lang-BySju1oT.js} +1 -1
  20. package/dist/{Index-vQ6uP49O.js → Index-DRwvmm_j.js} +10 -10
  21. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-Cj3hN3tg.js → LocationPicker.vue_vue_type_script_setup_true_lang-Ya4r9NNE.js} +1 -1
  22. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-DU9eIein.js → LottieAnimation.vue_vue_type_script_setup_true_lang-CDwtqqLQ.js} +1 -1
  23. package/dist/LoyaltyDashboard-8jn6SIWo.js +2865 -0
  24. package/dist/MainLayout-Bf42AcB1.js +143 -0
  25. package/dist/{Marketing-B6xMdQvW.js → Marketing-DruTMjiR.js} +7 -6
  26. package/dist/{MarketingMaterialEdit-0cZN4bek.js → MarketingMaterialEdit-moEHd_gP.js} +15 -14
  27. package/dist/Member-C9VTQqIm.js +654 -0
  28. package/dist/MemberDetailSheet.vue_vue_type_script_setup_true_lang-DEsVSWmv.js +1279 -0
  29. package/dist/MemberImportHistory-DZVwya9v.js +187 -0
  30. package/dist/MemberList-KusIfy1u.js +334 -0
  31. package/dist/{MemberTransactions-Bg-ziZy8.js → MemberTransactions-msyjdzlI.js} +1 -1
  32. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-jbDJkbZh.js → MessageInput.vue_vue_type_script_setup_true_lang-DbV-m3cC.js} +5928 -5644
  33. package/dist/MetricInfoTooltip.vue_vue_type_script_setup_true_lang-1DYGpJnD.js +40 -0
  34. package/dist/Mission-CUUxpBUF.js +360 -0
  35. package/dist/{Overview-nsyJGSCq.js → Overview-C9jyKXHX.js} +21 -20
  36. package/dist/Overview-CYKoF8Hp.js +1316 -0
  37. package/dist/Point-CPpQ07yp.js +288 -0
  38. package/dist/Promotion-CJ95m9Qb.js +423 -0
  39. package/dist/{Queue-Dkipt6fw.js → Queue-CX39ILh_.js} +14 -13
  40. package/dist/{Record-BFqx6vM-.js → Record-6I0qyXB5.js} +9 -9
  41. package/dist/Review-DoWu2XNT.js +45 -0
  42. package/dist/ReviewFacebookCallback-Co-5TnI7.js +238 -0
  43. package/dist/ReviewGoogleCallback-Ca7ZuMcF.js +213 -0
  44. package/dist/{Reward-DjFEE7I_.js → Reward-Cx_N6qBJ.js} +35 -35
  45. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-BzZ6VH80.js → RewardGroup.vue_vue_type_script_setup_true_lang-Cn5Yp37p.js} +14 -13
  46. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-A9jQX4jt.js → RuleGroup.vue_vue_type_script_setup_true_lang-M0c67Dyl.js} +196 -186
  47. package/dist/{Segment-BAjdUfZ6.js → Segment-Bx0EW966.js} +275 -276
  48. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-CAQPFzRH.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-ahvrEUGa.js} +37 -36
  49. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-Gkz8jhES.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-C7zSfZdl.js} +4 -4
  50. package/dist/{Setting-BK7y0XC-.js → Setting-DzEK3dWj.js} +14 -14
  51. package/dist/{SettingAdvertisements-DfQ645xr.js → SettingAdvertisements-BNALbI88.js} +12 -12
  52. package/dist/Settings-Cw85-xzq.js +230 -0
  53. package/dist/Store-BSqW1gwf.js +2612 -0
  54. package/dist/{StoreRewards-usHKOGmB.js → StoreRewards-CJXnS8Qf.js} +15 -15
  55. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-C6tUwHEj.js +1329 -0
  56. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DrcWUZuR.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-iylphGuV.js} +2 -2
  57. package/dist/{Tier-BF3V430O.js → Tier-DfitNxp2.js} +2580 -754
  58. package/dist/{Title-DwPuqKfJ.js → Title-QCbtOvKB.js} +39 -37
  59. package/dist/Transaction-dOCzlidD.js +45 -0
  60. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-DToNRTJS.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Be5X1C-Y.js} +26 -26
  61. package/dist/{Voucher-DnhVIl_o.js → Voucher-BfoCDwjg.js} +156 -133
  62. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-Btb3UZCn.js → VoucherEditor.vue_vue_type_script_setup_true_lang-0EIYoZ0F.js} +118 -124
  63. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-EFUW9DMY.js → ZodTextField.vue_vue_type_script_setup_true_lang-UdStgKbX.js} +2 -2
  64. package/dist/{app-i3r-6ZVm.js → app-BxTElIm-.js} +45168 -37577
  65. package/dist/app.js +1 -1
  66. package/dist/base.export-BmUK8hMh.js +75 -0
  67. package/dist/{business-i0Gxk7gG.js → business-DjAiT8tR.js} +5 -5
  68. package/dist/campaign-DlR3KF9m.js +368 -0
  69. package/dist/campaign-tAmQNoq7.js +100 -0
  70. package/dist/{campaign.enum-CbUTfxek.js → campaign.enum-BjwEQd11.js} +1 -1
  71. package/dist/{campaign.fn-BjHSIDd1.js → campaign.fn-C6kWWIQx.js} +53 -53
  72. package/dist/{collectible.enum-DN7E_kHg.js → collectible.enum-BrtXpT9S.js} +1 -1
  73. package/dist/collection.fn-CDhfM3Eq.js +26 -0
  74. package/dist/currency-10nX5QnT.js +7 -0
  75. package/dist/{duplicateCampaign-DmdJQEIA.js → duplicateCampaign-6oMZOvfM.js} +11 -11
  76. package/dist/{effect-DM4AzeQl.js → effect-T4YzuTc5.js} +1 -1
  77. package/dist/{email-addresses-BlqVJhwZ.js → email-addresses-BjODnJMM.js} +209 -201
  78. package/dist/google-C3S8u0mT.js +4 -0
  79. package/dist/{helper-CkdISSVP.js → helper-BCl5r5yZ.js} +1 -1
  80. package/dist/{index-DgzNGQgE.js → index-B9ZMIUMa.js} +2083 -2559
  81. package/dist/{index-CB7ytKOE.js → index-BBsK7TUw.js} +1588 -1522
  82. package/dist/index-BQk6zTgf.js +32437 -0
  83. package/dist/index-Bd4clHfr.js +901 -0
  84. package/dist/index-BeVWchv7.js +14550 -0
  85. package/dist/index-Bht1Z11w.js +72 -0
  86. package/dist/{index-FD50UHqf.js → index-BiolIgqR.js} +105 -123
  87. package/dist/{index-Cl8t41Sk.js → index-BxU--5J5.js} +5 -5
  88. package/dist/index-Bz6oSli7.js +151 -0
  89. package/dist/index-C5IfNJUl.js +53 -0
  90. package/dist/{index-BWsj6lCJ.js → index-CRvUvCMA.js} +14 -14
  91. package/dist/{index-B6xi1soU.js → index-CnaQt4Pn.js} +1 -1
  92. package/dist/{index-4EtrCy_K.js → index-Ctja--IE.js} +4 -4
  93. package/dist/{index-D6qeYVNz.js → index-D8rGhchh.js} +1 -1
  94. package/dist/{index-BrboOmPq.js → index-DJdTDF9C.js} +347 -216
  95. package/dist/index-DXiJa8Cw.js +137 -0
  96. package/dist/{index-CxdLExX0.js → index-DeQKLilv.js} +24 -9
  97. package/dist/{index-vI-ndGu_.js → index-DhtKt4OL.js} +5 -5
  98. package/dist/{index.esm2017-BX5CyKoc.js → index.esm2017-CEOegJjn.js} +132 -132
  99. package/dist/{loading-DTKDhqew.js → loading-Dx4SCvZY.js} +1 -1
  100. package/dist/{lodash-CCPBsqhe.js → lodash-Dq8OKCKK.js} +1 -1
  101. package/dist/member-import-DX-jn2uk.js +187 -0
  102. package/dist/membership-CltAa-gH.js +274 -0
  103. package/dist/{money-wMK3QkZ5.js → money-DsaAjJTI.js} +1 -1
  104. package/dist/{number-DjKVlWn0.js → number-DmhHKYgY.js} +1 -1
  105. package/dist/objectid-BdNv-dZX.js +145 -0
  106. package/dist/{plugins-D25PaNJk.js → plugins-BFKVM3uC.js} +13 -12
  107. package/dist/remy-Qz_pNsUS.js +13 -0
  108. package/dist/{reward-E63jqJHm.js → reward--SjvIeyy.js} +1 -1
  109. package/dist/{rule-RVvPtAnk.js → rule-CAKdNobZ.js} +335 -275
  110. package/dist/style.css +1 -1
  111. package/dist/{template-zNxOQaqe.js → template-Cfxc5eM8.js} +6 -6
  112. package/dist/timezone-D2b-V5XD.js +20 -0
  113. package/dist/transaction.fn-B5mLY7bz.js +71 -0
  114. package/dist/{trigger-BXV02FhP.js → trigger-DvYcjRBZ.js} +17 -17
  115. package/dist/useMarketingMaterialActions-DtqnjMSt.js +96 -0
  116. package/dist/{usePagination-BPcPhEnp.js → usePagination-DKX24g31.js} +1 -1
  117. package/dist/{user-Bd8S7R5u.js → user-fWb1NxGO.js} +1 -1
  118. package/dist/vue-i18n-wJReAVJw.js +2365 -0
  119. package/dist/{xlsx-_tQC9Ezf.js → xlsx-Mthhu4JR.js} +440 -440
  120. package/dist/{zod-C1j2GLZP.js → zod-CVpVUgBZ.js} +1 -1
  121. package/package.json +10 -6
  122. package/dist/Broadcast-Cy-i-WOT.js +0 -266
  123. package/dist/Card-f2XOtWxp.js +0 -910
  124. package/dist/Credit-CcZF4aQS.js +0 -260
  125. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +0 -58
  126. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-C7KZ8GMx.js +0 -3377
  127. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +0 -129
  128. package/dist/Game-CUW7NeVG.js +0 -330
  129. package/dist/LoyaltyDashboard-GqyUwvXz.js +0 -1082
  130. package/dist/MainLayout-R5NxIBR-.js +0 -41
  131. package/dist/Member-CC5F6Bmz.js +0 -280
  132. package/dist/MemberList-Cq4zxopX.js +0 -1601
  133. package/dist/Mission-DcCZ6tAG.js +0 -334
  134. package/dist/Point-D1vLd5hL.js +0 -262
  135. package/dist/Promotion-Cv7MW5RJ.js +0 -397
  136. package/dist/Review-CKhakUMe.js +0 -1123
  137. package/dist/ReviewFacebookCallback-xgRpXQAg.js +0 -243
  138. package/dist/ReviewGoogleCallback-Cqi_43qi.js +0 -208
  139. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-DDqK4kV1.js +0 -181
  140. package/dist/Store-uTRQ6KbC.js +0 -1996
  141. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Bb2sTsuA.js +0 -1130
  142. package/dist/Transaction-CnTEfMGU.js +0 -39
  143. package/dist/campaign-CbMlARNI.js +0 -219
  144. package/dist/campaign-f7FT91GR.js +0 -277
  145. package/dist/export-DQR-0lmK.js +0 -97
  146. package/dist/index-COrXX9MR.js +0 -52
  147. package/dist/index-CWiaP-aV.js +0 -28900
  148. package/dist/index-jVfDVEtz.js +0 -85
  149. package/dist/membership-rifuatxU.js +0 -255
  150. package/dist/objectid-DjpWkCxH.js +0 -145
  151. package/dist/useMarketingMaterialActions-5TFNqZVo.js +0 -107
  152. package/dist/vue-i18n-CgMK-TaC.js +0 -2365
@@ -0,0 +1,1329 @@
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 { B as ue } from "./index-B9ZMIUMa.js";
4
+ import "./index-BxU--5J5.js";
5
+ import { T as z } from "./transaction.fn-B5mLY7bz.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-DeNn_k19.js";
9
+ import { s as te } from "./index-CuvNtC_M.js";
10
+ import { f as W, F as Ae } from "./number-DmhHKYgY.js";
11
+ import { u as ve } from "./business-DjAiT8tR.js";
12
+ import { _ as he, u as Ne } from "./usePagination-DKX24g31.js";
13
+ import { c as de, p as Pe } from "./plugins-BFKVM3uC.js";
14
+ import { g as be } from "./user-fWb1NxGO.js";
15
+ import { B as xe, e as ke } from "./base.export-BmUK8hMh.js";
16
+ import { u as Se } from "./campaign-tAmQNoq7.js";
17
+ import "./index-D8rGhchh.js";
18
+ import "./index-DJdTDF9C.js";
19
+ import "./index-BBsK7TUw.js";
20
+ import "./index-Bd4clHfr.js";
21
+ import "./index-DhtKt4OL.js";
22
+ import { u as se } from "./vue-i18n-wJReAVJw.js";
23
+ import { o as j } from "./objectId-dwaoBfJX.js";
24
+ import { u as _e } from "./loading-Dx4SCvZY.js";
25
+ import { w as Me } from "./xlsx-Mthhu4JR.js";
26
+ import { useRouter as Ee } from "vue-router";
27
+ import { t as H } from "./index-CRvUvCMA.js";
28
+ import { R as ee } from "./app-BxTElIm-.js";
29
+ import { F as ie } from "./collectible.enum-BrtXpT9S.js";
30
+ import { useCoreStore as Ve } from "@feedmepos/mf-common";
31
+ import { c as Q } from "./string-Gcy5IM_H.js";
32
+ import { f as $e } from "./currency-10nX5QnT.js";
33
+ import { m as Oe } from "./index-DeQKLilv.js";
34
+ const Be = (f) => {
35
+ if (f.startsWith("_") || f.includes("."))
36
+ return f;
37
+ for (const v of ["pf_user_", "pf_collectible_"])
38
+ if (f.startsWith(v))
39
+ return `${v.slice(0, -1)}.${f.slice(v.length).replace(new RegExp("_", "g"), ".")}`;
40
+ return f.replace(new RegExp("_", "g"), ".");
41
+ };
42
+ function ze(f, v = { key: "_id", descending: !0 }) {
43
+ const u = E({
44
+ pageCount: 1,
45
+ searchValue: "",
46
+ pageIndex: 0,
47
+ totalRows: 0,
48
+ isLoading: !1,
49
+ pageSize: 10,
50
+ hasNext: !1
51
+ }), m = E(v), C = E([]), w = E([void 0]);
52
+ function N() {
53
+ w.value = [void 0], u.value.pageIndex = 0, u.value.pageCount = 1, u.value.hasNext = !1;
54
+ }
55
+ const V = async (b = {}) => {
56
+ const p = b.pageSize ?? u.value.pageSize, a = p !== u.value.pageSize;
57
+ a && N();
58
+ 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];
59
+ u.value.isLoading = !0, u.value.pageSize = p, C.value = [];
60
+ try {
61
+ const c = await f({
62
+ limit: p,
63
+ sortBy: m.value.key,
64
+ descending: m.value.descending,
65
+ search: u.value.searchValue,
66
+ ...n ? { cursor: n } : {}
67
+ });
68
+ 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);
69
+ } catch (c) {
70
+ console.error("Error fetching data:", c), u.value.hasNext = !1;
71
+ } finally {
72
+ u.value.isLoading = !1;
73
+ }
74
+ };
75
+ let R, g;
76
+ const h = (b) => (R && clearTimeout(R), g && g(), new Promise((p) => {
77
+ g = p, R = setTimeout(async () => {
78
+ R = void 0, g = void 0, await V(b), p();
79
+ }, 200);
80
+ }));
81
+ return {
82
+ tableMeta: u,
83
+ rowData: C,
84
+ sortBy: m,
85
+ pageCursors: w,
86
+ resetCursorState: N,
87
+ fetchData: V,
88
+ debouncedFetchData: h,
89
+ onSort: async (b) => {
90
+ b.length ? m.value = {
91
+ key: Be(b[0].id),
92
+ descending: b[0].desc
93
+ } : m.value = v, N(), await h({
94
+ pageIndex: 0,
95
+ pageSize: u.value.pageSize
96
+ });
97
+ },
98
+ onSearch: () => (N(), h({
99
+ pageIndex: 0,
100
+ pageSize: u.value.pageSize
101
+ }))
102
+ };
103
+ }
104
+ class Ue extends xe {
105
+ }
106
+ 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({
107
+ __name: "TransactionDetailSheet",
108
+ setup(f, { expose: v }) {
109
+ se();
110
+ const u = E(!1), m = E(), C = Se(), w = ve();
111
+ function N(h, s) {
112
+ u.value = h, m.value = s ?? null;
113
+ }
114
+ const V = U(() => {
115
+ var h, s;
116
+ return W(
117
+ ((s = m.value) == null ? void 0 : s.expiryAmount.reduce(
118
+ (S, b) => S + b.amount,
119
+ ((h = m.value) == null ? void 0 : h.amount) ?? 0
120
+ )) ?? 0,
121
+ 2
122
+ );
123
+ }), R = U(() => {
124
+ var h, s, S, b, p;
125
+ return m.value ? [
126
+ {
127
+ label: "Transaction ID",
128
+ value: (h = m.value) == null ? void 0 : h._id
129
+ },
130
+ {
131
+ label: "Date/Time",
132
+ value: A(j(m.value._id.toString())).format(
133
+ "D MMM YYYY, hh:mmA"
134
+ )
135
+ },
136
+ {
137
+ label: "Amount",
138
+ component: () => l(
139
+ "span",
140
+ {
141
+ class: [
142
+ "pr-2",
143
+ +V.value > 0 ? "text-fm-color-system-success-300" : "text-fm-color-system-error-300"
144
+ ]
145
+ },
146
+ V.value
147
+ )
148
+ },
149
+ {
150
+ label: "Type",
151
+ value: z.formattedType(m.value)
152
+ },
153
+ {
154
+ label: "Source",
155
+ value: te(z.getReason(m.value.source))
156
+ },
157
+ {
158
+ label: "User",
159
+ value: (S = (s = m.value) == null ? void 0 : s.pf_user) == null ? void 0 : S.name
160
+ },
161
+ {
162
+ label: "Phone Number",
163
+ value: (p = (b = m.value) == null ? void 0 : b.pf_user) == null ? void 0 : p.phoneNumber
164
+ }
165
+ ] : [];
166
+ }), g = U(() => {
167
+ var p, a, t, x;
168
+ if (!m.value) return [];
169
+ const h = [], s = (p = m.value) == null ? void 0 : p.metadata, S = m.value;
170
+ if (s != null && s.campaign) {
171
+ const e = C.campaigns.all.find(
172
+ (n) => n._id === (s == null ? void 0 : s.campaign)
173
+ );
174
+ e && h.push({
175
+ label: "Campaign",
176
+ value: e.name
177
+ });
178
+ }
179
+ const b = z.formattedRemark(S);
180
+ return b && h.push({
181
+ label: "Remark",
182
+ value: b
183
+ }), (a = m.value) != null && a.ref.startsWith("bill_") && h.push({
184
+ label: "Bill Number",
185
+ value: (t = m.value) == null ? void 0 : t.ref,
186
+ copy: () => {
187
+ var e;
188
+ return de((e = m.value) == null ? void 0 : e.ref);
189
+ }
190
+ }), s != null && s.location && h.push({
191
+ label: "Location",
192
+ value: (x = w.locations.find(
193
+ (e) => e._id.toString() === (s == null ? void 0 : s.location)
194
+ )) == null ? void 0 : x.name
195
+ }), S.source === ue.enum.STORE && h.push({
196
+ label: "Store Transaction",
197
+ value: S.ref
198
+ }), s != null && s.originTransaction && h.push({
199
+ label: "Parent Transaction",
200
+ value: s.originTransaction
201
+ }), s != null && s.referral_count && h.push({
202
+ label: "Referral Count",
203
+ value: s.referral_count
204
+ }), S.refundedFrom && h.push({
205
+ label: "Refunded From",
206
+ value: S.refundedFrom
207
+ }), h;
208
+ });
209
+ return v({
210
+ showSheet: N
211
+ }), (h, s) => {
212
+ const S = K("FmButton"), b = K("FmSideSheet");
213
+ return k(), ce(b, {
214
+ "max-width": 560,
215
+ modelValue: i(u),
216
+ "onUpdate:modelValue": s[1] || (s[1] = (p) => fe(u) ? u.value = p : null),
217
+ header: "Transaction Details"
218
+ }, {
219
+ "side-sheet-footer": ae(() => [
220
+ _("div", qe, [
221
+ D(S, {
222
+ label: "Close",
223
+ onClick: s[0] || (s[0] = (p) => N(!1)),
224
+ variant: "tertiary"
225
+ })
226
+ ])
227
+ ]),
228
+ default: ae(() => [
229
+ _("div", Ye, [
230
+ _("div", Le, [
231
+ (k(!0), O(X, null, ne(i(R), (p) => (k(), O("div", {
232
+ key: p.label,
233
+ class: "flex flex-col gap-4"
234
+ }, [
235
+ _("div", Ge, G(p.label), 1),
236
+ _("div", {
237
+ class: "text-fm-color-typo-secondary fm-typo-en-body-md-400 hover:underline",
238
+ onClick: p.copy
239
+ }, [
240
+ Re(G(p.accessorFn ? p.accessorFn() : p.value) + " ", 1),
241
+ (k(), ce(Ie(p.component)))
242
+ ], 8, Ke),
243
+ s[2] || (s[2] = _("hr", { class: "mt-3" }, null, -1))
244
+ ]))), 128)),
245
+ (k(!0), O(X, null, ne(i(g), (p) => (k(), O("div", {
246
+ key: p.label,
247
+ class: "flex flex-col gap-4"
248
+ }, [
249
+ _("div", je, G(p.label), 1),
250
+ _("div", {
251
+ class: "text-fm-color-typo-secondary fm-typo-en-body-md-400 hover:underline",
252
+ onClick: p.copy
253
+ }, G(p.accessorFn ? p.accessorFn() : p.value), 9, We),
254
+ s[3] || (s[3] = _("hr", { class: "mt-3" }, null, -1))
255
+ ]))), 128))
256
+ ])
257
+ ])
258
+ ]),
259
+ _: 1
260
+ }, 8, ["modelValue"]);
261
+ };
262
+ }
263
+ }), 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" }, jt = /* @__PURE__ */ re({
264
+ __name: "CollectionTransactions",
265
+ props: {
266
+ user: {
267
+ type: String
268
+ }
269
+ },
270
+ setup(f) {
271
+ const { t: v } = se(), u = ve(), m = Se(), C = Ee(), w = f, N = E(!1), { minor: V } = _e, R = [
272
+ {
273
+ header: "Transaction ID",
274
+ accessorKey: "_id",
275
+ meta: {
276
+ maxWidth: "100px"
277
+ },
278
+ cell(o) {
279
+ return l("div", { class: "flex items-center" }, [
280
+ l(T.FmIcon, {
281
+ name: "content_copy",
282
+ outline: !0,
283
+ size: "sm",
284
+ class: "cursor-pointer mr-4",
285
+ onClick: (r) => {
286
+ r.preventDefault(), r.stopPropagation(), de(o.row.original._id.toString());
287
+ }
288
+ }),
289
+ l(
290
+ "div",
291
+ { class: "pr-2 text-ellipsis overflow-hidden" },
292
+ o.row.original._id.toString()
293
+ )
294
+ ]);
295
+ },
296
+ enableSorting: !1
297
+ },
298
+ {
299
+ header: "Created at",
300
+ accessorKey: "_id",
301
+ accessorFn: (o) => A(j(o._id.toString())),
302
+ cell: (o) => A(j(o.row.original._id.toString())).format(
303
+ "D MMM YYYY, hh:mmA"
304
+ ),
305
+ enableSorting: !0
306
+ },
307
+ {
308
+ header: "Amount",
309
+ // accessorKey: 'totalAmount',
310
+ enableSorting: !1,
311
+ cell(o) {
312
+ var y, d, M, B;
313
+ const r = W(
314
+ o.row.original.expiryAmount.reduce(
315
+ (q, Y) => q + Y.amount,
316
+ o.row.original.amount ?? 0
317
+ ),
318
+ 2
319
+ ), 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(
320
+ "D MMM YYYY"
321
+ ) : "";
322
+ return l("div", { class: "flex items-center" }, [
323
+ l(
324
+ "div",
325
+ {
326
+ class: [
327
+ "pr-2",
328
+ +r > 0 ? "text-fm-color-system-success-300" : "text-fm-color-system-error-300"
329
+ ]
330
+ },
331
+ r
332
+ ),
333
+ l("div", { class: "flex items-center" }, [
334
+ o.row.original.expiryAmount.length > 0 ? l(
335
+ T.FmTooltip,
336
+ {
337
+ content: `Expired on ${P}`
338
+ },
339
+ [
340
+ l(T.FmIcon, {
341
+ name: "info",
342
+ outline: !0,
343
+ size: "sm"
344
+ })
345
+ ]
346
+ ) : l("div")
347
+ ])
348
+ ]);
349
+ }
350
+ },
351
+ {
352
+ header: "Type",
353
+ accessorKey: "pf_collectible.type",
354
+ accessorFn: (o) => z.formattedType(o),
355
+ meta: {
356
+ maxWidth: "200px"
357
+ },
358
+ cell(o) {
359
+ const r = z.formattedType(o.row.original);
360
+ return l("div", { class: "flex items-center" }, [
361
+ l("div", { class: "truncate text-ellipsis" }, r),
362
+ r.length > 20 ? l(
363
+ T.FmTooltip,
364
+ {
365
+ content: r
366
+ },
367
+ [
368
+ l(T.FmIcon, {
369
+ name: "info",
370
+ color: "primary",
371
+ outline: !0,
372
+ size: "sm"
373
+ })
374
+ ]
375
+ ) : null
376
+ ]);
377
+ }
378
+ },
379
+ {
380
+ header: "Source",
381
+ accessorKey: "source",
382
+ cell(o) {
383
+ var r;
384
+ return l("div", { class: "flex items-center gap-4" }, [
385
+ l(
386
+ "div",
387
+ { class: "truncate text-ellipsis" },
388
+ te(z.getReason(o.row.original.source))
389
+ ),
390
+ ...(r = o.row.original.metadata) != null && r.campaign ? [
391
+ l(
392
+ T.FmTooltip,
393
+ {
394
+ get content() {
395
+ var P;
396
+ return (P = m.campaigns.all.find(
397
+ (y) => {
398
+ var d;
399
+ return y._id === ((d = o.row.original.metadata) == null ? void 0 : d.campaign);
400
+ }
401
+ )) == null ? void 0 : P.name;
402
+ }
403
+ },
404
+ [
405
+ l(T.FmIcon, {
406
+ name: "info",
407
+ color: "primary",
408
+ size: "sm",
409
+ onClick: async (P) => {
410
+ P.preventDefault(), P.stopPropagation();
411
+ const y = m.campaigns.all.find(
412
+ (d) => {
413
+ var M;
414
+ return d._id === ((M = o.row.original.metadata) == null ? void 0 : M.campaign);
415
+ }
416
+ );
417
+ if (y)
418
+ switch (y.type) {
419
+ case "VOUCHER":
420
+ case "PROMOTION":
421
+ case "BROADCAST":
422
+ await C.push({
423
+ name: ee[`$connect-CAMPAIGN_${y.type}`]
424
+ });
425
+ break;
426
+ case "GAME":
427
+ case "CREDIT":
428
+ case "MISSION":
429
+ await C.push({
430
+ name: ee[`$connect-PROGRAM_${y.type}`]
431
+ });
432
+ break;
433
+ case "POINT":
434
+ await C.push({
435
+ name: ee["$connect-PROGRAM_EXPERIENCE"]
436
+ });
437
+ break;
438
+ case "COIN":
439
+ await C.push({
440
+ name: ee["$connect-PROGRAM_POINT"]
441
+ });
442
+ break;
443
+ }
444
+ }
445
+ })
446
+ ]
447
+ )
448
+ ] : []
449
+ ]);
450
+ }
451
+ },
452
+ {
453
+ header: "User",
454
+ accessorKey: "pf_user.name",
455
+ cell(o) {
456
+ return be(o.row.original.pf_user);
457
+ }
458
+ },
459
+ {
460
+ header: "Phone No.",
461
+ accessorKey: "pf_user.phoneNumber",
462
+ accessorFn: (o) => {
463
+ var r;
464
+ return ((r = o == null ? void 0 : o.pf_user) == null ? void 0 : r.phoneNumber) || "";
465
+ }
466
+ },
467
+ {
468
+ header: "Status",
469
+ id: "status",
470
+ enableSorting: !1,
471
+ cell(o) {
472
+ const r = !!o.row.original.refunded;
473
+ return l(T.FmChip, {
474
+ label: v(r ? "connect.transaction.refunded" : "connect.transaction.completed"),
475
+ variant: "plain",
476
+ class: r ? "text-fm-color-typo-warning bg-fm-color-system-warning-100" : "text-fm-color-typo-success bg-fm-color-system-success-100"
477
+ });
478
+ }
479
+ },
480
+ {
481
+ accessorFn: (o) => o.ref,
482
+ header: "References",
483
+ accessorKey: "ref",
484
+ cell(o) {
485
+ const r = z.formattedRemark(o.row.original);
486
+ return l("div", { class: "flex items-center justify-between gap-4" }, [
487
+ l("div", { class: "flex items-center" }, [
488
+ r ? l(
489
+ T.FmTooltip,
490
+ {
491
+ content: r
492
+ },
493
+ [
494
+ l(T.FmIcon, {
495
+ name: "info",
496
+ class: "pl-2",
497
+ outline: !0,
498
+ size: "sm"
499
+ })
500
+ ]
501
+ ) : l("div")
502
+ ]),
503
+ l("div", { class: "flex-1" }, o.row.original.ref)
504
+ ]);
505
+ }
506
+ },
507
+ {
508
+ header: "Actions",
509
+ cell(o) {
510
+ const r = o.row.original;
511
+ return l(
512
+ T.FmTooltip,
513
+ {
514
+ get content() {
515
+ return "Revert Transaction";
516
+ }
517
+ },
518
+ [
519
+ l(T.FmButton, {
520
+ variant: "tertiary",
521
+ icon: "amend",
522
+ iconColor: "neutral-gray-400",
523
+ disabled: !r.isRevertable,
524
+ onClick: (P) => {
525
+ P.stopPropagation(), n(r);
526
+ }
527
+ })
528
+ ]
529
+ );
530
+ }
531
+ }
532
+ ], g = E({
533
+ search: "",
534
+ "pf_collectible.type": [],
535
+ "metadata.location": [],
536
+ dateRange: {
537
+ startDate: A().subtract(7, "day").toISOString(),
538
+ endDate: A().endOf("day").toISOString()
539
+ },
540
+ source: []
541
+ }), h = () => ({
542
+ ...g.value,
543
+ user: w.user,
544
+ dateRange: {
545
+ start: new Date(g.value.dateRange.startDate).toISOString(),
546
+ end: new Date(g.value.dateRange.endDate).toISOString()
547
+ }
548
+ }), { tableMeta: s, rowData: S, onSort: b, debouncedFetchData: p, resetCursorState: a } = ze(async (o) => {
549
+ const r = await H.readAllCursor(
550
+ o,
551
+ h()
552
+ ), P = await Promise.all(
553
+ r.resources.map(async (y) => {
554
+ let d;
555
+ if (y.source !== ue.enum.BILL)
556
+ d = !1;
557
+ else {
558
+ const B = y.refunded || !!y.refundedFrom;
559
+ if (y.expiryAmount.reduce(
560
+ (Y, L) => Y + L.amount,
561
+ y.amount ?? 0
562
+ ) > 0) {
563
+ let Y = [];
564
+ [
565
+ ie.enum.STAMP,
566
+ ie.enum.POINT
567
+ ].includes(y.pf_collectible.type) ? d = !1 : d = !B;
568
+ } else
569
+ switch (y.pf_collectible.type) {
570
+ case ie.enum.VOUCHER:
571
+ d = y.expiryAmount.some(
572
+ (L) => !L.expiredAt || A(L.expiredAt).isAfter(A())
573
+ ) && !B;
574
+ break;
575
+ default:
576
+ d = !B;
577
+ break;
578
+ }
579
+ }
580
+ const M = t.value.find((B) => B._id === y.ref);
581
+ return {
582
+ ...y,
583
+ ref: (M == null ? void 0 : M.seqNumber) || y.ref,
584
+ isRevertable: d
585
+ };
586
+ })
587
+ );
588
+ return {
589
+ resources: r.resources.map((y) => {
590
+ const d = t.value.find((M) => M._id === y.ref);
591
+ return { ...y, ref: (d == null ? void 0 : d.seqNumber) || y.ref };
592
+ }),
593
+ meta: r.meta
594
+ };
595
+ }), t = E([]), x = ue.options.map((o) => ({ label: te(z.getReason(o)), value: o })), e = U(
596
+ () => u.locations.map((o) => ({ label: o.name, value: o._id }))
597
+ );
598
+ ge(
599
+ g,
600
+ () => {
601
+ a(), p({ pageIndex: 0 });
602
+ },
603
+ { deep: !0 }
604
+ );
605
+ async function n(o) {
606
+ V(
607
+ async () => {
608
+ await H.revertTransaction({
609
+ id: o._id.toString()
610
+ }), await p();
611
+ },
612
+ {
613
+ message: "Reverting transaction...",
614
+ successMessage: "Transaction reverted successfully"
615
+ }
616
+ );
617
+ }
618
+ async function c() {
619
+ try {
620
+ N.value = !0;
621
+ const o = new Ue(), r = h(), P = 1e3;
622
+ await V(
623
+ async () => {
624
+ var M, B, q, Y, L, pe;
625
+ let y, d = !0;
626
+ for (; d; ) {
627
+ const Z = await H.readAllCursor(
628
+ {
629
+ limit: P,
630
+ sortBy: "_id",
631
+ descending: !1,
632
+ ...y ? { cursor: y } : {}
633
+ },
634
+ r
635
+ );
636
+ if (!Z.resources.length)
637
+ break;
638
+ for (const $ of Z.resources)
639
+ o.addRecord({
640
+ TransactionID: $._id,
641
+ CreatedAt: A(j($._id.toString())).format(
642
+ "D MMM YYYY, hh:mmA"
643
+ ),
644
+ Amount: W(
645
+ $.expiryAmount.reduce(
646
+ (we, Ce) => we + Ce.amount,
647
+ $.amount ?? 0
648
+ ),
649
+ 2
650
+ ),
651
+ 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") : "",
652
+ Type: z.formattedType($),
653
+ Source: te(z.getReason($.source)),
654
+ User: ((L = $.pf_user) == null ? void 0 : L.name) || "",
655
+ "Phone No.": ((pe = $.pf_user) == null ? void 0 : pe.phoneNumber) || "",
656
+ References: $.ref,
657
+ Remark: z.formattedRemark($)
658
+ });
659
+ y = Z.meta.nextCursor ?? void 0, d = Z.meta.hasNext && !!y;
660
+ }
661
+ await Me(
662
+ o.buildExcel(),
663
+ `transactions-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
664
+ {
665
+ bookType: "xlsx",
666
+ bookSST: !1,
667
+ type: "array"
668
+ }
669
+ );
670
+ },
671
+ {
672
+ message: "Exporting transactions...",
673
+ successMessage: "transactions exported successfully"
674
+ }
675
+ );
676
+ } catch (o) {
677
+ console.error(o);
678
+ } finally {
679
+ N.value = !1;
680
+ }
681
+ }
682
+ const I = E(null);
683
+ function F(o) {
684
+ var r;
685
+ console.log(o), (r = I.value) == null || r.showSheet(!0, o.original);
686
+ }
687
+ return Fe(async () => {
688
+ await u.readLocations(), await m.read(), await p();
689
+ }), (o, r) => {
690
+ const P = K("FmSearch"), y = K("FmButton");
691
+ return k(), O(X, null, [
692
+ _("div", null, [
693
+ _("div", Qe, [
694
+ D(P, {
695
+ class: "hidden xs:!flex border-b border-fm-color-neutral-gray-100",
696
+ modelValue: i(g).search,
697
+ "onUpdate:modelValue": r[0] || (r[0] = (d) => i(g).search = d),
698
+ placeholder: "Search",
699
+ collapsible: ""
700
+ }, null, 8, ["modelValue"]),
701
+ D(y, {
702
+ icon: "ios_share",
703
+ variant: "tertiary",
704
+ onClick: c
705
+ })
706
+ ]),
707
+ _("div", Xe, [
708
+ _("div", Je, [
709
+ D(le, {
710
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
711
+ "right-icon": "keyboard_arrow_down",
712
+ modelValue: i(g)["metadata.location"],
713
+ "onUpdate:modelValue": r[1] || (r[1] = (d) => i(g)["metadata.location"] = d),
714
+ icon: "storefront",
715
+ "show-item-label": !0,
716
+ items: i(e)
717
+ }, null, 8, ["modelValue", "items"]),
718
+ D(le, {
719
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
720
+ "right-icon": "keyboard_arrow_down",
721
+ modelValue: i(g)["pf_collectible.type"],
722
+ "onUpdate:modelValue": r[2] || (r[2] = (d) => i(g)["pf_collectible.type"] = d),
723
+ label: "Type: ",
724
+ "show-item-label": !0,
725
+ items: [
726
+ { label: "Point", value: "COIN" },
727
+ { label: "Credit", value: "CREDIT" },
728
+ { label: "Voucher", value: "VOUCHER" },
729
+ { label: "Experience", value: "POINT" },
730
+ { label: "Tier", value: "TIER" },
731
+ { label: "Title", value: "TITLE" },
732
+ { label: "Game", value: "GAME" },
733
+ { label: "Stamp", value: "STAMP" }
734
+ ]
735
+ }, null, 8, ["modelValue"]),
736
+ D(le, {
737
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
738
+ "right-icon": "keyboard_arrow_down",
739
+ modelValue: i(g).source,
740
+ "onUpdate:modelValue": r[3] || (r[3] = (d) => i(g).source = d),
741
+ label: "Source: ",
742
+ "show-item-label": !0,
743
+ items: i(x)
744
+ }, null, 8, ["modelValue", "items"]),
745
+ D(ye, {
746
+ "model-value": {
747
+ startDate: i(g).dateRange.startDate,
748
+ endDate: i(g).dateRange.endDate
749
+ },
750
+ "onUpdate:modelValue": r[4] || (r[4] = (d) => i(g).dateRange = {
751
+ startDate: i(A)(d.startDate).startOf("d").toISOString(),
752
+ endDate: i(A)(d.endDate).endOf("d").toISOString()
753
+ })
754
+ }, null, 8, ["model-value"])
755
+ ]),
756
+ D(P, {
757
+ class: "xs:hidden",
758
+ modelValue: i(g).search,
759
+ "onUpdate:modelValue": r[5] || (r[5] = (d) => i(g).search = d),
760
+ placeholder: "Search",
761
+ collapsible: ""
762
+ }, null, 8, ["modelValue"]),
763
+ _("div", Ze, [
764
+ D(y, {
765
+ icon: "ios_share",
766
+ variant: "tertiary",
767
+ onClick: c
768
+ })
769
+ ])
770
+ ]),
771
+ D(he, {
772
+ loading: i(s).isLoading,
773
+ "row-data": i(S),
774
+ "row-count": i(s).totalRows,
775
+ "column-defs": R.filter(
776
+ (d) => !w.user || d.header !== "User" && d.header !== "Phone No."
777
+ ),
778
+ "page-count": i(s).pageCount,
779
+ "page-index": i(s).pageIndex,
780
+ "page-size": i(s).pageSize,
781
+ "shrink-at": !1,
782
+ "pagination-mode": "cursor",
783
+ "has-next": i(s).hasNext,
784
+ onSortChange: i(b),
785
+ onPageChange: r[6] || (r[6] = (d) => i(p)({
786
+ pageSize: d.pageSize,
787
+ pageIndex: d.pageIndex
788
+ })),
789
+ onRowClick: F
790
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "has-next", "onSortChange"])
791
+ ]),
792
+ D(He, {
793
+ ref_key: "transactionDetailSheet",
794
+ ref: I
795
+ }, null, 512)
796
+ ], 64);
797
+ };
798
+ }
799
+ });
800
+ class et extends xe {
801
+ }
802
+ function oe(f) {
803
+ return f.quantity ?? 1;
804
+ }
805
+ function Te(f, v) {
806
+ var u, m;
807
+ switch ((u = f.paymentType) == null ? void 0 : u.type) {
808
+ case "COIN":
809
+ return v("connect.store.paymentType.point");
810
+ case "CARD":
811
+ return v("connect.store.paymentType.cardActivation");
812
+ default:
813
+ return ((m = f.paymentType) == null ? void 0 : m.type) ?? v("connect.store.paymentType.notAvailable");
814
+ }
815
+ }
816
+ function J(f, v) {
817
+ return $e({
818
+ ...v,
819
+ amount: v.amount * oe(f)
820
+ });
821
+ }
822
+ function me(f) {
823
+ var v;
824
+ if (((v = f.paymentType) == null ? void 0 : v.type) === "COIN") {
825
+ if (f.bundle.coinPrice == null) return "N/A";
826
+ const u = f.bundle.coinPrice * oe(f);
827
+ return `${W(u, 2, !0)} points`;
828
+ }
829
+ return J(
830
+ f,
831
+ f.bundle.priceWithTaxes ?? f.bundle.price
832
+ );
833
+ }
834
+ function tt(f) {
835
+ return J(
836
+ f,
837
+ f.bundle.originalPrice ?? f.bundle.price
838
+ );
839
+ }
840
+ function at(f) {
841
+ const [v, ...u] = f.bundle.taxTotals ?? [];
842
+ if (!v) return null;
843
+ const m = u.reduce(
844
+ (C, w) => C + w.total.amount,
845
+ v.total.amount
846
+ );
847
+ return J(f, {
848
+ ...v.total,
849
+ amount: m
850
+ });
851
+ }
852
+ const nt = { class: "space-y-24 pr-12" }, ot = { class: "fm-typo-en-title-sm-800 mb-16" }, rt = {
853
+ key: 0,
854
+ class: "space-y-16"
855
+ }, st = { class: "fm-typo-en-body-lg-600" }, lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary break-words" }, it = {
856
+ key: 1,
857
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
858
+ }, ct = /* @__PURE__ */ re({
859
+ __name: "StoreTransactionDetailSheet",
860
+ setup(f, { expose: v }) {
861
+ const u = E(!1), m = E(null), { t: C } = se();
862
+ function w(a, t) {
863
+ u.value = a, m.value = t ?? null;
864
+ }
865
+ function N(a) {
866
+ if (!a.location) return "Online Store";
867
+ const t = Array.isArray(a.pf_location) ? a.pf_location[0] : a.pf_location;
868
+ return (t == null ? void 0 : t.name) ?? a.location.toString();
869
+ }
870
+ function V(a) {
871
+ return Array.isArray(a) ? a.flatMap((t) => typeof t != "object" || t === null || !("name" in t) || typeof t.name != "string" ? [] : [t.name]) : [];
872
+ }
873
+ function R(a, t, x, e) {
874
+ if (a.length === t)
875
+ return a.map((c) => x > 1 ? `${c} × ${x}` : c).join(", ");
876
+ const n = t * x;
877
+ return `${n} ${e}${n === 1 ? "" : "s"}`;
878
+ }
879
+ const g = U(() => {
880
+ var e, n, c;
881
+ const a = m.value;
882
+ if (!a) return [];
883
+ const t = a.pf_member, x = Te(a, C);
884
+ return [
885
+ { label: "Transaction ID", value: a._id.toString() },
886
+ {
887
+ label: "Date/Time",
888
+ value: A(j(a._id.toString())).format(
889
+ "D MMM YYYY, hh:mmA"
890
+ )
891
+ },
892
+ {
893
+ label: "Status",
894
+ value: Q.title(a.refund ? "REFUNDED" : a.status)
895
+ },
896
+ {
897
+ label: "Customer",
898
+ value: (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.email) ?? (t == null ? void 0 : t.phoneNumber) ?? "Unknown"
899
+ },
900
+ { label: "Location", value: N(a) },
901
+ {
902
+ label: "Payment Type",
903
+ 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)
904
+ },
905
+ { label: "Reference", value: a.ref || "N/A" },
906
+ ...a.paymentRef ? [{ label: "Payment Reference", value: a.paymentRef }] : [],
907
+ {
908
+ label: "Quantity",
909
+ value: oe(a).toString()
910
+ }
911
+ ];
912
+ }), h = U(() => {
913
+ const a = m.value;
914
+ return a ? [
915
+ { label: "Bundle Name", value: a.bundle.name },
916
+ {
917
+ label: "Bundle Value",
918
+ value: tt(a)
919
+ },
920
+ {
921
+ label: "Base Subtotal",
922
+ value: J(a, a.bundle.price)
923
+ },
924
+ {
925
+ label: "Selling Price",
926
+ value: me(a)
927
+ }
928
+ ] : [];
929
+ }), s = U(() => {
930
+ var n;
931
+ const a = m.value;
932
+ if (!a) return [];
933
+ const { bundle: t } = a, x = oe(a), e = [];
934
+ if (t.credit.normal > 0 && e.push({
935
+ label: "Credit",
936
+ value: `${W(
937
+ t.credit.normal * x,
938
+ 2,
939
+ !0
940
+ )} credits`
941
+ }), (n = t.credit.free) != null && n.amount) {
942
+ const c = `${t.credit.free.day} day${t.credit.free.day === 1 ? "" : "s"}`;
943
+ e.push({
944
+ label: "Free Credit",
945
+ value: `${W(
946
+ t.credit.free.amount * x,
947
+ 2,
948
+ !0
949
+ )} credits (${c})`
950
+ });
951
+ }
952
+ return t.vouchers.length > 0 && e.push({
953
+ label: "Vouchers",
954
+ value: R(
955
+ V(t.pf_vouchers),
956
+ t.vouchers.length,
957
+ x,
958
+ "voucher"
959
+ )
960
+ }), t.titles.length > 0 && e.push({
961
+ label: "Titles",
962
+ value: R(
963
+ V(t.pf_titles),
964
+ t.titles.length,
965
+ x,
966
+ "title"
967
+ )
968
+ }), e;
969
+ }), S = U(() => {
970
+ const a = m.value;
971
+ if (!a) return [];
972
+ const t = (a.bundle.taxTotals ?? []).map((e) => {
973
+ var c;
974
+ const n = (c = a.bundle._inclusiveTaxes) == null ? void 0 : c.some(
975
+ (I) => I.systemCode === e.systemCode && I.inclusive
976
+ );
977
+ return {
978
+ label: `${e.name} (${Ae(e.rate)}%, ${n ? "Inclusive" : "Exclusive"})`,
979
+ value: J(a, e.total)
980
+ };
981
+ }), x = at(a);
982
+ return x ? [...t, { label: "Tax Total", value: x }] : t;
983
+ }), b = U(() => {
984
+ var t;
985
+ const a = (t = m.value) == null ? void 0 : t.giftCard;
986
+ return a ? [
987
+ { label: "Movement", value: Q.title(a.movement) },
988
+ {
989
+ label: "Serial Number",
990
+ value: a.serialNumber ?? (a.movement === "PURCHASE" ? "Pending card issuance" : "Not available")
991
+ }
992
+ ] : [];
993
+ }), p = U(() => [
994
+ { title: "Transaction", items: g.value },
995
+ { title: "Bundle & Pricing", items: h.value },
996
+ { title: "Rewards", items: s.value, emptyText: "No rewards" },
997
+ { title: "Taxes", items: S.value, emptyText: "No taxes" },
998
+ ...b.value.length ? [{ title: "Gift Card", items: b.value }] : []
999
+ ]);
1000
+ return v({ showSheet: w }), (a, t) => {
1001
+ const x = K("FmButton"), e = K("FmSideSheet");
1002
+ return k(), ce(e, {
1003
+ modelValue: i(u),
1004
+ "onUpdate:modelValue": t[1] || (t[1] = (n) => fe(u) ? u.value = n : null),
1005
+ "max-width": 560,
1006
+ header: "Store Transaction Details"
1007
+ }, {
1008
+ "side-sheet-footer": ae(() => [
1009
+ D(x, {
1010
+ label: "Close",
1011
+ variant: "tertiary",
1012
+ onClick: t[0] || (t[0] = (n) => w(!1))
1013
+ })
1014
+ ]),
1015
+ default: ae(() => [
1016
+ _("div", nt, [
1017
+ (k(!0), O(X, null, ne(i(p), (n) => (k(), O("section", {
1018
+ key: n.title
1019
+ }, [
1020
+ _("h3", ot, G(n.title), 1),
1021
+ n.items.length ? (k(), O("div", rt, [
1022
+ (k(!0), O(X, null, ne(n.items, (c) => (k(), O("div", {
1023
+ key: c.label,
1024
+ class: "flex flex-col gap-4"
1025
+ }, [
1026
+ _("div", st, G(c.label), 1),
1027
+ _("div", lt, G(c.value), 1),
1028
+ t[2] || (t[2] = _("hr", { class: "mt-3 border-fm-color-neutral-gray-100" }, null, -1))
1029
+ ]))), 128))
1030
+ ])) : (k(), O("div", it, G(n.emptyText), 1))
1031
+ ]))), 128))
1032
+ ])
1033
+ ]),
1034
+ _: 1
1035
+ }, 8, ["modelValue"]);
1036
+ };
1037
+ }
1038
+ }), ut = { class: "flex items-center justify-between" }, mt = { class: "flex gap-8 items-center" }, dt = { class: "flex gap-8 items-center xs:hidden" }, Wt = /* @__PURE__ */ re({
1039
+ __name: "StoreTransactions",
1040
+ props: {
1041
+ user: {
1042
+ type: String
1043
+ }
1044
+ },
1045
+ setup(f) {
1046
+ const v = f, { minor: u } = _e, { t: m } = se();
1047
+ function C(e) {
1048
+ return Te(e, m);
1049
+ }
1050
+ function w(e) {
1051
+ return A(j(e._id.toString())).format(
1052
+ "D MMM YYYY, hh:mmA"
1053
+ );
1054
+ }
1055
+ function N(e) {
1056
+ var n, c;
1057
+ return e.location ? ((c = (n = e.pf_location) == null ? void 0 : n[0]) == null ? void 0 : c.name) ?? e.location.toString() : "Online Store";
1058
+ }
1059
+ const V = [
1060
+ {
1061
+ header: "Transaction ID",
1062
+ meta: {
1063
+ maxWidth: "150px"
1064
+ },
1065
+ cell(e) {
1066
+ return l("div", { class: "flex items-center" }, [
1067
+ l(T.FmIcon, {
1068
+ name: "content_copy",
1069
+ outline: !0,
1070
+ size: "sm",
1071
+ class: "cursor-pointer mr-4 shrink-0",
1072
+ onClick: (n) => {
1073
+ n.preventDefault(), n.stopPropagation(), de(e.row.original._id.toString());
1074
+ }
1075
+ }),
1076
+ l("div", { class: "truncate" }, e.row.original._id.toString())
1077
+ ]);
1078
+ }
1079
+ },
1080
+ {
1081
+ header: "Created at",
1082
+ accessorFn: w,
1083
+ enableSorting: !0
1084
+ },
1085
+ {
1086
+ header: "Bundle",
1087
+ accessorFn: (e) => e.bundle.name
1088
+ },
1089
+ {
1090
+ header: "Selling Price",
1091
+ cell: (e) => me(e.row.original)
1092
+ },
1093
+ {
1094
+ header: "Location",
1095
+ accessorFn: N
1096
+ },
1097
+ {
1098
+ header: "Payment Type",
1099
+ accessorFn: C,
1100
+ cell(e) {
1101
+ var n;
1102
+ return l("div", { class: "flex items-center gap-4" }, [
1103
+ l("div", { class: "flex items-center" }, [
1104
+ ((n = e.row.original.paymentType) == null ? void 0 : n.type) == "ONLINE" && e.row.original.paymentType.extra ? l(
1105
+ T.FmTooltip,
1106
+ {
1107
+ content: e.row.original.paymentType.extra
1108
+ },
1109
+ [
1110
+ l(T.FmIcon, {
1111
+ name: "info",
1112
+ outline: !0,
1113
+ size: "sm"
1114
+ })
1115
+ ]
1116
+ ) : l("div")
1117
+ ]),
1118
+ l("div", { class: "flex-1" }, C(e.row.original))
1119
+ ]);
1120
+ }
1121
+ },
1122
+ {
1123
+ header: "User",
1124
+ cell: (e) => be(e.row.original.pf_member)
1125
+ },
1126
+ {
1127
+ header: "Phone No.",
1128
+ accessorFn: (e) => e.pf_member.phoneNumber
1129
+ },
1130
+ {
1131
+ header: "Status",
1132
+ // accessorFn: (u) => u.status,
1133
+ cell(e) {
1134
+ var I, F, o, r;
1135
+ const n = e.row.original.status, c = {
1136
+ COMPLETED: "text-fm-color-typo-success bg-fm-color-system-success-100",
1137
+ REFUNDED: "text-fm-color-typo-warning bg-fm-color-system-warning-100"
1138
+ };
1139
+ return l("div", { class: "flex items-center gap-4" }, [
1140
+ l(T.FmChip, {
1141
+ label: Q.title(n),
1142
+ variant: "plain",
1143
+ class: c[n] ?? ""
1144
+ }),
1145
+ (F = (I = e.row.original) == null ? void 0 : I.refund) != null && F.reason ? l(
1146
+ T.FmTooltip,
1147
+ {
1148
+ content: (r = (o = e.row.original) == null ? void 0 : o.refund) == null ? void 0 : r.reason
1149
+ },
1150
+ [
1151
+ l(T.FmIcon, {
1152
+ name: "info",
1153
+ color: "primary",
1154
+ outline: !0,
1155
+ size: "sm"
1156
+ })
1157
+ ]
1158
+ ) : null
1159
+ ]);
1160
+ }
1161
+ },
1162
+ {
1163
+ header: "Source",
1164
+ accessorFn: (e) => e.source
1165
+ },
1166
+ {
1167
+ header: "Ref",
1168
+ accessorFn: (e) => e.ref
1169
+ },
1170
+ {
1171
+ id: "action",
1172
+ cell(e) {
1173
+ const n = e.row.original, c = n.status === "COMPLETED" && !n.refund && n.source == "ADMIN";
1174
+ return c ? l(
1175
+ T.FmMenu,
1176
+ {
1177
+ placement: "bottom-end",
1178
+ onClick: (I) => {
1179
+ I.stopPropagation();
1180
+ }
1181
+ },
1182
+ {
1183
+ "menu-button": () => l(T.FmButton, {
1184
+ icon: "settings",
1185
+ variant: "tertiary",
1186
+ if: c
1187
+ }),
1188
+ default: () => [
1189
+ l(T.FmMenuItem, {
1190
+ label: "Refund",
1191
+ sublabel: "Refund this transaction",
1192
+ onClick: async (I) => {
1193
+ I.stopPropagation(), await p(n);
1194
+ }
1195
+ })
1196
+ ]
1197
+ }
1198
+ ) : l("div");
1199
+ }
1200
+ }
1201
+ ], R = E({
1202
+ searchValue: "",
1203
+ dateRange: {
1204
+ startDate: A().subtract(7, "day").toISOString(),
1205
+ endDate: A().toISOString()
1206
+ }
1207
+ }), { tableMeta: g, rowData: h, onSort: s, debouncedFetchData: S, onSearch: b } = Ne(async (e) => {
1208
+ const n = {
1209
+ ...R.value.dateRange,
1210
+ user: v.user
1211
+ };
1212
+ return await H.readStoreTransactions(e, n);
1213
+ });
1214
+ async function p(e) {
1215
+ await Pe.confirm(
1216
+ "Are you sure you want to refund this transaction?",
1217
+ "Refund Store Transaction",
1218
+ "Confirm",
1219
+ "Cancel"
1220
+ ) && await u(
1221
+ async () => {
1222
+ var c;
1223
+ await Oe.refundStoreTransaction({
1224
+ id: e._id,
1225
+ reason: `ADMIN:${(c = Ve().sessionUser) == null ? void 0 : c.name}`
1226
+ }), await S();
1227
+ },
1228
+ {
1229
+ message: "Refunding transaction...",
1230
+ successMessage: "Transaction refunded successfully"
1231
+ }
1232
+ );
1233
+ }
1234
+ ge(
1235
+ R,
1236
+ () => {
1237
+ S();
1238
+ },
1239
+ { deep: !0 }
1240
+ ), De(async () => {
1241
+ await S();
1242
+ });
1243
+ const a = async () => ke({
1244
+ exporter: new et(),
1245
+ readFunction: (e) => H.readStoreTransactions(e, {
1246
+ ...R.value.dateRange,
1247
+ user: v.user
1248
+ }),
1249
+ transformRecord: (e) => {
1250
+ var n, c, I, F;
1251
+ return {
1252
+ "Transaction ID": e._id.toString(),
1253
+ "Created at": w(e),
1254
+ Bundle: e.bundle.name || "",
1255
+ "Selling Price": me(e),
1256
+ Location: N(e),
1257
+ "Payment Type": C(e),
1258
+ "Payment Extra": ((n = e.paymentType) == null ? void 0 : n.extra) || "",
1259
+ User: ((c = e.pf_member) == null ? void 0 : c.name) || "",
1260
+ "Phone No.": ((I = e.pf_member) == null ? void 0 : I.phoneNumber) || "",
1261
+ Status: Q.title(e.status),
1262
+ "Refund Reason": ((F = e.refund) == null ? void 0 : F.reason) || "",
1263
+ Source: e.source,
1264
+ Ref: (e == null ? void 0 : e.ref) || ""
1265
+ };
1266
+ },
1267
+ filename: "store-transactions"
1268
+ }), t = E(null);
1269
+ function x(e) {
1270
+ var n;
1271
+ (n = t.value) == null || n.showSheet(!0, e.original);
1272
+ }
1273
+ return (e, n) => {
1274
+ const c = K("FmSearch"), I = K("FmButton");
1275
+ return k(), O("div", null, [
1276
+ _("div", ut, [
1277
+ _("div", mt, [
1278
+ D(ye, {
1279
+ modelValue: i(R).dateRange,
1280
+ "onUpdate:modelValue": n[0] || (n[0] = (F) => i(R).dateRange = F)
1281
+ }, null, 8, ["modelValue"])
1282
+ ]),
1283
+ _("div", dt, [
1284
+ D(c, {
1285
+ modelValue: i(g).searchValue,
1286
+ "onUpdate:modelValue": [
1287
+ n[1] || (n[1] = (F) => i(g).searchValue = F),
1288
+ i(b)
1289
+ ],
1290
+ placeholder: "Search",
1291
+ collapsible: ""
1292
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1293
+ D(I, {
1294
+ icon: "ios_share",
1295
+ variant: "tertiary",
1296
+ onClick: a
1297
+ })
1298
+ ])
1299
+ ]),
1300
+ D(he, {
1301
+ loading: i(g).isLoading,
1302
+ "row-data": i(h),
1303
+ "row-count": i(g).totalRows,
1304
+ "column-defs": V.filter(
1305
+ (F) => !v.user || F.header !== "User" && F.header !== "Phone No."
1306
+ ),
1307
+ "page-count": i(g).pageCount,
1308
+ "page-index": i(g).pageIndex,
1309
+ "page-size": i(g).pageSize,
1310
+ "shrink-at": !1,
1311
+ onSortChange: i(s),
1312
+ onRowClick: x,
1313
+ onPageChange: n[2] || (n[2] = (F) => i(S)({
1314
+ pageSize: F.pageSize,
1315
+ pageIndex: F.pageIndex
1316
+ }))
1317
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "onSortChange"]),
1318
+ D(ct, {
1319
+ ref_key: "transactionDetailSheet",
1320
+ ref: t
1321
+ }, null, 512)
1322
+ ]);
1323
+ };
1324
+ }
1325
+ });
1326
+ export {
1327
+ jt as _,
1328
+ Wt as a
1329
+ };