@feedmepos/mf-connect 0.1.0-beta.9 → 0.1.1-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 (102) hide show
  1. package/dist/Analytic-C2etD-eu.js +620 -0
  2. package/dist/{App-DQUbRsdA.js → App-DlRvkDpN.js} +58 -59
  3. package/dist/Broadcast-DpCGUS6r.js +216 -0
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D-BFllvG.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Cj4IcH5D.js} +20 -20
  5. package/dist/Card-DjGC6jmq.js +823 -0
  6. package/dist/Collections-Q2pYWnJF.js +440 -0
  7. package/dist/Credit-DOIq2VYW.js +214 -0
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-C_ZKNWzb.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-D7ML8ePp.js} +1010 -1026
  9. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CyxWG5I7.js +344 -0
  10. package/dist/Experience-DUst4I0H.js +211 -0
  11. package/dist/Game-CXnQR-wV.js +250 -0
  12. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-ByhTB9Ie.js +144 -0
  13. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-CyGJxUol.js → MainLayout-DpZC6o3R.js} +53 -19
  14. package/dist/Marketing-CZfHsMFC.js +309 -0
  15. package/dist/Member-CX5Ohgeg.js +92 -0
  16. package/dist/MemberList-D8I3SaAs.js +1040 -0
  17. package/dist/MemberOverview-C2n9oJZh.js +58 -0
  18. package/dist/{MemberTransactions-zSxSnUkK.js → MemberTransactions-DfZNbCHD.js} +1 -1
  19. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-BxFVEoBX.js +203 -0
  20. package/dist/Mission-S1pwDbqp.js +248 -0
  21. package/dist/Point-BdLUcGZy.js +220 -0
  22. package/dist/Promotion-DWAeQGkU.js +244 -0
  23. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CTKKhH-r.js → RuleGroup.vue_vue_type_script_setup_true_lang-Dux_NMO5.js} +577 -568
  24. package/dist/Segment-CXSE8Bzf.js +560 -0
  25. package/dist/Setting-CLuXuEId.js +1870 -0
  26. package/dist/Store-Be3cui0S.js +1533 -0
  27. package/dist/StoreRewards-zFy_w8p4.js +429 -0
  28. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-2Jqj_rKv.js → StoreTransactions.vue_vue_type_script_setup_true_lang-DxGJKgbc.js} +10 -10
  29. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BkdSj0cX.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-Dreo45H1.js} +1 -1
  30. package/dist/{Tier-Cpl0FV8L.js → Tier-ChzcISYF.js} +453 -481
  31. package/dist/{Title-CbMDd1Et.js → Title-DQSjhBkT.js} +295 -314
  32. package/dist/Transaction-CeWmWpN_.js +36 -0
  33. package/dist/Voucher-BkLIxiZN.js +485 -0
  34. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js +140 -0
  35. package/dist/app-CLNirPsB.js +2974 -0
  36. package/dist/{app-VxaUCtgl.js → app-DuNsy0aC.js} +1 -1
  37. package/dist/app.js +3 -5
  38. package/dist/{business-DR7jpnLz.js → business-COGiTmLD.js} +1 -1
  39. package/dist/{campaign-MqcTb329.js → campaign-BHZMjQi5.js} +3 -5
  40. package/dist/{collection.fn-CvEoe61K.js → collection.fn-sAxtYO_r.js} +2 -2
  41. package/dist/dto-ndeeV_nc.js +1145 -0
  42. package/dist/{effect-BjjQeiQg.js → effect-BQt0rkdT.js} +9 -9
  43. package/dist/email-addresses-B3PazwKs.js +705 -0
  44. package/dist/{export-B8cvWh5n.js → export-D6r-xNji.js} +3 -3
  45. package/dist/{helper-DfgVNY7B.js → helper-CrjQw_Et.js} +1 -1
  46. package/dist/{index-CWR3qYjb.js → index-Btlj28Vg.js} +1 -1
  47. package/dist/{index-C7zMfUgy.js → index-Buy-yvAZ.js} +319 -304
  48. package/dist/{index-0UYoh1-7.js → index-C3AAy__p.js} +1 -1
  49. package/dist/index-CHAaFSD2.js +11 -0
  50. package/dist/{index-Dap5R3vr.js → index-Cg3RFxc9.js} +91 -102
  51. package/dist/{index-2P9w5u3m.js → index-CqpEhMr6.js} +4 -4
  52. package/dist/{index-BsfWRB8R.js → index-CvHj-wYi.js} +1 -1
  53. package/dist/index-DGLmbBnE.js +28997 -0
  54. package/dist/{index-CJ8Uh2Ja.js → index-DXpd07G3.js} +3 -3
  55. package/dist/{index-B5NufbUt.js → index-Daax_BQa.js} +1 -1
  56. package/dist/{index-C2JNcGc-.js → index-DrLEuIe1.js} +281 -299
  57. package/dist/{index-DBy30v8N.js → index-tSEYvA-2.js} +3 -3
  58. package/dist/{index.esm2017-D1X3PgpO.js → index.esm2017-a5BlZ76G.js} +55 -55
  59. package/dist/{loading-CJ3nOovJ.js → loading-B3XGyQ8W.js} +460 -469
  60. package/dist/{membership-B1cmSRyk.js → membership-GIOJ1ptN.js} +3 -3
  61. package/dist/money-z7VwzhZP.js +15 -0
  62. package/dist/number-DHYb2ua_.js +12 -0
  63. package/dist/{rule-builder-CSmOONdb.js → rule-builder-CcsWd5r9.js} +1 -1
  64. package/dist/{rule-ChWyR-0j.js → rule-iIEblTE4.js} +179 -177
  65. package/dist/style.css +1 -1
  66. package/dist/{template-Cug7aRK0.js → template-DMRMDZOW.js} +63 -63
  67. package/dist/{xlsx-CfgPFFvp.js → usePagination-CNFe0T2B.js} +3176 -2955
  68. package/package.json +5 -8
  69. package/dist/Analytic-CMXUjK_F.js +0 -622
  70. package/dist/Broadcast-DowFtHv6.js +0 -223
  71. package/dist/Card-C7rhL0pV.js +0 -825
  72. package/dist/Collections-B-1wlk3r.js +0 -453
  73. package/dist/Credit-DDjozmoF.js +0 -220
  74. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-pwMuIgs5.js +0 -345
  75. package/dist/Experience-BbE-c1Op.js +0 -221
  76. package/dist/Game-DQdRpaN-.js +0 -255
  77. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js +0 -144
  78. package/dist/MainLayout-B1aJoR95.js +0 -41
  79. package/dist/Marketing-Dgmxzg4h.js +0 -316
  80. package/dist/Member-w23oRVwN.js +0 -69
  81. package/dist/MemberList-BLIdjznQ.js +0 -1735
  82. package/dist/MemberOverview-wL_ailso.js +0 -58
  83. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-Dy_lMdZA.js +0 -432
  84. package/dist/Mission-Cjt0E083.js +0 -261
  85. package/dist/Point-CQJL3Ewu.js +0 -222
  86. package/dist/Promotion-BYViH3bu.js +0 -247
  87. package/dist/Segment-B9Jj1ak0.js +0 -437
  88. package/dist/Setting-DXWbgRxs.js +0 -1901
  89. package/dist/Store-Dswk2e_z.js +0 -1511
  90. package/dist/StoreRewards-CNUhG_Ue.js +0 -401
  91. package/dist/Transaction-BB-kk-84.js +0 -39
  92. package/dist/Voucher-b1_Jlm6X.js +0 -490
  93. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-pG-SrXp9.js +0 -56
  94. package/dist/app-DCHKJoql.js +0 -5639
  95. package/dist/dto-jcK3TGB7.js +0 -2770
  96. package/dist/index-Cv7pLAYq.js +0 -3
  97. package/dist/index-LrSSauN2.js +0 -29193
  98. package/dist/money-BEATdGS6.js +0 -15
  99. package/dist/number-CeAYAKCp.js +0 -12
  100. package/dist/usePagination-BeF5K3M7.js +0 -223
  101. package/dist/vue-i18n-BRhKDHdF.js +0 -2365
  102. package/dist/zod-Bg2FbC-D.js +0 -90
@@ -0,0 +1,1040 @@
1
+ import { defineComponent as ue, computed as Y, ref as X, resolveComponent as F, openBlock as y, createElementBlock as N, Fragment as ee, createElementVNode as a, unref as t, 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 ce } from "@feedmepos/ui-library";
4
+ import { e as et, M as tt } from "./email-addresses-B3PazwKs.js";
5
+ import { a as ot, _ as nt, w as at } from "./usePagination-CNFe0T2B.js";
6
+ import "./index-CHAaFSD2.js";
7
+ import { p as Ee, b as De, u as Ye } from "./loading-B3XGyQ8W.js";
8
+ import { u as ye, C as Be, s as st } from "./membership-GIOJ1ptN.js";
9
+ import { c as it } from "./index-DGLmbBnE.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 ct, b as dt, c as mt } from "./index-DXpd07G3.js";
13
+ import { F as ut } from "./index-tSEYvA-2.js";
14
+ import { C as pe } from "./collection.fn-sAxtYO_r.js";
15
+ import { defineStore as pt } from "pinia";
16
+ import { u as Le } from "./business-COGiTmLD.js";
17
+ import { m as J } from "./index-C3AAy__p.js";
18
+ import { o as ze } from "./objectId-dwaoBfJX.js";
19
+ import { f as me } from "./number-DHYb2ua_.js";
20
+ import { t as ft } from "./money-z7VwzhZP.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-CLNirPsB.js";
24
+ const _t = { class: "flex flex-col" }, ht = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800 mb-8" }, "Member tiering", -1), Ct = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Member Card", -1), St = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Titles", -1), Ft = { key: 1 }, Tt = /* @__PURE__ */ a("div", { class: "flex flex-nowrap gap-4 items-center" }, [
25
+ /* @__PURE__ */ a("div", { class: "flex-1" }, "Title"),
26
+ /* @__PURE__ */ a("div", { class: "flex-1" }, "Expires in days"),
27
+ /* @__PURE__ */ a("div", { class: "w-24 h-1" })
28
+ ], -1), wt = [
29
+ Tt
30
+ ], kt = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, Mt = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, At = /* @__PURE__ */ ue({
31
+ __name: "MemberStatsDialog",
32
+ props: {
33
+ member: {
34
+ type: Object,
35
+ required: !0
36
+ },
37
+ onSubmit: {
38
+ type: Function,
39
+ required: !0
40
+ }
41
+ },
42
+ setup(_) {
43
+ var W, H, G, D;
44
+ const q = be(), v = ye(), f = _, E = Y(
45
+ () => {
46
+ var r;
47
+ return (((r = f.member.collection) == null ? void 0 : r.TITLE) ?? []).reduce(
48
+ (c, u) => {
49
+ var n, l, b, m, C;
50
+ const o = v.sortedTitles.find(
51
+ (M) => M._id.toString() === u.collectible
52
+ );
53
+ if (!o) return c;
54
+ const e = [...u.expiryBalance ?? []].sort(
55
+ (M, U) => x(M.expiredAt).isAfter(x(U.expiredAt)) ? -1 : 1
56
+ );
57
+ return (n = e[0]) != null && n.expiredAt && x((l = e[0]) == null ? void 0 : l.expiredAt).isBefore(x()) || c.push({
58
+ _id: o._id,
59
+ name: o.name,
60
+ expiredAt: (b = e[0]) != null && b.expiredAt ? x((m = e[0]) == null ? void 0 : m.expiredAt).toISOString() : "",
61
+ expiresIn: x((C = e[0]) == null ? void 0 : C.expiredAt).diff(x(), "days")
62
+ }), c;
63
+ },
64
+ []
65
+ );
66
+ }
67
+ ), d = X({
68
+ cardNo: f.member.cardNo,
69
+ experience: ((H = (W = f.member.collection) == null ? void 0 : W.POINT) == null ? void 0 : H[0].balance) ?? 0,
70
+ tier: ((D = (G = f.member.collection) == null ? void 0 : G.TIER) == null ? void 0 : D[0].balance) ?? -1,
71
+ titles: E.value.map((r) => ({ expiredAt: r.expiresIn, id: r._id })) ?? void 0
72
+ }), V = Y(
73
+ () => (v.sortedTitles ?? []).map((r) => ({
74
+ label: r.name,
75
+ value: r._id.toString(),
76
+ sublabel: E.value.some((c) => c._id === r._id) ? "Owned" : void 0
77
+ }))
78
+ ), k = Y(() => (v.sortedTiers ?? []).map((r, c) => ({
79
+ label: r.name,
80
+ sublabel: `${r.option.from} - ${r.option.to}`,
81
+ from: r.option.from,
82
+ to: r.option.to,
83
+ value: c + 1
84
+ })));
85
+ function T() {
86
+ var u, o;
87
+ const r = ((u = k.value[(d.value.tier ?? 1) - 1]) == null ? void 0 : u.from) ?? 0, c = (o = k.value[(d.value.tier ?? 1) - 1]) == null ? void 0 : o.to;
88
+ d.value.experience = Math.min(
89
+ c ?? r,
90
+ Math.max(r, d.value.experience ?? 0)
91
+ );
92
+ }
93
+ const I = Y(() => {
94
+ var u, o, e, n, l, b;
95
+ const r = ((o = (u = f.member.collection) == null ? void 0 : u.TIER) == null ? void 0 : o[0].balance) ?? -1, c = ((n = (e = f.member.collection) == null ? void 0 : e.POINT) == null ? void 0 : n[0].balance) ?? 0;
96
+ if (r != d.value.tier) return !0;
97
+ if (d.value.experience && d.value.experience != c) {
98
+ const m = ((l = k.value[r - 1]) == null ? void 0 : l.from) ?? 0, C = ((b = k.value[r - 1]) == null ? void 0 : b.to) ?? 0;
99
+ if (d.value.experience < m || C && d.value.experience > C)
100
+ return !0;
101
+ }
102
+ return !1;
103
+ });
104
+ function h(r) {
105
+ var c;
106
+ return (c = E.value.find((u) => u._id === r)) == null ? void 0 : c.expiresIn;
107
+ }
108
+ const L = Y(() => {
109
+ const r = ut.safeParse(d.value);
110
+ return r.success ? void 0 : r.error.errors;
111
+ });
112
+ function $(r) {
113
+ var c, u;
114
+ return (u = (c = L.value) == null ? void 0 : c.find((o) => o.path.join(".") === r)) == null ? void 0 : u.message;
115
+ }
116
+ function K(r) {
117
+ var c;
118
+ return (c = L.value) == null ? void 0 : c.filter((u) => u.path.join(".").startsWith(r)).map((u) => u.message);
119
+ }
120
+ async function B() {
121
+ await f.onSubmit(d.value), q.close();
122
+ }
123
+ return (r, c) => {
124
+ var M, U;
125
+ const u = F("FmSelect"), o = F("FmStepperField"), e = F("FmTextField"), n = F("FmField"), l = F("FmFormGroup"), b = F("FmButton"), m = F("FmHelperText"), C = F("FmSpacer");
126
+ return y(), N(ee, null, [
127
+ a("div", _t, [
128
+ ht,
129
+ t(k).length ? (y(), j(u, {
130
+ key: 0,
131
+ modelValue: t(d).tier,
132
+ "onUpdate:modelValue": [
133
+ c[0] || (c[0] = (s) => t(d).tier = s),
134
+ T
135
+ ],
136
+ label: "Member Tier",
137
+ items: t(k),
138
+ "helper-text": $("tier"),
139
+ "helper-state": $("tier") ? "error" : void 0
140
+ }, null, 8, ["modelValue", "items", "helper-text", "helper-state"])) : ae("", !0),
141
+ g(o, {
142
+ "model-value": t(d).experience ?? 0,
143
+ "onUpdate:modelValue": c[1] || (c[1] = (s) => t(d).experience = s),
144
+ label: "Member Experience",
145
+ "max-fraction-digits": 0,
146
+ "helper-text": $("experience"),
147
+ "helper-state": $("experience") ? "error" : void 0
148
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
149
+ Ct,
150
+ g(e, {
151
+ modelValue: t(d).cardNo,
152
+ "onUpdate:modelValue": c[2] || (c[2] = (s) => t(d).cardNo = s),
153
+ label: "Card number",
154
+ "helper-text": $("cardNo"),
155
+ "helper-state": $("cardNo") ? "error" : void 0
156
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
157
+ St,
158
+ (M = t(d).titles) != null && M.length ? (y(), N("div", Ft, wt)) : ae("", !0),
159
+ (y(!0), N(ee, null, se(t(d).titles ?? [], (s, S) => (y(), N("div", { key: S }, [
160
+ a("div", kt, [
161
+ t(E).some((p) => p._id === s.id) ? (y(), j(l, {
162
+ key: 1,
163
+ "model-value": "",
164
+ class: "flex-1"
165
+ }, {
166
+ default: ne(() => [
167
+ g(n, {
168
+ disabled: !0,
169
+ class: "text-fm-color-typo-secondary"
170
+ }, {
171
+ default: ne(() => {
172
+ var p;
173
+ return [
174
+ fe(A((p = t(V).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 = h(p) ?? 1],
185
+ class: "flex-1",
186
+ items: t(V).filter(
187
+ (p) => {
188
+ var w;
189
+ return !((w = t(d).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(o, {
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 = t(d).titles) == null ? void 0 : w.splice(S, 1);
207
+ }
208
+ }, null, 8, ["onClick"])
209
+ ]),
210
+ (y(!0), N(ee, null, se(K(`titles.${S}`), (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
+ t(V).length && (((U = t(d).titles) == null ? void 0 : U.length) ?? 0) < t(V).length ? (y(), j(b, {
218
+ key: 2,
219
+ icon: "add",
220
+ label: "Give title",
221
+ variant: "plain",
222
+ onClick: c[3] || (c[3] = (s) => {
223
+ var S;
224
+ return t(d).titles = [
225
+ ...t(d).titles ?? [],
226
+ {
227
+ id: ((S = t(V).find(
228
+ (p) => {
229
+ var w;
230
+ return !((w = t(d).titles) != null && w.map((P) => P.id).includes(p.value));
231
+ }
232
+ )) == null ? void 0 : S.value) || t(V)[0].value,
233
+ expiredAt: 0
234
+ }
235
+ ];
236
+ })
237
+ })) : ae("", !0)
238
+ ]),
239
+ a("div", Mt, [
240
+ Pe(g(m, {
241
+ state: "warning",
242
+ text: "Updating member will cause tier to change"
243
+ }, null, 512), [
244
+ [Oe, t(I)]
245
+ ]),
246
+ g(C),
247
+ g(b, {
248
+ variant: "secondary",
249
+ label: "Cancel",
250
+ size: "md",
251
+ onClick: c[4] || (c[4] = (s) => t(q).close())
252
+ }),
253
+ g(b, {
254
+ disabled: !!t(L),
255
+ variant: "primary",
256
+ label: "Submit",
257
+ size: "md",
258
+ onClick: B
259
+ }, null, 8, ["disabled"])
260
+ ])
261
+ ], 64);
262
+ };
263
+ }
264
+ }), $t = { class: "fm-typo-en-title-sm-800" }, Nt = { class: "space-y-16" }, Vt = { class: "flex flex-nowrap gap-8 items-center justify-end pt-24 w-full" }, It = /* @__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(_) {
275
+ const q = be(), v = _, f = X({
276
+ amount: 1,
277
+ day: 1,
278
+ remark: void 0
279
+ }), E = X(!0), d = Y(() => pe.formattedType(v.type.toUpperCase()));
280
+ function V(I) {
281
+ E.value = I, !I && v.type === "coin" && (f.value.day = void 0);
282
+ }
283
+ async function k() {
284
+ if (v.action === "send") {
285
+ const I = f.value.day ? `, expire in ${f.value.day} days` : "";
286
+ Ee.confirm(
287
+ `Are you sure to send ${f.value.amount} ${d.value.toLowerCase()}${I}? This action cannot be reversed.`
288
+ ).then(async (h) => {
289
+ h && await v.onSubmit(f.value);
290
+ });
291
+ } else
292
+ Ee.confirm(
293
+ `Are you sure to deduct ${f.value.amount} ${d.value.toLowerCase()}? This action cannot be reversed.`
294
+ ).then(async (I) => {
295
+ I && await v.onSubmit(f.value);
296
+ });
297
+ }
298
+ const T = Y(() => {
299
+ const h = (v.action === "send" ? v.type === "coin" ? lt : ct : v.type === "coin" ? dt : mt).safeParse(f.value);
300
+ return h.success == !1 ? h.error.flatten().fieldErrors : void 0;
301
+ });
302
+ return (I, h) => {
303
+ const L = F("FmStepperField"), $ = F("FmSwitch"), K = F("FmTextarea"), B = F("FmButton"), W = F("FmCard");
304
+ return y(), j(W, { class: "flex flex-col gap-16 p-16" }, {
305
+ default: ne(() => {
306
+ var H, G, D, r, c, u;
307
+ return [
308
+ a("div", $t, A(v.action == "send" ? "Send" : "Deduct") + " " + A(t(Be)[v.type.toUpperCase()].name), 1),
309
+ fe(" " + A(t(T)) + " ", 1),
310
+ a("div", Nt, [
311
+ g(L, {
312
+ modelValue: t(f).amount,
313
+ "onUpdate:modelValue": h[0] || (h[0] = (o) => t(f).amount = o),
314
+ label: `${t(Be)[v.type.toUpperCase()].name} amount`,
315
+ "is-currency": !0,
316
+ "max-fraction-digits": 2,
317
+ "helper-state": (H = t(T)) != null && H.amount ? "error" : void 0,
318
+ "helper-text": (D = (G = t(T)) == null ? void 0 : G.amount) == null ? void 0 : D[0]
319
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"]),
320
+ _.action === "send" && v.type === "coin" ? (y(), j($, {
321
+ key: 0,
322
+ "model-value": t(E),
323
+ label: `${t(d)} expires`,
324
+ "label-placement": "right",
325
+ "onUpdate:modelValue": h[1] || (h[1] = (o) => V(o))
326
+ }, null, 8, ["model-value", "label"])) : ae("", !0),
327
+ _.action === "send" && t(E) ? (y(), j(L, {
328
+ key: 1,
329
+ modelValue: t(f).day,
330
+ "onUpdate:modelValue": h[2] || (h[2] = (o) => t(f).day = o),
331
+ label: `${t(d)} expires in`,
332
+ "max-fraction-digits": 0,
333
+ "append-text": "day(s)",
334
+ max: 9999,
335
+ min: 0,
336
+ "helper-state": (r = t(T)) != null && r.day ? "error" : void 0,
337
+ "helper-text": (u = (c = t(T)) == null ? void 0 : c.day) == null ? void 0 : u[0]
338
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : ae("", !0),
339
+ g(K, {
340
+ modelValue: t(f).remark,
341
+ "onUpdate:modelValue": h[3] || (h[3] = (o) => t(f).remark = o),
342
+ label: "Remark"
343
+ }, null, 8, ["modelValue"])
344
+ ]),
345
+ a("div", Vt, [
346
+ g(B, {
347
+ variant: "secondary",
348
+ label: "Cancel",
349
+ size: "md",
350
+ onClick: h[4] || (h[4] = (o) => t(q).close())
351
+ }),
352
+ g(B, {
353
+ disabled: !!t(T),
354
+ variant: "primary",
355
+ label: "Submit",
356
+ size: "md",
357
+ onClick: h[5] || (h[5] = async () => k())
358
+ }, null, 8, ["disabled"])
359
+ ])
360
+ ];
361
+ }),
362
+ _: 1
363
+ });
364
+ };
365
+ }
366
+ }), je = pt("segment", () => {
367
+ const _ = 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
+ _.value = v.resources;
376
+ }
377
+ return {
378
+ segments: _,
379
+ read: q
380
+ };
381
+ }), Et = { class: "flex flex-col flex-nowrap gap-y-24 max-h-full" }, Dt = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Profile Information", -1), Bt = { class: "space-y-16" }, Ut = { class: "flex gap-16 items-center" }, Pt = { class: "flex-auto" }, Ot = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1), Rt = { class: "fm-typo-en-body-md-600" }, Yt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zt = { class: "fm-typo-en-body-md-800" }, jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qt = { class: "fm-typo-en-body-md-600" }, Kt = /* @__PURE__ */ a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1), Gt = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Activities", -1), Ht = { class: "gap-16 grid grid-cols-2" }, Jt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xt = { class: "fm-typo-en-body-md-600" }, Wt = /* @__PURE__ */ a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1), Qt = { class: "space-y-8" }, Zt = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1), eo = {
382
+ key: 0,
383
+ class: "space-x-8"
384
+ }, to = {
385
+ key: 1,
386
+ class: "text-fm-color-typo-secondary"
387
+ }, oo = /* @__PURE__ */ a("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1), no = { class: "space-y-8" }, ao = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1), so = ["src"], io = { class: "fm-typo-en-body-md-600" }, ro = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, lo = {
388
+ key: 1,
389
+ class: "text-fm-color-typo-secondary"
390
+ }, co = {
391
+ key: 1,
392
+ class: "space-y-24"
393
+ }, mo = { class: "space-y-8" }, uo = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1), po = { class: "fm-typo-en-title-md-800" }, fo = { class: "space-y-4" }, bo = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1), yo = { class: "fm-typo-en-body-md-600" }, vo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, xo = { class: "space-y-8" }, go = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1), _o = { class: "fm-typo-en-title-md-800" }, ho = { class: "space-y-4" }, Co = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1), So = { class: "fm-typo-en-body-md-600" }, Fo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, To = /* @__PURE__ */ ue({
394
+ __name: "MemberDetailSheet",
395
+ props: {
396
+ member: {
397
+ type: Object,
398
+ required: !0
399
+ }
400
+ },
401
+ emits: ["update:member"],
402
+ setup(_, { expose: q, emit: v }) {
403
+ const f = ye(), E = Le(), d = je(), V = be(), { minor: k } = Ye, T = _, I = v, h = Y(() => E.locations.map((e) => ({
404
+ label: e.name,
405
+ value: e._id
406
+ }))), L = Y(() => (T.member.segment || []).map((e) => {
407
+ var n;
408
+ return ((n = d.segments.find((l) => l._id === e)) == null ? void 0 : n.name) || "";
409
+ }).filter(Boolean));
410
+ async function $(e, n) {
411
+ V.open({
412
+ title: "",
413
+ dialogComponent: It,
414
+ dialogComponentProps: {
415
+ type: e,
416
+ action: n,
417
+ onSubmit: async (l) => {
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 = `${e}-${n}`, C = b[m];
426
+ C && await C(T.member._id, l), I("update:member"), V.close();
427
+ },
428
+ {
429
+ message: `Adjusting ${pe.formattedType(e.toUpperCase()).toLowerCase()}`,
430
+ successMessage: `${l.amount} ${pe.formattedType(e.toUpperCase()).toLowerCase()} ${n} ${n == "send" ? "to" : "from"} ${T.member.phoneNumber}`
431
+ }
432
+ );
433
+ }
434
+ }
435
+ });
436
+ }
437
+ async function K() {
438
+ V.open({
439
+ title: "Update member statistics",
440
+ contentComponent: At,
441
+ contentComponentProps: {
442
+ member: T.member,
443
+ onSubmit: async (e) => {
444
+ await k(
445
+ async () => {
446
+ await J.updateMember(T.member._id, e), I("update:member"), V.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: (e) => {
465
+ var M, U, s, S, p;
466
+ const n = (((U = Ue.first((M = T.member.collection) == null ? void 0 : M.TIER)) == null ? void 0 : U.balance) || 0) - 1, l = H.value.name, b = ((S = (s = e.collection) == null ? void 0 : s.POINT) == null ? void 0 : S[0].balance) ?? 0, m = f.sortedTiers[n + 1], C = ((p = m == null ? void 0 : m.option) == null ? void 0 : p.to) ?? 1 / 0;
467
+ return `${l} (${b}/${C})`;
468
+ }
469
+ },
470
+ {
471
+ label: "Email",
472
+ key: "email"
473
+ },
474
+ {
475
+ label: "Birthday",
476
+ getter: (e) => e.birthday ? x(e.birthday).format("D MMM YYYY") : "-"
477
+ }
478
+ ], W = [
479
+ {
480
+ label: "Customer since",
481
+ getter: (e) => x(ze(e._id.toString())).format("D MMM YYYY")
482
+ },
483
+ {
484
+ label: "Joined at location",
485
+ getter: (e) => {
486
+ var n;
487
+ return e != null && e.location && ((n = h.value.find((l) => l.value == e.location)) == null ? void 0 : n.label) || "-";
488
+ }
489
+ },
490
+ {
491
+ label: "Total visit(s)",
492
+ getter: (e) => De.singularOrPlural(e.stats.visitCount, "bill")
493
+ },
494
+ {
495
+ label: "Last visit",
496
+ getter: (e) => x(e.stats.lastVisit).fromNow()
497
+ },
498
+ {
499
+ label: "Frequency",
500
+ getter: (e) => `Every ${De.singularOrPlural(Number(Math.ceil(e.stats.avgVisitFrequency).toFixed(0)), "day")}`
501
+ },
502
+ {
503
+ label: "Average spend",
504
+ getter: (e) => it.Dinero.fromNumber({ number: Number(e.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 l, b;
522
+ const e = (((b = Ue.first((l = T.member.collection) == null ? void 0 : l.TIER)) == null ? void 0 : b.balance) || 0) - 1, n = f.sortedTiers[e];
523
+ return { name: (n == null ? void 0 : n.name) || "-", tier: e, config: n };
524
+ }), G = Y(() => {
525
+ var e;
526
+ return (((e = T.member.collection) == null ? void 0 : e.TITLE) || []).map((n) => {
527
+ var b, m, C;
528
+ const l = (b = f.sortedTitles) == null ? void 0 : b.find(
529
+ (M) => M._id == n.collectible
530
+ );
531
+ return {
532
+ name: l == null ? void 0 : l.name,
533
+ expiredAt: (C = (m = n.expiryBalance) == null ? void 0 : m.at(-1)) == null ? void 0 : C.expiredAt,
534
+ collectible: l
535
+ };
536
+ }).filter(
537
+ (n) => n.expiredAt ? x(n.expiredAt).isAfter(x()) : !0
538
+ );
539
+ }), D = X(!0);
540
+ function r() {
541
+ D.value = !0, o.value = u[0];
542
+ }
543
+ function c() {
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
+ ], o = X(u[0]);
556
+ return Re(async () => {
557
+ await f.readMembership(), E.locations.length || await E.readLocations();
558
+ }), q({
559
+ showSheet: r,
560
+ hideSheet: c
561
+ }), (e, n) => {
562
+ const l = F("FmTabs"), b = F("FmAvatar"), m = F("FmButton"), C = F("FmChip"), M = F("FmCard"), U = F("FmSideSheet");
563
+ return y(), j(U, {
564
+ modelValue: t(D),
565
+ "onUpdate:modelValue": n[5] || (n[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(() => []),
572
+ default: ne(() => [
573
+ a("div", Et, [
574
+ g(l, {
575
+ "model-value": t(o).value,
576
+ items: u,
577
+ "onUpdate:modelValue": n[0] || (n[0] = (s) => o.value = u.find((S) => S.value === s))
578
+ }, null, 8, ["model-value"]),
579
+ t(o).value == "overview" ? (y(), N(ee, { key: 0 }, [
580
+ Dt,
581
+ a("div", Bt, [
582
+ a("div", Ut, [
583
+ g(b, {
584
+ name: _.member.photoUrl ? void 0 : _.member.name,
585
+ src: _.member.photoUrl || void 0
586
+ }, null, 8, ["name", "src"]),
587
+ a("div", Pt, [
588
+ Ot,
589
+ a("div", Rt, A(_.member.name), 1),
590
+ a("div", Yt, A(_.member._id), 1),
591
+ a("div", Lt, [
592
+ fe(" Member Card: "),
593
+ a("span", zt, A(_.member.cardNo ? _.member.cardNo : "-"), 1)
594
+ ])
595
+ ]),
596
+ g(m, {
597
+ variant: "tertiary",
598
+ icon: "settings",
599
+ onClick: K
600
+ })
601
+ ]),
602
+ (y(), N(ee, null, se(B, (s, S) => a("div", { key: S }, [
603
+ a("div", jt, A(s.label), 1),
604
+ a("div", qt, A(s.key ? _.member[s.key] : s.getter(_.member)), 1)
605
+ ])), 64))
606
+ ]),
607
+ Kt,
608
+ Gt,
609
+ a("div", Ht, [
610
+ (y(), N(ee, null, se(W, (s) => a("div", {
611
+ key: s.key
612
+ }, [
613
+ a("div", Jt, A(s.label), 1),
614
+ a("div", Xt, A(s.key ? T.member.stats[s.key] || "-" : s.getter(_.member)), 1)
615
+ ])), 64))
616
+ ]),
617
+ Wt,
618
+ a("div", Qt, [
619
+ Zt,
620
+ t(L).length ? (y(), N("div", eo, [
621
+ (y(!0), N(ee, null, se(t(L), (s) => (y(), j(C, {
622
+ label: s.toString()
623
+ }, null, 8, ["label"]))), 256))
624
+ ])) : (y(), N("div", to, "No titles"))
625
+ ]),
626
+ oo,
627
+ a("div", no, [
628
+ ao,
629
+ t(G).length ? (y(!0), N(ee, { key: 0 }, se(t(G).filter((s) => s.collectible), (s) => (y(), N("div", {
630
+ class: "flex items-center gap-x-8 h-48",
631
+ key: s.name
632
+ }, [
633
+ a("img", {
634
+ src: s.collectible.image || t(rt),
635
+ class: "aspect-square h-full object-contain"
636
+ }, null, 8, so),
637
+ a("div", null, [
638
+ a("div", io, A(s.name), 1),
639
+ a("div", ro, " Expired on " + A(t(x)(s.expiredAt).format("MMM D, Y")), 1)
640
+ ])
641
+ ]))), 128)) : (y(), N("div", lo, "No titles"))
642
+ ])
643
+ ], 64)) : t(o).value == "loyalty" ? (y(), N("div", co, [
644
+ g(M, {
645
+ class: "p-16 space-y-24",
646
+ variant: "outlined"
647
+ }, {
648
+ default: ne(() => {
649
+ var s, S, p, w, P, Q, Z;
650
+ return [
651
+ a("div", mo, [
652
+ uo,
653
+ a("div", po, A(((p = (S = (s = _.member.collection) == null ? void 0 : s.CREDIT) == null ? void 0 : S[0]) == null ? void 0 : p.balance) ?? 0), 1)
654
+ ]),
655
+ a("div", fo, [
656
+ bo,
657
+ a("div", yo, A(((Z = (Q = (P = (w = _.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 && t(x)(R.expiredAt).isAfter(t(x)()) && t(x)(R.expiredAt).isBefore(t(x)().add(30, "days")) ? O + R.amount : O,
659
+ 0
660
+ )) ?? 0), 1)
661
+ ]),
662
+ a("div", vo, [
663
+ g(m, {
664
+ label: "Add credit",
665
+ icon: "add",
666
+ variant: "plain",
667
+ onClick: n[1] || (n[1] = (O) => $("credit", "send"))
668
+ }),
669
+ g(m, {
670
+ label: "Deduct credit",
671
+ icon: "remove",
672
+ variant: "plain",
673
+ onClick: n[2] || (n[2] = (O) => $("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, S, p, w, P, Q, Z;
686
+ return [
687
+ a("div", xo, [
688
+ go,
689
+ a("div", _o, A(((p = (S = (s = _.member.collection) == null ? void 0 : s.COIN) == null ? void 0 : S[0]) == null ? void 0 : p.balance) ?? 0), 1)
690
+ ]),
691
+ a("div", ho, [
692
+ Co,
693
+ a("div", So, A(((Z = (Q = (P = (w = _.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 && t(x)(R.expiredAt).isAfter(t(x)()) && t(x)(R.expiredAt).isBefore(t(x)().add(30, "days")) ? O + R.amount : O,
695
+ 0
696
+ )) ?? 0), 1)
697
+ ]),
698
+ a("div", Fo, [
699
+ g(m, {
700
+ label: "Add point",
701
+ icon: "add",
702
+ variant: "plain",
703
+ onClick: n[3] || (n[3] = (O) => $("coin", "send"))
704
+ }),
705
+ g(m, {
706
+ label: "Deduct point",
707
+ icon: "remove",
708
+ variant: "plain",
709
+ onClick: n[4] || (n[4] = (O) => $("coin", "deduct"))
710
+ })
711
+ ])
712
+ ];
713
+ }),
714
+ _: 1
715
+ })
716
+ ])) : ae("", !0)
717
+ ])
718
+ ]),
719
+ _: 1
720
+ }, 8, ["modelValue"]);
721
+ };
722
+ }
723
+ }), wo = { class: "flex items-center justify-end" }, Xo = /* @__PURE__ */ ue({
724
+ __name: "MemberList",
725
+ setup(_) {
726
+ const q = je(), v = ye(), f = Le(), { minor: E } = Ye, d = xt(), V = [
727
+ {
728
+ header: "Name",
729
+ enableSorting: !0,
730
+ accessorKey: "name",
731
+ cell(o) {
732
+ return bt(o.row.original);
733
+ }
734
+ },
735
+ {
736
+ accessorFn: (o) => x(ze(o._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(o) {
746
+ return yt(
747
+ o.row.original,
748
+ v.sortedTiers
749
+ );
750
+ }
751
+ },
752
+ {
753
+ header: "Title",
754
+ enableSorting: !1,
755
+ cell(o) {
756
+ return vt(
757
+ o.row.original,
758
+ v.sortedTitles
759
+ );
760
+ }
761
+ },
762
+ {
763
+ accessorKey: "collection_CREDIT_0_balance",
764
+ accessorFn: (o) => {
765
+ var e, n, l;
766
+ return me(((l = (n = (e = o.collection) == null ? void 0 : e.CREDIT) == null ? void 0 : n[0]) == null ? void 0 : l.balance) ?? 0, 2);
767
+ },
768
+ header: "Credit(s)",
769
+ enableSorting: !0
770
+ },
771
+ {
772
+ accessorKey: "collection_POINT_0_balance",
773
+ accessorFn: (o) => {
774
+ var e, n, l;
775
+ return me(((l = (n = (e = o.collection) == null ? void 0 : e.POINT) == null ? void 0 : n[0]) == null ? void 0 : l.balance) ?? 0, 2);
776
+ },
777
+ header: "Experience(s)",
778
+ enableSorting: !0
779
+ },
780
+ {
781
+ accessorKey: "collection_COIN_0_balance",
782
+ accessorFn: (o) => {
783
+ var e, n, l;
784
+ return me(((l = (n = (e = o.collection) == null ? void 0 : e.COIN) == null ? void 0 : n[0]) == null ? void 0 : l.balance) ?? 0, 2);
785
+ },
786
+ header: "Point(s)",
787
+ enableSorting: !0
788
+ },
789
+ {
790
+ accessorFn: (o) => {
791
+ var e;
792
+ return ((e = o.stats) == null ? void 0 : e.visitCount) ?? 0;
793
+ },
794
+ header: "Total visit",
795
+ accessorKey: "stats.visitCount",
796
+ id: "stats.visitCount"
797
+ },
798
+ {
799
+ accessorFn: (o) => {
800
+ var e;
801
+ return (e = o.stats) == null ? void 0 : e.lastVisit;
802
+ },
803
+ sortingFn: (o, e) => {
804
+ var n, l;
805
+ return new Date((n = o.original.stats) == null ? void 0 : n.lastVisit).getTime() - new Date((l = e.original.stats) == null ? void 0 : l.lastVisit).getTime();
806
+ },
807
+ id: "stats.lastVisit",
808
+ header: "Last visit",
809
+ cell(o) {
810
+ var e, n;
811
+ return oe("div", { class: "flex items-center justify-end gap-4" }, [
812
+ oe(
813
+ "span",
814
+ (e = o.row.original.stats) != null && e.lastVisit ? x((n = o.row.original.stats) == null ? void 0 : n.lastVisit).fromNow() : "NA"
815
+ ),
816
+ oe(
817
+ ce.FmTooltip,
818
+ {
819
+ content: x(o.row.original.stats.lastVisit).format(
820
+ "D MMM YYYY - hh:mmA"
821
+ )
822
+ },
823
+ [oe(ce.FmIcon, { name: "info", outline: !0, size: "sm" })]
824
+ )
825
+ ]);
826
+ }
827
+ },
828
+ {
829
+ id: "actions",
830
+ cell(o) {
831
+ return oe(
832
+ ce.FmMenu,
833
+ {
834
+ placement: "bottom-end",
835
+ onClick: (e) => {
836
+ e.stopPropagation();
837
+ }
838
+ },
839
+ {
840
+ "menu-button": () => oe(ce.FmButton, { icon: "more_vert", variant: "tertiary" }),
841
+ default: () => [
842
+ oe(ce.FmMenuItem, {
843
+ label: "Transaction details",
844
+ onClick: async (e) => {
845
+ e.stopPropagation(), await D(o.row.original._id);
846
+ }
847
+ })
848
+ ]
849
+ }
850
+ );
851
+ }
852
+ }
853
+ ], { tableMeta: k, rowData: T, onSort: I, debouncedFetchData: h, onSearch: L } = ot(J.read), $ = X(), K = X(!1), B = X(), W = Y(() => f.locations.map((o) => ({
854
+ label: o.name,
855
+ value: o._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 h(), K.value = !1;
864
+ }
865
+ async function D(o) {
866
+ await d.push({
867
+ name: gt["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
868
+ params: { id: o }
869
+ });
870
+ }
871
+ const r = {
872
+ sortBy: "_id",
873
+ descending: !1,
874
+ rowsPerPage: 1e3,
875
+ page: 1,
876
+ rowsNumber: 0
877
+ };
878
+ function c(o) {
879
+ const e = x(o);
880
+ return e.isValid() ? e.format("DD/MM/YYYY") : "";
881
+ }
882
+ async function u() {
883
+ const o = new tt(), e = (await J.read({
884
+ limit: 1,
885
+ skip: 0,
886
+ sortBy: r.sortBy,
887
+ descending: r.descending
888
+ })).meta.totalResources ?? 0, n = r.rowsPerPage;
889
+ await E(
890
+ async () => {
891
+ var l, b, m, C, M, U, s, S, p, w, P, Q, Z, O, R, ve, xe, ge, _e, he, Ce, Se, Fe, Te, we, ke, Me, Ae;
892
+ for (let $e = 0; $e < e; $e += n) {
893
+ const qe = {
894
+ ...r,
895
+ limit: n,
896
+ skip: r.page - 1,
897
+ sortBy: r.sortBy,
898
+ descending: r.descending
899
+ }, Ke = await J.read(qe);
900
+ for (const i of Ke.resources) {
901
+ const Ge = (l = et.parseOneAddress(
902
+ i == null ? void 0 : i.email
903
+ )) != null && l.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
+ (de) => de._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, de, Ie;
915
+ const ie = (Ie = (de = (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 : de[0]) == null ? void 0 : Ie.expiredAt;
918
+ return z[te.name] = ie ? x(ie).format("DD/MM/YYYY") : "", z;
919
+ },
920
+ {}
921
+ ), Xe = ((U = (M = (C = i.collection) == null ? void 0 : C.CREDIT) == null ? void 0 : M.at(0)) == null ? void 0 : U.balance) || 0, Ne = ((w = (p = (S = (s = i.collection) == null ? void 0 : s.CREDIT) == null ? void 0 : S.at(0)) == null ? void 0 : p.expiryBalance) == null ? void 0 : w.reduce(
922
+ (z, te) => z + te.amount,
923
+ 0
924
+ )) || 0, Ve = 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: c((i == null ? void 0 : i.birthday) || void 0),
932
+ Credit: (Number(Ve) - Number(Ne)).toFixed(2),
933
+ FreeCredit: Number(Ne.toFixed(2)),
934
+ TotalCredit: Number(Ve),
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 ? ((Ce = (he = (_e = i.collection) == null ? void 0 : _e.TIER) == null ? void 0 : he.at(0)) == null ? void 0 : Ce.balance) ?? 0 : 0,
938
+ Tier: i != null && i.collection ? ((Te = (Fe = (Se = i.collection) == null ? void 0 : Se.TIER) == null ? void 0 : Fe.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: c(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: c(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
+ o.addRecord(We);
957
+ }
958
+ r.page++;
959
+ }
960
+ await at(
961
+ o.buildExcel(),
962
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
963
+ {
964
+ bookType: "xlsx",
965
+ bookSST: !1,
966
+ type: "array"
967
+ }
968
+ ), r.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 q.read(), await h();
978
+ }), (o, e) => {
979
+ const n = F("FmSearch"), l = F("FmButton"), b = F("FmSnackbar");
980
+ return y(), N("div", null, [
981
+ a("div", wo, [
982
+ g(n, {
983
+ class: "mt-4",
984
+ modelValue: t(k).searchValue,
985
+ "onUpdate:modelValue": [
986
+ e[0] || (e[0] = (m) => t(k).searchValue = m),
987
+ t(L)
988
+ ],
989
+ placeholder: "Search",
990
+ collapsible: ""
991
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
992
+ g(l, {
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: e[1] || (e[1] = (m) => K.value = !1),
1006
+ action: "Refresh",
1007
+ onOnAction: G
1008
+ }, null, 512), [
1009
+ [Oe, t(K)]
1010
+ ]),
1011
+ g(nt, {
1012
+ loading: t(k).isLoading,
1013
+ "row-data": t(T),
1014
+ "row-count": t(k).totalRows,
1015
+ "column-defs": V,
1016
+ "shrink-at": !1,
1017
+ "page-count": t(k).pageCount,
1018
+ "page-index": t(k).pageIndex,
1019
+ "page-size": t(k).pageSize,
1020
+ onSortChange: t(I),
1021
+ onPageChange: e[2] || (e[2] = (m) => t(h)({ pageSize: m.pageSize, pageIndex: m.pageIndex })),
1022
+ onRowClick: e[3] || (e[3] = (m) => {
1023
+ var C;
1024
+ B.value = m.original, (C = t($)) == null || C.showSheet();
1025
+ })
1026
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1027
+ t(B) ? (y(), j(To, {
1028
+ key: 0,
1029
+ ref_key: "sheetRef",
1030
+ ref: $,
1031
+ member: t(B),
1032
+ "onUpdate:member": H
1033
+ }, null, 8, ["member"])) : ae("", !0)
1034
+ ]);
1035
+ };
1036
+ }
1037
+ });
1038
+ export {
1039
+ Xo as default
1040
+ };