@feedmepos/mf-connect 0.1.0-beta.35 → 0.1.0-beta.37

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