@feedmepos/mf-connect 0.1.0-beta.7 → 0.1.0-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 (126) hide show
  1. package/dist/Analytic-CnF_WeRZ.js +427 -0
  2. package/dist/{App-DalxIjTu.js → App-DJwSTuRa.js} +445 -420
  3. package/dist/AuditLogs-RarW2PHL.js +1886 -0
  4. package/dist/Bin-BaixTvHW.js +166 -0
  5. package/dist/{Broadcast-uMAvsC--.js → Broadcast-8DEAMhyM.js} +56 -54
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-JxbENan8.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DPXoOupI.js} +6 -8
  7. package/dist/Card-DRwLZ-Mn.js +896 -0
  8. package/dist/Collections-WsPM9v03.js +459 -0
  9. package/dist/{Credit-QlnatflM.js → Credit-DMxRdTzt.js} +36 -34
  10. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-DLnvDVgf.js +108 -0
  11. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-BUzUIIUW.js +58 -0
  12. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-Bcj6o4Xi.js +2181 -0
  13. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BE07lc4M.js → EffectSheet.vue_vue_type_style_index_0_lang-CuJ8curT.js} +49 -49
  14. package/dist/{Experience-Czy41ifp.js → Experience-B0BV4Tc_.js} +32 -30
  15. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-BrPLkFX8.js +118 -0
  16. package/dist/Game-Bu6kJJHx.js +278 -0
  17. package/dist/Index-CX-aPFQt.js +259 -0
  18. package/dist/Marketing-CiVFwl6S.js +20071 -0
  19. package/dist/Member-DZfTtt13.js +333 -0
  20. package/dist/MemberList-CscwsZnv.js +1598 -0
  21. package/dist/MemberTransactions-BWNs6bUm.js +45 -0
  22. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-CtM73bcN.js → MessageInput.vue_vue_type_script_setup_true_lang-BrbRudIU.js} +134 -122
  23. package/dist/Mission-CyJ-9Qfl.js +296 -0
  24. package/dist/Overview-DLyt6VId.js +1078 -0
  25. package/dist/{Point-By6ogYy_.js → Point-Cc_0-RKm.js} +55 -53
  26. package/dist/Promotion-KqA8nev2.js +289 -0
  27. package/dist/Queue-i8--zps9.js +249 -0
  28. package/dist/Record-CLUO1JVc.js +340 -0
  29. package/dist/Reward-BEdUKQ3M.js +442 -0
  30. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-B9vnSbWj.js +150 -0
  31. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-B8zw1TmO.js +1727 -0
  32. package/dist/Segment-B8sYajZG.js +568 -0
  33. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-CmmI5Vwl.js +181 -0
  34. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-CIcXjbJG.js +186 -0
  35. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-DY3FMuIf.js +147 -0
  36. package/dist/Setting-DT8dRb2A.js +1931 -0
  37. package/dist/Store-BhsPWRkR.js +1841 -0
  38. package/dist/StoreRewards-Cx2WDZ3p.js +423 -0
  39. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Byb7GOoh.js +1028 -0
  40. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-nEdCD6la.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-Cb-FGTO9.js} +1 -1
  41. package/dist/{Tier-DvAs0-yx.js → Tier-kQy1vGwo.js} +327 -318
  42. package/dist/{Title-B_Trr39o.js → Title-DKv8FqpX.js} +224 -209
  43. package/dist/{Transaction-DCJw-b3H.js → Transaction-CSLllOgl.js} +2 -2
  44. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-CvpBdNBn.js +130 -0
  45. package/dist/Voucher-BP6fmSwu.js +354 -0
  46. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-CxQEg_HW.js +419 -0
  47. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-DXkhu8e9.js → ZodTextField.vue_vue_type_script_setup_true_lang-aurdXO2X.js} +1 -1
  48. package/dist/app-B3qgrQOd.js +7079 -0
  49. package/dist/app-s3iL79De.js +33357 -0
  50. package/dist/app.js +1 -1
  51. package/dist/business-DG2w8U-i.js +79 -0
  52. package/dist/campaign-BP6Rz-AH.js +1810 -0
  53. package/dist/{campaign--0_yMbMV.js → campaign-WPRZ4BRF.js} +2 -2
  54. package/dist/campaign.enum-CoqrWNTZ.js +20 -0
  55. package/dist/campaign.fn-BRPigTOA.js +758 -0
  56. package/dist/collectible.enum-Dy4sxF43.js +19 -0
  57. package/dist/{collection.fn-3TwPe7aF.js → collection.fn-DGnLyYgV.js} +2 -2
  58. package/dist/dto-xZ9I6-Jr.js +214 -0
  59. package/dist/{effect-BeR0LK61.js → effect-C0XoYTus.js} +33 -16
  60. package/dist/email-addresses-CJ87c7W1.js +705 -0
  61. package/dist/{export-xeLLhqvh.js → export-qlV-AbEl.js} +5 -5
  62. package/dist/{helper-B5iqfKh8.js → helper-DzYe8aNx.js} +1 -1
  63. package/dist/{index-BOdtpNkP.js → index-4vdSri7m.js} +266 -173
  64. package/dist/{index-CU_d8jjU.js → index-BfSj7cUl.js} +1 -1
  65. package/dist/index-Bj0ULpXi.js +29556 -0
  66. package/dist/index-BnZ4yaMH.js +115 -0
  67. package/dist/index-Bo5DJXxs.js +54 -0
  68. package/dist/{index-Ct_wR519.js → index-BuvJH6SU.js} +24 -21
  69. package/dist/index-C2GEs8di.js +32 -0
  70. package/dist/{index-CyKZ-SsN.js → index-CJuOTcCE.js} +1 -1
  71. package/dist/index-CsaQJMAR.js +66 -0
  72. package/dist/{index-DP-dGMJC.js → index-DReysUPw.js} +2230 -871
  73. package/dist/{index-CAn5heDe.js → index-DgCjRb3o.js} +48 -4
  74. package/dist/index-IwITtvVu.js +56 -0
  75. package/dist/{index-Bh-uaaBG.js → index-n3wiQlbk.js} +1506 -1480
  76. package/dist/index-vh86FiIQ.js +10 -0
  77. package/dist/{index.esm2017-5jeDA5Zo.js → index.esm2017-CkJhTmme.js} +154 -154
  78. package/dist/loading-DwJdwl4G.js +71 -0
  79. package/dist/{membership-D0nqqWNZ.js → membership-DvPK3h8f.js} +54 -46
  80. package/dist/money-C_WIbr_x.js +15 -0
  81. package/dist/number-ZeVoGhzP.js +12 -0
  82. package/dist/objectid-8lkX6otO.js +145 -0
  83. package/dist/{loading-C-JDVajU.js → plugins-D20keyDW.js} +2990 -3062
  84. package/dist/remy-vue-client-Cpppk9h-.js +1693 -0
  85. package/dist/reward-CqnMEq_w.js +36 -0
  86. package/dist/{rule-Dn_GgBCe.js → rule-D7htGgWz.js} +185 -178
  87. package/dist/{rule-builder-BXt29Es4.js → rule-builder-BbJpYQ0n.js} +1 -1
  88. package/dist/style.css +1 -1
  89. package/dist/{template-D2Oi3dxP.js → template-BWQCVHm7.js} +5 -5
  90. package/dist/trigger-DMuv0_O7.js +144 -0
  91. package/dist/user-C_v2C0qN.js +54 -0
  92. package/dist/vue-i18n-N8_TEEd0.js +2365 -0
  93. package/dist/{xlsx-CCRCidY2.js → xlsx-CsPDNSTo.js} +1 -1
  94. package/package.json +11 -7
  95. package/dist/Analytic-BMpS6jWb.js +0 -622
  96. package/dist/Card-DV8-g69L.js +0 -825
  97. package/dist/Collections-DRafEHT1.js +0 -453
  98. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-TDoMehSB.js +0 -2813
  99. package/dist/Game-CD3zSitz.js +0 -255
  100. package/dist/Marketing-NNes8z6Q.js +0 -316
  101. package/dist/Member-CTqBgYuV.js +0 -69
  102. package/dist/MemberList-B99tS5ce.js +0 -1733
  103. package/dist/MemberTransactions-D1YCXPOg.js +0 -38
  104. package/dist/Mission-XbBVKBiE.js +0 -261
  105. package/dist/Promotion-DKcBr-RI.js +0 -247
  106. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-D1ESqEFO.js +0 -1753
  107. package/dist/Segment-B8cszL-F.js +0 -437
  108. package/dist/Setting-aZYABlMW.js +0 -1901
  109. package/dist/Store-Bx2tyJwe.js +0 -1511
  110. package/dist/StoreRewards-DTp9G6gw.js +0 -401
  111. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-B2W7ly5Z.js +0 -890
  112. package/dist/Voucher-jqv3ji90.js +0 -490
  113. package/dist/app-WlcUVbFb.js +0 -5764
  114. package/dist/app-_w0hjM7u.js +0 -53428
  115. package/dist/business-BC4-i1cU.js +0 -78
  116. package/dist/dto-Ns2dLn1B.js +0 -2770
  117. package/dist/index-BWb9vRCi.js +0 -29193
  118. package/dist/index-CpU9aqyW.js +0 -206
  119. package/dist/index-CqO_ZvtD.js +0 -99
  120. package/dist/index-CuvNtC_M.js +0 -61
  121. package/dist/index-DsNsA2uX.js +0 -298
  122. package/dist/index-WAMr3npT.js +0 -762
  123. package/dist/money-hdbrblud.js +0 -15
  124. package/dist/number-CRWGOZaW.js +0 -12
  125. package/dist/user-Bm4KttFq.js +0 -37
  126. package/dist/vue-i18n-Dud8fvmw.js +0 -2365
@@ -0,0 +1,1598 @@
1
+ import { defineComponent as be, computed as H, ref as G, resolveComponent as I, openBlock as p, createElementBlock as A, Fragment as q, createElementVNode as n, unref as t, createBlock as R, createCommentVNode as ce, createVNode as _, renderList as ie, withCtx as xe, createTextVNode as Fe, toDisplayString as $, withDirectives as ze, vShow as je, watch as qe, onBeforeMount as lt, h as K, onMounted as Ke, isRef as ct, normalizeClass as dt } from "vue";
2
+ import { h as S } from "./moment-BWErdI6_.js";
3
+ import { useDialog as Ee, components as ve } from "@feedmepos/ui-library";
4
+ import { e as mt, M as ut } from "./email-addresses-CJ87c7W1.js";
5
+ import { w as pt } from "./xlsx-CsPDNSTo.js";
6
+ import "./index-CJuOTcCE.js";
7
+ import { p as Pe, c as Oe, b as Re } from "./plugins-D20keyDW.js";
8
+ import { u as Ie, C as Ue, s as ft } from "./membership-DvPK3h8f.js";
9
+ import { c as bt } from "./index-Bj0ULpXi.js";
10
+ import { _ as Le } from "./lodash-B5I3zXaY.js";
11
+ import { D as yt } from "./type_drinks-D6jnpvwV.js";
12
+ import { c as gt, d as vt, e as xt, f as ht, g as _t } from "./index-DReysUPw.js";
13
+ import { u as Ge } from "./loading-DwJdwl4G.js";
14
+ import { C as Ae } from "./collection.fn-DGnLyYgV.js";
15
+ import { u as He } from "./business-DG2w8U-i.js";
16
+ import { defineStore as St } from "pinia";
17
+ import { f as ee } from "./number-ZeVoGhzP.js";
18
+ import "./index-4vdSri7m.js";
19
+ import "./index-n3wiQlbk.js";
20
+ import "./index-BfSj7cUl.js";
21
+ import "./index-Bo5DJXxs.js";
22
+ import { s as Ct } from "./index-CsaQJMAR.js";
23
+ import { u as We, _ as Je } from "./usePagination-BeF5K3M7.js";
24
+ import { B as wt, e as Ft } from "./export-qlV-AbEl.js";
25
+ import { m as Me } from "./index-DgCjRb3o.js";
26
+ import { o as Ce } from "./objectId-dwaoBfJX.js";
27
+ import { F as ke } from "./collectible.enum-Dy4sxF43.js";
28
+ import { g as Mt, b as Tt } from "./campaign-BP6Rz-AH.js";
29
+ import { useRouter as Xe } from "vue-router";
30
+ import { m as le } from "./index-BuvJH6SU.js";
31
+ import { t as kt } from "./index-IwITtvVu.js";
32
+ import { R as Qe } from "./app-B3qgrQOd.js";
33
+ import { t as At } from "./money-C_WIbr_x.js";
34
+ import { g as Et, a as It, b as Vt } from "./user-C_v2C0qN.js";
35
+ const $t = { class: "flex flex-col" }, Bt = { key: 1 }, Dt = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, Nt = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, Yt = /* @__PURE__ */ be({
36
+ __name: "MemberStatsDialog",
37
+ props: {
38
+ member: {
39
+ type: Object,
40
+ required: !0
41
+ },
42
+ onSubmit: {
43
+ type: Function,
44
+ required: !0
45
+ }
46
+ },
47
+ setup(y) {
48
+ var de, ae, W, re;
49
+ const k = Ee(), f = Ie(), x = y, s = H(
50
+ () => {
51
+ var d;
52
+ return (((d = x.member.collection) == null ? void 0 : d.TITLE) ?? []).reduce(
53
+ (c, M) => {
54
+ var w, T, O, E, U;
55
+ const r = f.sortedTitles.find(
56
+ (te) => te._id.toString() === M.collectible
57
+ );
58
+ if (!r) return c;
59
+ const l = [...M.expiryBalance ?? []].sort(
60
+ (te, z) => S(te.expiredAt).isAfter(S(z.expiredAt)) ? -1 : 1
61
+ );
62
+ return (w = l[0]) != null && w.expiredAt && S((T = l[0]) == null ? void 0 : T.expiredAt).isBefore(S()) || c.push({
63
+ _id: r._id,
64
+ name: r.name,
65
+ expiredAt: (O = l[0]) != null && O.expiredAt ? S((E = l[0]) == null ? void 0 : E.expiredAt).toISOString() : "",
66
+ expiresIn: S((U = l[0]) == null ? void 0 : U.expiredAt).diff(S(), "days")
67
+ }), c;
68
+ },
69
+ []
70
+ );
71
+ }
72
+ ), o = G({
73
+ cardNo: x.member.cardNo,
74
+ experience: ((ae = (de = x.member.collection) == null ? void 0 : de.POINT) == null ? void 0 : ae[0].balance) ?? 0,
75
+ tier: ((re = (W = x.member.collection) == null ? void 0 : W.TIER) == null ? void 0 : re[0].balance) ?? -1,
76
+ titles: s.value.map((d) => ({ expiredAt: d.expiresIn, id: d._id })) ?? void 0
77
+ }), g = H(
78
+ () => (f.sortedTitles ?? []).map((d) => ({
79
+ label: d.name,
80
+ value: d._id.toString(),
81
+ sublabel: s.value.some((c) => c._id === d._id) ? "Owned" : void 0
82
+ }))
83
+ ), m = H(() => (f.sortedTiers ?? []).map((d, c) => ({
84
+ label: d.name,
85
+ sublabel: `${d.option.from} - ${d.option.to}`,
86
+ from: d.option.from,
87
+ to: d.option.to,
88
+ value: c + 1
89
+ })));
90
+ function C() {
91
+ var M, r;
92
+ const d = ((M = m.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : M.from) ?? 0, c = (r = m.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : r.to;
93
+ o.value.experience = Math.min(
94
+ c ?? d,
95
+ Math.max(d, o.value.experience ?? 0)
96
+ );
97
+ }
98
+ const u = H(() => {
99
+ var M, r, l, w, T, O;
100
+ const d = ((r = (M = x.member.collection) == null ? void 0 : M.TIER) == null ? void 0 : r[0].balance) ?? -1, c = ((w = (l = x.member.collection) == null ? void 0 : l.POINT) == null ? void 0 : w[0].balance) ?? 0;
101
+ if (d != o.value.tier) return !0;
102
+ if (o.value.experience && o.value.experience != c) {
103
+ const E = ((T = m.value[d - 1]) == null ? void 0 : T.from) ?? 0, U = ((O = m.value[d - 1]) == null ? void 0 : O.to) ?? 0;
104
+ if (o.value.experience < E || U && o.value.experience > U)
105
+ return !0;
106
+ }
107
+ return !1;
108
+ });
109
+ function v(d) {
110
+ var c;
111
+ return (c = s.value.find((M) => M._id === d)) == null ? void 0 : c.expiresIn;
112
+ }
113
+ const V = H(() => {
114
+ const d = gt.safeParse(o.value);
115
+ return d.success ? void 0 : d.error.errors;
116
+ });
117
+ function D(d) {
118
+ var c, M;
119
+ return (M = (c = V.value) == null ? void 0 : c.find((r) => r.path.join(".") === d)) == null ? void 0 : M.message;
120
+ }
121
+ function L(d) {
122
+ var c;
123
+ return (c = V.value) == null ? void 0 : c.filter((M) => M.path.join(".").startsWith(d)).map((M) => M.message);
124
+ }
125
+ async function P() {
126
+ await x.onSubmit(o.value), k.close();
127
+ }
128
+ return (d, c) => {
129
+ var te, z;
130
+ const M = I("FmSelect"), r = I("FmStepperField"), l = I("FmTextField"), w = I("FmField"), T = I("FmFormGroup"), O = I("FmButton"), E = I("FmHelperText"), U = I("FmSpacer");
131
+ return p(), A(q, null, [
132
+ n("div", $t, [
133
+ c[6] || (c[6] = n("div", { class: "fm-typo-en-title-sm-800 mb-8" }, "Member tiering", -1)),
134
+ t(m).length ? (p(), R(M, {
135
+ key: 0,
136
+ modelValue: t(o).tier,
137
+ "onUpdate:modelValue": [
138
+ c[0] || (c[0] = (F) => t(o).tier = F),
139
+ C
140
+ ],
141
+ label: "Member Tier",
142
+ items: t(m),
143
+ "helper-text": D("tier"),
144
+ "helper-state": D("tier") ? "error" : void 0
145
+ }, null, 8, ["modelValue", "items", "helper-text", "helper-state"])) : ce("", !0),
146
+ _(r, {
147
+ "model-value": t(o).experience ?? 0,
148
+ "onUpdate:modelValue": c[1] || (c[1] = (F) => t(o).experience = F),
149
+ label: "Member Experience",
150
+ "max-fraction-digits": 0,
151
+ "helper-text": D("experience"),
152
+ "helper-state": D("experience") ? "error" : void 0
153
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
154
+ c[7] || (c[7] = n("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Member Card", -1)),
155
+ _(l, {
156
+ modelValue: t(o).cardNo,
157
+ "onUpdate:modelValue": c[2] || (c[2] = (F) => t(o).cardNo = F),
158
+ label: "Card number",
159
+ "helper-text": D("cardNo"),
160
+ "helper-state": D("cardNo") ? "error" : void 0
161
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
162
+ c[8] || (c[8] = n("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Titles", -1)),
163
+ (te = t(o).titles) != null && te.length ? (p(), A("div", Bt, c[5] || (c[5] = [
164
+ n("div", { class: "flex flex-nowrap gap-4 items-center" }, [
165
+ n("div", { class: "flex-1" }, "Title"),
166
+ n("div", { class: "flex-1" }, "Expires in days"),
167
+ n("div", { class: "w-24 h-1" })
168
+ ], -1)
169
+ ]))) : ce("", !0),
170
+ (p(!0), A(q, null, ie(t(o).titles ?? [], (F, J) => (p(), A("div", { key: J }, [
171
+ n("div", Dt, [
172
+ t(s).some((a) => a._id === F.id) ? (p(), R(T, {
173
+ key: 1,
174
+ "model-value": "",
175
+ class: "flex-1"
176
+ }, {
177
+ default: xe(() => [
178
+ _(w, {
179
+ disabled: !0,
180
+ class: "text-fm-color-typo-secondary"
181
+ }, {
182
+ default: xe(() => {
183
+ var a;
184
+ return [
185
+ Fe($((a = t(g).find((e) => e.value === F.id)) == null ? void 0 : a.label), 1)
186
+ ];
187
+ }),
188
+ _: 2
189
+ }, 1024)
190
+ ]),
191
+ _: 2
192
+ }, 1024)) : (p(), R(M, {
193
+ key: 0,
194
+ modelValue: F.id,
195
+ "onUpdate:modelValue": [(a) => F.id = a, (a) => F.expiredAt = v(a) ?? 1],
196
+ class: "flex-1",
197
+ items: t(g).filter(
198
+ (a) => {
199
+ var e;
200
+ return !((e = t(o).titles) != null && e.map((b) => b.id).includes(a.value)) || F.id === a.value;
201
+ }
202
+ )
203
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "items"])),
204
+ _(r, {
205
+ modelValue: F.expiredAt,
206
+ "onUpdate:modelValue": (a) => F.expiredAt = a,
207
+ class: "flex-1",
208
+ label: "",
209
+ "max-fraction-digits": 0
210
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
211
+ _(O, {
212
+ class: "w-24 h-24",
213
+ icon: "close",
214
+ variant: "tertiary",
215
+ onClick: (a) => {
216
+ var e;
217
+ return (e = t(o).titles) == null ? void 0 : e.splice(J, 1);
218
+ }
219
+ }, null, 8, ["onClick"])
220
+ ]),
221
+ (p(!0), A(q, null, ie(L(`titles.${J}`), (a, e) => (p(), R(E, {
222
+ key: e,
223
+ class: "items-center",
224
+ state: "error",
225
+ text: a.toString()
226
+ }, null, 8, ["text"]))), 128))
227
+ ]))), 128)),
228
+ t(g).length && (((z = t(o).titles) == null ? void 0 : z.length) ?? 0) < t(g).length ? (p(), R(O, {
229
+ key: 2,
230
+ icon: "add",
231
+ label: "Give title",
232
+ variant: "plain",
233
+ onClick: c[3] || (c[3] = (F) => {
234
+ var J;
235
+ return t(o).titles = [
236
+ ...t(o).titles ?? [],
237
+ {
238
+ id: ((J = t(g).find(
239
+ (a) => {
240
+ var e;
241
+ return !((e = t(o).titles) != null && e.map((b) => b.id).includes(a.value));
242
+ }
243
+ )) == null ? void 0 : J.value) || t(g)[0].value,
244
+ expiredAt: 0
245
+ }
246
+ ];
247
+ })
248
+ })) : ce("", !0)
249
+ ]),
250
+ n("div", Nt, [
251
+ ze(_(E, {
252
+ state: "warning",
253
+ text: "Updating member will cause tier to change"
254
+ }, null, 512), [
255
+ [je, t(u)]
256
+ ]),
257
+ _(U),
258
+ _(O, {
259
+ variant: "secondary",
260
+ label: "Cancel",
261
+ size: "md",
262
+ onClick: c[4] || (c[4] = (F) => t(k).close())
263
+ }),
264
+ _(O, {
265
+ disabled: !!t(V),
266
+ variant: "primary",
267
+ label: "Submit",
268
+ size: "md",
269
+ onClick: P
270
+ }, null, 8, ["disabled"])
271
+ ])
272
+ ], 64);
273
+ };
274
+ }
275
+ }), Pt = { class: "fm-typo-en-title-sm-800" }, Ot = { class: "space-y-16" }, Rt = { class: "flex flex-nowrap gap-8 items-center justify-end pt-24 w-full" }, Ut = /* @__PURE__ */ be({
276
+ __name: "CreditCoinDialog",
277
+ props: {
278
+ type: { type: String, required: !0 },
279
+ action: { type: String, required: !0 },
280
+ onSubmit: {
281
+ type: Function,
282
+ required: !0
283
+ }
284
+ },
285
+ setup(y) {
286
+ const k = Ee(), f = y, x = G({
287
+ amount: 1,
288
+ day: 1,
289
+ remark: void 0
290
+ }), s = G(!0), o = H(() => Ae.formattedType(f.type.toUpperCase()));
291
+ function g(u) {
292
+ s.value = u, !u && f.type === "coin" && (x.value.day = void 0);
293
+ }
294
+ async function m() {
295
+ if (f.action === "send") {
296
+ const u = x.value.day ? `, expire in ${x.value.day} days` : "";
297
+ Pe.confirm(
298
+ `Are you sure to send ${x.value.amount} ${o.value.toLowerCase()}${u}? This action cannot be reversed.`
299
+ ).then(async (v) => {
300
+ v && await f.onSubmit(x.value);
301
+ });
302
+ } else
303
+ Pe.confirm(
304
+ `Are you sure to deduct ${x.value.amount} ${o.value.toLowerCase()}? This action cannot be reversed.`
305
+ ).then(async (u) => {
306
+ u && await f.onSubmit(x.value);
307
+ });
308
+ }
309
+ const C = H(() => {
310
+ const v = (f.action === "send" ? f.type === "coin" ? vt : xt : f.type === "coin" ? ht : _t).safeParse(x.value);
311
+ return v.success == !1 ? v.error.flatten().fieldErrors : void 0;
312
+ });
313
+ return (u, v) => {
314
+ const V = I("FmStepperField"), D = I("FmSwitch"), L = I("FmTextarea"), P = I("FmButton"), de = I("FmCard");
315
+ return p(), R(de, { class: "flex flex-col gap-16 p-16" }, {
316
+ default: xe(() => {
317
+ var ae, W, re, d, c, M;
318
+ return [
319
+ n("div", Pt, $(f.action == "send" ? "Send" : "Deduct") + " " + $(t(Ue)[f.type.toUpperCase()].name), 1),
320
+ Fe(" " + $(t(C)) + " ", 1),
321
+ n("div", Ot, [
322
+ _(V, {
323
+ modelValue: t(x).amount,
324
+ "onUpdate:modelValue": v[0] || (v[0] = (r) => t(x).amount = r),
325
+ label: `${t(Ue)[f.type.toUpperCase()].name} amount`,
326
+ "is-currency": !0,
327
+ "max-fraction-digits": 2,
328
+ "helper-state": (ae = t(C)) != null && ae.amount ? "error" : void 0,
329
+ "helper-text": (re = (W = t(C)) == null ? void 0 : W.amount) == null ? void 0 : re[0]
330
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"]),
331
+ y.action === "send" && f.type === "coin" ? (p(), R(D, {
332
+ key: 0,
333
+ "model-value": t(s),
334
+ label: `${t(o)} expires`,
335
+ "label-placement": "right",
336
+ "onUpdate:modelValue": v[1] || (v[1] = (r) => g(r))
337
+ }, null, 8, ["model-value", "label"])) : ce("", !0),
338
+ y.action === "send" && t(s) ? (p(), R(V, {
339
+ key: 1,
340
+ modelValue: t(x).day,
341
+ "onUpdate:modelValue": v[2] || (v[2] = (r) => t(x).day = r),
342
+ label: `${t(o)} expires in`,
343
+ "max-fraction-digits": 0,
344
+ "append-text": "day(s)",
345
+ max: 9999,
346
+ min: 0,
347
+ "helper-state": (d = t(C)) != null && d.day ? "error" : void 0,
348
+ "helper-text": (M = (c = t(C)) == null ? void 0 : c.day) == null ? void 0 : M[0]
349
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : ce("", !0),
350
+ _(L, {
351
+ modelValue: t(x).remark,
352
+ "onUpdate:modelValue": v[3] || (v[3] = (r) => t(x).remark = r),
353
+ label: "Remark"
354
+ }, null, 8, ["modelValue"])
355
+ ]),
356
+ n("div", Rt, [
357
+ _(P, {
358
+ variant: "secondary",
359
+ label: "Cancel",
360
+ size: "md",
361
+ onClick: v[4] || (v[4] = (r) => t(k).close())
362
+ }),
363
+ _(P, {
364
+ disabled: !!t(C),
365
+ variant: "primary",
366
+ label: "Submit",
367
+ size: "md",
368
+ onClick: v[5] || (v[5] = async () => m())
369
+ }, null, 8, ["disabled"])
370
+ ])
371
+ ];
372
+ }),
373
+ _: 1
374
+ });
375
+ };
376
+ }
377
+ }), Ze = St("segment", () => {
378
+ const y = G([]);
379
+ async function k() {
380
+ const f = await ft.readAll({
381
+ limit: 1e3,
382
+ skip: 0,
383
+ sortBy: "_id",
384
+ descending: !0
385
+ });
386
+ y.value = f.resources;
387
+ }
388
+ return {
389
+ segments: y,
390
+ read: k
391
+ };
392
+ });
393
+ class Lt extends wt {
394
+ }
395
+ const zt = { class: "border border-fm-color-neutral-gray-100 rounded-lg p-16" }, jt = { class: "hidden xs:flex items-center justify-end" }, qt = { class: "flex items-center justify-between mb-4" }, Kt = { class: "flex items-center justify-between gap-x-8" }, Gt = { class: "fm-typo-en-body-lg-600" }, Ht = { class: "px-4 py-0.5 rounded-md bg-fm-color-neutral-gray-100 fm-typo-en-body-md-600" }, Wt = { class: "xs:hidden flex justify-between gap-x-4" }, Te = /* @__PURE__ */ be({
396
+ __name: "MemberCollectionTable",
397
+ props: {
398
+ member: {
399
+ type: Object,
400
+ required: !0
401
+ },
402
+ title: {
403
+ type: String,
404
+ default: ""
405
+ },
406
+ columns: {
407
+ type: Array,
408
+ default: [],
409
+ required: !0
410
+ },
411
+ filters: {
412
+ type: Object,
413
+ default: {}
414
+ },
415
+ withExport: {
416
+ type: Boolean,
417
+ default: !1
418
+ },
419
+ transformExportRecord: {
420
+ type: Function
421
+ }
422
+ },
423
+ setup(y) {
424
+ const k = y, f = G({
425
+ search: ""
426
+ }), x = G(!1), { tableMeta: s, rowData: o, onSort: g, debouncedFetchData: m, onSearch: C } = We(async (v) => {
427
+ const V = {
428
+ ...f.value,
429
+ ...k.filters
430
+ };
431
+ return await Me.readCollectionsByMemberId(
432
+ k.member._id.toString(),
433
+ v,
434
+ V
435
+ );
436
+ });
437
+ qe(
438
+ f,
439
+ () => {
440
+ m();
441
+ },
442
+ { deep: !0 }
443
+ );
444
+ async function u() {
445
+ try {
446
+ x.value = !0;
447
+ const v = {
448
+ ...f.value,
449
+ ...k.filters
450
+ };
451
+ await Ft({
452
+ exporter: new Lt(),
453
+ readFunction: (V) => Me.readCollectionsByMemberId(
454
+ k.member._id.toString(),
455
+ V,
456
+ v
457
+ ),
458
+ transformRecord: k.transformExportRecord,
459
+ filename: `${k.member._id.toString()}-${k.title.replace(" ", "-").toLowerCase()}`
460
+ });
461
+ } catch (v) {
462
+ console.error(v);
463
+ } finally {
464
+ x.value = !1;
465
+ }
466
+ }
467
+ return lt(async () => {
468
+ await m();
469
+ }), (v, V) => {
470
+ const D = I("FmSearch"), L = I("FmButton");
471
+ return p(), A("div", zt, [
472
+ n("div", jt, [
473
+ _(D, {
474
+ class: "hidden xs:flex",
475
+ modelValue: t(f).search,
476
+ "onUpdate:modelValue": [
477
+ V[0] || (V[0] = (P) => t(f).search = P),
478
+ t(C)
479
+ ],
480
+ placeholder: "Search",
481
+ collapsible: ""
482
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
483
+ y.withExport ? (p(), R(L, {
484
+ key: 0,
485
+ icon: "ios_share",
486
+ variant: "tertiary",
487
+ onClick: u
488
+ })) : ce("", !0)
489
+ ]),
490
+ n("div", qt, [
491
+ n("div", Kt, [
492
+ n("div", Gt, $(k.title), 1),
493
+ n("div", Ht, $(t(s).totalRows), 1)
494
+ ]),
495
+ n("div", Wt, [
496
+ _(D, {
497
+ modelValue: t(f).search,
498
+ "onUpdate:modelValue": [
499
+ V[1] || (V[1] = (P) => t(f).search = P),
500
+ t(C)
501
+ ],
502
+ placeholder: "Search"
503
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
504
+ y.withExport ? (p(), R(L, {
505
+ key: 0,
506
+ icon: "ios_share",
507
+ variant: "tertiary",
508
+ onClick: u
509
+ })) : ce("", !0)
510
+ ])
511
+ ]),
512
+ _(Je, {
513
+ loading: t(s).isLoading,
514
+ "row-data": t(o),
515
+ "row-count": t(s).totalRows,
516
+ "column-defs": y.columns,
517
+ "page-count": t(s).pageCount,
518
+ "page-index": t(s).pageIndex,
519
+ "page-size": t(s).pageSize,
520
+ "shrink-at": !1,
521
+ onSortChange: t(g),
522
+ onPageChange: V[2] || (V[2] = (P) => t(m)({
523
+ pageSize: P.pageSize,
524
+ pageIndex: P.pageIndex
525
+ }))
526
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "onSortChange"])
527
+ ]);
528
+ };
529
+ }
530
+ }), Jt = /* @__PURE__ */ be({
531
+ __name: "MemberVouchers",
532
+ props: {
533
+ member: {
534
+ type: Object,
535
+ required: !0
536
+ }
537
+ },
538
+ setup(y) {
539
+ const k = y, f = [
540
+ {
541
+ header: "Voucher title",
542
+ meta: {
543
+ maxWidth: "300px"
544
+ },
545
+ cell(o) {
546
+ var g;
547
+ return K(
548
+ "div",
549
+ { class: "text-ellipsis truncate" },
550
+ ((g = o.row.original.pf_collectible) == null ? void 0 : g.name) || "-"
551
+ );
552
+ },
553
+ enableSorting: !1
554
+ },
555
+ {
556
+ header: "Claimed at",
557
+ accessorKey: "_id",
558
+ accessorFn: (o) => S(Ce(o._id.toString())).format("D MMM YYYY"),
559
+ enableSorting: !1
560
+ },
561
+ {
562
+ header: "Expired at",
563
+ cell(o) {
564
+ var m, C, u, v;
565
+ const g = (C = (m = o.row.original.expiryBalance) == null ? void 0 : m[0]) != null && C.expiredAt ? S((v = (u = o.row.original.expiryBalance) == null ? void 0 : u[0]) == null ? void 0 : v.expiredAt).format(
566
+ "D MMM YYYY"
567
+ ) : "-";
568
+ return K("div", {}, g);
569
+ },
570
+ enableSorting: !0
571
+ },
572
+ {
573
+ header: "Transfer open",
574
+ accessorFn: (o) => {
575
+ var g, m, C;
576
+ return Ct((C = (m = (g = o.pf_collectible) == null ? void 0 : g.options) == null ? void 0 : m.enableTransfer) == null ? void 0 : C.toString());
577
+ },
578
+ enableSorting: !1
579
+ }
580
+ ], x = (o) => ({
581
+ type: ke.enum.VOUCHER,
582
+ isActive: o
583
+ }), s = (o) => {
584
+ var g, m, C, u, v, V, D;
585
+ return {
586
+ CollectionID: o._id,
587
+ Title: (g = o.pf_collectible) == null ? void 0 : g.name,
588
+ ClaimedAt: S(Ce(o._id.toString())).format(
589
+ "D MMM YYYY, hh:mmA"
590
+ ),
591
+ ExpiredAt: (C = (m = o.expiryBalance) == null ? void 0 : m[0]) != null && C.expiredAt ? S((v = (u = o.expiryBalance) == null ? void 0 : u[0]) == null ? void 0 : v.expiredAt).format("D MMM YYYY") : "",
592
+ TransferOpen: ((D = (V = o.pf_collectible) == null ? void 0 : V.options) == null ? void 0 : D.enableTransfer) || !1
593
+ };
594
+ };
595
+ return (o, g) => (p(), A(q, null, [
596
+ g[0] || (g[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Voucher Collections", -1)),
597
+ _(Te, {
598
+ member: k.member,
599
+ columns: f,
600
+ title: "Active voucher",
601
+ filters: x(!0),
602
+ withExport: !0,
603
+ transformExportRecord: s
604
+ }, null, 8, ["member", "filters"]),
605
+ _(Te, {
606
+ member: k.member,
607
+ columns: f,
608
+ title: "Past voucher",
609
+ filters: x(!1),
610
+ withExport: !0,
611
+ transformExportRecord: s
612
+ }, null, 8, ["member", "filters"])
613
+ ], 64));
614
+ }
615
+ }), Xt = /* @__PURE__ */ be({
616
+ __name: "MemberMissions",
617
+ props: {
618
+ member: {
619
+ type: Object,
620
+ required: !0
621
+ }
622
+ },
623
+ setup(y) {
624
+ const k = y, f = [
625
+ {
626
+ header: "Mission title",
627
+ meta: {
628
+ maxWidth: "300px"
629
+ },
630
+ cell(s) {
631
+ var o;
632
+ return K(
633
+ "div",
634
+ { class: "text-ellipsis truncate" },
635
+ ((o = s.row.original.pf_campaign) == null ? void 0 : o.name) || "Deleted Campaign"
636
+ );
637
+ },
638
+ enableSorting: !1
639
+ },
640
+ {
641
+ header: "Type",
642
+ accessorFn: (s) => {
643
+ var o, g, m;
644
+ return Oe.title(((m = (g = (o = s == null ? void 0 : s.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : g.mission) == null ? void 0 : m.type) || "-");
645
+ },
646
+ enableSorting: !1
647
+ },
648
+ {
649
+ header: "Status",
650
+ cell(s) {
651
+ if (s.row.original.pf_campaign) {
652
+ const o = {
653
+ active: "text-fm-color-typo-warning bg-fm-color-system-warning-100",
654
+ upcoming: "text-fm-color-typo-info bg-fm-color-system-info-100",
655
+ completed: "text-fm-color-typo-success bg-fm-color-system-success-100",
656
+ expired: "text-fm-color-typo-error bg-fm-color-system-error-100"
657
+ }, g = Mt(
658
+ s.row.original.pf_campaign
659
+ ), C = s.row.original.balance === s.row.original.pf_collectible.extras.mission.end && g === "active" ? "completed" : g;
660
+ return K(ve.FmChip, {
661
+ class: o[C],
662
+ label: Oe.title(C),
663
+ compact: !0
664
+ });
665
+ }
666
+ return K(ve.FmChip, {
667
+ class: "",
668
+ label: "-",
669
+ compact: !0
670
+ });
671
+ },
672
+ enableSorting: !1
673
+ },
674
+ {
675
+ header: "Summary",
676
+ accessorFn: (s) => s != null && s.pf_campaign ? Tt(s.pf_campaign) : "Deleted Campaign",
677
+ enableSorting: !1
678
+ },
679
+ {
680
+ header: "Current Step",
681
+ accessorKey: "balance",
682
+ enableSorting: !1
683
+ },
684
+ {
685
+ header: "Total Step",
686
+ accessorFn: (s) => {
687
+ var o, g, m;
688
+ return ((m = (g = (o = s == null ? void 0 : s.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : g.mission) == null ? void 0 : m.end) ?? 0;
689
+ },
690
+ enableSorting: !1
691
+ }
692
+ ], x = {
693
+ type: ke.enum.STAMP
694
+ };
695
+ return (s, o) => (p(), A(q, null, [
696
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Mission", -1)),
697
+ _(Te, {
698
+ member: k.member,
699
+ columns: f,
700
+ title: "Mission",
701
+ filters: x
702
+ }, null, 8, ["member"])
703
+ ], 64));
704
+ }
705
+ }), Qt = /* @__PURE__ */ be({
706
+ __name: "MemberGames",
707
+ props: {
708
+ member: {
709
+ type: Object,
710
+ required: !0
711
+ }
712
+ },
713
+ setup(y) {
714
+ const k = y, f = [
715
+ {
716
+ header: "Game title",
717
+ meta: {
718
+ maxWidth: "300px"
719
+ },
720
+ cell(s) {
721
+ var o;
722
+ return K(
723
+ "div",
724
+ { class: "text-ellipsis truncate" },
725
+ ((o = s.row.original.pf_campaign) == null ? void 0 : o.name) || "-"
726
+ );
727
+ },
728
+ enableSorting: !1
729
+ },
730
+ {
731
+ header: "Claimed at",
732
+ accessorKey: "_id",
733
+ accessorFn: (s) => S(Ce(s._id.toString())).format("D MMM YYYY"),
734
+ enableSorting: !1
735
+ },
736
+ {
737
+ header: "Expired at",
738
+ cell(s) {
739
+ var g, m, C, u;
740
+ const o = (m = (g = s.row.original.expiryBalance) == null ? void 0 : g[0]) != null && m.expiredAt ? S((u = (C = s.row.original.expiryBalance) == null ? void 0 : C[0]) == null ? void 0 : u.expiredAt).format(
741
+ "D MMM YYYY"
742
+ ) : "-";
743
+ return K("div", {}, o);
744
+ },
745
+ enableSorting: !1
746
+ },
747
+ {
748
+ header: "Token received",
749
+ accessorKey: "balance",
750
+ enableSorting: !1
751
+ }
752
+ ], x = (s) => ({
753
+ type: ke.enum.GAME,
754
+ isActive: s
755
+ });
756
+ return (s, o) => (p(), A(q, null, [
757
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Game program", -1)),
758
+ _(Te, {
759
+ member: k.member,
760
+ columns: f,
761
+ title: "Active game token",
762
+ filters: x(!0)
763
+ }, null, 8, ["member", "filters"])
764
+ ], 64));
765
+ }
766
+ }), Zt = { class: "flex flex-col flex-nowrap gap-y-24 max-h-full" }, eo = { class: "grid md:grid-cols-2 lg:grid-cols-2 gap-x-36 gap-y-24" }, to = { class: "space-y-16" }, oo = { class: "flex gap-16 items-center" }, no = { class: "flex-auto" }, ao = { class: "fm-typo-en-body-md-600" }, ro = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, io = { class: "fm-typo-en-body-md-800" }, lo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, co = { class: "fm-typo-en-body-md-800" }, mo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, uo = { class: "fm-typo-en-body-md-600" }, po = { class: "gap-16 grid grid-cols-1" }, fo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bo = { class: "fm-typo-en-body-md-600" }, yo = { class: "p-16 grid md:grid-cols-3 lg:grid-cols-3 border-2 border-fm-color-neutral-gray-100 rounded-lg gap-16 divide-y md:divide-y-0 lg:divide-y-0 md:divide-x lg:divide-x divide-fm-color-neutral-gray-100" }, go = { class: "flex justify-between mb-16" }, vo = { class: "fm-typo-en-title-sm-600" }, xo = ["onClick"], ho = { class: "flex flex-col gap-y-16" }, _o = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, So = { class: "fm-typo-en-body-md-600" }, Co = { class: "space-y-8" }, wo = {
767
+ key: 0,
768
+ class: "space-x-8"
769
+ }, Fo = {
770
+ key: 1,
771
+ class: "text-fm-color-typo-secondary"
772
+ }, Mo = { class: "space-y-8" }, To = ["src"], ko = { class: "fm-typo-en-body-md-600" }, Ao = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Eo = {
773
+ key: 1,
774
+ class: "text-fm-color-typo-secondary"
775
+ }, Io = {
776
+ key: 1,
777
+ class: "space-y-24"
778
+ }, Vo = { class: "space-y-8" }, $o = { class: "fm-typo-en-title-md-800" }, Bo = { class: "space-y-4" }, Do = { class: "fm-typo-en-body-md-600" }, No = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, Yo = { class: "space-y-8" }, Po = { class: "fm-typo-en-title-md-800" }, Oo = { class: "space-y-4" }, Ro = { class: "fm-typo-en-body-md-600" }, Uo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, Lo = /* @__PURE__ */ be({
779
+ __name: "MemberDetailSheet",
780
+ props: {
781
+ member: {
782
+ type: Object,
783
+ required: !0
784
+ }
785
+ },
786
+ emits: ["update:member"],
787
+ setup(y, { expose: k, emit: f }) {
788
+ const x = Xe(), s = He(), o = Ie(), g = Ze(), m = Ee(), { minor: C } = Ge, u = y, v = f, V = H(() => s.locations.map((a) => ({
789
+ label: a.name,
790
+ value: a._id
791
+ }))), D = H(() => (u.member.segment || []).map((a) => {
792
+ var e;
793
+ return ((e = g.segments.find((b) => b._id === a)) == null ? void 0 : e.name) || "";
794
+ }).filter(Boolean)), L = [
795
+ {
796
+ label: "Loyalty",
797
+ stats: [
798
+ {
799
+ label: "Experiences",
800
+ getter: (a) => {
801
+ var e, b, B;
802
+ return ee(((B = (b = (e = a.collection) == null ? void 0 : e.POINT) == null ? void 0 : b[0]) == null ? void 0 : B.balance) ?? 0, 2);
803
+ }
804
+ },
805
+ {
806
+ label: "Credits",
807
+ getter: (a) => {
808
+ var e, b, B;
809
+ return ee(((B = (b = (e = a.collection) == null ? void 0 : e.CREDIT) == null ? void 0 : b[0]) == null ? void 0 : B.balance) ?? 0, 2);
810
+ }
811
+ }
812
+ ]
813
+ },
814
+ {
815
+ label: "Voucher",
816
+ stats: [
817
+ {
818
+ label: "Active vouchers",
819
+ getter: () => ee(w.value.active, 0)
820
+ },
821
+ {
822
+ label: "Past vouchers",
823
+ getter: () => ee(w.value.past, 0)
824
+ }
825
+ ]
826
+ },
827
+ {
828
+ label: "Mission",
829
+ stats: [
830
+ {
831
+ label: "Stamp missions",
832
+ getter: () => ee(l.value.stamp, 0)
833
+ },
834
+ {
835
+ label: "Progress missions",
836
+ getter: () => ee(l.value.progressive, 0)
837
+ }
838
+ ]
839
+ },
840
+ {
841
+ label: "Game",
842
+ stats: [
843
+ {
844
+ label: "Tokens",
845
+ getter: (a) => {
846
+ var e, b;
847
+ return ee(
848
+ ((b = (e = a.collection) == null ? void 0 : e.GAME) == null ? void 0 : b.reduce(
849
+ (B, N) => B + N.balance,
850
+ 0
851
+ )) || 0,
852
+ 0
853
+ );
854
+ }
855
+ }
856
+ ]
857
+ },
858
+ {
859
+ label: "Store bundle",
860
+ stats: [
861
+ {
862
+ label: "Bundle purchased",
863
+ getter: () => ee(O.value, 0)
864
+ }
865
+ ]
866
+ }
867
+ ], de = (() => {
868
+ const e = [];
869
+ for (let b = 0; b < L.length; b += 3)
870
+ e.push(L.slice(b, b + 3));
871
+ return e;
872
+ })();
873
+ async function ae(a, e) {
874
+ switch (a.stopPropagation(), e) {
875
+ case "Store bundle":
876
+ await x.push({
877
+ name: Qe["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
878
+ params: { id: u.member._id.toString() },
879
+ query: { tab: "store" }
880
+ });
881
+ break;
882
+ default:
883
+ F.value = z.find((b) => b.label === e) || z[0];
884
+ break;
885
+ }
886
+ }
887
+ async function W(a, e) {
888
+ m.open({
889
+ title: "",
890
+ dialogComponent: Ut,
891
+ dialogComponentProps: {
892
+ type: a,
893
+ action: e,
894
+ onSubmit: async (b) => {
895
+ await C(
896
+ async () => {
897
+ const B = {
898
+ "credit-send": le.sendCredit,
899
+ "credit-deduct": le.deductCredit,
900
+ "coin-send": le.sendCoin,
901
+ "coin-deduct": le.deductCoin
902
+ }, N = `${a}-${e}`, X = B[N];
903
+ X && await X(u.member._id, b), v("update:member"), m.close();
904
+ },
905
+ {
906
+ message: `Adjusting ${Ae.formattedType(
907
+ a.toUpperCase()
908
+ ).toLowerCase()}`,
909
+ successMessage: `${b.amount} ${Ae.formattedType(
910
+ a.toUpperCase()
911
+ ).toLowerCase()} ${e} ${e == "send" ? "to" : "from"} ${u.member.phoneNumber}`
912
+ }
913
+ );
914
+ }
915
+ }
916
+ });
917
+ }
918
+ async function re() {
919
+ m.open({
920
+ title: "Update member statistics",
921
+ contentComponent: Yt,
922
+ contentComponentProps: {
923
+ member: u.member,
924
+ onSubmit: async (a) => {
925
+ await C(
926
+ async () => {
927
+ await le.updateMember(u.member._id, a), v("update:member"), m.close();
928
+ },
929
+ {
930
+ message: "Updating member stats",
931
+ successMessage: `Updated member ${u.member.phoneNumber} stats successfully`
932
+ }
933
+ );
934
+ }
935
+ }
936
+ });
937
+ }
938
+ const d = [
939
+ {
940
+ label: "Mobile No.",
941
+ key: "phoneNumber"
942
+ },
943
+ {
944
+ label: "Tier",
945
+ getter: (a) => {
946
+ var se, me, ye, h, Y;
947
+ const e = (((me = Le.first((se = u.member.collection) == null ? void 0 : se.TIER)) == null ? void 0 : me.balance) || 0) - 1, b = M.value.name, B = ((h = (ye = a.collection) == null ? void 0 : ye.POINT) == null ? void 0 : h[0].balance) ?? 0, N = o.sortedTiers[e + 1], X = ((Y = N == null ? void 0 : N.option) == null ? void 0 : Y.to) ?? 1 / 0;
948
+ return `${b} (${B}/${X})`;
949
+ }
950
+ },
951
+ {
952
+ label: "Email",
953
+ key: "email"
954
+ },
955
+ {
956
+ label: "Birthday",
957
+ getter: (a) => a.birthday ? S(a.birthday).format("D MMM YYYY") : "-"
958
+ }
959
+ ], c = [
960
+ {
961
+ label: "Customer since",
962
+ getter: (a) => S(Ce(a._id.toString())).format("D MMM YYYY")
963
+ },
964
+ {
965
+ label: "Joined at location",
966
+ getter: (a) => {
967
+ var e;
968
+ return a != null && a.location && ((e = V.value.find((b) => b.value == a.location)) == null ? void 0 : e.label) || "-";
969
+ }
970
+ },
971
+ {
972
+ label: "Total visit(s)",
973
+ getter: (a) => Re.singularOrPlural(a.stats.visitCount, "bill")
974
+ },
975
+ {
976
+ label: "Last visit",
977
+ getter: (a) => S(a.stats.lastVisit).fromNow()
978
+ },
979
+ {
980
+ label: "Frequency",
981
+ getter: (a) => `Every ${Re.singularOrPlural(
982
+ Number(Math.ceil(a.stats.avgVisitFrequency).toFixed(0)),
983
+ "day"
984
+ )}`
985
+ },
986
+ {
987
+ label: "Average spend",
988
+ getter: (a) => bt.Dinero.fromNumber({ number: Number(a.stats.avgBillSize || 0) }).toFormat(
989
+ !0
990
+ )
991
+ }
992
+ // {
993
+ // label: 'Feedback',
994
+ // key: 'feedbackCount',
995
+ // },
996
+ // {
997
+ // label: 'Tier Earned this season',
998
+ // key: 'lastSeasonTierEarned',
999
+ // },
1000
+ // {
1001
+ // label: 'Point Earned this season',
1002
+ // key: 'lastSeasonPointEarned',
1003
+ // },
1004
+ ], M = H(() => {
1005
+ var b, B;
1006
+ const a = (((B = Le.first((b = u.member.collection) == null ? void 0 : b.TIER)) == null ? void 0 : B.balance) || 0) - 1, e = o.sortedTiers[a];
1007
+ return { name: (e == null ? void 0 : e.name) || "-", tier: a, config: e };
1008
+ }), r = H(() => {
1009
+ var a;
1010
+ return (((a = u.member.collection) == null ? void 0 : a.TITLE) || []).map((e) => {
1011
+ var B, N, X;
1012
+ const b = (B = o.sortedTitles) == null ? void 0 : B.find(
1013
+ (se) => se._id == e.collectible
1014
+ );
1015
+ return {
1016
+ name: b == null ? void 0 : b.name,
1017
+ expiredAt: (X = (N = e.expiryBalance) == null ? void 0 : N.at(-1)) == null ? void 0 : X.expiredAt,
1018
+ collectible: b
1019
+ };
1020
+ }).filter(
1021
+ (e) => e.expiredAt ? S(e.expiredAt).isAfter(S()) : !0
1022
+ );
1023
+ }), l = G({ stamp: 0, progressive: 0 }), w = G({ active: 0, past: 0 }), T = G([]), O = H(
1024
+ () => T.value.reduce((a, e) => a + e.count, 0)
1025
+ ), E = G(!0);
1026
+ function U() {
1027
+ E.value = !0, F.value = z[0];
1028
+ }
1029
+ function te() {
1030
+ E.value = !1;
1031
+ }
1032
+ const z = [
1033
+ {
1034
+ label: "Overview",
1035
+ value: "overview"
1036
+ },
1037
+ {
1038
+ label: "Loyalty",
1039
+ value: "loyalty"
1040
+ },
1041
+ {
1042
+ label: "Voucher",
1043
+ value: "voucher"
1044
+ },
1045
+ {
1046
+ label: "Mission",
1047
+ value: "mission"
1048
+ },
1049
+ {
1050
+ label: "Game",
1051
+ value: "game"
1052
+ }
1053
+ ], F = G(z[0]), J = async () => {
1054
+ w.value = await Me.readCollectionCountByMemberId(
1055
+ u.member._id.toString(),
1056
+ ke.enum.VOUCHER
1057
+ ), T.value = await kt.readPurchaseCountByMember(
1058
+ u.member._id.toString()
1059
+ ), l.value = await Me.readMissionCountByMemberId(
1060
+ u.member._id.toString()
1061
+ );
1062
+ };
1063
+ return Ke(async () => {
1064
+ await o.readMembership(), await J(), s.locations.length || await s.readLocations();
1065
+ }), qe(E, async () => {
1066
+ await J();
1067
+ }), k({
1068
+ showSheet: U,
1069
+ hideSheet: te
1070
+ }), (a, e) => {
1071
+ const b = I("FmTabs"), B = I("FmAvatar"), N = I("FmButton"), X = I("FmIcon"), se = I("FmChip"), me = I("FmCard"), ye = I("FmSideSheet");
1072
+ return p(), R(ye, {
1073
+ modelValue: t(E),
1074
+ "onUpdate:modelValue": e[5] || (e[5] = (h) => ct(E) ? E.value = h : null),
1075
+ header: "Member Detail",
1076
+ "dismiss-away": "",
1077
+ "close-button": !0,
1078
+ "max-width": 1100
1079
+ }, {
1080
+ "side-sheet-footer": xe(() => e[19] || (e[19] = [])),
1081
+ default: xe(() => [
1082
+ n("div", Zt, [
1083
+ n("div", null, [
1084
+ _(b, {
1085
+ "model-value": t(F).value,
1086
+ items: z,
1087
+ class: "overflow-x-auto",
1088
+ "onUpdate:modelValue": e[0] || (e[0] = (h) => F.value = z.find((Y) => Y.value === h))
1089
+ }, null, 8, ["model-value"])
1090
+ ]),
1091
+ t(F).value == "overview" ? (p(), A(q, { key: 0 }, [
1092
+ n("div", eo, [
1093
+ n("div", null, [
1094
+ e[9] || (e[9] = n("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Profile Information", -1)),
1095
+ n("div", to, [
1096
+ n("div", oo, [
1097
+ _(B, {
1098
+ name: y.member.photoUrl ? void 0 : y.member.name,
1099
+ src: y.member.photoUrl || void 0
1100
+ }, null, 8, ["name", "src"]),
1101
+ n("div", no, [
1102
+ e[8] || (e[8] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1)),
1103
+ n("div", ao, $(y.member.name), 1),
1104
+ n("div", ro, $(y.member._id), 1),
1105
+ n("div", so, [
1106
+ e[6] || (e[6] = Fe(" Member Card: ")),
1107
+ n("span", io, $(y.member.cardNo ? y.member.cardNo : "-"), 1)
1108
+ ]),
1109
+ n("div", lo, [
1110
+ e[7] || (e[7] = Fe(" Referral Code: ")),
1111
+ n("span", co, $(y.member.referralCode ? y.member.referralCode : "-"), 1)
1112
+ ])
1113
+ ]),
1114
+ _(N, {
1115
+ variant: "tertiary",
1116
+ icon: "settings",
1117
+ onClick: re
1118
+ })
1119
+ ]),
1120
+ (p(), A(q, null, ie(d, (h, Y) => n("div", { key: Y }, [
1121
+ n("div", mo, $(h.label), 1),
1122
+ n("div", uo, $(h.key ? y.member[h.key] : h.getter(y.member)), 1)
1123
+ ])), 64))
1124
+ ])
1125
+ ]),
1126
+ n("div", null, [
1127
+ e[10] || (e[10] = n("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Activities", -1)),
1128
+ n("div", po, [
1129
+ (p(), A(q, null, ie(c, (h) => n("div", {
1130
+ key: h.key
1131
+ }, [
1132
+ n("div", fo, $(h.label), 1),
1133
+ n("div", bo, $(h.key ? u.member.stats[h.key] || "-" : h.getter(y.member)), 1)
1134
+ ])), 64))
1135
+ ])
1136
+ ])
1137
+ ]),
1138
+ e[13] || (e[13] = n("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
1139
+ (p(!0), A(q, null, ie(t(de), (h) => (p(), A("div", yo, [
1140
+ (p(!0), A(q, null, ie(h, (Y, oe) => (p(), A("div", { key: oe }, [
1141
+ n("div", {
1142
+ class: dt(oe !== 0 ? "pt-12 md:pt-0 lg:pt-0 md:pl-12 lg:pl-12" : "")
1143
+ }, [
1144
+ n("div", go, [
1145
+ n("div", vo, $(Y.label), 1),
1146
+ n("button", {
1147
+ onClick: (j) => ae(j, Y.label)
1148
+ }, [
1149
+ _(X, {
1150
+ name: "chevron_right",
1151
+ outline: "",
1152
+ size: "md"
1153
+ })
1154
+ ], 8, xo)
1155
+ ]),
1156
+ n("div", ho, [
1157
+ (p(!0), A(q, null, ie(Y.stats, (j) => (p(), A("div", {
1158
+ key: j.key
1159
+ }, [
1160
+ n("div", _o, $(j.label), 1),
1161
+ n("div", So, $(j.getter(y.member)), 1)
1162
+ ]))), 128))
1163
+ ])
1164
+ ], 2)
1165
+ ]))), 128))
1166
+ ]))), 256)),
1167
+ n("div", Co, [
1168
+ e[11] || (e[11] = n("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1)),
1169
+ t(D).length ? (p(), A("div", wo, [
1170
+ (p(!0), A(q, null, ie(t(D), (h) => (p(), R(se, {
1171
+ label: h.toString()
1172
+ }, null, 8, ["label"]))), 256))
1173
+ ])) : (p(), A("div", Fo, "No titles"))
1174
+ ]),
1175
+ e[14] || (e[14] = n("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
1176
+ n("div", Mo, [
1177
+ e[12] || (e[12] = n("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1)),
1178
+ t(r).length ? (p(!0), A(q, { key: 0 }, ie(t(r).filter((h) => h.collectible), (h) => (p(), A("div", {
1179
+ class: "flex items-center gap-x-8 h-48",
1180
+ key: h.name
1181
+ }, [
1182
+ n("img", {
1183
+ src: h.collectible.image || t(yt),
1184
+ class: "aspect-square h-full object-contain"
1185
+ }, null, 8, To),
1186
+ n("div", null, [
1187
+ n("div", ko, $(h.name), 1),
1188
+ n("div", Ao, " Expired on " + $(t(S)(h.expiredAt).format("MMM D, Y")), 1)
1189
+ ])
1190
+ ]))), 128)) : (p(), A("div", Eo, "No titles"))
1191
+ ])
1192
+ ], 64)) : t(F).value == "loyalty" ? (p(), A("div", Io, [
1193
+ _(me, {
1194
+ class: "p-16 space-y-24",
1195
+ variant: "outlined"
1196
+ }, {
1197
+ default: xe(() => {
1198
+ var h, Y, oe, j, ue, pe, fe;
1199
+ return [
1200
+ n("div", Vo, [
1201
+ e[15] || (e[15] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1)),
1202
+ n("div", $o, $(((oe = (Y = (h = y.member.collection) == null ? void 0 : h.CREDIT) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1203
+ ]),
1204
+ n("div", Bo, [
1205
+ e[16] || (e[16] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1)),
1206
+ n("div", Do, $(((fe = (pe = (ue = (j = y.member.collection) == null ? void 0 : j.CREDIT) == null ? void 0 : ue[0]) == null ? void 0 : pe.expiryBalance) == null ? void 0 : fe.reduce(
1207
+ (Q, Z) => Z.expiredAt && t(S)(Z.expiredAt).isAfter(t(S)()) && t(S)(Z.expiredAt).isBefore(t(S)().add(30, "days")) ? Q + Z.amount : Q,
1208
+ 0
1209
+ )) ?? 0), 1)
1210
+ ]),
1211
+ n("div", No, [
1212
+ _(N, {
1213
+ label: "Add credit",
1214
+ icon: "add",
1215
+ variant: "plain",
1216
+ onClick: e[1] || (e[1] = (Q) => W("credit", "send"))
1217
+ }),
1218
+ _(N, {
1219
+ label: "Deduct credit",
1220
+ icon: "remove",
1221
+ variant: "plain",
1222
+ onClick: e[2] || (e[2] = (Q) => W("credit", "deduct"))
1223
+ })
1224
+ ])
1225
+ ];
1226
+ }),
1227
+ _: 1
1228
+ }),
1229
+ _(me, {
1230
+ class: "p-16 space-y-24",
1231
+ variant: "outlined"
1232
+ }, {
1233
+ default: xe(() => {
1234
+ var h, Y, oe, j, ue, pe, fe;
1235
+ return [
1236
+ n("div", Yo, [
1237
+ e[17] || (e[17] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1)),
1238
+ n("div", Po, $(((oe = (Y = (h = y.member.collection) == null ? void 0 : h.COIN) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1239
+ ]),
1240
+ n("div", Oo, [
1241
+ e[18] || (e[18] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1)),
1242
+ n("div", Ro, $(((fe = (pe = (ue = (j = y.member.collection) == null ? void 0 : j.COIN) == null ? void 0 : ue[0]) == null ? void 0 : pe.expiryBalance) == null ? void 0 : fe.reduce(
1243
+ (Q, Z) => Z.expiredAt && t(S)(Z.expiredAt).isAfter(t(S)()) && t(S)(Z.expiredAt).isBefore(t(S)().add(30, "days")) ? Q + Z.amount : Q,
1244
+ 0
1245
+ )) ?? 0), 1)
1246
+ ]),
1247
+ n("div", Uo, [
1248
+ _(N, {
1249
+ label: "Add point",
1250
+ icon: "add",
1251
+ variant: "plain",
1252
+ onClick: e[3] || (e[3] = (Q) => W("coin", "send"))
1253
+ }),
1254
+ _(N, {
1255
+ label: "Deduct point",
1256
+ icon: "remove",
1257
+ variant: "plain",
1258
+ onClick: e[4] || (e[4] = (Q) => W("coin", "deduct"))
1259
+ })
1260
+ ])
1261
+ ];
1262
+ }),
1263
+ _: 1
1264
+ })
1265
+ ])) : t(F).value == "voucher" ? (p(), R(Jt, {
1266
+ key: 2,
1267
+ member: u.member
1268
+ }, null, 8, ["member"])) : t(F).value == "mission" ? (p(), R(Xt, {
1269
+ key: 3,
1270
+ member: u.member
1271
+ }, null, 8, ["member"])) : t(F).value == "game" ? (p(), R(Qt, {
1272
+ key: 4,
1273
+ member: u.member
1274
+ }, null, 8, ["member"])) : ce("", !0)
1275
+ ])
1276
+ ]),
1277
+ _: 1
1278
+ }, 8, ["modelValue"]);
1279
+ };
1280
+ }
1281
+ }), zo = { class: "flex items-center justify-end" }, Fn = /* @__PURE__ */ be({
1282
+ __name: "MemberList",
1283
+ setup(y) {
1284
+ const k = Ze(), f = Ie(), x = He(), { minor: s } = Ge, o = Xe(), g = [
1285
+ {
1286
+ header: "Name",
1287
+ enableSorting: !0,
1288
+ accessorKey: "name",
1289
+ cell(r) {
1290
+ return Et(r.row.original);
1291
+ }
1292
+ },
1293
+ {
1294
+ accessorFn: (r) => S(Ce(r._id.toString())).format("D MMM YYYY"),
1295
+ header: "Customer Since",
1296
+ accessorKey: "_id",
1297
+ id: "_id"
1298
+ },
1299
+ {
1300
+ accessorKey: "collection_TIER_0_balance",
1301
+ header: "Tier",
1302
+ enableSorting: !0,
1303
+ cell(r) {
1304
+ return It(
1305
+ r.row.original,
1306
+ f.sortedTiers
1307
+ );
1308
+ }
1309
+ },
1310
+ {
1311
+ header: "Title",
1312
+ enableSorting: !1,
1313
+ cell(r) {
1314
+ return Vt(
1315
+ r.row.original,
1316
+ f.sortedTitles
1317
+ );
1318
+ }
1319
+ },
1320
+ {
1321
+ accessorKey: "collection_CREDIT_0_balance",
1322
+ accessorFn: (r) => {
1323
+ var l, w, T;
1324
+ return ee(((T = (w = (l = r.collection) == null ? void 0 : l.CREDIT) == null ? void 0 : w[0]) == null ? void 0 : T.balance) ?? 0, 2);
1325
+ },
1326
+ header: "Credit(s)",
1327
+ enableSorting: !0
1328
+ },
1329
+ {
1330
+ accessorKey: "collection_POINT_0_balance",
1331
+ accessorFn: (r) => {
1332
+ var l, w, T;
1333
+ return ee(((T = (w = (l = r.collection) == null ? void 0 : l.POINT) == null ? void 0 : w[0]) == null ? void 0 : T.balance) ?? 0, 2);
1334
+ },
1335
+ header: "Experience(s)",
1336
+ enableSorting: !0
1337
+ },
1338
+ {
1339
+ accessorKey: "collection_COIN_0_balance",
1340
+ accessorFn: (r) => {
1341
+ var l, w, T;
1342
+ return ee(((T = (w = (l = r.collection) == null ? void 0 : l.COIN) == null ? void 0 : w[0]) == null ? void 0 : T.balance) ?? 0, 2);
1343
+ },
1344
+ header: "Point(s)",
1345
+ enableSorting: !0
1346
+ },
1347
+ {
1348
+ accessorFn: (r) => {
1349
+ var l;
1350
+ return ((l = r.stats) == null ? void 0 : l.visitCount) ?? 0;
1351
+ },
1352
+ header: "Total visit",
1353
+ accessorKey: "stats.visitCount",
1354
+ id: "stats.visitCount"
1355
+ },
1356
+ {
1357
+ accessorFn: (r) => {
1358
+ var l;
1359
+ return (l = r.stats) == null ? void 0 : l.lastVisit;
1360
+ },
1361
+ sortingFn: (r, l) => {
1362
+ var w, T;
1363
+ return new Date((w = r.original.stats) == null ? void 0 : w.lastVisit).getTime() - new Date((T = l.original.stats) == null ? void 0 : T.lastVisit).getTime();
1364
+ },
1365
+ id: "stats.lastVisit",
1366
+ header: "Last visit",
1367
+ cell(r) {
1368
+ var l, w;
1369
+ return K("div", { class: "flex items-center justify-end gap-4" }, [
1370
+ K(
1371
+ "span",
1372
+ (l = r.row.original.stats) != null && l.lastVisit ? S((w = r.row.original.stats) == null ? void 0 : w.lastVisit).fromNow() : "NA"
1373
+ ),
1374
+ K(
1375
+ ve.FmTooltip,
1376
+ {
1377
+ content: S(r.row.original.stats.lastVisit).format(
1378
+ "D MMM YYYY - hh:mmA"
1379
+ )
1380
+ },
1381
+ [K(ve.FmIcon, { name: "info", outline: !0, size: "sm" })]
1382
+ )
1383
+ ]);
1384
+ }
1385
+ },
1386
+ {
1387
+ id: "actions",
1388
+ cell(r) {
1389
+ return K(
1390
+ ve.FmMenu,
1391
+ {
1392
+ placement: "bottom-end",
1393
+ onClick: (l) => {
1394
+ l.stopPropagation();
1395
+ }
1396
+ },
1397
+ {
1398
+ "menu-button": () => K(ve.FmButton, { icon: "more_vert", variant: "tertiary" }),
1399
+ default: () => [
1400
+ K(ve.FmMenuItem, {
1401
+ label: "Transaction details",
1402
+ onClick: async (l) => {
1403
+ l.stopPropagation(), await re(r.row.original._id);
1404
+ }
1405
+ })
1406
+ ]
1407
+ }
1408
+ );
1409
+ }
1410
+ }
1411
+ ], { tableMeta: m, rowData: C, onSort: u, debouncedFetchData: v, onSearch: V } = We(le.read), D = G(), L = G(!1), P = G(), de = H(() => x.locations.map((r) => ({
1412
+ label: r.name,
1413
+ value: r._id
1414
+ })));
1415
+ async function ae() {
1416
+ P.value = await le.readById(
1417
+ P.value._id.toString()
1418
+ ), L.value = !0;
1419
+ }
1420
+ async function W() {
1421
+ await v(), L.value = !1;
1422
+ }
1423
+ async function re(r) {
1424
+ await o.push({
1425
+ name: Qe["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
1426
+ params: { id: r }
1427
+ });
1428
+ }
1429
+ const d = {
1430
+ sortBy: "_id",
1431
+ descending: !1,
1432
+ rowsPerPage: 1e3,
1433
+ page: 1,
1434
+ rowsNumber: 0
1435
+ };
1436
+ function c(r) {
1437
+ const l = S(r);
1438
+ return l.isValid() ? l.format("DD/MM/YYYY") : "";
1439
+ }
1440
+ async function M() {
1441
+ const r = new ut(), l = (await le.read({
1442
+ limit: 1,
1443
+ skip: 0,
1444
+ sortBy: d.sortBy,
1445
+ descending: d.descending
1446
+ })).meta.totalResources ?? 0, w = d.rowsPerPage;
1447
+ await s(
1448
+ async () => {
1449
+ var T, O, E, U, te, z, F, J, a, e, b, B, N, X, se, me, ye, h, Y, oe, j, ue, pe, fe, Q, Z, Ve, $e;
1450
+ for (let Be = 0; Be < l; Be += w) {
1451
+ const et = {
1452
+ ...d,
1453
+ limit: w,
1454
+ skip: d.page - 1,
1455
+ sortBy: d.sortBy,
1456
+ descending: d.descending
1457
+ }, tt = await le.read(et);
1458
+ for (const i of tt.resources) {
1459
+ const ot = (T = mt.parseOneAddress(
1460
+ i == null ? void 0 : i.email
1461
+ )) != null && T.domain.includes("feedmepos.com") ? void 0 : i.email, nt = (E = ((O = i == null ? void 0 : i.collection) == null ? void 0 : O.TITLE) || []) == null ? void 0 : E.reduce(
1462
+ (ne, ge) => {
1463
+ var _e, Se;
1464
+ const he = (Se = (_e = f.sortedTitles) == null ? void 0 : _e.find(
1465
+ (we) => we._id === ge.collectible
1466
+ )) == null ? void 0 : Se.name;
1467
+ return !he || ge.balance <= 0 || ne.push(he), ne;
1468
+ },
1469
+ []
1470
+ ), at = (f.sortedTitles || []).reduce(
1471
+ (ne, ge) => {
1472
+ var _e, Se, we, Ye;
1473
+ const he = (Ye = (we = (Se = (((_e = i == null ? void 0 : i.collection) == null ? void 0 : _e.TITLE) || []).find(
1474
+ (it) => it.collectible === ge._id
1475
+ )) == null ? void 0 : Se.expiryBalance) == null ? void 0 : we[0]) == null ? void 0 : Ye.expiredAt;
1476
+ return ne[ge.name] = he ? S(he).format("DD/MM/YYYY") : "", ne;
1477
+ },
1478
+ {}
1479
+ ), rt = ((z = (te = (U = i.collection) == null ? void 0 : U.CREDIT) == null ? void 0 : te.at(0)) == null ? void 0 : z.balance) || 0, De = ((e = (a = (J = (F = i.collection) == null ? void 0 : F.CREDIT) == null ? void 0 : J.at(0)) == null ? void 0 : a.expiryBalance) == null ? void 0 : e.reduce(
1480
+ (ne, ge) => ne + ge.amount,
1481
+ 0
1482
+ )) || 0, Ne = ee(rt, 2), st = {
1483
+ ID: i._id.toString(),
1484
+ Name: ((b = i.name) == null ? void 0 : b.trim()) || "",
1485
+ Phone: ((B = i == null ? void 0 : i.phoneNumber) == null ? void 0 : B.trim()) || "",
1486
+ Email: ot || "",
1487
+ Gender: i.gender || "",
1488
+ CardNo: i.cardNo || "",
1489
+ Birthday: i != null && i.birthday ? c(i == null ? void 0 : i.birthday) : "",
1490
+ Credit: (Number(Ne) - Number(De)).toFixed(2),
1491
+ FreeCredit: Number(De.toFixed(2)),
1492
+ TotalCredit: Number(Ne),
1493
+ Exp: i != null && i.collection ? ((se = (X = (N = i.collection) == null ? void 0 : N.POINT) == null ? void 0 : X.at(0)) == null ? void 0 : se.balance) ?? 0 : 0,
1494
+ Point: i != null && i.collection ? ((h = (ye = (me = i.collection) == null ? void 0 : me.COIN) == null ? void 0 : ye.at(0)) == null ? void 0 : h.balance) ?? 0 : 0,
1495
+ Level: i != null && i.collection ? ((j = (oe = (Y = i.collection) == null ? void 0 : Y.TIER) == null ? void 0 : oe.at(0)) == null ? void 0 : j.balance) ?? 0 : 0,
1496
+ Tier: i != null && i.collection ? ((fe = (pe = (ue = i.collection) == null ? void 0 : ue.TIER) == null ? void 0 : pe.at(0)) == null ? void 0 : fe.balance) ?? 0 : 0,
1497
+ Titles: nt.join(","),
1498
+ ...at,
1499
+ TotalTransaction: i.stats.visitCount,
1500
+ AvgSpent: At(Number(i.stats.avgBillSize || 0)).toFormat(
1501
+ !1
1502
+ ),
1503
+ TotalSpent: i.stats.avgBillSize * i.stats.visitCount,
1504
+ LastVisit: c(i.stats.lastVisit),
1505
+ Feedback: ((Q = i.stats) == null ? void 0 : Q.feedbackCount) || 0,
1506
+ LastSeasonTierEarned: ((Z = i.stats) == null ? void 0 : Z.lastSeasonTierEarned) || 0,
1507
+ LastSeasonPointEarned: ((Ve = i.stats) == null ? void 0 : Ve.lastSeasonPointEarned) || 0,
1508
+ JoinedAt: c(i.joinAt || void 0),
1509
+ JoinedAtLocation: i.location && (($e = de.value.find((ne) => ne.value == i.location)) == null ? void 0 : $e.label) || "-",
1510
+ VisitFrequency: `${Number(
1511
+ Math.ceil(i.stats.avgVisitFrequency).toFixed(0)
1512
+ )}`
1513
+ };
1514
+ r.addRecord(st);
1515
+ }
1516
+ d.page++;
1517
+ }
1518
+ await pt(
1519
+ r.buildExcel(),
1520
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
1521
+ {
1522
+ bookType: "xlsx",
1523
+ bookSST: !1,
1524
+ type: "array"
1525
+ }
1526
+ ), d.page = 1;
1527
+ },
1528
+ {
1529
+ message: "Exporting member...",
1530
+ successMessage: "Member exported successfully"
1531
+ }
1532
+ );
1533
+ }
1534
+ return Ke(async () => {
1535
+ await f.readMembership(), await x.readLocations(), await k.read(), await x.readLocations(), await v();
1536
+ }), (r, l) => {
1537
+ const w = I("FmSearch"), T = I("FmButton"), O = I("FmSnackbar");
1538
+ return p(), A("div", null, [
1539
+ n("div", zo, [
1540
+ _(w, {
1541
+ class: "mt-4",
1542
+ modelValue: t(m).searchValue,
1543
+ "onUpdate:modelValue": [
1544
+ l[0] || (l[0] = (E) => t(m).searchValue = E),
1545
+ t(V)
1546
+ ],
1547
+ placeholder: "Search",
1548
+ collapsible: ""
1549
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1550
+ _(T, {
1551
+ icon: "ios_share",
1552
+ variant: "tertiary",
1553
+ onClick: M
1554
+ })
1555
+ ]),
1556
+ ze(_(O, {
1557
+ "z-index": 0,
1558
+ class: "!max-w-full my-16",
1559
+ title: "Info",
1560
+ description: "Current list is not up to date, please refresh table for latest data.",
1561
+ variant: "info",
1562
+ dismissable: "",
1563
+ onOnDismiss: l[1] || (l[1] = (E) => L.value = !1),
1564
+ action: "Refresh",
1565
+ onOnAction: W
1566
+ }, null, 512), [
1567
+ [je, t(L)]
1568
+ ]),
1569
+ _(Je, {
1570
+ loading: t(m).isLoading,
1571
+ "row-data": t(C),
1572
+ "row-count": t(m).totalRows,
1573
+ "column-defs": g,
1574
+ "shrink-at": !1,
1575
+ "page-count": t(m).pageCount,
1576
+ "page-index": t(m).pageIndex,
1577
+ "page-size": t(m).pageSize,
1578
+ onSortChange: t(u),
1579
+ onPageChange: l[2] || (l[2] = (E) => t(v)({ pageSize: E.pageSize, pageIndex: E.pageIndex })),
1580
+ onRowClick: l[3] || (l[3] = (E) => {
1581
+ var U;
1582
+ P.value = E.original, (U = t(D)) == null || U.showSheet();
1583
+ })
1584
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1585
+ t(P) ? (p(), R(Lo, {
1586
+ key: 0,
1587
+ ref_key: "sheetRef",
1588
+ ref: D,
1589
+ member: t(P),
1590
+ "onUpdate:member": ae
1591
+ }, null, 8, ["member"])) : ce("", !0)
1592
+ ]);
1593
+ };
1594
+ }
1595
+ });
1596
+ export {
1597
+ Fn as default
1598
+ };