@feedmepos/mf-connect 0.1.0-beta.3 → 0.1.0-beta.30

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