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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/{Analytic-DYfm1eg5.js → Analytic-BQQMo8gn.js} +18 -17
  2. package/dist/{App-DV85I2xq.js → App-XbDR-3id.js} +6 -6
  3. package/dist/{Broadcast-CNpwvxRx.js → Broadcast-BV0fALHZ.js} +8 -8
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Bv8Ki3vl.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Cmq6EQxz.js} +6 -7
  5. package/dist/{Card-Bk4hfK9U.js → Card-ni0g9f0W.js} +16 -17
  6. package/dist/{Collections-CrND62Vz.js → Collections-CzqFRaQq.js} +4 -4
  7. package/dist/{Credit-ICo98p8n.js → Credit-BhaiYIIH.js} +8 -8
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-LFtf2JM3.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-ByIKDwhp.js} +27 -27
  9. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-CdVIbAT3.js → EffectSheet.vue_vue_type_style_index_0_lang-CCPGbV9-.js} +6 -6
  10. package/dist/{Experience-BqMJUymq.js → Experience-l24HNuYa.js} +8 -8
  11. package/dist/{Game-DvjisU7I.js → Game-CYR3nNcT.js} +8 -8
  12. package/dist/{Index-Vbv5hpsB.js → Index-BYC9ThLe.js} +9 -9
  13. package/dist/{Marketing-CU6GUm2L.js → Marketing-C_oZtbqT.js} +5 -5
  14. package/dist/{Member-Dcyb6og-.js → Member-DxAoZFfz.js} +4 -4
  15. package/dist/MemberList-CyHaxFqq.js +1538 -0
  16. package/dist/MemberTransactions-Ce1N88OQ.js +45 -0
  17. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-B_q37PEs.js → MessageInput.vue_vue_type_script_setup_true_lang-CwF3Vok8.js} +2 -2
  18. package/dist/{Mission-_Vi8gaKQ.js → Mission-DdgpqYWl.js} +8 -8
  19. package/dist/{Overview-8ZkvZh2U.js → Overview-DVcotUZ5.js} +412 -396
  20. package/dist/{Point-BqmJ8ak3.js → Point-B56BrM7H.js} +8 -8
  21. package/dist/{Promotion-CDOtfUpE.js → Promotion-4yL1H9g5.js} +9 -9
  22. package/dist/{Record-NUadzYL2.js → Record-DZ2SbNCg.js} +5 -5
  23. package/dist/{Reward-CgRFzQHO.js → Reward-DX5V3RGG.js} +34 -34
  24. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-Cg5cJLSS.js → RewardGroup.vue_vue_type_script_setup_true_lang-D9UFAixa.js} +12 -13
  25. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-Bac_RiwJ.js → RuleGroup.vue_vue_type_script_setup_true_lang-4tF-6JVC.js} +14 -15
  26. package/dist/{Segment-bHLt_9xi.js → Segment-DKpM-dlV.js} +68 -68
  27. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-DWulr5sA.js → SelectItems.vue_vue_type_script_setup_true_lang-4Co06qsp.js} +2 -2
  28. package/dist/{Setting-AQjJ0LBm.js → Setting-CbV6piRR.js} +8 -8
  29. package/dist/{Store-DzGhYzS9.js → Store-BIMMzBEA.js} +19 -20
  30. package/dist/{StoreRewards-BN33UZrN.js → StoreRewards-Tr8TXAWt.js} +12 -12
  31. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-CF7R6Mbf.js → StoreTransactions.vue_vue_type_script_setup_true_lang-wPxHMj1_.js} +330 -363
  32. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-C3wxmJBS.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-CaRE8E-o.js} +1 -1
  33. package/dist/{Tier-BaIm0-nO.js → Tier-BN3HKQpg.js} +20 -21
  34. package/dist/{Title-CGU2TRSf.js → Title-DhDuDHSD.js} +20 -21
  35. package/dist/{Transaction-DA2CK2a4.js → Transaction-Tz3ewMZm.js} +2 -2
  36. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-DSVVsk_u.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-w5Cq6L8_.js} +6 -6
  37. package/dist/{Voucher-Bzh_fJpa.js → Voucher-CdEDGQkq.js} +11 -11
  38. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-Bflyp1V0.js → VoucherEditor.vue_vue_type_script_setup_true_lang-CajIUE-r.js} +10 -10
  39. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-Wh_Pc7qk.js → ZodTextField.vue_vue_type_script_setup_true_lang-CFCVdVWx.js} +1 -1
  40. package/dist/{app-CBijF7l9.js → app-Cx8AYCg_.js} +1 -1
  41. package/dist/{app-Ceasya0M.js → app-oW33KZ3o.js} +212 -186
  42. package/dist/app.js +1 -1
  43. package/dist/{business-BJ-cyfj6.js → business-DjK1cD6M.js} +1 -1
  44. package/dist/{dto-BnknKYcg.js → campaign-D4CDaSod.js} +610 -818
  45. package/dist/{campaign-B5Cvxv_n.js → campaign-DBISpYyM.js} +2 -2
  46. package/dist/{campaign.enum-CwvY4pwh.js → campaign.enum-BB6zKvqL.js} +1 -1
  47. package/dist/{campaign.fn-CWcwUEiZ.js → campaign.fn-BBuN-vxE.js} +2 -2
  48. package/dist/{collectible.enum-COdcR96r.js → collectible.enum-BkzPmWP5.js} +1 -1
  49. package/dist/{collection.fn-BTQbGCVW.js → collection.fn--9IoH5C8.js} +2 -2
  50. package/dist/dto-Cf4bZ2Ha.js +214 -0
  51. package/dist/{effect-DqWwcDoL.js → effect-BpSxSe0d.js} +1 -1
  52. package/dist/{email-addresses-DPPlvfPT.js → email-addresses-wHQnOKcN.js} +1 -1
  53. package/dist/{export-FXBFFRdK.js → export-pg40fbOp.js} +3 -3
  54. package/dist/{helper-C776lUH-.js → helper-vuZmD3vd.js} +1 -1
  55. package/dist/{index-BG5txN30.js → index-BbhmmxBp.js} +2057 -1010
  56. package/dist/{index-D62SBn2q.js → index-BjcUav4X.js} +3 -3
  57. package/dist/{index-CRlD2sul.js → index-Bl60bODV.js} +3 -3
  58. package/dist/{index-BjAdYoh3.js → index-CCRD2tgv.js} +12 -13
  59. package/dist/{index-Cgaj4reE.js → index-D6knHtFJ.js} +1 -1
  60. package/dist/{index-CxU9mwRl.js → index-D8CIHJ0z.js} +1 -1
  61. package/dist/{index-CpD4ezv2.js → index-DInxnKvr.js} +22 -4
  62. package/dist/index-K7WU4vc1.js +44 -0
  63. package/dist/{index-C1aWGTdZ.js → index-UNh4BJAd.js} +1 -1
  64. package/dist/{index-DeMgVwv8.js → index-VjvyNKmR.js} +6 -6
  65. package/dist/{index-CZaQ-veW.js → index-t-NFK-AQ.js} +1 -1
  66. package/dist/{index-I27oHD1a.js → index-tWez6zPm.js} +1 -1
  67. package/dist/{index.esm2017-Cf8UXsST.js → index.esm2017-Djt10vTu.js} +1 -1
  68. package/dist/{loading-DCSdIZqP.js → loading-CVE2HNjb.js} +4 -4
  69. package/dist/{membership-KiKcnWxt.js → membership-BLkSVFx9.js} +3 -3
  70. package/dist/{money-B_LMR19r.js → money-DqUkifCn.js} +1 -1
  71. package/dist/{number-Bk18T5Xb.js → number-BPlOwScu.js} +1 -1
  72. package/dist/{objectid-CZ5qnZ1J.js → objectid-J3u1WeUz.js} +8 -8
  73. package/dist/{reward-ozVC4wTW.js → reward-B9WzNBWQ.js} +1 -1
  74. package/dist/{rule-CWT8hI3A.js → rule-FtBYuezP.js} +3 -3
  75. package/dist/{rule-builder-DTEvWEjJ.js → rule-builder-caiYx8mw.js} +1 -1
  76. package/dist/{template-9N1FRXDZ.js → template-C1Iii37r.js} +4 -4
  77. package/dist/{trigger-C2-zYC46.js → trigger-DEH6eTbm.js} +6 -6
  78. package/dist/{user-DBxVxr4P.js → user-DqSmwkKW.js} +1 -1
  79. package/dist/{vue-i18n-BK0qKZu-.js → vue-i18n-4lC91qO3.js} +296 -296
  80. package/dist/{xlsx-CmKV4f40.js → xlsx-DNspY5sG.js} +1 -1
  81. package/package.json +1 -1
  82. package/dist/MemberList-CBO6SVE-.js +0 -1044
  83. package/dist/MemberTransactions-BuPoUtjA.js +0 -38
  84. package/dist/index-Dw1WniG7.js +0 -1050
@@ -1,1044 +0,0 @@
1
- import { defineComponent as pe, computed as Y, ref as X, resolveComponent as _, openBlock as v, createElementBlock as V, Fragment as ee, createElementVNode as a, unref as o, createBlock as j, createCommentVNode as ae, createVNode as C, renderList as se, withCtx as ne, createTextVNode as ue, toDisplayString as M, withDirectives as Pe, vShow as Re, onMounted as Oe, isRef as Ze, h as oe } from "vue";
2
- import { h as g } 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-DPPlvfPT.js";
5
- import { w as ot } from "./xlsx-CmKV4f40.js";
6
- import "./index-CZaQ-veW.js";
7
- import { p as Ee, b as De, u as Ye } from "./loading-DCSdIZqP.js";
8
- import { u as ye, C as Be, s as nt } from "./membership-KiKcnWxt.js";
9
- import { c as at } from "./index-D62SBn2q.js";
10
- import { _ as Ue } from "./lodash-B5I3zXaY.js";
11
- import { D as st } from "./type_drinks-D6jnpvwV.js";
12
- import { F as it, a as rt, b as lt, c as dt, d as ct } from "./index-BG5txN30.js";
13
- import { C as fe } from "./collection.fn-BTQbGCVW.js";
14
- import { u as Le } from "./business-BJ-cyfj6.js";
15
- import { defineStore as mt } from "pinia";
16
- import { m as J } from "./index-CxU9mwRl.js";
17
- import { o as ze } from "./objectId-dwaoBfJX.js";
18
- import { f as me } from "./number-Bk18T5Xb.js";
19
- import { t as ut } from "./money-B_LMR19r.js";
20
- import { u as pt, _ as ft } from "./usePagination-BeF5K3M7.js";
21
- import { g as bt, a as yt, b as vt } from "./user-DBxVxr4P.js";
22
- import { useRouter as xt } from "vue-router";
23
- import { R as gt } from "./app-Ceasya0M.js";
24
- const Ct = { class: "flex flex-col" }, St = { key: 1 }, ht = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, Ft = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, _t = /* @__PURE__ */ pe({
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(b) {
37
- var W, H, G, D;
38
- const q = be(), x = ye(), u = b, I = Y(
39
- () => {
40
- var l;
41
- return (((l = u.member.collection) == null ? void 0 : l.TITLE) ?? []).reduce(
42
- (r, p) => {
43
- var e, d, y, m, h;
44
- const n = x.sortedTitles.find(
45
- (A) => A._id.toString() === p.collectible
46
- );
47
- if (!n) return r;
48
- const t = [...p.expiryBalance ?? []].sort(
49
- (A, U) => g(A.expiredAt).isAfter(g(U.expiredAt)) ? -1 : 1
50
- );
51
- return (e = t[0]) != null && e.expiredAt && g((d = t[0]) == null ? void 0 : d.expiredAt).isBefore(g()) || r.push({
52
- _id: n._id,
53
- name: n.name,
54
- expiredAt: (y = t[0]) != null && y.expiredAt ? g((m = t[0]) == null ? void 0 : m.expiredAt).toISOString() : "",
55
- expiresIn: g((h = t[0]) == null ? void 0 : h.expiredAt).diff(g(), "days")
56
- }), r;
57
- },
58
- []
59
- );
60
- }
61
- ), c = X({
62
- cardNo: u.member.cardNo,
63
- experience: ((H = (W = u.member.collection) == null ? void 0 : W.POINT) == null ? void 0 : H[0].balance) ?? 0,
64
- tier: ((D = (G = u.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
- () => (x.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(() => (x.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 p, n;
81
- const l = ((p = k.value[(c.value.tier ?? 1) - 1]) == null ? void 0 : p.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 p, n, t, e, d, y;
89
- const l = ((n = (p = u.member.collection) == null ? void 0 : p.TIER) == null ? void 0 : n[0].balance) ?? -1, r = ((e = (t = u.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, h = ((y = k.value[l - 1]) == null ? void 0 : y.to) ?? 0;
93
- if (c.value.experience < m || h && c.value.experience > h)
94
- return !0;
95
- }
96
- return !1;
97
- });
98
- function S(l) {
99
- var r;
100
- return (r = I.value.find((p) => p._id === l)) == null ? void 0 : r.expiresIn;
101
- }
102
- const L = Y(() => {
103
- const l = it.safeParse(c.value);
104
- return l.success ? void 0 : l.error.errors;
105
- });
106
- function N(l) {
107
- var r, p;
108
- return (p = (r = L.value) == null ? void 0 : r.find((n) => n.path.join(".") === l)) == null ? void 0 : p.message;
109
- }
110
- function K(l) {
111
- var r;
112
- return (r = L.value) == null ? void 0 : r.filter((p) => p.path.join(".").startsWith(l)).map((p) => p.message);
113
- }
114
- async function B() {
115
- await u.onSubmit(c.value), q.close();
116
- }
117
- return (l, r) => {
118
- var A, U;
119
- const p = _("FmSelect"), n = _("FmStepperField"), t = _("FmTextField"), e = _("FmField"), d = _("FmFormGroup"), y = _("FmButton"), m = _("FmHelperText"), h = _("FmSpacer");
120
- return v(), 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 ? (v(), j(p, {
124
- key: 0,
125
- modelValue: o(c).tier,
126
- "onUpdate:modelValue": [
127
- r[0] || (r[0] = (i) => o(c).tier = i),
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
- C(n, {
136
- "model-value": o(c).experience ?? 0,
137
- "onUpdate:modelValue": r[1] || (r[1] = (i) => o(c).experience = i),
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
- C(t, {
145
- modelValue: o(c).cardNo,
146
- "onUpdate:modelValue": r[2] || (r[2] = (i) => o(c).cardNo = i),
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
- (A = o(c).titles) != null && A.length ? (v(), 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
- (v(!0), V(ee, null, se(o(c).titles ?? [], (i, F) => (v(), V("div", { key: F }, [
160
- a("div", ht, [
161
- o(I).some((f) => f._id === i.id) ? (v(), j(d, {
162
- key: 1,
163
- "model-value": "",
164
- class: "flex-1"
165
- }, {
166
- default: ne(() => [
167
- C(e, {
168
- disabled: !0,
169
- class: "text-fm-color-typo-secondary"
170
- }, {
171
- default: ne(() => {
172
- var f;
173
- return [
174
- ue(M((f = o($).find((w) => w.value === i.id)) == null ? void 0 : f.label), 1)
175
- ];
176
- }),
177
- _: 2
178
- }, 1024)
179
- ]),
180
- _: 2
181
- }, 1024)) : (v(), j(p, {
182
- key: 0,
183
- modelValue: i.id,
184
- "onUpdate:modelValue": [(f) => i.id = f, (f) => i.expiredAt = S(f) ?? 1],
185
- class: "flex-1",
186
- items: o($).filter(
187
- (f) => {
188
- var w;
189
- return !((w = o(c).titles) != null && w.map((P) => P.id).includes(f.value)) || i.id === f.value;
190
- }
191
- )
192
- }, null, 8, ["modelValue", "onUpdate:modelValue", "items"])),
193
- C(n, {
194
- modelValue: i.expiredAt,
195
- "onUpdate:modelValue": (f) => i.expiredAt = f,
196
- class: "flex-1",
197
- label: "",
198
- "max-fraction-digits": 0
199
- }, null, 8, ["modelValue", "onUpdate:modelValue"]),
200
- C(y, {
201
- class: "w-24 h-24",
202
- icon: "close",
203
- variant: "tertiary",
204
- onClick: (f) => {
205
- var w;
206
- return (w = o(c).titles) == null ? void 0 : w.splice(F, 1);
207
- }
208
- }, null, 8, ["onClick"])
209
- ]),
210
- (v(!0), V(ee, null, se(K(`titles.${F}`), (f, w) => (v(), j(m, {
211
- key: w,
212
- class: "items-center",
213
- state: "error",
214
- text: f.toString()
215
- }, null, 8, ["text"]))), 128))
216
- ]))), 128)),
217
- o($).length && (((U = o(c).titles) == null ? void 0 : U.length) ?? 0) < o($).length ? (v(), j(y, {
218
- key: 2,
219
- icon: "add",
220
- label: "Give title",
221
- variant: "plain",
222
- onClick: r[3] || (r[3] = (i) => {
223
- var F;
224
- return o(c).titles = [
225
- ...o(c).titles ?? [],
226
- {
227
- id: ((F = o($).find(
228
- (f) => {
229
- var w;
230
- return !((w = o(c).titles) != null && w.map((P) => P.id).includes(f.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(C(m, {
241
- state: "warning",
242
- text: "Updating member will cause tier to change"
243
- }, null, 512), [
244
- [Re, o(E)]
245
- ]),
246
- C(h),
247
- C(y, {
248
- variant: "secondary",
249
- label: "Cancel",
250
- size: "md",
251
- onClick: r[4] || (r[4] = (i) => o(q).close())
252
- }),
253
- C(y, {
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__ */ pe({
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(b) {
275
- const q = be(), x = b, u = X({
276
- amount: 1,
277
- day: 1,
278
- remark: void 0
279
- }), I = X(!0), c = Y(() => fe.formattedType(x.type.toUpperCase()));
280
- function $(E) {
281
- I.value = E, !E && x.type === "coin" && (u.value.day = void 0);
282
- }
283
- async function k() {
284
- if (x.action === "send") {
285
- const E = u.value.day ? `, expire in ${u.value.day} days` : "";
286
- Ee.confirm(
287
- `Are you sure to send ${u.value.amount} ${c.value.toLowerCase()}${E}? This action cannot be reversed.`
288
- ).then(async (S) => {
289
- S && await x.onSubmit(u.value);
290
- });
291
- } else
292
- Ee.confirm(
293
- `Are you sure to deduct ${u.value.amount} ${c.value.toLowerCase()}? This action cannot be reversed.`
294
- ).then(async (E) => {
295
- E && await x.onSubmit(u.value);
296
- });
297
- }
298
- const T = Y(() => {
299
- const S = (x.action === "send" ? x.type === "coin" ? rt : lt : x.type === "coin" ? dt : ct).safeParse(u.value);
300
- return S.success == !1 ? S.error.flatten().fieldErrors : void 0;
301
- });
302
- return (E, S) => {
303
- const L = _("FmStepperField"), N = _("FmSwitch"), K = _("FmTextarea"), B = _("FmButton"), W = _("FmCard");
304
- return v(), j(W, { class: "flex flex-col gap-16 p-16" }, {
305
- default: ne(() => {
306
- var H, G, D, l, r, p;
307
- return [
308
- a("div", Tt, M(x.action == "send" ? "Send" : "Deduct") + " " + M(o(Be)[x.type.toUpperCase()].name), 1),
309
- ue(" " + M(o(T)) + " ", 1),
310
- a("div", wt, [
311
- C(L, {
312
- modelValue: o(u).amount,
313
- "onUpdate:modelValue": S[0] || (S[0] = (n) => o(u).amount = n),
314
- label: `${o(Be)[x.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
- b.action === "send" && x.type === "coin" ? (v(), 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
- b.action === "send" && o(I) ? (v(), j(L, {
328
- key: 1,
329
- modelValue: o(u).day,
330
- "onUpdate:modelValue": S[2] || (S[2] = (n) => o(u).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": (p = (r = o(T)) == null ? void 0 : r.day) == null ? void 0 : p[0]
338
- }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : ae("", !0),
339
- C(K, {
340
- modelValue: o(u).remark,
341
- "onUpdate:modelValue": S[3] || (S[3] = (n) => o(u).remark = n),
342
- label: "Remark"
343
- }, null, 8, ["modelValue"])
344
- ]),
345
- a("div", kt, [
346
- C(B, {
347
- variant: "secondary",
348
- label: "Cancel",
349
- size: "md",
350
- onClick: S[4] || (S[4] = (n) => o(q).close())
351
- }),
352
- C(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 = mt("segment", () => {
367
- const b = X([]);
368
- async function q() {
369
- const x = await nt.readAll({
370
- limit: 1e3,
371
- skip: 0,
372
- sortBy: "_id",
373
- descending: !0
374
- });
375
- b.value = x.resources;
376
- }
377
- return {
378
- segments: b,
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-800" }, Rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ot = { class: "fm-typo-en-body-md-600" }, Yt = { class: "gap-16 grid grid-cols-2" }, Lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-md-600" }, jt = { class: "space-y-8" }, qt = {
382
- key: 0,
383
- class: "space-x-8"
384
- }, Kt = {
385
- key: 1,
386
- class: "text-fm-color-typo-secondary"
387
- }, Gt = { class: "space-y-8" }, Ht = ["src"], Jt = { class: "fm-typo-en-body-md-600" }, Xt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Wt = {
388
- key: 1,
389
- class: "text-fm-color-typo-secondary"
390
- }, Qt = {
391
- key: 1,
392
- class: "space-y-24"
393
- }, Zt = { class: "space-y-8" }, eo = { class: "fm-typo-en-title-md-800" }, to = { class: "space-y-4" }, oo = { class: "fm-typo-en-body-md-600" }, no = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, ao = { class: "space-y-8" }, so = { class: "fm-typo-en-title-md-800" }, io = { class: "space-y-4" }, ro = { class: "fm-typo-en-body-md-600" }, lo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, co = /* @__PURE__ */ pe({
394
- __name: "MemberDetailSheet",
395
- props: {
396
- member: {
397
- type: Object,
398
- required: !0
399
- }
400
- },
401
- emits: ["update:member"],
402
- setup(b, { expose: q, emit: x }) {
403
- const u = Le(), I = ye(), c = je(), $ = be(), { minor: k } = Ye, T = b, E = x, S = Y(() => u.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 y = {
421
- "credit-send": J.sendCredit,
422
- "credit-deduct": J.deductCredit,
423
- "coin-send": J.sendCoin,
424
- "coin-deduct": J.deductCoin
425
- }, m = `${t}-${e}`, h = y[m];
426
- h && await h(T.member._id, d), E("update:member"), $.close();
427
- },
428
- {
429
- message: `Adjusting ${fe.formattedType(t.toUpperCase()).toLowerCase()}`,
430
- successMessage: `${d.amount} ${fe.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: _t,
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 A, U, i, F, f;
466
- const e = (((U = Ue.first((A = T.member.collection) == null ? void 0 : A.TIER)) == null ? void 0 : U.balance) || 0) - 1, d = H.value.name, y = ((F = (i = t.collection) == null ? void 0 : i.POINT) == null ? void 0 : F[0].balance) ?? 0, m = I.sortedTiers[e + 1], h = ((f = m == null ? void 0 : m.option) == null ? void 0 : f.to) ?? 1 / 0;
467
- return `${d} (${y}/${h})`;
468
- }
469
- },
470
- {
471
- label: "Email",
472
- key: "email"
473
- },
474
- {
475
- label: "Birthday",
476
- getter: (t) => t.birthday ? g(t.birthday).format("D MMM YYYY") : "-"
477
- }
478
- ], W = [
479
- {
480
- label: "Customer since",
481
- getter: (t) => g(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) => g(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) => at.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, y;
522
- const t = (((y = Ue.first((d = T.member.collection) == null ? void 0 : d.TIER)) == null ? void 0 : y.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 y, m, h;
528
- const d = (y = I.sortedTitles) == null ? void 0 : y.find(
529
- (A) => A._id == e.collectible
530
- );
531
- return {
532
- name: d == null ? void 0 : d.name,
533
- expiredAt: (h = (m = e.expiryBalance) == null ? void 0 : m.at(-1)) == null ? void 0 : h.expiredAt,
534
- collectible: d
535
- };
536
- }).filter(
537
- (e) => e.expiredAt ? g(e.expiredAt).isAfter(g()) : !0
538
- );
539
- }), D = X(!0);
540
- function l() {
541
- D.value = !0, n.value = p[0];
542
- }
543
- function r() {
544
- D.value = !1;
545
- }
546
- const p = [
547
- {
548
- label: "Overview",
549
- value: "overview"
550
- },
551
- {
552
- label: "Loyalty",
553
- value: "loyalty"
554
- }
555
- ], n = X(p[0]);
556
- return Oe(async () => {
557
- await I.readMembership(), u.locations.length || await u.readLocations();
558
- }), q({
559
- showSheet: l,
560
- hideSheet: r
561
- }), (t, e) => {
562
- const d = _("FmTabs"), y = _("FmAvatar"), m = _("FmButton"), h = _("FmChip"), A = _("FmCard"), U = _("FmSideSheet");
563
- return v(), j(U, {
564
- modelValue: o(D),
565
- "onUpdate:modelValue": e[5] || (e[5] = (i) => Ze(D) ? D.value = i : null),
566
- header: "Member Detail",
567
- "dismiss-away": "",
568
- "close-button": !0,
569
- "max-width": 550
570
- }, {
571
- "side-sheet-footer": ne(() => e[20] || (e[20] = [])),
572
- default: ne(() => [
573
- a("div", At, [
574
- C(d, {
575
- "model-value": o(n).value,
576
- items: p,
577
- "onUpdate:modelValue": e[0] || (e[0] = (i) => n.value = p.find((F) => F.value === i))
578
- }, null, 8, ["model-value"]),
579
- o(n).value == "overview" ? (v(), V(ee, { key: 0 }, [
580
- e[11] || (e[11] = a("div", { class: "fm-typo-en-title-sm-800" }, "Profile Information", -1)),
581
- a("div", Nt, [
582
- a("div", Vt, [
583
- C(y, {
584
- name: b.member.photoUrl ? void 0 : b.member.name,
585
- src: b.member.photoUrl || void 0
586
- }, null, 8, ["name", "src"]),
587
- a("div", It, [
588
- e[8] || (e[8] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1)),
589
- a("div", $t, M(b.member.name), 1),
590
- a("div", Et, M(b.member._id), 1),
591
- a("div", Dt, [
592
- e[6] || (e[6] = ue(" Member Card: ")),
593
- a("span", Bt, M(b.member.cardNo ? b.member.cardNo : "-"), 1)
594
- ]),
595
- a("div", Ut, [
596
- e[7] || (e[7] = ue(" Referral Code: ")),
597
- a("span", Pt, M(b.member.referralCode ? b.member.referralCode : "-"), 1)
598
- ])
599
- ]),
600
- C(m, {
601
- variant: "tertiary",
602
- icon: "settings",
603
- onClick: K
604
- })
605
- ]),
606
- (v(), V(ee, null, se(B, (i, F) => a("div", { key: F }, [
607
- a("div", Rt, M(i.label), 1),
608
- a("div", Ot, M(i.key ? b.member[i.key] : i.getter(b.member)), 1)
609
- ])), 64))
610
- ]),
611
- e[12] || (e[12] = a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
612
- e[13] || (e[13] = a("div", { class: "fm-typo-en-title-sm-800" }, "Activities", -1)),
613
- a("div", Yt, [
614
- (v(), V(ee, null, se(W, (i) => a("div", {
615
- key: i.key
616
- }, [
617
- a("div", Lt, M(i.label), 1),
618
- a("div", zt, M(i.key ? T.member.stats[i.key] || "-" : i.getter(b.member)), 1)
619
- ])), 64))
620
- ]),
621
- e[14] || (e[14] = a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
622
- a("div", jt, [
623
- e[9] || (e[9] = a("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1)),
624
- o(L).length ? (v(), V("div", qt, [
625
- (v(!0), V(ee, null, se(o(L), (i) => (v(), j(h, {
626
- label: i.toString()
627
- }, null, 8, ["label"]))), 256))
628
- ])) : (v(), V("div", Kt, "No titles"))
629
- ]),
630
- e[15] || (e[15] = a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
631
- a("div", Gt, [
632
- e[10] || (e[10] = a("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1)),
633
- o(G).length ? (v(!0), V(ee, { key: 0 }, se(o(G).filter((i) => i.collectible), (i) => (v(), V("div", {
634
- class: "flex items-center gap-x-8 h-48",
635
- key: i.name
636
- }, [
637
- a("img", {
638
- src: i.collectible.image || o(st),
639
- class: "aspect-square h-full object-contain"
640
- }, null, 8, Ht),
641
- a("div", null, [
642
- a("div", Jt, M(i.name), 1),
643
- a("div", Xt, " Expired on " + M(o(g)(i.expiredAt).format("MMM D, Y")), 1)
644
- ])
645
- ]))), 128)) : (v(), V("div", Wt, "No titles"))
646
- ])
647
- ], 64)) : o(n).value == "loyalty" ? (v(), V("div", Qt, [
648
- C(A, {
649
- class: "p-16 space-y-24",
650
- variant: "outlined"
651
- }, {
652
- default: ne(() => {
653
- var i, F, f, w, P, Q, Z;
654
- return [
655
- a("div", Zt, [
656
- e[16] || (e[16] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1)),
657
- a("div", eo, M(((f = (F = (i = b.member.collection) == null ? void 0 : i.CREDIT) == null ? void 0 : F[0]) == null ? void 0 : f.balance) ?? 0), 1)
658
- ]),
659
- a("div", to, [
660
- e[17] || (e[17] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1)),
661
- a("div", oo, M(((Z = (Q = (P = (w = b.member.collection) == null ? void 0 : w.CREDIT) == null ? void 0 : P[0]) == null ? void 0 : Q.expiryBalance) == null ? void 0 : Z.reduce(
662
- (R, O) => O.expiredAt && o(g)(O.expiredAt).isAfter(o(g)()) && o(g)(O.expiredAt).isBefore(o(g)().add(30, "days")) ? R + O.amount : R,
663
- 0
664
- )) ?? 0), 1)
665
- ]),
666
- a("div", no, [
667
- C(m, {
668
- label: "Add credit",
669
- icon: "add",
670
- variant: "plain",
671
- onClick: e[1] || (e[1] = (R) => N("credit", "send"))
672
- }),
673
- C(m, {
674
- label: "Deduct credit",
675
- icon: "remove",
676
- variant: "plain",
677
- onClick: e[2] || (e[2] = (R) => N("credit", "deduct"))
678
- })
679
- ])
680
- ];
681
- }),
682
- _: 1
683
- }),
684
- C(A, {
685
- class: "p-16 space-y-24",
686
- variant: "outlined"
687
- }, {
688
- default: ne(() => {
689
- var i, F, f, w, P, Q, Z;
690
- return [
691
- a("div", ao, [
692
- e[18] || (e[18] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1)),
693
- a("div", so, M(((f = (F = (i = b.member.collection) == null ? void 0 : i.COIN) == null ? void 0 : F[0]) == null ? void 0 : f.balance) ?? 0), 1)
694
- ]),
695
- a("div", io, [
696
- e[19] || (e[19] = a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1)),
697
- a("div", ro, M(((Z = (Q = (P = (w = b.member.collection) == null ? void 0 : w.COIN) == null ? void 0 : P[0]) == null ? void 0 : Q.expiryBalance) == null ? void 0 : Z.reduce(
698
- (R, O) => O.expiredAt && o(g)(O.expiredAt).isAfter(o(g)()) && o(g)(O.expiredAt).isBefore(o(g)().add(30, "days")) ? R + O.amount : R,
699
- 0
700
- )) ?? 0), 1)
701
- ]),
702
- a("div", lo, [
703
- C(m, {
704
- label: "Add point",
705
- icon: "add",
706
- variant: "plain",
707
- onClick: e[3] || (e[3] = (R) => N("coin", "send"))
708
- }),
709
- C(m, {
710
- label: "Deduct point",
711
- icon: "remove",
712
- variant: "plain",
713
- onClick: e[4] || (e[4] = (R) => N("coin", "deduct"))
714
- })
715
- ])
716
- ];
717
- }),
718
- _: 1
719
- })
720
- ])) : ae("", !0)
721
- ])
722
- ]),
723
- _: 1
724
- }, 8, ["modelValue"]);
725
- };
726
- }
727
- }), mo = { class: "flex items-center justify-end" }, Do = /* @__PURE__ */ pe({
728
- __name: "MemberList",
729
- setup(b) {
730
- const q = je(), x = ye(), u = Le(), { minor: I } = Ye, c = xt(), $ = [
731
- {
732
- header: "Name",
733
- enableSorting: !0,
734
- accessorKey: "name",
735
- cell(n) {
736
- return bt(n.row.original);
737
- }
738
- },
739
- {
740
- accessorFn: (n) => g(ze(n._id.toString())).format("D MMM YYYY"),
741
- header: "Customer Since",
742
- accessorKey: "_id",
743
- id: "_id"
744
- },
745
- {
746
- accessorKey: "collection_TIER_0_balance",
747
- header: "Tier",
748
- enableSorting: !0,
749
- cell(n) {
750
- return yt(
751
- n.row.original,
752
- x.sortedTiers
753
- );
754
- }
755
- },
756
- {
757
- header: "Title",
758
- enableSorting: !1,
759
- cell(n) {
760
- return vt(
761
- n.row.original,
762
- x.sortedTitles
763
- );
764
- }
765
- },
766
- {
767
- accessorKey: "collection_CREDIT_0_balance",
768
- accessorFn: (n) => {
769
- var t, e, d;
770
- return me(((d = (e = (t = n.collection) == null ? void 0 : t.CREDIT) == null ? void 0 : e[0]) == null ? void 0 : d.balance) ?? 0, 2);
771
- },
772
- header: "Credit(s)",
773
- enableSorting: !0
774
- },
775
- {
776
- accessorKey: "collection_POINT_0_balance",
777
- accessorFn: (n) => {
778
- var t, e, d;
779
- return me(((d = (e = (t = n.collection) == null ? void 0 : t.POINT) == null ? void 0 : e[0]) == null ? void 0 : d.balance) ?? 0, 2);
780
- },
781
- header: "Experience(s)",
782
- enableSorting: !0
783
- },
784
- {
785
- accessorKey: "collection_COIN_0_balance",
786
- accessorFn: (n) => {
787
- var t, e, d;
788
- return me(((d = (e = (t = n.collection) == null ? void 0 : t.COIN) == null ? void 0 : e[0]) == null ? void 0 : d.balance) ?? 0, 2);
789
- },
790
- header: "Point(s)",
791
- enableSorting: !0
792
- },
793
- {
794
- accessorFn: (n) => {
795
- var t;
796
- return ((t = n.stats) == null ? void 0 : t.visitCount) ?? 0;
797
- },
798
- header: "Total visit",
799
- accessorKey: "stats.visitCount",
800
- id: "stats.visitCount"
801
- },
802
- {
803
- accessorFn: (n) => {
804
- var t;
805
- return (t = n.stats) == null ? void 0 : t.lastVisit;
806
- },
807
- sortingFn: (n, t) => {
808
- var e, d;
809
- 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();
810
- },
811
- id: "stats.lastVisit",
812
- header: "Last visit",
813
- cell(n) {
814
- var t, e;
815
- return oe("div", { class: "flex items-center justify-end gap-4" }, [
816
- oe(
817
- "span",
818
- (t = n.row.original.stats) != null && t.lastVisit ? g((e = n.row.original.stats) == null ? void 0 : e.lastVisit).fromNow() : "NA"
819
- ),
820
- oe(
821
- de.FmTooltip,
822
- {
823
- content: g(n.row.original.stats.lastVisit).format(
824
- "D MMM YYYY - hh:mmA"
825
- )
826
- },
827
- [oe(de.FmIcon, { name: "info", outline: !0, size: "sm" })]
828
- )
829
- ]);
830
- }
831
- },
832
- {
833
- id: "actions",
834
- cell(n) {
835
- return oe(
836
- de.FmMenu,
837
- {
838
- placement: "bottom-end",
839
- onClick: (t) => {
840
- t.stopPropagation();
841
- }
842
- },
843
- {
844
- "menu-button": () => oe(de.FmButton, { icon: "more_vert", variant: "tertiary" }),
845
- default: () => [
846
- oe(de.FmMenuItem, {
847
- label: "Transaction details",
848
- onClick: async (t) => {
849
- t.stopPropagation(), await D(n.row.original._id);
850
- }
851
- })
852
- ]
853
- }
854
- );
855
- }
856
- }
857
- ], { tableMeta: k, rowData: T, onSort: E, debouncedFetchData: S, onSearch: L } = pt(J.read), N = X(), K = X(!1), B = X(), W = Y(() => u.locations.map((n) => ({
858
- label: n.name,
859
- value: n._id
860
- })));
861
- async function H() {
862
- B.value = await J.readById(
863
- B.value._id.toString()
864
- ), K.value = !0;
865
- }
866
- async function G() {
867
- await S(), K.value = !1;
868
- }
869
- async function D(n) {
870
- await c.push({
871
- name: gt["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
872
- params: { id: n }
873
- });
874
- }
875
- const l = {
876
- sortBy: "_id",
877
- descending: !1,
878
- rowsPerPage: 1e3,
879
- page: 1,
880
- rowsNumber: 0
881
- };
882
- function r(n) {
883
- const t = g(n);
884
- return t.isValid() ? t.format("DD/MM/YYYY") : "";
885
- }
886
- async function p() {
887
- const n = new tt(), t = (await J.read({
888
- limit: 1,
889
- skip: 0,
890
- sortBy: l.sortBy,
891
- descending: l.descending
892
- })).meta.totalResources ?? 0, e = l.rowsPerPage;
893
- await I(
894
- async () => {
895
- var d, y, m, h, A, U, i, F, f, w, P, Q, Z, R, O, ve, xe, ge, Ce, Se, he, Fe, _e, Te, we, ke, Me, Ae;
896
- for (let Ne = 0; Ne < t; Ne += e) {
897
- const qe = {
898
- ...l,
899
- limit: e,
900
- skip: l.page - 1,
901
- sortBy: l.sortBy,
902
- descending: l.descending
903
- }, Ke = await J.read(qe);
904
- for (const s of Ke.resources) {
905
- const Ge = (d = et.parseOneAddress(
906
- s == null ? void 0 : s.email
907
- )) != null && d.domain.includes("feedmepos.com") ? void 0 : s.email, He = (m = ((y = s == null ? void 0 : s.collection) == null ? void 0 : y.TITLE) || []) == null ? void 0 : m.reduce(
908
- (z, te) => {
909
- var re, le;
910
- const ie = (le = (re = x.sortedTitles) == null ? void 0 : re.find(
911
- (ce) => ce._id === te.collectible
912
- )) == null ? void 0 : le.name;
913
- return !ie || te.balance <= 0 || z.push(ie), z;
914
- },
915
- []
916
- ), Je = (x.sortedTitles || []).reduce(
917
- (z, te) => {
918
- var re, le, ce, $e;
919
- const ie = ($e = (ce = (le = (((re = s == null ? void 0 : s.collection) == null ? void 0 : re.TITLE) || []).find(
920
- (Qe) => Qe.collectible === te._id
921
- )) == null ? void 0 : le.expiryBalance) == null ? void 0 : ce[0]) == null ? void 0 : $e.expiredAt;
922
- return z[te.name] = ie ? g(ie).format("DD/MM/YYYY") : "", z;
923
- },
924
- {}
925
- ), Xe = ((U = (A = (h = s.collection) == null ? void 0 : h.CREDIT) == null ? void 0 : A.at(0)) == null ? void 0 : U.balance) || 0, Ve = ((w = (f = (F = (i = s.collection) == null ? void 0 : i.CREDIT) == null ? void 0 : F.at(0)) == null ? void 0 : f.expiryBalance) == null ? void 0 : w.reduce(
926
- (z, te) => z + te.amount,
927
- 0
928
- )) || 0, Ie = me(Xe, 2), We = {
929
- ID: s._id.toString(),
930
- Name: ((P = s.name) == null ? void 0 : P.trim()) || "",
931
- Phone: ((Q = s == null ? void 0 : s.phoneNumber) == null ? void 0 : Q.trim()) || "",
932
- Email: Ge || "",
933
- Gender: s.gender || "",
934
- CardNo: s.cardNo || "",
935
- Birthday: s != null && s.birthday ? r(s == null ? void 0 : s.birthday) : "",
936
- Credit: (Number(Ie) - Number(Ve)).toFixed(2),
937
- FreeCredit: Number(Ve.toFixed(2)),
938
- TotalCredit: Number(Ie),
939
- Exp: s != null && s.collection ? ((O = (R = (Z = s.collection) == null ? void 0 : Z.POINT) == null ? void 0 : R.at(0)) == null ? void 0 : O.balance) ?? 0 : 0,
940
- Point: s != null && s.collection ? ((ge = (xe = (ve = s.collection) == null ? void 0 : ve.COIN) == null ? void 0 : xe.at(0)) == null ? void 0 : ge.balance) ?? 0 : 0,
941
- Level: s != null && s.collection ? ((he = (Se = (Ce = s.collection) == null ? void 0 : Ce.TIER) == null ? void 0 : Se.at(0)) == null ? void 0 : he.balance) ?? 0 : 0,
942
- Tier: s != null && s.collection ? ((Te = (_e = (Fe = s.collection) == null ? void 0 : Fe.TIER) == null ? void 0 : _e.at(0)) == null ? void 0 : Te.balance) ?? 0 : 0,
943
- Titles: He.join(","),
944
- ...Je,
945
- TotalTransaction: s.stats.visitCount,
946
- AvgSpent: ut(Number(s.stats.avgBillSize || 0)).toFormat(
947
- !1
948
- ),
949
- TotalSpent: s.stats.avgBillSize * s.stats.visitCount,
950
- LastVisit: r(s.stats.lastVisit),
951
- Feedback: ((we = s.stats) == null ? void 0 : we.feedbackCount) || 0,
952
- LastSeasonTierEarned: ((ke = s.stats) == null ? void 0 : ke.lastSeasonTierEarned) || 0,
953
- LastSeasonPointEarned: ((Me = s.stats) == null ? void 0 : Me.lastSeasonPointEarned) || 0,
954
- JoinedAt: r(s.joinAt || void 0),
955
- JoinedAtLocation: s.location && ((Ae = W.value.find((z) => z.value == s.location)) == null ? void 0 : Ae.label) || "-",
956
- VisitFrequency: `${Number(
957
- Math.ceil(s.stats.avgVisitFrequency).toFixed(0)
958
- )}`
959
- };
960
- n.addRecord(We);
961
- }
962
- l.page++;
963
- }
964
- await ot(
965
- n.buildExcel(),
966
- `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
967
- {
968
- bookType: "xlsx",
969
- bookSST: !1,
970
- type: "array"
971
- }
972
- ), l.page = 1;
973
- },
974
- {
975
- message: "Exporting member...",
976
- successMessage: "Member exported successfully"
977
- }
978
- );
979
- }
980
- return Oe(async () => {
981
- await x.readMembership(), await u.readLocations(), await q.read(), await u.readLocations(), await S();
982
- }), (n, t) => {
983
- const e = _("FmSearch"), d = _("FmButton"), y = _("FmSnackbar");
984
- return v(), V("div", null, [
985
- a("div", mo, [
986
- C(e, {
987
- class: "mt-4",
988
- modelValue: o(k).searchValue,
989
- "onUpdate:modelValue": [
990
- t[0] || (t[0] = (m) => o(k).searchValue = m),
991
- o(L)
992
- ],
993
- placeholder: "Search",
994
- collapsible: ""
995
- }, null, 8, ["modelValue", "onUpdate:modelValue"]),
996
- C(d, {
997
- icon: "ios_share",
998
- variant: "tertiary",
999
- onClick: p
1000
- })
1001
- ]),
1002
- Pe(C(y, {
1003
- "z-index": 0,
1004
- class: "!max-w-full my-16",
1005
- title: "Info",
1006
- description: "Current list is not up to date, please refresh table for latest data.",
1007
- variant: "info",
1008
- dismissable: "",
1009
- onOnDismiss: t[1] || (t[1] = (m) => K.value = !1),
1010
- action: "Refresh",
1011
- onOnAction: G
1012
- }, null, 512), [
1013
- [Re, o(K)]
1014
- ]),
1015
- C(ft, {
1016
- loading: o(k).isLoading,
1017
- "row-data": o(T),
1018
- "row-count": o(k).totalRows,
1019
- "column-defs": $,
1020
- "shrink-at": !1,
1021
- "page-count": o(k).pageCount,
1022
- "page-index": o(k).pageIndex,
1023
- "page-size": o(k).pageSize,
1024
- onSortChange: o(E),
1025
- onPageChange: t[2] || (t[2] = (m) => o(S)({ pageSize: m.pageSize, pageIndex: m.pageIndex })),
1026
- onRowClick: t[3] || (t[3] = (m) => {
1027
- var h;
1028
- B.value = m.original, (h = o(N)) == null || h.showSheet();
1029
- })
1030
- }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1031
- o(B) ? (v(), j(co, {
1032
- key: 0,
1033
- ref_key: "sheetRef",
1034
- ref: N,
1035
- member: o(B),
1036
- "onUpdate:member": H
1037
- }, null, 8, ["member"])) : ae("", !0)
1038
- ]);
1039
- };
1040
- }
1041
- });
1042
- export {
1043
- Do as default
1044
- };