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