@feedmepos/mf-connect 0.1.0-beta.45 → 0.1.0-beta.47

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