@feedmepos/mf-connect 0.1.0-beta.34 → 0.1.0-beta.36

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