@feedmepos/mf-connect 0.1.0-beta.11 → 0.1.0-beta.13

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 (66) hide show
  1. package/dist/{Analytic-IpLNFnjo.js → Analytic-hvE4B2NP.js} +9 -9
  2. package/dist/{App-D9Bi7WTi.js → App-GwIOv-m-.js} +201 -201
  3. package/dist/{Broadcast-3BNGmPyG.js → Broadcast-Bdwj5qA3.js} +8 -8
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CnVZZnAO.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DY4xs9ra.js} +8 -8
  5. package/dist/{Card-CpE7eylY.js → Card-FzeDxGpd.js} +126 -126
  6. package/dist/{Collections-DFZ_McBC.js → Collections-DnltkOji.js} +4 -4
  7. package/dist/{Credit-Beml9hZH.js → Credit-BjOs1-SV.js} +8 -8
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-XZtq7qUh.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-B_Si_AQ1.js} +66 -63
  9. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-CrViguLt.js → EffectSheet.vue_vue_type_style_index_0_lang-B2flXsB2.js} +6 -6
  10. package/dist/{Experience-HYyi__Wf.js → Experience-C4DvTIRT.js} +8 -8
  11. package/dist/{Game-Dtn11CP_.js → Game-CH9nOj1Y.js} +8 -8
  12. package/dist/{Marketing-BYMpQugE.js → Marketing-COgP0cW-.js} +5 -5
  13. package/dist/{Member-BP5W6ocI.js → Member-D9UOCOnD.js} +4 -4
  14. package/dist/MemberList-BiqQuhWx.js +1040 -0
  15. package/dist/{MemberTransactions-BDuQ2poX.js → MemberTransactions-B6DqB6mk.js} +1 -1
  16. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-hkK13pIu.js → MessageInput.vue_vue_type_script_setup_true_lang-Dkn6ic59.js} +2 -2
  17. package/dist/{Mission-CVPfpXqE.js → Mission-65OFi1cJ.js} +8 -8
  18. package/dist/{Point-CNq0UR3i.js → Point-8HmgJRmV.js} +8 -8
  19. package/dist/{Promotion-DDGkSEq4.js → Promotion-NN9iJfPq.js} +9 -9
  20. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CAmHafWG.js → RuleGroup.vue_vue_type_script_setup_true_lang-D4f7298N.js} +226 -217
  21. package/dist/{Segment-BTChC1dG.js → Segment-CnLQiZ3g.js} +13 -13
  22. package/dist/{Setting-v3mUUrpu.js → Setting-DmZU3gAP.js} +8 -8
  23. package/dist/{Store-C0yfrePX.js → Store-BkUj4woF.js} +13 -13
  24. package/dist/{StoreRewards-D5iGadfW.js → StoreRewards-D49SIccs.js} +12 -12
  25. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-kfT1Myf8.js → StoreTransactions.vue_vue_type_script_setup_true_lang-ClY5DLPQ.js} +10 -10
  26. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-CSYS1qZG.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-BS4PXh2q.js} +1 -1
  27. package/dist/{Tier-Dm78VvDR.js → Tier-rRoE4M3e.js} +15 -15
  28. package/dist/{Title-DBFXMOFn.js → Title-ByHAW7J5.js} +15 -15
  29. package/dist/{Transaction-BqxS-rpt.js → Transaction-daG9-W0y.js} +2 -2
  30. package/dist/{Voucher-DSe_1GCt.js → Voucher-B9xf0e6x.js} +11 -11
  31. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-iV7RhMM0.js → ZodTextField.vue_vue_type_script_setup_true_lang-T3nC1YZf.js} +1 -1
  32. package/dist/{app-CnclNehS.js → app-BNcCsLJ1.js} +24 -24
  33. package/dist/{app-BKZTSa3I.js → app-CO5FtQ_v.js} +1 -1
  34. package/dist/app.js +1 -1
  35. package/dist/{business-BhDQlLuP.js → business-BhQb-hkF.js} +1 -1
  36. package/dist/{campaign-CQ9Nt5aw.js → campaign-26brACND.js} +2 -2
  37. package/dist/{collection.fn-CCFKWzrd.js → collection.fn-yhoNFXoc.js} +2 -2
  38. package/dist/{dto-C9p4nlpM.js → dto-Ha-7No98.js} +9 -9
  39. package/dist/{effect-BW2ndqNC.js → effect-BMN_DZq2.js} +1 -1
  40. package/dist/{email-addresses-f6Qi69T4.js → email-addresses-CiIGkdZd.js} +1 -1
  41. package/dist/{export-BTF1th7Q.js → export-DqdobYQ9.js} +3 -3
  42. package/dist/{helper-AHY68CPn.js → helper-CxKVaS7J.js} +1 -1
  43. package/dist/{index-DtGPRAq2.js → index-BggU-YHH.js} +319 -304
  44. package/dist/{index-Cg9npkzC.js → index-CICZWUs_.js} +5 -5
  45. package/dist/{index-t3RW39Z7.js → index-CKzehlZH.js} +1 -1
  46. package/dist/{index-D6XbU0Qa.js → index-CM_02sYD.js} +3 -3
  47. package/dist/{index-tkSRs4ZW.js → index-CNk82BB9.js} +3 -3
  48. package/dist/{index-DuLGLnDF.js → index-CvCUq_ma.js} +1 -1
  49. package/dist/{index-DX0qEaPU.js → index-D6wN6YpG.js} +1 -1
  50. package/dist/{index-WbzCjhRU.js → index-DYTBka1k.js} +1 -1
  51. package/dist/{index-Cc2nUHpJ.js → index-Du0pfy3X.js} +1 -1
  52. package/dist/{index-BElfYwE6.js → index-LPxuEkQA.js} +34 -33
  53. package/dist/{index-CsC5CEEX.js → index-ko44g5Wh.js} +2 -2
  54. package/dist/{index-BD3B1WsX.js → index-x7P8HJ9i.js} +2 -2
  55. package/dist/{index.esm2017-D_SvBpjK.js → index.esm2017-BJmoEKbU.js} +1 -1
  56. package/dist/{loading-DYgnbsuc.js → loading-sqn4egKz.js} +4 -4
  57. package/dist/{membership-DD0hHJl3.js → membership-CFgp0Gr1.js} +3 -3
  58. package/dist/{money-Cgrz-BtT.js → money-BIslIi4C.js} +1 -1
  59. package/dist/{number-DnNIyLAO.js → number-CmUbTbIe.js} +1 -1
  60. package/dist/{rule-builder-CtABwqc_.js → rule-builder-CZqF05r6.js} +1 -1
  61. package/dist/{rule-BtuowduB.js → rule-xgVE9qkb.js} +179 -177
  62. package/dist/{template-DLkN8BDg.js → template-BC7H5E09.js} +4 -4
  63. package/dist/{usePagination-Dt34_eYZ.js → usePagination-DSH2zVJ_.js} +1 -1
  64. package/dist/{vue-i18n-Bzlk0Afk.js → vue-i18n-ClNna7Hi.js} +2 -2
  65. package/package.json +1 -1
  66. package/dist/MemberList-CBHldoAX.js +0 -1036
@@ -0,0 +1,1040 @@
1
+ import { defineComponent as ue, computed as Y, ref as X, resolveComponent as h, openBlock as y, createElementBlock as V, Fragment as ee, createElementVNode as a, unref as o, createBlock as j, createCommentVNode as ae, createVNode as g, renderList as se, withCtx as ne, createTextVNode as fe, toDisplayString as A, withDirectives as Pe, vShow as Oe, onMounted as Re, isRef as Ze, h as oe } from "vue";
2
+ import { h as x } from "./moment-BWErdI6_.js";
3
+ import { useDialog as be, components as de } from "@feedmepos/ui-library";
4
+ import { e as et, M as tt } from "./email-addresses-CiIGkdZd.js";
5
+ import { a as ot, _ as nt, w as at } from "./usePagination-DSH2zVJ_.js";
6
+ import "./index-DYTBka1k.js";
7
+ import { p as Ee, b as De, u as Ye } from "./loading-sqn4egKz.js";
8
+ import { u as ye, C as Be, s as st } from "./membership-CFgp0Gr1.js";
9
+ import { c as it } from "./index-CNk82BB9.js";
10
+ import { _ as Ue } from "./lodash-B5I3zXaY.js";
11
+ import { D as rt } from "./type_drinks-D6jnpvwV.js";
12
+ import { F as lt, a as dt, b as ct, c as mt } from "./index-x7P8HJ9i.js";
13
+ import { F as ut } from "./index-CM_02sYD.js";
14
+ import { C as pe } from "./collection.fn-yhoNFXoc.js";
15
+ import { u as Le } from "./business-BhQb-hkF.js";
16
+ import { defineStore as pt } from "pinia";
17
+ import { m as J } from "./index-D6wN6YpG.js";
18
+ import { o as ze } from "./objectId-dwaoBfJX.js";
19
+ import { f as me } from "./number-CmUbTbIe.js";
20
+ import { t as ft } from "./money-BIslIi4C.js";
21
+ import { g as bt, a as yt, b as vt } from "./user-Bm4KttFq.js";
22
+ import { useRouter as xt } from "vue-router";
23
+ import { R as gt } from "./app-BNcCsLJ1.js";
24
+ const Ct = { class: "flex flex-col" }, St = { key: 1 }, _t = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, Ft = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, ht = /* @__PURE__ */ ue({
25
+ __name: "MemberStatsDialog",
26
+ props: {
27
+ member: {
28
+ type: Object,
29
+ required: !0
30
+ },
31
+ onSubmit: {
32
+ type: Function,
33
+ required: !0
34
+ }
35
+ },
36
+ setup(C) {
37
+ var W, H, G, D;
38
+ const q = be(), v = ye(), f = C, I = Y(
39
+ () => {
40
+ var l;
41
+ return (((l = f.member.collection) == null ? void 0 : l.TITLE) ?? []).reduce(
42
+ (r, u) => {
43
+ var e, d, b, m, _;
44
+ const n = v.sortedTitles.find(
45
+ (M) => M._id.toString() === u.collectible
46
+ );
47
+ if (!n) return r;
48
+ const t = [...u.expiryBalance ?? []].sort(
49
+ (M, U) => x(M.expiredAt).isAfter(x(U.expiredAt)) ? -1 : 1
50
+ );
51
+ return (e = t[0]) != null && e.expiredAt && x((d = t[0]) == null ? void 0 : d.expiredAt).isBefore(x()) || r.push({
52
+ _id: n._id,
53
+ name: n.name,
54
+ expiredAt: (b = t[0]) != null && b.expiredAt ? x((m = t[0]) == null ? void 0 : m.expiredAt).toISOString() : "",
55
+ expiresIn: x((_ = t[0]) == null ? void 0 : _.expiredAt).diff(x(), "days")
56
+ }), r;
57
+ },
58
+ []
59
+ );
60
+ }
61
+ ), c = X({
62
+ cardNo: f.member.cardNo,
63
+ experience: ((H = (W = f.member.collection) == null ? void 0 : W.POINT) == null ? void 0 : H[0].balance) ?? 0,
64
+ tier: ((D = (G = f.member.collection) == null ? void 0 : G.TIER) == null ? void 0 : D[0].balance) ?? -1,
65
+ titles: I.value.map((l) => ({ expiredAt: l.expiresIn, id: l._id })) ?? void 0
66
+ }), $ = Y(
67
+ () => (v.sortedTitles ?? []).map((l) => ({
68
+ label: l.name,
69
+ value: l._id.toString(),
70
+ sublabel: I.value.some((r) => r._id === l._id) ? "Owned" : void 0
71
+ }))
72
+ ), k = Y(() => (v.sortedTiers ?? []).map((l, r) => ({
73
+ label: l.name,
74
+ sublabel: `${l.option.from} - ${l.option.to}`,
75
+ from: l.option.from,
76
+ to: l.option.to,
77
+ value: r + 1
78
+ })));
79
+ function T() {
80
+ var u, n;
81
+ const l = ((u = k.value[(c.value.tier ?? 1) - 1]) == null ? void 0 : u.from) ?? 0, r = (n = k.value[(c.value.tier ?? 1) - 1]) == null ? void 0 : n.to;
82
+ c.value.experience = Math.min(
83
+ r ?? l,
84
+ Math.max(l, c.value.experience ?? 0)
85
+ );
86
+ }
87
+ const E = Y(() => {
88
+ var u, n, t, e, d, b;
89
+ const l = ((n = (u = f.member.collection) == null ? void 0 : u.TIER) == null ? void 0 : n[0].balance) ?? -1, r = ((e = (t = f.member.collection) == null ? void 0 : t.POINT) == null ? void 0 : e[0].balance) ?? 0;
90
+ if (l != c.value.tier) return !0;
91
+ if (c.value.experience && c.value.experience != r) {
92
+ const m = ((d = k.value[l - 1]) == null ? void 0 : d.from) ?? 0, _ = ((b = k.value[l - 1]) == null ? void 0 : b.to) ?? 0;
93
+ if (c.value.experience < m || _ && c.value.experience > _)
94
+ return !0;
95
+ }
96
+ return !1;
97
+ });
98
+ function S(l) {
99
+ var r;
100
+ return (r = I.value.find((u) => u._id === l)) == null ? void 0 : r.expiresIn;
101
+ }
102
+ const L = Y(() => {
103
+ const l = ut.safeParse(c.value);
104
+ return l.success ? void 0 : l.error.errors;
105
+ });
106
+ function N(l) {
107
+ var r, u;
108
+ return (u = (r = L.value) == null ? void 0 : r.find((n) => n.path.join(".") === l)) == null ? void 0 : u.message;
109
+ }
110
+ function K(l) {
111
+ var r;
112
+ return (r = L.value) == null ? void 0 : r.filter((u) => u.path.join(".").startsWith(l)).map((u) => u.message);
113
+ }
114
+ async function B() {
115
+ await f.onSubmit(c.value), q.close();
116
+ }
117
+ return (l, r) => {
118
+ var M, U;
119
+ const u = h("FmSelect"), n = h("FmStepperField"), t = h("FmTextField"), e = h("FmField"), d = h("FmFormGroup"), b = h("FmButton"), m = h("FmHelperText"), _ = h("FmSpacer");
120
+ return y(), V(ee, null, [
121
+ a("div", Ct, [
122
+ r[6] || (r[6] = a("div", { class: "fm-typo-en-title-sm-800 mb-8" }, "Member tiering", -1)),
123
+ o(k).length ? (y(), j(u, {
124
+ key: 0,
125
+ modelValue: o(c).tier,
126
+ "onUpdate:modelValue": [
127
+ r[0] || (r[0] = (s) => o(c).tier = s),
128
+ T
129
+ ],
130
+ label: "Member Tier",
131
+ items: o(k),
132
+ "helper-text": N("tier"),
133
+ "helper-state": N("tier") ? "error" : void 0
134
+ }, null, 8, ["modelValue", "items", "helper-text", "helper-state"])) : ae("", !0),
135
+ g(n, {
136
+ "model-value": o(c).experience ?? 0,
137
+ "onUpdate:modelValue": r[1] || (r[1] = (s) => o(c).experience = s),
138
+ label: "Member Experience",
139
+ "max-fraction-digits": 0,
140
+ "helper-text": N("experience"),
141
+ "helper-state": N("experience") ? "error" : void 0
142
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
143
+ r[7] || (r[7] = a("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Member Card", -1)),
144
+ g(t, {
145
+ modelValue: o(c).cardNo,
146
+ "onUpdate:modelValue": r[2] || (r[2] = (s) => o(c).cardNo = s),
147
+ label: "Card number",
148
+ "helper-text": N("cardNo"),
149
+ "helper-state": N("cardNo") ? "error" : void 0
150
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
151
+ r[8] || (r[8] = a("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Titles", -1)),
152
+ (M = o(c).titles) != null && M.length ? (y(), V("div", St, r[5] || (r[5] = [
153
+ a("div", { class: "flex flex-nowrap gap-4 items-center" }, [
154
+ a("div", { class: "flex-1" }, "Title"),
155
+ a("div", { class: "flex-1" }, "Expires in days"),
156
+ a("div", { class: "w-24 h-1" })
157
+ ], -1)
158
+ ]))) : ae("", !0),
159
+ (y(!0), V(ee, null, se(o(c).titles ?? [], (s, F) => (y(), V("div", { key: F }, [
160
+ a("div", _t, [
161
+ o(I).some((p) => p._id === s.id) ? (y(), j(d, {
162
+ key: 1,
163
+ "model-value": "",
164
+ class: "flex-1"
165
+ }, {
166
+ default: ne(() => [
167
+ g(e, {
168
+ disabled: !0,
169
+ class: "text-fm-color-typo-secondary"
170
+ }, {
171
+ default: ne(() => {
172
+ var p;
173
+ return [
174
+ fe(A((p = o($).find((w) => w.value === s.id)) == null ? void 0 : p.label), 1)
175
+ ];
176
+ }),
177
+ _: 2
178
+ }, 1024)
179
+ ]),
180
+ _: 2
181
+ }, 1024)) : (y(), j(u, {
182
+ key: 0,
183
+ modelValue: s.id,
184
+ "onUpdate:modelValue": [(p) => s.id = p, (p) => s.expiredAt = S(p) ?? 1],
185
+ class: "flex-1",
186
+ items: o($).filter(
187
+ (p) => {
188
+ var w;
189
+ return !((w = o(c).titles) != null && w.map((P) => P.id).includes(p.value)) || s.id === p.value;
190
+ }
191
+ )
192
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "items"])),
193
+ g(n, {
194
+ modelValue: s.expiredAt,
195
+ "onUpdate:modelValue": (p) => s.expiredAt = p,
196
+ class: "flex-1",
197
+ label: "",
198
+ "max-fraction-digits": 0
199
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
200
+ g(b, {
201
+ class: "w-24 h-24",
202
+ icon: "close",
203
+ variant: "tertiary",
204
+ onClick: (p) => {
205
+ var w;
206
+ return (w = o(c).titles) == null ? void 0 : w.splice(F, 1);
207
+ }
208
+ }, null, 8, ["onClick"])
209
+ ]),
210
+ (y(!0), V(ee, null, se(K(`titles.${F}`), (p, w) => (y(), j(m, {
211
+ key: w,
212
+ class: "items-center",
213
+ state: "error",
214
+ text: p.toString()
215
+ }, null, 8, ["text"]))), 128))
216
+ ]))), 128)),
217
+ o($).length && (((U = o(c).titles) == null ? void 0 : U.length) ?? 0) < o($).length ? (y(), j(b, {
218
+ key: 2,
219
+ icon: "add",
220
+ label: "Give title",
221
+ variant: "plain",
222
+ onClick: r[3] || (r[3] = (s) => {
223
+ var F;
224
+ return o(c).titles = [
225
+ ...o(c).titles ?? [],
226
+ {
227
+ id: ((F = o($).find(
228
+ (p) => {
229
+ var w;
230
+ return !((w = o(c).titles) != null && w.map((P) => P.id).includes(p.value));
231
+ }
232
+ )) == null ? void 0 : F.value) || o($)[0].value,
233
+ expiredAt: 0
234
+ }
235
+ ];
236
+ })
237
+ })) : ae("", !0)
238
+ ]),
239
+ a("div", Ft, [
240
+ Pe(g(m, {
241
+ state: "warning",
242
+ text: "Updating member will cause tier to change"
243
+ }, null, 512), [
244
+ [Oe, o(E)]
245
+ ]),
246
+ g(_),
247
+ g(b, {
248
+ variant: "secondary",
249
+ label: "Cancel",
250
+ size: "md",
251
+ onClick: r[4] || (r[4] = (s) => o(q).close())
252
+ }),
253
+ g(b, {
254
+ disabled: !!o(L),
255
+ variant: "primary",
256
+ label: "Submit",
257
+ size: "md",
258
+ onClick: B
259
+ }, null, 8, ["disabled"])
260
+ ])
261
+ ], 64);
262
+ };
263
+ }
264
+ }), Tt = { class: "fm-typo-en-title-sm-800" }, wt = { class: "space-y-16" }, kt = { class: "flex flex-nowrap gap-8 items-center justify-end pt-24 w-full" }, Mt = /* @__PURE__ */ ue({
265
+ __name: "CreditCoinDialog",
266
+ props: {
267
+ type: { type: String, required: !0 },
268
+ action: { type: String, required: !0 },
269
+ onSubmit: {
270
+ type: Function,
271
+ required: !0
272
+ }
273
+ },
274
+ setup(C) {
275
+ const q = be(), v = C, f = X({
276
+ amount: 1,
277
+ day: 1,
278
+ remark: void 0
279
+ }), I = X(!0), c = Y(() => pe.formattedType(v.type.toUpperCase()));
280
+ function $(E) {
281
+ I.value = E, !E && v.type === "coin" && (f.value.day = void 0);
282
+ }
283
+ async function k() {
284
+ if (v.action === "send") {
285
+ const E = f.value.day ? `, expire in ${f.value.day} days` : "";
286
+ Ee.confirm(
287
+ `Are you sure to send ${f.value.amount} ${c.value.toLowerCase()}${E}? This action cannot be reversed.`
288
+ ).then(async (S) => {
289
+ S && await v.onSubmit(f.value);
290
+ });
291
+ } else
292
+ Ee.confirm(
293
+ `Are you sure to deduct ${f.value.amount} ${c.value.toLowerCase()}? This action cannot be reversed.`
294
+ ).then(async (E) => {
295
+ E && await v.onSubmit(f.value);
296
+ });
297
+ }
298
+ const T = Y(() => {
299
+ const S = (v.action === "send" ? v.type === "coin" ? lt : dt : v.type === "coin" ? ct : mt).safeParse(f.value);
300
+ return S.success == !1 ? S.error.flatten().fieldErrors : void 0;
301
+ });
302
+ return (E, S) => {
303
+ const L = h("FmStepperField"), N = h("FmSwitch"), K = h("FmTextarea"), B = h("FmButton"), W = h("FmCard");
304
+ return y(), j(W, { class: "flex flex-col gap-16 p-16" }, {
305
+ default: ne(() => {
306
+ var H, G, D, l, r, u;
307
+ return [
308
+ a("div", Tt, A(v.action == "send" ? "Send" : "Deduct") + " " + A(o(Be)[v.type.toUpperCase()].name), 1),
309
+ fe(" " + A(o(T)) + " ", 1),
310
+ a("div", wt, [
311
+ g(L, {
312
+ modelValue: o(f).amount,
313
+ "onUpdate:modelValue": S[0] || (S[0] = (n) => o(f).amount = n),
314
+ label: `${o(Be)[v.type.toUpperCase()].name} amount`,
315
+ "is-currency": !0,
316
+ "max-fraction-digits": 2,
317
+ "helper-state": (H = o(T)) != null && H.amount ? "error" : void 0,
318
+ "helper-text": (D = (G = o(T)) == null ? void 0 : G.amount) == null ? void 0 : D[0]
319
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"]),
320
+ C.action === "send" && v.type === "coin" ? (y(), j(N, {
321
+ key: 0,
322
+ "model-value": o(I),
323
+ label: `${o(c)} expires`,
324
+ "label-placement": "right",
325
+ "onUpdate:modelValue": S[1] || (S[1] = (n) => $(n))
326
+ }, null, 8, ["model-value", "label"])) : ae("", !0),
327
+ C.action === "send" && o(I) ? (y(), j(L, {
328
+ key: 1,
329
+ modelValue: o(f).day,
330
+ "onUpdate:modelValue": S[2] || (S[2] = (n) => o(f).day = n),
331
+ label: `${o(c)} expires in`,
332
+ "max-fraction-digits": 0,
333
+ "append-text": "day(s)",
334
+ max: 9999,
335
+ min: 0,
336
+ "helper-state": (l = o(T)) != null && l.day ? "error" : void 0,
337
+ "helper-text": (u = (r = o(T)) == null ? void 0 : r.day) == null ? void 0 : u[0]
338
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : ae("", !0),
339
+ g(K, {
340
+ modelValue: o(f).remark,
341
+ "onUpdate:modelValue": S[3] || (S[3] = (n) => o(f).remark = n),
342
+ label: "Remark"
343
+ }, null, 8, ["modelValue"])
344
+ ]),
345
+ a("div", kt, [
346
+ g(B, {
347
+ variant: "secondary",
348
+ label: "Cancel",
349
+ size: "md",
350
+ onClick: S[4] || (S[4] = (n) => o(q).close())
351
+ }),
352
+ g(B, {
353
+ disabled: !!o(T),
354
+ variant: "primary",
355
+ label: "Submit",
356
+ size: "md",
357
+ onClick: S[5] || (S[5] = async () => k())
358
+ }, null, 8, ["disabled"])
359
+ ])
360
+ ];
361
+ }),
362
+ _: 1
363
+ });
364
+ };
365
+ }
366
+ }), je = pt("segment", () => {
367
+ const C = X([]);
368
+ async function q() {
369
+ const v = await st.readAll({
370
+ limit: 1e3,
371
+ skip: 0,
372
+ sortBy: "_id",
373
+ descending: !0
374
+ });
375
+ C.value = v.resources;
376
+ }
377
+ return {
378
+ segments: C,
379
+ read: q
380
+ };
381
+ }), At = { class: "flex flex-col flex-nowrap gap-y-24 max-h-full" }, Nt = { class: "space-y-16" }, Vt = { class: "flex gap-16 items-center" }, It = { class: "flex-auto" }, $t = { class: "fm-typo-en-body-md-600" }, Et = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Dt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bt = { class: "fm-typo-en-body-md-800" }, Ut = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pt = { class: "fm-typo-en-body-md-600" }, Ot = { class: "gap-16 grid grid-cols-2" }, Rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yt = { class: "fm-typo-en-body-md-600" }, Lt = { class: "space-y-8" }, zt = {
382
+ key: 0,
383
+ class: "space-x-8"
384
+ }, jt = {
385
+ key: 1,
386
+ class: "text-fm-color-typo-secondary"
387
+ }, qt = { class: "space-y-8" }, Kt = ["src"], Gt = { class: "fm-typo-en-body-md-600" }, Ht = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Jt = {
388
+ key: 1,
389
+ class: "text-fm-color-typo-secondary"
390
+ }, Xt = {
391
+ key: 1,
392
+ class: "space-y-24"
393
+ }, Wt = { class: "space-y-8" }, Qt = { class: "fm-typo-en-title-md-800" }, Zt = { class: "space-y-4" }, eo = { class: "fm-typo-en-body-md-600" }, to = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, oo = { class: "space-y-8" }, no = { class: "fm-typo-en-title-md-800" }, ao = { class: "space-y-4" }, so = { class: "fm-typo-en-body-md-600" }, io = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, ro = /* @__PURE__ */ ue({
394
+ __name: "MemberDetailSheet",
395
+ props: {
396
+ member: {
397
+ type: Object,
398
+ required: !0
399
+ }
400
+ },
401
+ emits: ["update:member"],
402
+ setup(C, { expose: q, emit: v }) {
403
+ const f = Le(), I = ye(), c = je(), $ = be(), { minor: k } = Ye, T = C, E = v, S = Y(() => f.locations.map((t) => ({
404
+ label: t.name,
405
+ value: t._id
406
+ }))), L = Y(() => (T.member.segment || []).map((t) => {
407
+ var e;
408
+ return ((e = c.segments.find((d) => d._id === t)) == null ? void 0 : e.name) || "";
409
+ }).filter(Boolean));
410
+ async function N(t, e) {
411
+ $.open({
412
+ title: "",
413
+ dialogComponent: Mt,
414
+ dialogComponentProps: {
415
+ type: t,
416
+ action: e,
417
+ onSubmit: async (d) => {
418
+ await k(
419
+ async () => {
420
+ const b = {
421
+ "credit-send": J.sendCredit,
422
+ "credit-deduct": J.deductCredit,
423
+ "coin-send": J.sendCoin,
424
+ "coin-deduct": J.deductCoin
425
+ }, m = `${t}-${e}`, _ = b[m];
426
+ _ && await _(T.member._id, d), E("update:member"), $.close();
427
+ },
428
+ {
429
+ message: `Adjusting ${pe.formattedType(t.toUpperCase()).toLowerCase()}`,
430
+ successMessage: `${d.amount} ${pe.formattedType(t.toUpperCase()).toLowerCase()} ${e} ${e == "send" ? "to" : "from"} ${T.member.phoneNumber}`
431
+ }
432
+ );
433
+ }
434
+ }
435
+ });
436
+ }
437
+ async function K() {
438
+ $.open({
439
+ title: "Update member statistics",
440
+ contentComponent: ht,
441
+ contentComponentProps: {
442
+ member: T.member,
443
+ onSubmit: async (t) => {
444
+ await k(
445
+ async () => {
446
+ await J.updateMember(T.member._id, t), E("update:member"), $.close();
447
+ },
448
+ {
449
+ message: "Updating member stats",
450
+ successMessage: `Updated member ${T.member.phoneNumber} stats successfully`
451
+ }
452
+ );
453
+ }
454
+ }
455
+ });
456
+ }
457
+ const B = [
458
+ {
459
+ label: "Mobile No.",
460
+ key: "phoneNumber"
461
+ },
462
+ {
463
+ label: "Tier",
464
+ getter: (t) => {
465
+ var M, U, s, F, p;
466
+ const e = (((U = Ue.first((M = T.member.collection) == null ? void 0 : M.TIER)) == null ? void 0 : U.balance) || 0) - 1, d = H.value.name, b = ((F = (s = t.collection) == null ? void 0 : s.POINT) == null ? void 0 : F[0].balance) ?? 0, m = I.sortedTiers[e + 1], _ = ((p = m == null ? void 0 : m.option) == null ? void 0 : p.to) ?? 1 / 0;
467
+ return `${d} (${b}/${_})`;
468
+ }
469
+ },
470
+ {
471
+ label: "Email",
472
+ key: "email"
473
+ },
474
+ {
475
+ label: "Birthday",
476
+ getter: (t) => t.birthday ? x(t.birthday).format("D MMM YYYY") : "-"
477
+ }
478
+ ], W = [
479
+ {
480
+ label: "Customer since",
481
+ getter: (t) => x(ze(t._id.toString())).format("D MMM YYYY")
482
+ },
483
+ {
484
+ label: "Joined at location",
485
+ getter: (t) => {
486
+ var e;
487
+ return t != null && t.location && ((e = S.value.find((d) => d.value == t.location)) == null ? void 0 : e.label) || "-";
488
+ }
489
+ },
490
+ {
491
+ label: "Total visit(s)",
492
+ getter: (t) => De.singularOrPlural(t.stats.visitCount, "bill")
493
+ },
494
+ {
495
+ label: "Last visit",
496
+ getter: (t) => x(t.stats.lastVisit).fromNow()
497
+ },
498
+ {
499
+ label: "Frequency",
500
+ getter: (t) => `Every ${De.singularOrPlural(Number(Math.ceil(t.stats.avgVisitFrequency).toFixed(0)), "day")}`
501
+ },
502
+ {
503
+ label: "Average spend",
504
+ getter: (t) => it.Dinero.fromNumber({ number: Number(t.stats.avgBillSize || 0) }).toFormat(
505
+ !0
506
+ )
507
+ }
508
+ // {
509
+ // label: 'Feedback',
510
+ // key: 'feedbackCount',
511
+ // },
512
+ // {
513
+ // label: 'Tier Earned this season',
514
+ // key: 'lastSeasonTierEarned',
515
+ // },
516
+ // {
517
+ // label: 'Point Earned this season',
518
+ // key: 'lastSeasonPointEarned',
519
+ // },
520
+ ], H = Y(() => {
521
+ var d, b;
522
+ const t = (((b = Ue.first((d = T.member.collection) == null ? void 0 : d.TIER)) == null ? void 0 : b.balance) || 0) - 1, e = I.sortedTiers[t];
523
+ return { name: (e == null ? void 0 : e.name) || "-", tier: t, config: e };
524
+ }), G = Y(() => {
525
+ var t;
526
+ return (((t = T.member.collection) == null ? void 0 : t.TITLE) || []).map((e) => {
527
+ var b, m, _;
528
+ const d = (b = I.sortedTitles) == null ? void 0 : b.find(
529
+ (M) => M._id == e.collectible
530
+ );
531
+ return {
532
+ name: d == null ? void 0 : d.name,
533
+ expiredAt: (_ = (m = e.expiryBalance) == null ? void 0 : m.at(-1)) == null ? void 0 : _.expiredAt,
534
+ collectible: d
535
+ };
536
+ }).filter(
537
+ (e) => e.expiredAt ? x(e.expiredAt).isAfter(x()) : !0
538
+ );
539
+ }), D = X(!0);
540
+ function l() {
541
+ D.value = !0, n.value = u[0];
542
+ }
543
+ function r() {
544
+ D.value = !1;
545
+ }
546
+ const u = [
547
+ {
548
+ label: "Overview",
549
+ value: "overview"
550
+ },
551
+ {
552
+ label: "Loyalty",
553
+ value: "loyalty"
554
+ }
555
+ ], n = X(u[0]);
556
+ return Re(async () => {
557
+ await I.readMembership(), f.locations.length || await f.readLocations();
558
+ }), q({
559
+ showSheet: l,
560
+ hideSheet: r
561
+ }), (t, e) => {
562
+ const d = h("FmTabs"), b = h("FmAvatar"), m = h("FmButton"), _ = h("FmChip"), M = h("FmCard"), U = h("FmSideSheet");
563
+ return y(), j(U, {
564
+ modelValue: o(D),
565
+ "onUpdate:modelValue": e[5] || (e[5] = (s) => Ze(D) ? D.value = s : null),
566
+ header: "Member Detail",
567
+ "dismiss-away": "",
568
+ "close-button": !0,
569
+ "max-width": 550
570
+ }, {
571
+ "side-sheet-footer": ne(() => e[19] || (e[19] = [])),
572
+ default: ne(() => [
573
+ a("div", At, [
574
+ g(d, {
575
+ "model-value": o(n).value,
576
+ items: u,
577
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => n.value = u.find((F) => F.value === s))
578
+ }, null, 8, ["model-value"]),
579
+ o(n).value == "overview" ? (y(), V(ee, { key: 0 }, [
580
+ e[10] || (e[10] = a("div", { class: "fm-typo-en-title-sm-800" }, "Profile Information", -1)),
581
+ a("div", Nt, [
582
+ a("div", Vt, [
583
+ g(b, {
584
+ name: C.member.photoUrl ? void 0 : C.member.name,
585
+ src: C.member.photoUrl || void 0
586
+ }, null, 8, ["name", "src"]),
587
+ a("div", It, [
588
+ e[7] || (e[7] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1)),
589
+ a("div", $t, A(C.member.name), 1),
590
+ a("div", Et, A(C.member._id), 1),
591
+ a("div", Dt, [
592
+ e[6] || (e[6] = fe(" Member Card: ")),
593
+ a("span", Bt, A(C.member.cardNo ? C.member.cardNo : "-"), 1)
594
+ ])
595
+ ]),
596
+ g(m, {
597
+ variant: "tertiary",
598
+ icon: "settings",
599
+ onClick: K
600
+ })
601
+ ]),
602
+ (y(), V(ee, null, se(B, (s, F) => a("div", { key: F }, [
603
+ a("div", Ut, A(s.label), 1),
604
+ a("div", Pt, A(s.key ? C.member[s.key] : s.getter(C.member)), 1)
605
+ ])), 64))
606
+ ]),
607
+ e[11] || (e[11] = a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
608
+ e[12] || (e[12] = a("div", { class: "fm-typo-en-title-sm-800" }, "Activities", -1)),
609
+ a("div", Ot, [
610
+ (y(), V(ee, null, se(W, (s) => a("div", {
611
+ key: s.key
612
+ }, [
613
+ a("div", Rt, A(s.label), 1),
614
+ a("div", Yt, A(s.key ? T.member.stats[s.key] || "-" : s.getter(C.member)), 1)
615
+ ])), 64))
616
+ ]),
617
+ e[13] || (e[13] = a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
618
+ a("div", Lt, [
619
+ e[8] || (e[8] = a("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1)),
620
+ o(L).length ? (y(), V("div", zt, [
621
+ (y(!0), V(ee, null, se(o(L), (s) => (y(), j(_, {
622
+ label: s.toString()
623
+ }, null, 8, ["label"]))), 256))
624
+ ])) : (y(), V("div", jt, "No titles"))
625
+ ]),
626
+ e[14] || (e[14] = a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
627
+ a("div", qt, [
628
+ e[9] || (e[9] = a("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1)),
629
+ o(G).length ? (y(!0), V(ee, { key: 0 }, se(o(G).filter((s) => s.collectible), (s) => (y(), V("div", {
630
+ class: "flex items-center gap-x-8 h-48",
631
+ key: s.name
632
+ }, [
633
+ a("img", {
634
+ src: s.collectible.image || o(rt),
635
+ class: "aspect-square h-full object-contain"
636
+ }, null, 8, Kt),
637
+ a("div", null, [
638
+ a("div", Gt, A(s.name), 1),
639
+ a("div", Ht, " Expired on " + A(o(x)(s.expiredAt).format("MMM D, Y")), 1)
640
+ ])
641
+ ]))), 128)) : (y(), V("div", Jt, "No titles"))
642
+ ])
643
+ ], 64)) : o(n).value == "loyalty" ? (y(), V("div", Xt, [
644
+ g(M, {
645
+ class: "p-16 space-y-24",
646
+ variant: "outlined"
647
+ }, {
648
+ default: ne(() => {
649
+ var s, F, p, w, P, Q, Z;
650
+ return [
651
+ a("div", Wt, [
652
+ e[15] || (e[15] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1)),
653
+ a("div", Qt, A(((p = (F = (s = C.member.collection) == null ? void 0 : s.CREDIT) == null ? void 0 : F[0]) == null ? void 0 : p.balance) ?? 0), 1)
654
+ ]),
655
+ a("div", Zt, [
656
+ e[16] || (e[16] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1)),
657
+ a("div", eo, A(((Z = (Q = (P = (w = C.member.collection) == null ? void 0 : w.CREDIT) == null ? void 0 : P[0]) == null ? void 0 : Q.expiryBalance) == null ? void 0 : Z.reduce(
658
+ (O, R) => R.expiredAt && o(x)(R.expiredAt).isAfter(o(x)()) && o(x)(R.expiredAt).isBefore(o(x)().add(30, "days")) ? O + R.amount : O,
659
+ 0
660
+ )) ?? 0), 1)
661
+ ]),
662
+ a("div", to, [
663
+ g(m, {
664
+ label: "Add credit",
665
+ icon: "add",
666
+ variant: "plain",
667
+ onClick: e[1] || (e[1] = (O) => N("credit", "send"))
668
+ }),
669
+ g(m, {
670
+ label: "Deduct credit",
671
+ icon: "remove",
672
+ variant: "plain",
673
+ onClick: e[2] || (e[2] = (O) => N("credit", "deduct"))
674
+ })
675
+ ])
676
+ ];
677
+ }),
678
+ _: 1
679
+ }),
680
+ g(M, {
681
+ class: "p-16 space-y-24",
682
+ variant: "outlined"
683
+ }, {
684
+ default: ne(() => {
685
+ var s, F, p, w, P, Q, Z;
686
+ return [
687
+ a("div", oo, [
688
+ e[17] || (e[17] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1)),
689
+ a("div", no, A(((p = (F = (s = C.member.collection) == null ? void 0 : s.COIN) == null ? void 0 : F[0]) == null ? void 0 : p.balance) ?? 0), 1)
690
+ ]),
691
+ a("div", ao, [
692
+ e[18] || (e[18] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1)),
693
+ a("div", so, A(((Z = (Q = (P = (w = C.member.collection) == null ? void 0 : w.COIN) == null ? void 0 : P[0]) == null ? void 0 : Q.expiryBalance) == null ? void 0 : Z.reduce(
694
+ (O, R) => R.expiredAt && o(x)(R.expiredAt).isAfter(o(x)()) && o(x)(R.expiredAt).isBefore(o(x)().add(30, "days")) ? O + R.amount : O,
695
+ 0
696
+ )) ?? 0), 1)
697
+ ]),
698
+ a("div", io, [
699
+ g(m, {
700
+ label: "Add point",
701
+ icon: "add",
702
+ variant: "plain",
703
+ onClick: e[3] || (e[3] = (O) => N("coin", "send"))
704
+ }),
705
+ g(m, {
706
+ label: "Deduct point",
707
+ icon: "remove",
708
+ variant: "plain",
709
+ onClick: e[4] || (e[4] = (O) => N("coin", "deduct"))
710
+ })
711
+ ])
712
+ ];
713
+ }),
714
+ _: 1
715
+ })
716
+ ])) : ae("", !0)
717
+ ])
718
+ ]),
719
+ _: 1
720
+ }, 8, ["modelValue"]);
721
+ };
722
+ }
723
+ }), lo = { class: "flex items-center justify-end" }, $o = /* @__PURE__ */ ue({
724
+ __name: "MemberList",
725
+ setup(C) {
726
+ const q = je(), v = ye(), f = Le(), { minor: I } = Ye, c = xt(), $ = [
727
+ {
728
+ header: "Name",
729
+ enableSorting: !0,
730
+ accessorKey: "name",
731
+ cell(n) {
732
+ return bt(n.row.original);
733
+ }
734
+ },
735
+ {
736
+ accessorFn: (n) => x(ze(n._id.toString())).format("D MMM YYYY"),
737
+ header: "Customer Since",
738
+ accessorKey: "_id",
739
+ id: "_id"
740
+ },
741
+ {
742
+ accessorKey: "collection_TIER_0_balance",
743
+ header: "Tier",
744
+ enableSorting: !0,
745
+ cell(n) {
746
+ return yt(
747
+ n.row.original,
748
+ v.sortedTiers
749
+ );
750
+ }
751
+ },
752
+ {
753
+ header: "Title",
754
+ enableSorting: !1,
755
+ cell(n) {
756
+ return vt(
757
+ n.row.original,
758
+ v.sortedTitles
759
+ );
760
+ }
761
+ },
762
+ {
763
+ accessorKey: "collection_CREDIT_0_balance",
764
+ accessorFn: (n) => {
765
+ var t, e, d;
766
+ return me(((d = (e = (t = n.collection) == null ? void 0 : t.CREDIT) == null ? void 0 : e[0]) == null ? void 0 : d.balance) ?? 0, 2);
767
+ },
768
+ header: "Credit(s)",
769
+ enableSorting: !0
770
+ },
771
+ {
772
+ accessorKey: "collection_POINT_0_balance",
773
+ accessorFn: (n) => {
774
+ var t, e, d;
775
+ return me(((d = (e = (t = n.collection) == null ? void 0 : t.POINT) == null ? void 0 : e[0]) == null ? void 0 : d.balance) ?? 0, 2);
776
+ },
777
+ header: "Experience(s)",
778
+ enableSorting: !0
779
+ },
780
+ {
781
+ accessorKey: "collection_COIN_0_balance",
782
+ accessorFn: (n) => {
783
+ var t, e, d;
784
+ return me(((d = (e = (t = n.collection) == null ? void 0 : t.COIN) == null ? void 0 : e[0]) == null ? void 0 : d.balance) ?? 0, 2);
785
+ },
786
+ header: "Point(s)",
787
+ enableSorting: !0
788
+ },
789
+ {
790
+ accessorFn: (n) => {
791
+ var t;
792
+ return ((t = n.stats) == null ? void 0 : t.visitCount) ?? 0;
793
+ },
794
+ header: "Total visit",
795
+ accessorKey: "stats.visitCount",
796
+ id: "stats.visitCount"
797
+ },
798
+ {
799
+ accessorFn: (n) => {
800
+ var t;
801
+ return (t = n.stats) == null ? void 0 : t.lastVisit;
802
+ },
803
+ sortingFn: (n, t) => {
804
+ var e, d;
805
+ return new Date((e = n.original.stats) == null ? void 0 : e.lastVisit).getTime() - new Date((d = t.original.stats) == null ? void 0 : d.lastVisit).getTime();
806
+ },
807
+ id: "stats.lastVisit",
808
+ header: "Last visit",
809
+ cell(n) {
810
+ var t, e;
811
+ return oe("div", { class: "flex items-center justify-end gap-4" }, [
812
+ oe(
813
+ "span",
814
+ (t = n.row.original.stats) != null && t.lastVisit ? x((e = n.row.original.stats) == null ? void 0 : e.lastVisit).fromNow() : "NA"
815
+ ),
816
+ oe(
817
+ de.FmTooltip,
818
+ {
819
+ content: x(n.row.original.stats.lastVisit).format(
820
+ "D MMM YYYY - hh:mmA"
821
+ )
822
+ },
823
+ [oe(de.FmIcon, { name: "info", outline: !0, size: "sm" })]
824
+ )
825
+ ]);
826
+ }
827
+ },
828
+ {
829
+ id: "actions",
830
+ cell(n) {
831
+ return oe(
832
+ de.FmMenu,
833
+ {
834
+ placement: "bottom-end",
835
+ onClick: (t) => {
836
+ t.stopPropagation();
837
+ }
838
+ },
839
+ {
840
+ "menu-button": () => oe(de.FmButton, { icon: "more_vert", variant: "tertiary" }),
841
+ default: () => [
842
+ oe(de.FmMenuItem, {
843
+ label: "Transaction details",
844
+ onClick: async (t) => {
845
+ t.stopPropagation(), await D(n.row.original._id);
846
+ }
847
+ })
848
+ ]
849
+ }
850
+ );
851
+ }
852
+ }
853
+ ], { tableMeta: k, rowData: T, onSort: E, debouncedFetchData: S, onSearch: L } = ot(J.read), N = X(), K = X(!1), B = X(), W = Y(() => f.locations.map((n) => ({
854
+ label: n.name,
855
+ value: n._id
856
+ })));
857
+ async function H() {
858
+ B.value = await J.readById(
859
+ B.value._id.toString()
860
+ ), K.value = !0;
861
+ }
862
+ async function G() {
863
+ await S(), K.value = !1;
864
+ }
865
+ async function D(n) {
866
+ await c.push({
867
+ name: gt["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
868
+ params: { id: n }
869
+ });
870
+ }
871
+ const l = {
872
+ sortBy: "_id",
873
+ descending: !1,
874
+ rowsPerPage: 1e3,
875
+ page: 1,
876
+ rowsNumber: 0
877
+ };
878
+ function r(n) {
879
+ const t = x(n);
880
+ return t.isValid() ? t.format("DD/MM/YYYY") : "";
881
+ }
882
+ async function u() {
883
+ const n = new tt(), t = (await J.read({
884
+ limit: 1,
885
+ skip: 0,
886
+ sortBy: l.sortBy,
887
+ descending: l.descending
888
+ })).meta.totalResources ?? 0, e = l.rowsPerPage;
889
+ await I(
890
+ async () => {
891
+ var d, b, m, _, M, U, s, F, p, w, P, Q, Z, O, R, ve, xe, ge, Ce, Se, _e, Fe, he, Te, we, ke, Me, Ae;
892
+ for (let Ne = 0; Ne < t; Ne += e) {
893
+ const qe = {
894
+ ...l,
895
+ limit: e,
896
+ skip: l.page - 1,
897
+ sortBy: l.sortBy,
898
+ descending: l.descending
899
+ }, Ke = await J.read(qe);
900
+ for (const i of Ke.resources) {
901
+ const Ge = (d = et.parseOneAddress(
902
+ i == null ? void 0 : i.email
903
+ )) != null && d.domain.includes("feedmepos.com") ? void 0 : i.email, He = (m = ((b = i == null ? void 0 : i.collection) == null ? void 0 : b.TITLE) || []) == null ? void 0 : m.reduce(
904
+ (z, te) => {
905
+ var re, le;
906
+ const ie = (le = (re = v.sortedTitles) == null ? void 0 : re.find(
907
+ (ce) => ce._id === te.collectible
908
+ )) == null ? void 0 : le.name;
909
+ return !ie || te.balance <= 0 || z.push(ie), z;
910
+ },
911
+ []
912
+ ), Je = (v.sortedTitles || []).reduce(
913
+ (z, te) => {
914
+ var re, le, ce, $e;
915
+ const ie = ($e = (ce = (le = (((re = i == null ? void 0 : i.collection) == null ? void 0 : re.TITLE) || []).find(
916
+ (Qe) => Qe.collectible === te._id
917
+ )) == null ? void 0 : le.expiryBalance) == null ? void 0 : ce[0]) == null ? void 0 : $e.expiredAt;
918
+ return z[te.name] = ie ? x(ie).format("DD/MM/YYYY") : "", z;
919
+ },
920
+ {}
921
+ ), Xe = ((U = (M = (_ = i.collection) == null ? void 0 : _.CREDIT) == null ? void 0 : M.at(0)) == null ? void 0 : U.balance) || 0, Ve = ((w = (p = (F = (s = i.collection) == null ? void 0 : s.CREDIT) == null ? void 0 : F.at(0)) == null ? void 0 : p.expiryBalance) == null ? void 0 : w.reduce(
922
+ (z, te) => z + te.amount,
923
+ 0
924
+ )) || 0, Ie = me(Xe, 2), We = {
925
+ ID: i._id.toString(),
926
+ Name: ((P = i.name) == null ? void 0 : P.trim()) || "",
927
+ Phone: ((Q = i == null ? void 0 : i.phoneNumber) == null ? void 0 : Q.trim()) || "",
928
+ Email: Ge || "",
929
+ Gender: i.gender || "",
930
+ CardNo: i.cardNo || "",
931
+ Birthday: r((i == null ? void 0 : i.birthday) || void 0),
932
+ Credit: (Number(Ie) - Number(Ve)).toFixed(2),
933
+ FreeCredit: Number(Ve.toFixed(2)),
934
+ TotalCredit: Number(Ie),
935
+ Exp: i != null && i.collection ? ((R = (O = (Z = i.collection) == null ? void 0 : Z.POINT) == null ? void 0 : O.at(0)) == null ? void 0 : R.balance) ?? 0 : 0,
936
+ Point: i != null && i.collection ? ((ge = (xe = (ve = i.collection) == null ? void 0 : ve.COIN) == null ? void 0 : xe.at(0)) == null ? void 0 : ge.balance) ?? 0 : 0,
937
+ Level: i != null && i.collection ? ((_e = (Se = (Ce = i.collection) == null ? void 0 : Ce.TIER) == null ? void 0 : Se.at(0)) == null ? void 0 : _e.balance) ?? 0 : 0,
938
+ Tier: i != null && i.collection ? ((Te = (he = (Fe = i.collection) == null ? void 0 : Fe.TIER) == null ? void 0 : he.at(0)) == null ? void 0 : Te.balance) ?? 0 : 0,
939
+ Titles: He.join(","),
940
+ ...Je,
941
+ TotalTransaction: i.stats.visitCount,
942
+ AvgSpent: ft(Number(i.stats.avgBillSize || 0)).toFormat(
943
+ !1
944
+ ),
945
+ TotalSpent: i.stats.avgBillSize * i.stats.visitCount,
946
+ LastVisit: r(i.stats.lastVisit),
947
+ Feedback: ((we = i.stats) == null ? void 0 : we.feedbackCount) || 0,
948
+ LastSeasonTierEarned: ((ke = i.stats) == null ? void 0 : ke.lastSeasonTierEarned) || 0,
949
+ LastSeasonPointEarned: ((Me = i.stats) == null ? void 0 : Me.lastSeasonPointEarned) || 0,
950
+ JoinedAt: r(i.joinAt || void 0),
951
+ JoinedAtLocation: i.location && ((Ae = W.value.find((z) => z.value == i.location)) == null ? void 0 : Ae.label) || "-",
952
+ VisitFrequency: `${Number(
953
+ Math.ceil(i.stats.avgVisitFrequency).toFixed(0)
954
+ )}`
955
+ };
956
+ n.addRecord(We);
957
+ }
958
+ l.page++;
959
+ }
960
+ await at(
961
+ n.buildExcel(),
962
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
963
+ {
964
+ bookType: "xlsx",
965
+ bookSST: !1,
966
+ type: "array"
967
+ }
968
+ ), l.page = 1;
969
+ },
970
+ {
971
+ message: "Exporting member...",
972
+ successMessage: "Member exported successfully"
973
+ }
974
+ );
975
+ }
976
+ return Re(async () => {
977
+ await v.readMembership(), await f.readLocations(), await q.read(), await S();
978
+ }), (n, t) => {
979
+ const e = h("FmSearch"), d = h("FmButton"), b = h("FmSnackbar");
980
+ return y(), V("div", null, [
981
+ a("div", lo, [
982
+ g(e, {
983
+ class: "mt-4",
984
+ modelValue: o(k).searchValue,
985
+ "onUpdate:modelValue": [
986
+ t[0] || (t[0] = (m) => o(k).searchValue = m),
987
+ o(L)
988
+ ],
989
+ placeholder: "Search",
990
+ collapsible: ""
991
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
992
+ g(d, {
993
+ icon: "ios_share",
994
+ variant: "tertiary",
995
+ onClick: u
996
+ })
997
+ ]),
998
+ Pe(g(b, {
999
+ "z-index": 0,
1000
+ class: "!max-w-full my-16",
1001
+ title: "Info",
1002
+ description: "Current list is not up to date, please refresh table for latest data.",
1003
+ variant: "info",
1004
+ dismissable: "",
1005
+ onOnDismiss: t[1] || (t[1] = (m) => K.value = !1),
1006
+ action: "Refresh",
1007
+ onOnAction: G
1008
+ }, null, 512), [
1009
+ [Oe, o(K)]
1010
+ ]),
1011
+ g(nt, {
1012
+ loading: o(k).isLoading,
1013
+ "row-data": o(T),
1014
+ "row-count": o(k).totalRows,
1015
+ "column-defs": $,
1016
+ "shrink-at": !1,
1017
+ "page-count": o(k).pageCount,
1018
+ "page-index": o(k).pageIndex,
1019
+ "page-size": o(k).pageSize,
1020
+ onSortChange: o(E),
1021
+ onPageChange: t[2] || (t[2] = (m) => o(S)({ pageSize: m.pageSize, pageIndex: m.pageIndex })),
1022
+ onRowClick: t[3] || (t[3] = (m) => {
1023
+ var _;
1024
+ B.value = m.original, (_ = o(N)) == null || _.showSheet();
1025
+ })
1026
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1027
+ o(B) ? (y(), j(ro, {
1028
+ key: 0,
1029
+ ref_key: "sheetRef",
1030
+ ref: N,
1031
+ member: o(B),
1032
+ "onUpdate:member": H
1033
+ }, null, 8, ["member"])) : ae("", !0)
1034
+ ]);
1035
+ };
1036
+ }
1037
+ });
1038
+ export {
1039
+ $o as default
1040
+ };