@feedmepos/mf-connect 0.1.14-prod → 0.1.16-prod

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 (89) hide show
  1. package/dist/{Analytic-MRp7gtO3.js → Analytic-9_JkMO2c.js} +18 -17
  2. package/dist/{App-BU3B2A-F.js → App-DfbUtaeM.js} +68 -64
  3. package/dist/Bin-BoolyqZn.js +165 -0
  4. package/dist/{Broadcast-DmciJlSU.js → Broadcast-8UwFqqzp.js} +8 -8
  5. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DJPOgBXj.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CjoVXqOG.js} +6 -7
  6. package/dist/{Card-Dq2cAgTi.js → Card-BFEc9Zgu.js} +78 -79
  7. package/dist/{Collections-B4x4VH1a.js → Collections-DqlqGVcv.js} +5 -5
  8. package/dist/{Credit-CVdT1KBU.js → Credit-BuKQEMU2.js} +8 -8
  9. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-BmjXu-U7.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-BjCVR7D4.js} +27 -27
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-A_uosv-g.js → EffectSheet.vue_vue_type_style_index_0_lang-DXBqS4zs.js} +8 -8
  11. package/dist/{Experience-CEeXWbue.js → Experience-BTf5f-Kb.js} +8 -8
  12. package/dist/{Game-mx5c5ZhV.js → Game-Ci_39vHg.js} +8 -8
  13. package/dist/{Index-DQ1qadwz.js → Index-8JLenrzT.js} +9 -9
  14. package/dist/{Marketing-CciBZijv.js → Marketing-XAmIlYCx.js} +5 -5
  15. package/dist/{Member-C51SlKxj.js → Member-Bvxgoep1.js} +4 -4
  16. package/dist/MemberList-BvX98Yt-.js +1596 -0
  17. package/dist/MemberTransactions-DJt3aJ-h.js +45 -0
  18. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-DZu24zwy.js → MessageInput.vue_vue_type_script_setup_true_lang-OFqra1ac.js} +45 -33
  19. package/dist/{Mission-LpCnpKYD.js → Mission-D_CqN5Es.js} +8 -8
  20. package/dist/{Overview-DxvOqUao.js → Overview-FRebjePW.js} +62 -63
  21. package/dist/{Point-BmI7y6h6.js → Point-C_amiOK4.js} +8 -8
  22. package/dist/{Promotion-MHaOqrwu.js → Promotion-qt_pE8uB.js} +9 -9
  23. package/dist/{Record-75BxMATe.js → Record-2eAijNwr.js} +6 -6
  24. package/dist/{Reward-8VfyFuEt.js → Reward-DLNijsC9.js} +35 -35
  25. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-D12_r-9X.js → RewardGroup.vue_vue_type_script_setup_true_lang-dsxs4d5k.js} +12 -13
  26. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-BIdBxvN7.js → RuleGroup.vue_vue_type_script_setup_true_lang-BZ4ORSgp.js} +14 -15
  27. package/dist/{Segment-I9FUibZy.js → Segment-QKuGmThT.js} +13 -13
  28. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-BGeR0-AG.js → SelectItems.vue_vue_type_script_setup_true_lang-C02QXf6B.js} +2 -2
  29. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-DXpzjbIh.js +147 -0
  30. package/dist/Setting-GTro0uCw.js +1877 -0
  31. package/dist/{Store-CQkGNSSm.js → Store-CTxmlEVr.js} +55 -56
  32. package/dist/{StoreRewards-DOtjveqw.js → StoreRewards-Bm9NXXH2.js} +12 -12
  33. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-Cf9IsQXS.js → StoreTransactions.vue_vue_type_script_setup_true_lang-CrxFaBDj.js} +321 -354
  34. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DPmeW62s.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-Cf2JpXND.js} +1 -1
  35. package/dist/{Tier-DAj_5abZ.js → Tier-CB64ZbLz.js} +20 -21
  36. package/dist/{Title-DryO4wcO.js → Title-62HEE-nU.js} +20 -21
  37. package/dist/{Transaction-DpibVFU-.js → Transaction-CK9Igmnp.js} +2 -2
  38. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-DoiPRPPo.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-DJB9g9bg.js} +6 -6
  39. package/dist/Voucher-CZLp6Mfd.js +353 -0
  40. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-DRnVggfC.js → VoucherEditor.vue_vue_type_script_setup_true_lang-DKunt5iP.js} +10 -10
  41. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-BzBcsSYS.js → ZodTextField.vue_vue_type_script_setup_true_lang-CP0wAVaD.js} +1 -1
  42. package/dist/{app-BoQTcBOD.js → app-BsOd2LLI.js} +651 -615
  43. package/dist/{app-BzPle2EI.js → app-D7g1W_8e.js} +1 -1
  44. package/dist/app.js +1 -1
  45. package/dist/{business-H9a63ymR.js → business-e0ErhqsW.js} +1 -1
  46. package/dist/{dto-BBLfD0Lh.js → campaign-CcRs_0FM.js} +610 -819
  47. package/dist/{campaign-CR-16mwD.js → campaign-CcdO3quq.js} +2 -2
  48. package/dist/{campaign.enum-DcaetYuk.js → campaign.enum-DSB0ntaX.js} +1 -1
  49. package/dist/{campaign.fn-BqGZqM77.js → campaign.fn-BSxLDscM.js} +133 -133
  50. package/dist/{collectible.enum-YKtiwQbt.js → collectible.enum-DR19JADq.js} +3 -3
  51. package/dist/{collection.fn-CI8lSAsC.js → collection.fn-Bm_oNhCa.js} +2 -2
  52. package/dist/dto-3LqyQCjQ.js +214 -0
  53. package/dist/{effect-36H79d0n.js → effect-BuC4ddqL.js} +1 -1
  54. package/dist/{email-addresses-drrACeqJ.js → email-addresses-FxQM5JQh.js} +1 -1
  55. package/dist/{export-BgnO3lJs.js → export-DB_vSJ5r.js} +5 -5
  56. package/dist/{helper-CcV9DZXq.js → helper-Czc_ykUT.js} +1 -1
  57. package/dist/index-0EgN5Vaf.js +115 -0
  58. package/dist/{index-Cidu1YZP.js → index-B-gmFyeP.js} +5 -5
  59. package/dist/{index-CB1CnEOn.js → index-C2Y3Z6cQ.js} +1 -1
  60. package/dist/{index-mgoYj6L9.js → index-CavK1FD8.js} +1 -1
  61. package/dist/{index-BEDXujqZ.js → index-DF7DfJ1p.js} +1 -1
  62. package/dist/{index-DydNNBhY.js → index-DJmQQbIZ.js} +29 -4
  63. package/dist/{index-CibFRBGu.js → index-DP1XHU5I.js} +6 -6
  64. package/dist/{index-BRTpdfj3.js → index-DTirkGj1.js} +2057 -1010
  65. package/dist/{index-ZycLk3NR.js → index-Dc_5fMdM.js} +1 -1
  66. package/dist/index-Dvp6UpsY.js +44 -0
  67. package/dist/{index-BPbhXWRp.js → index-KXIH9y_C.js} +12 -13
  68. package/dist/{index-DLAAi9ur.js → index-o3ez16Wf.js} +3 -3
  69. package/dist/{index.esm2017-QS_XhcBp.js → index.esm2017-DsCfyosK.js} +1 -1
  70. package/dist/{loading-LktVwV5k.js → loading-CsMKK-RP.js} +4 -4
  71. package/dist/{membership-7ETvXph3.js → membership-ChU9QHZQ.js} +6 -6
  72. package/dist/{money-BYszknw8.js → money-CG2aMqwR.js} +1 -1
  73. package/dist/{number-Dmd4vT4F.js → number-DOiTymUW.js} +1 -1
  74. package/dist/{objectid-BQtSeCVi.js → objectid-DEgIJB4V.js} +4 -4
  75. package/dist/{reward-DJGOX-D1.js → reward-bezIYRz1.js} +1 -1
  76. package/dist/{rule-D7jM4gdg.js → rule-BXvIZA60.js} +3 -3
  77. package/dist/{rule-builder-FO9UeYUJ.js → rule-builder-BD_t-4Oq.js} +1 -1
  78. package/dist/{template-C4Ddrpk1.js → template-CYa8Yqzb.js} +4 -4
  79. package/dist/{trigger-w7Q4qOMB.js → trigger-B2Ihm351.js} +13 -13
  80. package/dist/{usePagination-PH1OvyZM.js → usePagination-Dus-uVGw.js} +1 -1
  81. package/dist/{user-DRPXRVy2.js → user-BkIvuR0M.js} +1 -1
  82. package/dist/{vue-i18n-B49HKiTU.js → vue-i18n-BOO66JER.js} +112 -112
  83. package/package.json +1 -1
  84. package/dist/MemberList-D1x731cU.js +0 -1043
  85. package/dist/MemberTransactions-BpoTQHFQ.js +0 -38
  86. package/dist/Setting-B8V2I0EZ.js +0 -1871
  87. package/dist/Voucher-CSc0_dGX.js +0 -491
  88. package/dist/index-6RqtavHk.js +0 -1051
  89. package/dist/index-B5ii6hOh.js +0 -99
@@ -0,0 +1,1596 @@
1
+ import { defineComponent as be, computed as H, ref as G, resolveComponent as $, openBlock as u, createElementBlock as A, Fragment as q, createElementVNode as t, unref as e, createBlock as R, createCommentVNode as ce, createVNode as h, renderList as ie, withCtx as xe, createTextVNode as Fe, toDisplayString as V, 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-FxQM5JQh.js";
5
+ import { a as Ge, _ as He, w as pt } from "./usePagination-Dus-uVGw.js";
6
+ import "./index-C2Y3Z6cQ.js";
7
+ import { p as Pe, c as Oe, b as Re, u as We } from "./loading-CsMKK-RP.js";
8
+ import { u as $e, C as Ue, s as ft } from "./membership-ChU9QHZQ.js";
9
+ import { c as bt } from "./index-o3ez16Wf.js";
10
+ import { _ as Le } from "./lodash-B5I3zXaY.js";
11
+ import { D as yt } from "./type_drinks-D6jnpvwV.js";
12
+ import { b as gt, c as vt, d as xt, e as _t, f as ht } from "./index-DTirkGj1.js";
13
+ import { C as Ae } from "./collection.fn-Bm_oNhCa.js";
14
+ import { defineStore as St } from "pinia";
15
+ import { u as Je } from "./business-e0ErhqsW.js";
16
+ import { f as ee } from "./number-DOiTymUW.js";
17
+ import "./index-DP1XHU5I.js";
18
+ import "./index-KXIH9y_C.js";
19
+ import "./index-CavK1FD8.js";
20
+ import "./index-B-gmFyeP.js";
21
+ import { s as Ct } from "./index-CuvNtC_M.js";
22
+ import { B as wt, e as Ft } from "./export-DB_vSJ5r.js";
23
+ import { m as Me } from "./index-DJmQQbIZ.js";
24
+ import { o as Ce } from "./objectId-dwaoBfJX.js";
25
+ import { F as ke } from "./collectible.enum-DR19JADq.js";
26
+ import { g as Mt, b as Tt } from "./campaign-CcRs_0FM.js";
27
+ import { useRouter as Xe } from "vue-router";
28
+ import { m as le } from "./index-Dc_5fMdM.js";
29
+ import { t as kt } from "./index-Dvp6UpsY.js";
30
+ import { R as Qe } from "./app-BsOd2LLI.js";
31
+ import { t as At } from "./money-CG2aMqwR.js";
32
+ import { g as Et, a as $t, b as It } from "./user-BkIvuR0M.js";
33
+ const Vt = { class: "flex flex-col" }, Bt = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800 mb-8" }, "Member tiering", -1), Dt = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Member Card", -1), Nt = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Titles", -1), Yt = { key: 1 }, Pt = /* @__PURE__ */ t("div", { class: "flex flex-nowrap gap-4 items-center" }, [
34
+ /* @__PURE__ */ t("div", { class: "flex-1" }, "Title"),
35
+ /* @__PURE__ */ t("div", { class: "flex-1" }, "Expires in days"),
36
+ /* @__PURE__ */ t("div", { class: "w-24 h-1" })
37
+ ], -1), Ot = [
38
+ Pt
39
+ ], Rt = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, Ut = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, Lt = /* @__PURE__ */ be({
40
+ __name: "MemberStatsDialog",
41
+ props: {
42
+ member: {
43
+ type: Object,
44
+ required: !0
45
+ },
46
+ onSubmit: {
47
+ type: Function,
48
+ required: !0
49
+ }
50
+ },
51
+ setup(y) {
52
+ var de, ne, W, se;
53
+ const k = Ee(), p = $e(), x = y, r = H(
54
+ () => {
55
+ var c;
56
+ return (((c = x.member.collection) == null ? void 0 : c.TITLE) ?? []).reduce(
57
+ (f, M) => {
58
+ var w, T, O, E, U;
59
+ const s = p.sortedTitles.find(
60
+ (te) => te._id.toString() === M.collectible
61
+ );
62
+ if (!s) return f;
63
+ const l = [...M.expiryBalance ?? []].sort(
64
+ (te, z) => S(te.expiredAt).isAfter(S(z.expiredAt)) ? -1 : 1
65
+ );
66
+ return (w = l[0]) != null && w.expiredAt && S((T = l[0]) == null ? void 0 : T.expiredAt).isBefore(S()) || f.push({
67
+ _id: s._id,
68
+ name: s.name,
69
+ expiredAt: (O = l[0]) != null && O.expiredAt ? S((E = l[0]) == null ? void 0 : E.expiredAt).toISOString() : "",
70
+ expiresIn: S((U = l[0]) == null ? void 0 : U.expiredAt).diff(S(), "days")
71
+ }), f;
72
+ },
73
+ []
74
+ );
75
+ }
76
+ ), o = G({
77
+ cardNo: x.member.cardNo,
78
+ experience: ((ne = (de = x.member.collection) == null ? void 0 : de.POINT) == null ? void 0 : ne[0].balance) ?? 0,
79
+ tier: ((se = (W = x.member.collection) == null ? void 0 : W.TIER) == null ? void 0 : se[0].balance) ?? -1,
80
+ titles: r.value.map((c) => ({ expiredAt: c.expiresIn, id: c._id })) ?? void 0
81
+ }), v = H(
82
+ () => (p.sortedTitles ?? []).map((c) => ({
83
+ label: c.name,
84
+ value: c._id.toString(),
85
+ sublabel: r.value.some((f) => f._id === c._id) ? "Owned" : void 0
86
+ }))
87
+ ), d = H(() => (p.sortedTiers ?? []).map((c, f) => ({
88
+ label: c.name,
89
+ sublabel: `${c.option.from} - ${c.option.to}`,
90
+ from: c.option.from,
91
+ to: c.option.to,
92
+ value: f + 1
93
+ })));
94
+ function C() {
95
+ var M, s;
96
+ const c = ((M = d.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : M.from) ?? 0, f = (s = d.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : s.to;
97
+ o.value.experience = Math.min(
98
+ f ?? c,
99
+ Math.max(c, o.value.experience ?? 0)
100
+ );
101
+ }
102
+ const m = H(() => {
103
+ var M, s, l, w, T, O;
104
+ const c = ((s = (M = x.member.collection) == null ? void 0 : M.TIER) == null ? void 0 : s[0].balance) ?? -1, f = ((w = (l = x.member.collection) == null ? void 0 : l.POINT) == null ? void 0 : w[0].balance) ?? 0;
105
+ if (c != o.value.tier) return !0;
106
+ if (o.value.experience && o.value.experience != f) {
107
+ const E = ((T = d.value[c - 1]) == null ? void 0 : T.from) ?? 0, U = ((O = d.value[c - 1]) == null ? void 0 : O.to) ?? 0;
108
+ if (o.value.experience < E || U && o.value.experience > U)
109
+ return !0;
110
+ }
111
+ return !1;
112
+ });
113
+ function g(c) {
114
+ var f;
115
+ return (f = r.value.find((M) => M._id === c)) == null ? void 0 : f.expiresIn;
116
+ }
117
+ const I = H(() => {
118
+ const c = gt.safeParse(o.value);
119
+ return c.success ? void 0 : c.error.errors;
120
+ });
121
+ function D(c) {
122
+ var f, M;
123
+ return (M = (f = I.value) == null ? void 0 : f.find((s) => s.path.join(".") === c)) == null ? void 0 : M.message;
124
+ }
125
+ function L(c) {
126
+ var f;
127
+ return (f = I.value) == null ? void 0 : f.filter((M) => M.path.join(".").startsWith(c)).map((M) => M.message);
128
+ }
129
+ async function P() {
130
+ await x.onSubmit(o.value), k.close();
131
+ }
132
+ return (c, f) => {
133
+ var te, z;
134
+ const M = $("FmSelect"), s = $("FmStepperField"), l = $("FmTextField"), w = $("FmField"), T = $("FmFormGroup"), O = $("FmButton"), E = $("FmHelperText"), U = $("FmSpacer");
135
+ return u(), A(q, null, [
136
+ t("div", Vt, [
137
+ Bt,
138
+ e(d).length ? (u(), R(M, {
139
+ key: 0,
140
+ modelValue: e(o).tier,
141
+ "onUpdate:modelValue": [
142
+ f[0] || (f[0] = (F) => e(o).tier = F),
143
+ C
144
+ ],
145
+ label: "Member Tier",
146
+ items: e(d),
147
+ "helper-text": D("tier"),
148
+ "helper-state": D("tier") ? "error" : void 0
149
+ }, null, 8, ["modelValue", "items", "helper-text", "helper-state"])) : ce("", !0),
150
+ h(s, {
151
+ "model-value": e(o).experience ?? 0,
152
+ "onUpdate:modelValue": f[1] || (f[1] = (F) => e(o).experience = F),
153
+ label: "Member Experience",
154
+ "max-fraction-digits": 0,
155
+ "helper-text": D("experience"),
156
+ "helper-state": D("experience") ? "error" : void 0
157
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
158
+ Dt,
159
+ h(l, {
160
+ modelValue: e(o).cardNo,
161
+ "onUpdate:modelValue": f[2] || (f[2] = (F) => e(o).cardNo = F),
162
+ label: "Card number",
163
+ "helper-text": D("cardNo"),
164
+ "helper-state": D("cardNo") ? "error" : void 0
165
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
166
+ Nt,
167
+ (te = e(o).titles) != null && te.length ? (u(), A("div", Yt, Ot)) : ce("", !0),
168
+ (u(!0), A(q, null, ie(e(o).titles ?? [], (F, J) => (u(), A("div", { key: J }, [
169
+ t("div", Rt, [
170
+ e(r).some((a) => a._id === F.id) ? (u(), R(T, {
171
+ key: 1,
172
+ "model-value": "",
173
+ class: "flex-1"
174
+ }, {
175
+ default: xe(() => [
176
+ h(w, {
177
+ disabled: !0,
178
+ class: "text-fm-color-typo-secondary"
179
+ }, {
180
+ default: xe(() => {
181
+ var a;
182
+ return [
183
+ Fe(V((a = e(v).find((n) => n.value === F.id)) == null ? void 0 : a.label), 1)
184
+ ];
185
+ }),
186
+ _: 2
187
+ }, 1024)
188
+ ]),
189
+ _: 2
190
+ }, 1024)) : (u(), R(M, {
191
+ key: 0,
192
+ modelValue: F.id,
193
+ "onUpdate:modelValue": [(a) => F.id = a, (a) => F.expiredAt = g(a) ?? 1],
194
+ class: "flex-1",
195
+ items: e(v).filter(
196
+ (a) => {
197
+ var n;
198
+ return !((n = e(o).titles) != null && n.map((b) => b.id).includes(a.value)) || F.id === a.value;
199
+ }
200
+ )
201
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "items"])),
202
+ h(s, {
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
+ h(O, {
210
+ class: "w-24 h-24",
211
+ icon: "close",
212
+ variant: "tertiary",
213
+ onClick: (a) => {
214
+ var n;
215
+ return (n = e(o).titles) == null ? void 0 : n.splice(J, 1);
216
+ }
217
+ }, null, 8, ["onClick"])
218
+ ]),
219
+ (u(!0), A(q, null, ie(L(`titles.${J}`), (a, n) => (u(), R(E, {
220
+ key: n,
221
+ class: "items-center",
222
+ state: "error",
223
+ text: a.toString()
224
+ }, null, 8, ["text"]))), 128))
225
+ ]))), 128)),
226
+ e(v).length && (((z = e(o).titles) == null ? void 0 : z.length) ?? 0) < e(v).length ? (u(), R(O, {
227
+ key: 2,
228
+ icon: "add",
229
+ label: "Give title",
230
+ variant: "plain",
231
+ onClick: f[3] || (f[3] = (F) => {
232
+ var J;
233
+ return e(o).titles = [
234
+ ...e(o).titles ?? [],
235
+ {
236
+ id: ((J = e(v).find(
237
+ (a) => {
238
+ var n;
239
+ return !((n = e(o).titles) != null && n.map((b) => b.id).includes(a.value));
240
+ }
241
+ )) == null ? void 0 : J.value) || e(v)[0].value,
242
+ expiredAt: 0
243
+ }
244
+ ];
245
+ })
246
+ })) : ce("", !0)
247
+ ]),
248
+ t("div", Ut, [
249
+ ze(h(E, {
250
+ state: "warning",
251
+ text: "Updating member will cause tier to change"
252
+ }, null, 512), [
253
+ [je, e(m)]
254
+ ]),
255
+ h(U),
256
+ h(O, {
257
+ variant: "secondary",
258
+ label: "Cancel",
259
+ size: "md",
260
+ onClick: f[4] || (f[4] = (F) => e(k).close())
261
+ }),
262
+ h(O, {
263
+ disabled: !!e(I),
264
+ variant: "primary",
265
+ label: "Submit",
266
+ size: "md",
267
+ onClick: P
268
+ }, null, 8, ["disabled"])
269
+ ])
270
+ ], 64);
271
+ };
272
+ }
273
+ }), zt = { class: "fm-typo-en-title-sm-800" }, jt = { class: "space-y-16" }, qt = { class: "flex flex-nowrap gap-8 items-center justify-end pt-24 w-full" }, Kt = /* @__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(), p = y, x = G({
285
+ amount: 1,
286
+ day: 1,
287
+ remark: void 0
288
+ }), r = G(!0), o = H(() => Ae.formattedType(p.type.toUpperCase()));
289
+ function v(m) {
290
+ r.value = m, !m && p.type === "coin" && (x.value.day = void 0);
291
+ }
292
+ async function d() {
293
+ if (p.action === "send") {
294
+ const m = x.value.day ? `, expire in ${x.value.day} days` : "";
295
+ Pe.confirm(
296
+ `Are you sure to send ${x.value.amount} ${o.value.toLowerCase()}${m}? This action cannot be reversed.`
297
+ ).then(async (g) => {
298
+ g && await p.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 (m) => {
304
+ m && await p.onSubmit(x.value);
305
+ });
306
+ }
307
+ const C = H(() => {
308
+ const g = (p.action === "send" ? p.type === "coin" ? vt : xt : p.type === "coin" ? _t : ht).safeParse(x.value);
309
+ return g.success == !1 ? g.error.flatten().fieldErrors : void 0;
310
+ });
311
+ return (m, g) => {
312
+ const I = $("FmStepperField"), D = $("FmSwitch"), L = $("FmTextarea"), P = $("FmButton"), de = $("FmCard");
313
+ return u(), R(de, { class: "flex flex-col gap-16 p-16" }, {
314
+ default: xe(() => {
315
+ var ne, W, se, c, f, M;
316
+ return [
317
+ t("div", zt, V(p.action == "send" ? "Send" : "Deduct") + " " + V(e(Ue)[p.type.toUpperCase()].name), 1),
318
+ Fe(" " + V(e(C)) + " ", 1),
319
+ t("div", jt, [
320
+ h(I, {
321
+ modelValue: e(x).amount,
322
+ "onUpdate:modelValue": g[0] || (g[0] = (s) => e(x).amount = s),
323
+ label: `${e(Ue)[p.type.toUpperCase()].name} amount`,
324
+ "is-currency": !0,
325
+ "max-fraction-digits": 2,
326
+ "helper-state": (ne = e(C)) != null && ne.amount ? "error" : void 0,
327
+ "helper-text": (se = (W = e(C)) == null ? void 0 : W.amount) == null ? void 0 : se[0]
328
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"]),
329
+ y.action === "send" && p.type === "coin" ? (u(), R(D, {
330
+ key: 0,
331
+ "model-value": e(r),
332
+ label: `${e(o)} expires`,
333
+ "label-placement": "right",
334
+ "onUpdate:modelValue": g[1] || (g[1] = (s) => v(s))
335
+ }, null, 8, ["model-value", "label"])) : ce("", !0),
336
+ y.action === "send" && e(r) ? (u(), R(I, {
337
+ key: 1,
338
+ modelValue: e(x).day,
339
+ "onUpdate:modelValue": g[2] || (g[2] = (s) => e(x).day = s),
340
+ label: `${e(o)} expires in`,
341
+ "max-fraction-digits": 0,
342
+ "append-text": "day(s)",
343
+ max: 9999,
344
+ min: 0,
345
+ "helper-state": (c = e(C)) != null && c.day ? "error" : void 0,
346
+ "helper-text": (M = (f = e(C)) == null ? void 0 : f.day) == null ? void 0 : M[0]
347
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : ce("", !0),
348
+ h(L, {
349
+ modelValue: e(x).remark,
350
+ "onUpdate:modelValue": g[3] || (g[3] = (s) => e(x).remark = s),
351
+ label: "Remark"
352
+ }, null, 8, ["modelValue"])
353
+ ]),
354
+ t("div", qt, [
355
+ h(P, {
356
+ variant: "secondary",
357
+ label: "Cancel",
358
+ size: "md",
359
+ onClick: g[4] || (g[4] = (s) => e(k).close())
360
+ }),
361
+ h(P, {
362
+ disabled: !!e(C),
363
+ variant: "primary",
364
+ label: "Submit",
365
+ size: "md",
366
+ onClick: g[5] || (g[5] = async () => d())
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 p = await ft.readAll({
379
+ limit: 1e3,
380
+ skip: 0,
381
+ sortBy: "_id",
382
+ descending: !0
383
+ });
384
+ y.value = p.resources;
385
+ }
386
+ return {
387
+ segments: y,
388
+ read: k
389
+ };
390
+ });
391
+ class Gt extends wt {
392
+ }
393
+ const Ht = { class: "border border-fm-color-neutral-gray-100 rounded-lg p-16" }, Wt = { class: "hidden xs:flex items-center justify-end" }, Jt = { class: "flex items-center justify-between mb-4" }, Xt = { class: "flex items-center justify-between gap-x-8" }, Qt = { class: "fm-typo-en-body-lg-600" }, Zt = { class: "px-4 py-0.5 rounded-md bg-fm-color-neutral-gray-100 fm-typo-en-body-md-600" }, eo = { 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, p = G({
423
+ search: ""
424
+ }), x = G(!1), { tableMeta: r, rowData: o, onSort: v, debouncedFetchData: d, onSearch: C } = Ge(async (g) => {
425
+ const I = {
426
+ ...p.value,
427
+ ...k.filters
428
+ };
429
+ return await Me.readCollectionsByMemberId(
430
+ k.member._id.toString(),
431
+ g,
432
+ I
433
+ );
434
+ });
435
+ qe(
436
+ p,
437
+ () => {
438
+ d();
439
+ },
440
+ { deep: !0 }
441
+ );
442
+ async function m() {
443
+ try {
444
+ x.value = !0;
445
+ const g = {
446
+ ...p.value,
447
+ ...k.filters
448
+ };
449
+ await Ft({
450
+ exporter: new Gt(),
451
+ readFunction: (I) => Me.readCollectionsByMemberId(
452
+ k.member._id.toString(),
453
+ I,
454
+ g
455
+ ),
456
+ transformRecord: k.transformExportRecord,
457
+ filename: `${k.member._id.toString()}-${k.title.replace(" ", "-").toLowerCase()}`
458
+ });
459
+ } catch (g) {
460
+ console.error(g);
461
+ } finally {
462
+ x.value = !1;
463
+ }
464
+ }
465
+ return lt(async () => {
466
+ await d();
467
+ }), (g, I) => {
468
+ const D = $("FmSearch"), L = $("FmButton");
469
+ return u(), A("div", Ht, [
470
+ t("div", Wt, [
471
+ h(D, {
472
+ class: "hidden xs:flex",
473
+ modelValue: e(p).search,
474
+ "onUpdate:modelValue": [
475
+ I[0] || (I[0] = (P) => e(p).search = P),
476
+ e(C)
477
+ ],
478
+ placeholder: "Search",
479
+ collapsible: ""
480
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
481
+ y.withExport ? (u(), R(L, {
482
+ key: 0,
483
+ icon: "ios_share",
484
+ variant: "tertiary",
485
+ onClick: m
486
+ })) : ce("", !0)
487
+ ]),
488
+ t("div", Jt, [
489
+ t("div", Xt, [
490
+ t("div", Qt, V(k.title), 1),
491
+ t("div", Zt, V(e(r).totalRows), 1)
492
+ ]),
493
+ t("div", eo, [
494
+ h(D, {
495
+ modelValue: e(p).search,
496
+ "onUpdate:modelValue": [
497
+ I[1] || (I[1] = (P) => e(p).search = P),
498
+ e(C)
499
+ ],
500
+ placeholder: "Search"
501
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
502
+ y.withExport ? (u(), R(L, {
503
+ key: 0,
504
+ icon: "ios_share",
505
+ variant: "tertiary",
506
+ onClick: m
507
+ })) : ce("", !0)
508
+ ])
509
+ ]),
510
+ h(He, {
511
+ loading: e(r).isLoading,
512
+ "row-data": e(o),
513
+ "row-count": e(r).totalRows,
514
+ "column-defs": y.columns,
515
+ "page-count": e(r).pageCount,
516
+ "page-index": e(r).pageIndex,
517
+ "page-size": e(r).pageSize,
518
+ "shrink-at": !1,
519
+ onSortChange: e(v),
520
+ onPageChange: I[2] || (I[2] = (P) => e(d)({
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
+ }), to = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Voucher Collections", -1), oo = /* @__PURE__ */ be({
529
+ __name: "MemberVouchers",
530
+ props: {
531
+ member: {
532
+ type: Object,
533
+ required: !0
534
+ }
535
+ },
536
+ setup(y) {
537
+ const k = y, p = [
538
+ {
539
+ header: "Voucher title",
540
+ meta: {
541
+ maxWidth: "300px"
542
+ },
543
+ cell(o) {
544
+ var v;
545
+ return K(
546
+ "div",
547
+ { class: "text-ellipsis truncate" },
548
+ ((v = o.row.original.pf_collectible) == null ? void 0 : v.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 d, C, m, g;
563
+ const v = (C = (d = o.row.original.expiryBalance) == null ? void 0 : d[0]) != null && C.expiredAt ? S((g = (m = o.row.original.expiryBalance) == null ? void 0 : m[0]) == null ? void 0 : g.expiredAt).format(
564
+ "D MMM YYYY"
565
+ ) : "-";
566
+ return K("div", {}, v);
567
+ },
568
+ enableSorting: !0
569
+ },
570
+ {
571
+ header: "Transfer open",
572
+ accessorFn: (o) => {
573
+ var v, d, C;
574
+ return Ct((C = (d = (v = o.pf_collectible) == null ? void 0 : v.options) == null ? void 0 : d.enableTransfer) == null ? void 0 : C.toString());
575
+ },
576
+ enableSorting: !1
577
+ }
578
+ ], x = (o) => ({
579
+ type: ke.enum.VOUCHER,
580
+ isActive: o
581
+ }), r = (o) => {
582
+ var v, d, C, m, g, I, D;
583
+ return {
584
+ CollectionID: o._id,
585
+ Title: (v = o.pf_collectible) == null ? void 0 : v.name,
586
+ ClaimedAt: S(Ce(o._id.toString())).format(
587
+ "D MMM YYYY, hh:mmA"
588
+ ),
589
+ ExpiredAt: (C = (d = o.expiryBalance) == null ? void 0 : d[0]) != null && C.expiredAt ? S((g = (m = o.expiryBalance) == null ? void 0 : m[0]) == null ? void 0 : g.expiredAt).format("D MMM YYYY") : "",
590
+ TransferOpen: ((D = (I = o.pf_collectible) == null ? void 0 : I.options) == null ? void 0 : D.enableTransfer) || !1
591
+ };
592
+ };
593
+ return (o, v) => (u(), A(q, null, [
594
+ to,
595
+ h(Te, {
596
+ member: k.member,
597
+ columns: p,
598
+ title: "Active voucher",
599
+ filters: x(!0),
600
+ withExport: !0,
601
+ transformExportRecord: r
602
+ }, null, 8, ["member", "filters"]),
603
+ h(Te, {
604
+ member: k.member,
605
+ columns: p,
606
+ title: "Past voucher",
607
+ filters: x(!1),
608
+ withExport: !0,
609
+ transformExportRecord: r
610
+ }, null, 8, ["member", "filters"])
611
+ ], 64));
612
+ }
613
+ }), ao = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Mission", -1), no = /* @__PURE__ */ be({
614
+ __name: "MemberMissions",
615
+ props: {
616
+ member: {
617
+ type: Object,
618
+ required: !0
619
+ }
620
+ },
621
+ setup(y) {
622
+ const k = y, p = [
623
+ {
624
+ header: "Mission title",
625
+ meta: {
626
+ maxWidth: "300px"
627
+ },
628
+ cell(r) {
629
+ var o;
630
+ return K(
631
+ "div",
632
+ { class: "text-ellipsis truncate" },
633
+ ((o = r.row.original.pf_campaign) == null ? void 0 : o.name) || "Deleted Campaign"
634
+ );
635
+ },
636
+ enableSorting: !1
637
+ },
638
+ {
639
+ header: "Type",
640
+ accessorFn: (r) => {
641
+ var o, v, d;
642
+ return Oe.title(((d = (v = (o = r == null ? void 0 : r.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : v.mission) == null ? void 0 : d.type) || "-");
643
+ },
644
+ enableSorting: !1
645
+ },
646
+ {
647
+ header: "Status",
648
+ cell(r) {
649
+ if (r.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
+ }, v = Mt(
656
+ r.row.original.pf_campaign
657
+ ), C = r.row.original.balance === r.row.original.pf_collectible.extras.mission.end && v === "active" ? "completed" : v;
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: (r) => r != null && r.pf_campaign ? Tt(r.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: (r) => {
685
+ var o, v, d;
686
+ return ((d = (v = (o = r == null ? void 0 : r.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : v.mission) == null ? void 0 : d.end) ?? 0;
687
+ },
688
+ enableSorting: !1
689
+ }
690
+ ], x = {
691
+ type: ke.enum.STAMP
692
+ };
693
+ return (r, o) => (u(), A(q, null, [
694
+ ao,
695
+ h(Te, {
696
+ member: k.member,
697
+ columns: p,
698
+ title: "Mission",
699
+ filters: x
700
+ }, null, 8, ["member"])
701
+ ], 64));
702
+ }
703
+ }), so = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Game program", -1), ro = /* @__PURE__ */ be({
704
+ __name: "MemberGames",
705
+ props: {
706
+ member: {
707
+ type: Object,
708
+ required: !0
709
+ }
710
+ },
711
+ setup(y) {
712
+ const k = y, p = [
713
+ {
714
+ header: "Game title",
715
+ meta: {
716
+ maxWidth: "300px"
717
+ },
718
+ cell(r) {
719
+ var o;
720
+ return K(
721
+ "div",
722
+ { class: "text-ellipsis truncate" },
723
+ ((o = r.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: (r) => S(Ce(r._id.toString())).format("D MMM YYYY"),
732
+ enableSorting: !1
733
+ },
734
+ {
735
+ header: "Expired at",
736
+ cell(r) {
737
+ var v, d, C, m;
738
+ const o = (d = (v = r.row.original.expiryBalance) == null ? void 0 : v[0]) != null && d.expiredAt ? S((m = (C = r.row.original.expiryBalance) == null ? void 0 : C[0]) == null ? void 0 : m.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 = (r) => ({
751
+ type: ke.enum.GAME,
752
+ isActive: r
753
+ });
754
+ return (r, o) => (u(), A(q, null, [
755
+ so,
756
+ h(Te, {
757
+ member: k.member,
758
+ columns: p,
759
+ title: "Active game token",
760
+ filters: x(!0)
761
+ }, null, 8, ["member", "filters"])
762
+ ], 64));
763
+ }
764
+ }), io = { class: "flex flex-col flex-nowrap gap-y-24 max-h-full" }, lo = { class: "grid md:grid-cols-2 lg:grid-cols-2 gap-x-36 gap-y-24" }, co = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Profile Information", -1), mo = { class: "space-y-16" }, uo = { class: "flex gap-16 items-center" }, po = { class: "flex-auto" }, fo = /* @__PURE__ */ t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1), bo = { class: "fm-typo-en-body-md-600" }, yo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, go = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vo = { class: "fm-typo-en-body-md-800" }, xo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _o = { class: "fm-typo-en-body-md-600" }, ho = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, So = { class: "fm-typo-en-body-md-800" }, Co = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Activities", -1), wo = { class: "gap-16 grid grid-cols-1" }, Fo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Mo = { class: "fm-typo-en-body-md-600" }, To = /* @__PURE__ */ t("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1), ko = { 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" }, Ao = { class: "flex justify-between mb-16" }, Eo = { class: "fm-typo-en-title-sm-600" }, $o = ["onClick"], Io = { class: "flex flex-col gap-y-16" }, Vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bo = { class: "fm-typo-en-body-md-600" }, Do = { class: "space-y-8" }, No = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1), Yo = {
765
+ key: 0,
766
+ class: "space-x-8"
767
+ }, Po = {
768
+ key: 1,
769
+ class: "text-fm-color-typo-secondary"
770
+ }, Oo = /* @__PURE__ */ t("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1), Ro = { class: "space-y-8" }, Uo = /* @__PURE__ */ t("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1), Lo = ["src"], zo = { class: "fm-typo-en-body-md-600" }, jo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, qo = {
771
+ key: 1,
772
+ class: "text-fm-color-typo-secondary"
773
+ }, Ko = {
774
+ key: 1,
775
+ class: "space-y-24"
776
+ }, Go = { class: "space-y-8" }, Ho = /* @__PURE__ */ t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1), Wo = { class: "fm-typo-en-title-md-800" }, Jo = { class: "space-y-4" }, Xo = /* @__PURE__ */ t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1), Qo = { class: "fm-typo-en-body-md-600" }, Zo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, ea = { class: "space-y-8" }, ta = /* @__PURE__ */ t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1), oa = { class: "fm-typo-en-title-md-800" }, aa = { class: "space-y-4" }, na = /* @__PURE__ */ t("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1), sa = { class: "fm-typo-en-body-md-600" }, ra = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, ia = /* @__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: p }) {
786
+ const x = Xe(), r = $e(), o = Je(), v = Ze(), d = Ee(), { minor: C } = We, m = y, g = p, I = H(() => o.locations.map((a) => ({
787
+ label: a.name,
788
+ value: a._id
789
+ }))), D = H(() => (m.member.segment || []).map((a) => {
790
+ var n;
791
+ return ((n = v.segments.find((b) => b._id === a)) == null ? void 0 : n.name) || "";
792
+ }).filter(Boolean)), L = [
793
+ {
794
+ label: "Loyalty",
795
+ stats: [
796
+ {
797
+ label: "Experiences",
798
+ getter: (a) => {
799
+ var n, b, B;
800
+ return ee(((B = (b = (n = a.collection) == null ? void 0 : n.POINT) == null ? void 0 : b[0]) == null ? void 0 : B.balance) ?? 0, 2);
801
+ }
802
+ },
803
+ {
804
+ label: "Credits",
805
+ getter: (a) => {
806
+ var n, b, B;
807
+ return ee(((B = (b = (n = a.collection) == null ? void 0 : n.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 n, b;
845
+ return ee(
846
+ ((b = (n = a.collection) == null ? void 0 : n.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 n = [];
867
+ for (let b = 0; b < L.length; b += 3)
868
+ n.push(L.slice(b, b + 3));
869
+ return n;
870
+ })();
871
+ async function ne(a, n) {
872
+ switch (a.stopPropagation(), n) {
873
+ case "Store bundle":
874
+ await x.push({
875
+ name: Qe["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
876
+ params: { id: m.member._id.toString() },
877
+ query: { tab: "store" }
878
+ });
879
+ break;
880
+ default:
881
+ F.value = z.find((b) => b.label === n) || z[0];
882
+ break;
883
+ }
884
+ }
885
+ async function W(a, n) {
886
+ d.open({
887
+ title: "",
888
+ dialogComponent: Kt,
889
+ dialogComponentProps: {
890
+ type: a,
891
+ action: n,
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}-${n}`, X = B[N];
901
+ X && await X(m.member._id, b), g("update:member"), d.close();
902
+ },
903
+ {
904
+ message: `Adjusting ${Ae.formattedType(
905
+ a.toUpperCase()
906
+ ).toLowerCase()}`,
907
+ successMessage: `${b.amount} ${Ae.formattedType(
908
+ a.toUpperCase()
909
+ ).toLowerCase()} ${n} ${n == "send" ? "to" : "from"} ${m.member.phoneNumber}`
910
+ }
911
+ );
912
+ }
913
+ }
914
+ });
915
+ }
916
+ async function se() {
917
+ d.open({
918
+ title: "Update member statistics",
919
+ contentComponent: Lt,
920
+ contentComponentProps: {
921
+ member: m.member,
922
+ onSubmit: async (a) => {
923
+ await C(
924
+ async () => {
925
+ await le.updateMember(m.member._id, a), g("update:member"), d.close();
926
+ },
927
+ {
928
+ message: "Updating member stats",
929
+ successMessage: `Updated member ${m.member.phoneNumber} stats successfully`
930
+ }
931
+ );
932
+ }
933
+ }
934
+ });
935
+ }
936
+ const c = [
937
+ {
938
+ label: "Mobile No.",
939
+ key: "phoneNumber"
940
+ },
941
+ {
942
+ label: "Tier",
943
+ getter: (a) => {
944
+ var re, me, ye, _, Y;
945
+ const n = (((me = Le.first((re = m.member.collection) == null ? void 0 : re.TIER)) == null ? void 0 : me.balance) || 0) - 1, b = M.value.name, B = ((_ = (ye = a.collection) == null ? void 0 : ye.POINT) == null ? void 0 : _[0].balance) ?? 0, N = r.sortedTiers[n + 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
+ ], f = [
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 n;
966
+ return a != null && a.location && ((n = I.value.find((b) => b.value == a.location)) == null ? void 0 : n.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 = m.member.collection) == null ? void 0 : b.TIER)) == null ? void 0 : B.balance) || 0) - 1, n = r.sortedTiers[a];
1005
+ return { name: (n == null ? void 0 : n.name) || "-", tier: a, config: n };
1006
+ }), s = H(() => {
1007
+ var a;
1008
+ return (((a = m.member.collection) == null ? void 0 : a.TITLE) || []).map((n) => {
1009
+ var B, N, X;
1010
+ const b = (B = r.sortedTitles) == null ? void 0 : B.find(
1011
+ (re) => re._id == n.collectible
1012
+ );
1013
+ return {
1014
+ name: b == null ? void 0 : b.name,
1015
+ expiredAt: (X = (N = n.expiryBalance) == null ? void 0 : N.at(-1)) == null ? void 0 : X.expiredAt,
1016
+ collectible: b
1017
+ };
1018
+ }).filter(
1019
+ (n) => n.expiredAt ? S(n.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, n) => a + n.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
+ m.member._id.toString(),
1054
+ ke.enum.VOUCHER
1055
+ ), T.value = await kt.readPurchaseCountByMember(
1056
+ m.member._id.toString()
1057
+ ), l.value = await Me.readMissionCountByMemberId(
1058
+ m.member._id.toString()
1059
+ );
1060
+ };
1061
+ return Ke(async () => {
1062
+ await r.readMembership(), await J(), o.locations.length || await o.readLocations();
1063
+ }), qe(E, async () => {
1064
+ await J();
1065
+ }), k({
1066
+ showSheet: U,
1067
+ hideSheet: te
1068
+ }), (a, n) => {
1069
+ const b = $("FmTabs"), B = $("FmAvatar"), N = $("FmButton"), X = $("FmIcon"), re = $("FmChip"), me = $("FmCard"), ye = $("FmSideSheet");
1070
+ return u(), R(ye, {
1071
+ modelValue: e(E),
1072
+ "onUpdate:modelValue": n[5] || (n[5] = (_) => ct(E) ? E.value = _ : null),
1073
+ header: "Member Detail",
1074
+ "dismiss-away": "",
1075
+ "close-button": !0,
1076
+ "max-width": 1100
1077
+ }, {
1078
+ "side-sheet-footer": xe(() => []),
1079
+ default: xe(() => [
1080
+ t("div", io, [
1081
+ t("div", null, [
1082
+ h(b, {
1083
+ "model-value": e(F).value,
1084
+ items: z,
1085
+ class: "overflow-x-auto",
1086
+ "onUpdate:modelValue": n[0] || (n[0] = (_) => F.value = z.find((Y) => Y.value === _))
1087
+ }, null, 8, ["model-value"])
1088
+ ]),
1089
+ e(F).value == "overview" ? (u(), A(q, { key: 0 }, [
1090
+ t("div", lo, [
1091
+ t("div", null, [
1092
+ co,
1093
+ t("div", mo, [
1094
+ t("div", uo, [
1095
+ h(B, {
1096
+ name: y.member.photoUrl ? void 0 : y.member.name,
1097
+ src: y.member.photoUrl || void 0
1098
+ }, null, 8, ["name", "src"]),
1099
+ t("div", po, [
1100
+ fo,
1101
+ t("div", bo, V(y.member.name), 1),
1102
+ t("div", yo, V(y.member._id), 1),
1103
+ t("div", go, [
1104
+ Fe(" Member Card: "),
1105
+ t("span", vo, V(y.member.cardNo ? y.member.cardNo : "-"), 1)
1106
+ ])
1107
+ ]),
1108
+ h(N, {
1109
+ variant: "tertiary",
1110
+ icon: "settings",
1111
+ onClick: se
1112
+ })
1113
+ ]),
1114
+ (u(), A(q, null, ie(c, (_, Y) => t("div", { key: Y }, [
1115
+ t("div", xo, V(_.label), 1),
1116
+ t("div", _o, V(_.key ? y.member[_.key] : _.getter(y.member)), 1)
1117
+ ])), 64)),
1118
+ t("div", ho, [
1119
+ Fe(" Referral Code: "),
1120
+ t("span", So, V(y.member.referralCode ? y.member.referralCode : "-"), 1)
1121
+ ])
1122
+ ])
1123
+ ]),
1124
+ t("div", null, [
1125
+ Co,
1126
+ t("div", wo, [
1127
+ (u(), A(q, null, ie(f, (_) => t("div", {
1128
+ key: _.key
1129
+ }, [
1130
+ t("div", Fo, V(_.label), 1),
1131
+ t("div", Mo, V(_.key ? m.member.stats[_.key] || "-" : _.getter(y.member)), 1)
1132
+ ])), 64))
1133
+ ])
1134
+ ])
1135
+ ]),
1136
+ To,
1137
+ (u(!0), A(q, null, ie(e(de), (_) => (u(), A("div", ko, [
1138
+ (u(!0), A(q, null, ie(_, (Y, oe) => (u(), A("div", { key: oe }, [
1139
+ t("div", {
1140
+ class: dt(oe !== 0 ? "pt-12 md:pt-0 lg:pt-0 md:pl-12 lg:pl-12" : "")
1141
+ }, [
1142
+ t("div", Ao, [
1143
+ t("div", Eo, V(Y.label), 1),
1144
+ t("button", {
1145
+ onClick: (j) => ne(j, Y.label)
1146
+ }, [
1147
+ h(X, {
1148
+ name: "chevron_right",
1149
+ outline: "",
1150
+ size: "md"
1151
+ })
1152
+ ], 8, $o)
1153
+ ]),
1154
+ t("div", Io, [
1155
+ (u(!0), A(q, null, ie(Y.stats, (j) => (u(), A("div", {
1156
+ key: j.key
1157
+ }, [
1158
+ t("div", Vo, V(j.label), 1),
1159
+ t("div", Bo, V(j.getter(y.member)), 1)
1160
+ ]))), 128))
1161
+ ])
1162
+ ], 2)
1163
+ ]))), 128))
1164
+ ]))), 256)),
1165
+ t("div", Do, [
1166
+ No,
1167
+ e(D).length ? (u(), A("div", Yo, [
1168
+ (u(!0), A(q, null, ie(e(D), (_) => (u(), R(re, {
1169
+ label: _.toString()
1170
+ }, null, 8, ["label"]))), 256))
1171
+ ])) : (u(), A("div", Po, "No titles"))
1172
+ ]),
1173
+ Oo,
1174
+ t("div", Ro, [
1175
+ Uo,
1176
+ e(s).length ? (u(!0), A(q, { key: 0 }, ie(e(s).filter((_) => _.collectible), (_) => (u(), A("div", {
1177
+ class: "flex items-center gap-x-8 h-48",
1178
+ key: _.name
1179
+ }, [
1180
+ t("img", {
1181
+ src: _.collectible.image || e(yt),
1182
+ class: "aspect-square h-full object-contain"
1183
+ }, null, 8, Lo),
1184
+ t("div", null, [
1185
+ t("div", zo, V(_.name), 1),
1186
+ t("div", jo, " Expired on " + V(e(S)(_.expiredAt).format("MMM D, Y")), 1)
1187
+ ])
1188
+ ]))), 128)) : (u(), A("div", qo, "No titles"))
1189
+ ])
1190
+ ], 64)) : e(F).value == "loyalty" ? (u(), A("div", Ko, [
1191
+ h(me, {
1192
+ class: "p-16 space-y-24",
1193
+ variant: "outlined"
1194
+ }, {
1195
+ default: xe(() => {
1196
+ var _, Y, oe, j, ue, pe, fe;
1197
+ return [
1198
+ t("div", Go, [
1199
+ Ho,
1200
+ t("div", Wo, V(((oe = (Y = (_ = y.member.collection) == null ? void 0 : _.CREDIT) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1201
+ ]),
1202
+ t("div", Jo, [
1203
+ Xo,
1204
+ t("div", Qo, V(((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 && e(S)(Z.expiredAt).isAfter(e(S)()) && e(S)(Z.expiredAt).isBefore(e(S)().add(30, "days")) ? Q + Z.amount : Q,
1206
+ 0
1207
+ )) ?? 0), 1)
1208
+ ]),
1209
+ t("div", Zo, [
1210
+ h(N, {
1211
+ label: "Add credit",
1212
+ icon: "add",
1213
+ variant: "plain",
1214
+ onClick: n[1] || (n[1] = (Q) => W("credit", "send"))
1215
+ }),
1216
+ h(N, {
1217
+ label: "Deduct credit",
1218
+ icon: "remove",
1219
+ variant: "plain",
1220
+ onClick: n[2] || (n[2] = (Q) => W("credit", "deduct"))
1221
+ })
1222
+ ])
1223
+ ];
1224
+ }),
1225
+ _: 1
1226
+ }),
1227
+ h(me, {
1228
+ class: "p-16 space-y-24",
1229
+ variant: "outlined"
1230
+ }, {
1231
+ default: xe(() => {
1232
+ var _, Y, oe, j, ue, pe, fe;
1233
+ return [
1234
+ t("div", ea, [
1235
+ ta,
1236
+ t("div", oa, V(((oe = (Y = (_ = y.member.collection) == null ? void 0 : _.COIN) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1237
+ ]),
1238
+ t("div", aa, [
1239
+ na,
1240
+ t("div", sa, V(((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 && e(S)(Z.expiredAt).isAfter(e(S)()) && e(S)(Z.expiredAt).isBefore(e(S)().add(30, "days")) ? Q + Z.amount : Q,
1242
+ 0
1243
+ )) ?? 0), 1)
1244
+ ]),
1245
+ t("div", ra, [
1246
+ h(N, {
1247
+ label: "Add point",
1248
+ icon: "add",
1249
+ variant: "plain",
1250
+ onClick: n[3] || (n[3] = (Q) => W("coin", "send"))
1251
+ }),
1252
+ h(N, {
1253
+ label: "Deduct point",
1254
+ icon: "remove",
1255
+ variant: "plain",
1256
+ onClick: n[4] || (n[4] = (Q) => W("coin", "deduct"))
1257
+ })
1258
+ ])
1259
+ ];
1260
+ }),
1261
+ _: 1
1262
+ })
1263
+ ])) : e(F).value == "voucher" ? (u(), R(oo, {
1264
+ key: 2,
1265
+ member: m.member
1266
+ }, null, 8, ["member"])) : e(F).value == "mission" ? (u(), R(no, {
1267
+ key: 3,
1268
+ member: m.member
1269
+ }, null, 8, ["member"])) : e(F).value == "game" ? (u(), R(ro, {
1270
+ key: 4,
1271
+ member: m.member
1272
+ }, null, 8, ["member"])) : ce("", !0)
1273
+ ])
1274
+ ]),
1275
+ _: 1
1276
+ }, 8, ["modelValue"]);
1277
+ };
1278
+ }
1279
+ }), la = { class: "flex items-center justify-end" }, Ua = /* @__PURE__ */ be({
1280
+ __name: "MemberList",
1281
+ setup(y) {
1282
+ const k = Ze(), p = $e(), x = Je(), { minor: r } = We, o = Xe(), v = [
1283
+ {
1284
+ header: "Name",
1285
+ enableSorting: !0,
1286
+ accessorKey: "name",
1287
+ cell(s) {
1288
+ return Et(s.row.original);
1289
+ }
1290
+ },
1291
+ {
1292
+ accessorFn: (s) => S(Ce(s._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(s) {
1302
+ return $t(
1303
+ s.row.original,
1304
+ p.sortedTiers
1305
+ );
1306
+ }
1307
+ },
1308
+ {
1309
+ header: "Title",
1310
+ enableSorting: !1,
1311
+ cell(s) {
1312
+ return It(
1313
+ s.row.original,
1314
+ p.sortedTitles
1315
+ );
1316
+ }
1317
+ },
1318
+ {
1319
+ accessorKey: "collection_CREDIT_0_balance",
1320
+ accessorFn: (s) => {
1321
+ var l, w, T;
1322
+ return ee(((T = (w = (l = s.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: (s) => {
1330
+ var l, w, T;
1331
+ return ee(((T = (w = (l = s.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: (s) => {
1339
+ var l, w, T;
1340
+ return ee(((T = (w = (l = s.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: (s) => {
1347
+ var l;
1348
+ return ((l = s.stats) == null ? void 0 : l.visitCount) ?? 0;
1349
+ },
1350
+ header: "Total visit",
1351
+ accessorKey: "stats.visitCount",
1352
+ id: "stats.visitCount"
1353
+ },
1354
+ {
1355
+ accessorFn: (s) => {
1356
+ var l;
1357
+ return (l = s.stats) == null ? void 0 : l.lastVisit;
1358
+ },
1359
+ sortingFn: (s, l) => {
1360
+ var w, T;
1361
+ return new Date((w = s.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(s) {
1366
+ var l, w;
1367
+ return K("div", { class: "flex items-center justify-end gap-4" }, [
1368
+ K(
1369
+ "span",
1370
+ (l = s.row.original.stats) != null && l.lastVisit ? S((w = s.row.original.stats) == null ? void 0 : w.lastVisit).fromNow() : "NA"
1371
+ ),
1372
+ K(
1373
+ ve.FmTooltip,
1374
+ {
1375
+ content: S(s.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(s) {
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 se(s.row.original._id);
1402
+ }
1403
+ })
1404
+ ]
1405
+ }
1406
+ );
1407
+ }
1408
+ }
1409
+ ], { tableMeta: d, rowData: C, onSort: m, debouncedFetchData: g, onSearch: I } = Ge(le.read), D = G(), L = G(!1), P = G(), de = H(() => x.locations.map((s) => ({
1410
+ label: s.name,
1411
+ value: s._id
1412
+ })));
1413
+ async function ne() {
1414
+ P.value = await le.readById(
1415
+ P.value._id.toString()
1416
+ ), L.value = !0;
1417
+ }
1418
+ async function W() {
1419
+ await g(), L.value = !1;
1420
+ }
1421
+ async function se(s) {
1422
+ await o.push({
1423
+ name: Qe["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
1424
+ params: { id: s }
1425
+ });
1426
+ }
1427
+ const c = {
1428
+ sortBy: "_id",
1429
+ descending: !1,
1430
+ rowsPerPage: 1e3,
1431
+ page: 1,
1432
+ rowsNumber: 0
1433
+ };
1434
+ function f(s) {
1435
+ const l = S(s);
1436
+ return l.isValid() ? l.format("DD/MM/YYYY") : "";
1437
+ }
1438
+ async function M() {
1439
+ const s = new ut(), l = (await le.read({
1440
+ limit: 1,
1441
+ skip: 0,
1442
+ sortBy: c.sortBy,
1443
+ descending: c.descending
1444
+ })).meta.totalResources ?? 0, w = c.rowsPerPage;
1445
+ await r(
1446
+ async () => {
1447
+ var T, O, E, U, te, z, F, J, a, n, b, B, N, X, re, me, ye, _, Y, oe, j, ue, pe, fe, Q, Z, Ie, Ve;
1448
+ for (let Be = 0; Be < l; Be += w) {
1449
+ const et = {
1450
+ ...c,
1451
+ limit: w,
1452
+ skip: c.page - 1,
1453
+ sortBy: c.sortBy,
1454
+ descending: c.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, at = (E = ((O = i == null ? void 0 : i.collection) == null ? void 0 : O.TITLE) || []) == null ? void 0 : E.reduce(
1460
+ (ae, ge) => {
1461
+ var he, Se;
1462
+ const _e = (Se = (he = p.sortedTitles) == null ? void 0 : he.find(
1463
+ (we) => we._id === ge.collectible
1464
+ )) == null ? void 0 : Se.name;
1465
+ return !_e || ge.balance <= 0 || ae.push(_e), ae;
1466
+ },
1467
+ []
1468
+ ), nt = (p.sortedTitles || []).reduce(
1469
+ (ae, ge) => {
1470
+ var he, Se, we, Ye;
1471
+ const _e = (Ye = (we = (Se = (((he = i == null ? void 0 : i.collection) == null ? void 0 : he.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 ae[ge.name] = _e ? S(_e).format("DD/MM/YYYY") : "", ae;
1475
+ },
1476
+ {}
1477
+ ), st = ((z = (te = (U = i.collection) == null ? void 0 : U.CREDIT) == null ? void 0 : te.at(0)) == null ? void 0 : z.balance) || 0, De = ((n = (a = (J = (F = i.collection) == null ? void 0 : F.CREDIT) == null ? void 0 : J.at(0)) == null ? void 0 : a.expiryBalance) == null ? void 0 : n.reduce(
1478
+ (ae, ge) => ae + ge.amount,
1479
+ 0
1480
+ )) || 0, Ne = ee(st, 2), rt = {
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 ? f(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 ? ((re = (X = (N = i.collection) == null ? void 0 : N.POINT) == null ? void 0 : X.at(0)) == null ? void 0 : re.balance) ?? 0 : 0,
1492
+ Point: i != null && i.collection ? ((_ = (ye = (me = i.collection) == null ? void 0 : me.COIN) == null ? void 0 : ye.at(0)) == null ? void 0 : _.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: at.join(","),
1496
+ ...nt,
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: f(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: ((Ie = i.stats) == null ? void 0 : Ie.lastSeasonPointEarned) || 0,
1506
+ JoinedAt: f(i.joinAt || void 0),
1507
+ JoinedAtLocation: i.location && ((Ve = de.value.find((ae) => ae.value == i.location)) == null ? void 0 : Ve.label) || "-",
1508
+ VisitFrequency: `${Number(
1509
+ Math.ceil(i.stats.avgVisitFrequency).toFixed(0)
1510
+ )}`
1511
+ };
1512
+ s.addRecord(rt);
1513
+ }
1514
+ c.page++;
1515
+ }
1516
+ await pt(
1517
+ s.buildExcel(),
1518
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
1519
+ {
1520
+ bookType: "xlsx",
1521
+ bookSST: !1,
1522
+ type: "array"
1523
+ }
1524
+ ), c.page = 1;
1525
+ },
1526
+ {
1527
+ message: "Exporting member...",
1528
+ successMessage: "Member exported successfully"
1529
+ }
1530
+ );
1531
+ }
1532
+ return Ke(async () => {
1533
+ await p.readMembership(), await k.read(), await x.readLocations(), await g();
1534
+ }), (s, l) => {
1535
+ const w = $("FmSearch"), T = $("FmButton"), O = $("FmSnackbar");
1536
+ return u(), A("div", null, [
1537
+ t("div", la, [
1538
+ h(w, {
1539
+ class: "mt-4",
1540
+ modelValue: e(d).searchValue,
1541
+ "onUpdate:modelValue": [
1542
+ l[0] || (l[0] = (E) => e(d).searchValue = E),
1543
+ e(I)
1544
+ ],
1545
+ placeholder: "Search",
1546
+ collapsible: ""
1547
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1548
+ h(T, {
1549
+ icon: "ios_share",
1550
+ variant: "tertiary",
1551
+ onClick: M
1552
+ })
1553
+ ]),
1554
+ ze(h(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, e(L)]
1566
+ ]),
1567
+ h(He, {
1568
+ loading: e(d).isLoading,
1569
+ "row-data": e(C),
1570
+ "row-count": e(d).totalRows,
1571
+ "column-defs": v,
1572
+ "shrink-at": !1,
1573
+ "page-count": e(d).pageCount,
1574
+ "page-index": e(d).pageIndex,
1575
+ "page-size": e(d).pageSize,
1576
+ onSortChange: e(m),
1577
+ onPageChange: l[2] || (l[2] = (E) => e(g)({ pageSize: E.pageSize, pageIndex: E.pageIndex })),
1578
+ onRowClick: l[3] || (l[3] = (E) => {
1579
+ var U;
1580
+ P.value = E.original, (U = e(D)) == null || U.showSheet();
1581
+ })
1582
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1583
+ e(P) ? (u(), R(ia, {
1584
+ key: 0,
1585
+ ref_key: "sheetRef",
1586
+ ref: D,
1587
+ member: e(P),
1588
+ "onUpdate:member": ne
1589
+ }, null, 8, ["member"])) : ce("", !0)
1590
+ ]);
1591
+ };
1592
+ }
1593
+ });
1594
+ export {
1595
+ Ua as default
1596
+ };