@feedmepos/mf-connect 0.1.30-prod → 0.1.32-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 (90) hide show
  1. package/dist/{Analytic-C_uRY3I5.js → Analytic-DRJEtVnN.js} +11 -11
  2. package/dist/{App-zOAwWGz6.js → App-C1IuGBAJ.js} +7 -7
  3. package/dist/{Bin-CePm_uVx.js → Bin-CM9cU-iH.js} +8 -8
  4. package/dist/{Broadcast-BcRSoknR.js → Broadcast-1Fy8Nob5.js} +9 -9
  5. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-5StwY5c9.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DiAEDcl5.js} +6 -6
  6. package/dist/{Card-Dmyxmub5.js → Card-CnuSjjCj.js} +97 -96
  7. package/dist/{Collections-DiV_e9h-.js → Collections-DAj_A1iu.js} +21 -20
  8. package/dist/{Credit-CkGdHhn2.js → Credit-DLH2GYYz.js} +9 -9
  9. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-SulDMna0.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-C4Sy1K8q.js} +29 -28
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-CSY1HXaL.js → EffectSheet.vue_vue_type_style_index_0_lang-D4--kNds.js} +6 -6
  11. package/dist/{Experience-DjsOWpa9.js → Experience-Dgyi4U-L.js} +9 -9
  12. package/dist/FileSaver.min-NlMItPOc.js +74 -0
  13. package/dist/{Game-2_J99uIX.js → Game-VKYjF7hq.js} +10 -10
  14. package/dist/{Index-a1eFJ8i1.js → Index-B0BkKPLD.js} +10 -10
  15. package/dist/{Marketing-Clz0CYrY.js → Marketing-Bzl7m10d.js} +6 -6
  16. package/dist/Member-CDmDoJFr.js +287 -0
  17. package/dist/{MemberList-D-5IP783.js → MemberList-C4l_Q9y1.js} +38 -37
  18. package/dist/{MemberTransactions-B7D_qrLX.js → MemberTransactions-SUlFwOov.js} +1 -1
  19. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-XhbiT524.js → MessageInput.vue_vue_type_script_setup_true_lang-Buj3xx1j.js} +17 -16
  20. package/dist/{Mission-B7UVVT1j.js → Mission-BriLVrc4.js} +88 -93
  21. package/dist/{Overview-BfZuRgE-.js → Overview-AklJfO0G.js} +64 -63
  22. package/dist/{Point-MGLwWD4B.js → Point-B7VnNPaG.js} +9 -9
  23. package/dist/{Promotion-BrhYslNt.js → Promotion-hlKzzWJD.js} +10 -10
  24. package/dist/{Queue-Bz160bZx.js → Queue-gOxy9cBG.js} +76 -65
  25. package/dist/{Record-DrpOYO01.js → Record-BwWXqFv6.js} +17 -16
  26. package/dist/{Reward-ClX3C1Sp.js → Reward-JKh-M0oD.js} +15 -15
  27. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-0L9iBoC4.js → RewardGroup.vue_vue_type_script_setup_true_lang-DFogiHWh.js} +11 -11
  28. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-BlCyumkR.js → RuleGroup.vue_vue_type_script_setup_true_lang-CTOfCYsE.js} +15 -14
  29. package/dist/Segment-BlMx0eoR.js +880 -0
  30. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-D5eLqSso.js → SelectItems.vue_vue_type_script_setup_true_lang-DCsFcqQ5.js} +2 -2
  31. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-Cb3yPiSc.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-G01kJeLd.js} +11 -11
  32. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-B_RBF59b.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-gUoBLfVo.js} +3 -3
  33. package/dist/{Setting-CgRON4iT.js → Setting-CoKP6Z-F.js} +43 -42
  34. package/dist/{Store-BGbO2NeC.js → Store-CxUagz23.js} +28 -27
  35. package/dist/{StoreRewards-DyCWcVsT.js → StoreRewards-CLSQgaNo.js} +13 -13
  36. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-ePVWe6Kb.js → StoreTransactions.vue_vue_type_script_setup_true_lang-V4rH3vAQ.js} +26 -25
  37. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DLQOZH-k.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DJ7incG7.js} +1 -1
  38. package/dist/{Tier-B7LRmyHJ.js → Tier-DwTL1xNM.js} +22 -21
  39. package/dist/{Title-DrQaQ7ew.js → Title-DhBL_eYK.js} +19 -19
  40. package/dist/{Transaction-B2M_gPhT.js → Transaction-CRskHsNr.js} +2 -2
  41. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-Bc8cnLBQ.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-DoE7rDgi.js} +6 -6
  42. package/dist/{Voucher-BcVMrpOm.js → Voucher-CxDqASF5.js} +12 -12
  43. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-DIfHJ6Sw.js → VoucherEditor.vue_vue_type_script_setup_true_lang-wkihtNI3.js} +10 -10
  44. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-DfinebCV.js → ZodTextField.vue_vue_type_script_setup_true_lang-BeLTXjOv.js} +1 -1
  45. package/dist/{app-BXGrI0oQ.js → app-CTFwjMxq.js} +1 -1
  46. package/dist/{app-Sjl26OK7.js → app-QgT2HXjv.js} +34 -30
  47. package/dist/app.js +1 -1
  48. package/dist/{business-ICKi8JNz.js → business-DhCzKu3V.js} +1 -1
  49. package/dist/{campaign-AiWYrbax.js → campaign-CFggCOe6.js} +9 -9
  50. package/dist/{campaign-BExdhFR9.js → campaign-DAgovrbX.js} +2 -2
  51. package/dist/{campaign.enum-WEt42FO9.js → campaign.enum-pZr63pXN.js} +1 -1
  52. package/dist/{campaign.fn-CHQ63XNa.js → campaign.fn-CM_t1wNu.js} +135 -135
  53. package/dist/{collectible.enum-DFaOnC3D.js → collectible.enum-fbWiJ-v2.js} +1 -1
  54. package/dist/{collection.fn-B3XEjDdU.js → collection.fn-BrbSJ0dj.js} +2 -2
  55. package/dist/{dto-B09V82Pa.js → dto-BcLrcoo_.js} +12 -12
  56. package/dist/{effect-CUcku1wp.js → effect-WVUo2VX0.js} +1 -1
  57. package/dist/{email-addresses-CSpdONTz.js → email-addresses-B8YBttOp.js} +1 -1
  58. package/dist/{export-DJfDtT62.js → export-FilTnKIf.js} +3 -3
  59. package/dist/{helper-CbSsYPpI.js → helper-A-JE89j8.js} +1 -1
  60. package/dist/{index-DsmYdmgu.js → index-BPCfLPV5.js} +1 -1
  61. package/dist/{index-Clj1WSBs.js → index-BSavh-ab.js} +3 -3
  62. package/dist/{index-BSTUrmqB.js → index-C1vwtNMj.js} +6 -6
  63. package/dist/{index-QyxsXvZB.js → index-CK_9lnGD.js} +3 -3
  64. package/dist/{index-B3HoKsL8.js → index-CX4Q-ODj.js} +1 -1
  65. package/dist/{index-D98bOypJ.js → index-CyqffI0r.js} +1 -1
  66. package/dist/{index-DeYzI7Ad.js → index-CzH8ux-h.js} +2 -2
  67. package/dist/{index-DLsHC8RI.js → index-CzbdA0d3.js} +1 -1
  68. package/dist/{plugins-BZn2aS9v.js → index-DFS6jDHm.js} +3784 -3989
  69. package/dist/{index-C1wvmxnj.js → index-DI956UFg.js} +1 -1
  70. package/dist/{index-C_bBUep_.js → index-DvM-OpLR.js} +469 -456
  71. package/dist/{index-BaR_Lcm6.js → index-FsTLGrIL.js} +1 -1
  72. package/dist/{index-ZQcFToUw.js → index-OehNKdCW.js} +1 -1
  73. package/dist/{index.esm2017-D0ExClUr.js → index.esm2017-CScWJGpE.js} +1 -1
  74. package/dist/{loading-BPPrnQNO.js → loading-CXZ39_xw.js} +1 -1
  75. package/dist/{membership-XRsihZq0.js → membership-Bg_pBT1C.js} +54 -48
  76. package/dist/{money-hdSAgWNM.js → money-D4vhiGvs.js} +1 -1
  77. package/dist/{number-DYeV4NB_.js → number-p3U-wKsr.js} +1 -1
  78. package/dist/{objectid-CC8rUDIT.js → objectid-C_k8DXMk.js} +8 -8
  79. package/dist/plugins-BzCgGFW_.js +208 -0
  80. package/dist/{reward-6Gs4Tj0g.js → reward-DL7dVgek.js} +1 -1
  81. package/dist/{rule-builder-C7d79jSS.js → rule-builder-DZEGo8FL.js} +1 -1
  82. package/dist/{rule-BRP3Seyh.js → rule-iUlMzG59.js} +3 -3
  83. package/dist/{template-B0NSZx7m.js → template-FZF9V1B2.js} +4 -4
  84. package/dist/{trigger-B5-fD0op.js → trigger-woPb5C0Z.js} +4 -4
  85. package/dist/{user-t4f-8zfV.js → user-CoOoRDFP.js} +1 -1
  86. package/dist/{vue-i18n-Byc8euZx.js → vue-i18n-5r8XYctA.js} +348 -348
  87. package/dist/{xlsx-C_z356In.js → xlsx-Cx714TFU.js} +1 -1
  88. package/package.json +1 -1
  89. package/dist/Member-TNxdgh6i.js +0 -348
  90. package/dist/Segment-OY9qUZnY.js +0 -578
@@ -1,578 +0,0 @@
1
- import { defineComponent as Q, onMounted as ue, openBlock as x, createElementBlock as D, createElementVNode as i, toDisplayString as $, unref as o, createVNode as l, ref as H, computed as X, resolveComponent as S, createBlock as W, isRef as ye, createSlots as _e, withCtx as C, Fragment as q, h as B, onBeforeMount as ve, renderList as he } from "vue";
2
- import { _ as Se } from "./campaign-CpzFl8Vr.js";
3
- import { F as re, p as xe } from "./plugins-BZn2aS9v.js";
4
- import { u as we } from "./loading-BPPrnQNO.js";
5
- import { components as Z } from "@feedmepos/ui-library";
6
- import { u as pe, _ as me } from "./usePagination-JoYaROkV.js";
7
- import { u as Fe } from "./vue-i18n-Byc8euZx.js";
8
- import { w as Ce } from "./xlsx-C_z356In.js";
9
- import { e as Me, M as ke } from "./email-addresses-CSpdONTz.js";
10
- import { Z as Ie } from "./zod-Bg2FbC-D.js";
11
- import { h as Pe } from "./index-C_bBUep_.js";
12
- import { u as Re } from "./app-wDQR6dpb.js";
13
- import { R as Be } from "./rule-builder-C7d79jSS.js";
14
- import { _ as Ee } from "./ZodTextField.vue_vue_type_script_setup_true_lang-DfinebCV.js";
15
- import { _ as $e } from "./RuleGroup.vue_vue_type_script_setup_true_lang-BlCyumkR.js";
16
- import { h as z } from "./moment-BWErdI6_.js";
17
- import { s as E, u as De } from "./membership-XRsihZq0.js";
18
- import { o as Ye } from "./objectId-dwaoBfJX.js";
19
- import { u as ge } from "./business-ICKi8JNz.js";
20
- import { f as be } from "./number-DYeV4NB_.js";
21
- import { t as Le } from "./money-hdSAgWNM.js";
22
- import { m as ce } from "./index-BaR_Lcm6.js";
23
- const Te = Pe.extend({
24
- _id: re.optional(),
25
- business: re.optional()
26
- }), Ne = { class: "space-y-16 pr-12" }, Ve = { class: "fm-typo-en-title-md-800" }, ze = { class: "flex space-x-8" }, Ae = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, Ue = { class: "text-fm-color-typo-secondary" }, Oe = /* @__PURE__ */ i("div", null, "contacts in your segment", -1), je = /* @__PURE__ */ Q({
27
- __name: "ReviewSegment",
28
- props: {
29
- title: {},
30
- segment: {}
31
- },
32
- setup(e) {
33
- const r = e, h = [
34
- {
35
- header: "Name",
36
- accessorFn: (n) => n.name
37
- },
38
- {
39
- header: "Id",
40
- accessorFn: (n) => n._id
41
- },
42
- {
43
- header: "Customer Since",
44
- accessorFn: (n) => z(Ye(n._id.toString())).format("DD MMM YYYY")
45
- },
46
- {
47
- header: "Phone",
48
- accessorFn: (n) => n.phoneNumber
49
- },
50
- {
51
- header: "Birthday",
52
- accessorFn: (n) => z(n.birthday).format("DD MMM YYYY")
53
- },
54
- {
55
- header: "Last Visit",
56
- accessorFn: (n) => z(n.stats.lastVisit).format("DD MMM YYYY")
57
- }
58
- ];
59
- async function _(n) {
60
- return r.segment._id ? (console.log(n), await E.paginateSegmentUsers(
61
- r.segment._id,
62
- n
63
- )) : {
64
- resources: [],
65
- meta: {
66
- totalResources: 0,
67
- totalPages: 0,
68
- skip: n.skip,
69
- limit: n.limit,
70
- sortBy: n.sortBy
71
- }
72
- };
73
- }
74
- const { tableMeta: c, rowData: d, onSort: M, debouncedFetchData: g, onSearch: s } = pe(_);
75
- return ue(async () => {
76
- await g();
77
- }), (n, f) => (x(), D("div", Ne, [
78
- i("div", Ve, $(r.title), 1),
79
- i("div", ze, [
80
- i("div", Ae, $(n.segment.members.length), 1),
81
- i("div", Ue, [
82
- Oe,
83
- i("div", null, "as of " + $(o(z)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
84
- ])
85
- ]),
86
- l(me, {
87
- loading: o(c).isLoading,
88
- "row-data": o(d),
89
- "row-count": o(c).totalRows,
90
- "column-defs": h,
91
- "page-size": o(c).pageSize,
92
- "page-count": o(c).pageCount,
93
- "page-index": o(c).pageIndex,
94
- onSortChange: o(M),
95
- onPageChange: f[0] || (f[0] = (w) => o(g)({ pageSize: w.pageSize, pageIndex: w.pageIndex }))
96
- }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
97
- ]));
98
- }
99
- }), He = { class: "flex items-center gap-x-8" }, qe = /* @__PURE__ */ i("div", null, "Review segment", -1), Je = {
100
- key: 0,
101
- class: "space-y-16 pr-12"
102
- }, Ge = /* @__PURE__ */ i("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1), Ze = { class: "flex items-center gap-8" }, We = /* @__PURE__ */ Q({
103
- __name: "SegmentSheet",
104
- emits: ["update:model-value"],
105
- setup(e, { expose: r, emit: h }) {
106
- const _ = Re(), c = H(!1), d = H(!1), M = {
107
- name: "",
108
- rule: Be.scaffoldGroup(),
109
- members: []
110
- }, g = Te, s = H(M), n = X(() => {
111
- const v = g.safeParse(s.value);
112
- return v.success ? [] : v.error.errors;
113
- });
114
- function f(v) {
115
- c.value = !0, d.value = !1, v ? s.value = { ...v } : s.value = { ...M };
116
- }
117
- function w() {
118
- c.value = !1;
119
- }
120
- async function I() {
121
- g.safeParse(s.value).success && (d.value = !0);
122
- }
123
- function Y() {
124
- d.value = !1;
125
- }
126
- async function b() {
127
- k("update:model-value", s.value);
128
- }
129
- ue(async () => {
130
- });
131
- const k = h;
132
- return r({
133
- showSheet: f,
134
- hideSheet: w
135
- }), (v, t) => {
136
- const a = S("FmButton"), F = S("FmSideSheet");
137
- return x(), W(F, {
138
- modelValue: o(c),
139
- "onUpdate:modelValue": t[5] || (t[5] = (u) => ye(c) ? c.value = u : null),
140
- header: "Add segment",
141
- "dismiss-away": "",
142
- "close-button": !0,
143
- "max-width": 1100
144
- }, _e({
145
- "side-sheet-footer": C(() => [
146
- i("div", Ze, [
147
- o(d) ? (x(), D(q, { key: 0 }, [
148
- l(a, {
149
- label: "Save Segment",
150
- onClick: b,
151
- loading: o(_).isLoading,
152
- disabled: o(n).length > 0 || o(_).isLoading
153
- }, null, 8, ["loading", "disabled"]),
154
- l(a, {
155
- label: "Cancel",
156
- onClick: t[3] || (t[3] = (u) => Y()),
157
- variant: "tertiary"
158
- })
159
- ], 64)) : (x(), D(q, { key: 1 }, [
160
- l(a, {
161
- label: "Review Segment",
162
- disabled: o(n).length > 0 || o(_).isLoading,
163
- onClick: I
164
- }, null, 8, ["disabled"]),
165
- l(a, {
166
- label: "Cancel",
167
- onClick: t[4] || (t[4] = (u) => w()),
168
- variant: "tertiary"
169
- })
170
- ], 64))
171
- ])
172
- ]),
173
- default: C(() => {
174
- var u;
175
- return [
176
- o(d) ? (x(), W(je, {
177
- key: 1,
178
- title: o(s).name,
179
- segment: o(s)
180
- }, null, 8, ["title", "segment"])) : (x(), D("div", Je, [
181
- l(Ee, {
182
- modelValue: o(s).name,
183
- "onUpdate:modelValue": t[1] || (t[1] = (y) => o(s).name = y),
184
- label: "Segment title",
185
- schema: o(Ie).typeAtPath(o(g), "name")
186
- }, null, 8, ["modelValue", "schema"]),
187
- Ge,
188
- l($e, {
189
- "trigger-type": "MEMBERSHIP_JOINED",
190
- includeOnly: "user",
191
- "model-value": (u = o(s)) == null ? void 0 : u.rule,
192
- "onUpdate:modelValue": t[2] || (t[2] = (y) => {
193
- o(s).rule = y;
194
- })
195
- }, null, 8, ["model-value"])
196
- ]))
197
- ];
198
- }),
199
- _: 2
200
- }, [
201
- o(d) ? {
202
- name: "side-sheet-header",
203
- fn: C(() => [
204
- i("div", He, [
205
- l(a, {
206
- icon: "arrow_back",
207
- variant: "tertiary",
208
- onClick: t[0] || (t[0] = (u) => d.value = !1)
209
- }),
210
- qe
211
- ])
212
- ]),
213
- key: "0"
214
- } : void 0
215
- ]), 1032, ["modelValue"]);
216
- };
217
- }
218
- }), de = De(), Ke = ge();
219
- function K(e) {
220
- const r = z(e);
221
- return r.isValid() ? r.format("DD/MM/YYYY") : "";
222
- }
223
- const Qe = {
224
- mapMemberExportRow: (e) => {
225
- var n, f, w, I, Y, b, k, v, t, a, F, u, y, P, L, T, N, V, J, p, A, ee, te, oe, ae, ne, se, ie;
226
- const r = X(() => Ke.locations.map((m) => ({
227
- label: m.name,
228
- value: m._id
229
- }))), h = (n = Me.parseOneAddress(
230
- e == null ? void 0 : e.email
231
- )) != null && n.domain.includes("feedmepos.com") ? void 0 : e.email, _ = (w = ((f = e == null ? void 0 : e.collection) == null ? void 0 : f.TITLE) || []) == null ? void 0 : w.reduce(
232
- (m, R) => {
233
- var O, j;
234
- const U = (j = (O = de.sortedTitles) == null ? void 0 : O.find(
235
- (G) => G._id === R.collectible
236
- )) == null ? void 0 : j.name;
237
- return !U || R.balance <= 0 || m.push(U), m;
238
- },
239
- []
240
- ), c = (de.sortedTitles || []).reduce(
241
- (m, R) => {
242
- var O, j, G, le;
243
- const U = (le = (G = (j = (((O = e == null ? void 0 : e.collection) == null ? void 0 : O.TITLE) || []).find(
244
- (fe) => fe.collectible === R._id
245
- )) == null ? void 0 : j.expiryBalance) == null ? void 0 : G[0]) == null ? void 0 : le.expiredAt;
246
- return m[R.name] = U ? z(U).format("DD/MM/YYYY") : "", m;
247
- },
248
- {}
249
- ), d = ((b = (Y = (I = e.collection) == null ? void 0 : I.CREDIT) == null ? void 0 : Y.at(0)) == null ? void 0 : b.balance) || 0, M = ((a = (t = (v = (k = e.collection) == null ? void 0 : k.CREDIT) == null ? void 0 : v.at(0)) == null ? void 0 : t.expiryBalance) == null ? void 0 : a.reduce(
250
- (m, R) => m + R.amount,
251
- 0
252
- )) || 0, g = be(d, 2);
253
- return {
254
- ID: e._id.toString(),
255
- Name: ((F = e.name) == null ? void 0 : F.trim()) || "",
256
- Phone: ((u = e == null ? void 0 : e.phoneNumber) == null ? void 0 : u.trim()) || "",
257
- Email: h || "",
258
- Gender: e.gender || "",
259
- CardNo: e.cardNo || "",
260
- Birthday: e != null && e.birthday ? K(e == null ? void 0 : e.birthday) : "",
261
- Credit: parseFloat((Number(g) - Number(M)).toFixed(2)),
262
- FreeCredit: Number(M.toFixed(2)),
263
- TotalCredit: Number(g),
264
- Exp: e != null && e.collection ? ((L = (P = (y = e.collection) == null ? void 0 : y.POINT) == null ? void 0 : P.at(0)) == null ? void 0 : L.balance) ?? 0 : 0,
265
- Point: e != null && e.collection ? ((V = (N = (T = e.collection) == null ? void 0 : T.COIN) == null ? void 0 : N.at(0)) == null ? void 0 : V.balance) ?? 0 : 0,
266
- Level: e != null && e.collection ? ((A = (p = (J = e.collection) == null ? void 0 : J.TIER) == null ? void 0 : p.at(0)) == null ? void 0 : A.balance) ?? 0 : 0,
267
- Tier: e != null && e.collection ? ((oe = (te = (ee = e.collection) == null ? void 0 : ee.TIER) == null ? void 0 : te.at(0)) == null ? void 0 : oe.balance) ?? 0 : 0,
268
- Titles: _.join(","),
269
- ...c,
270
- TotalTransaction: e.stats.visitCount,
271
- AvgSpent: Le(Number(e.stats.avgBillSize || 0)).toFormat(
272
- !1
273
- ),
274
- TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
275
- LastVisit: K(e.stats.lastVisit),
276
- Feedback: ((ae = e.stats) == null ? void 0 : ae.feedbackCount) || 0,
277
- LastSeasonTierEarned: ((ne = e.stats) == null ? void 0 : ne.lastSeasonTierEarned) || 0,
278
- LastSeasonPointEarned: ((se = e.stats) == null ? void 0 : se.lastSeasonPointEarned) || 0,
279
- JoinedAt: K(e.joinAt || void 0),
280
- JoinedAtLocation: e.location && ((ie = r.value.find((m) => m.value == e.location)) == null ? void 0 : ie.label) || "-",
281
- VisitFrequency: `${Number(
282
- Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
283
- )}`
284
- };
285
- }
286
- }, Xe = { class: "flex items-center" }, et = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, tt = { class: "px-24 flex flex-col gap-y-16" }, ot = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, at = { class: "fm-typo-en-body-md-600" }, nt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, st = /* @__PURE__ */ i("img", {
287
- src: Se,
288
- class: "aspect-square w-[150px]"
289
- }, null, -1), it = /* @__PURE__ */ i("div", { class: "flex flex-col gap-16 text-center" }, [
290
- /* @__PURE__ */ i("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
291
- /* @__PURE__ */ i("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Segments allow you to categorize your customers based on various criteria, enabling targeted marketing and personalized experiences. ")
292
- ], -1), Rt = /* @__PURE__ */ Q({
293
- __name: "Segment",
294
- setup(e) {
295
- const { minor: r } = we, { t: h } = Fe(), _ = ge(), { mapMemberExportRow: c } = Qe, d = H(0), M = [
296
- {
297
- header: h("connect.loyalty.segment.table.name"),
298
- accessorFn: (t) => t.name
299
- },
300
- {
301
- header: h("connect.loyalty.segment.table.total_customers"),
302
- accessorFn: (t) => t.memberCount ?? 0
303
- },
304
- {
305
- header: h("connect.loyalty.segment.table.customer_percentage"),
306
- accessorFn: (t) => ((t.memberCount ?? 0) * 100 / d.value).toFixed(2)
307
- },
308
- {
309
- header: h("connect.loyalty.segment.table.actions"),
310
- meta: {
311
- maxWidth: "100px"
312
- },
313
- cell(t) {
314
- return B("div", { class: "flex items-center justify-end" }, [
315
- B(
316
- Z.FmMenu,
317
- {
318
- placement: "bottom-end",
319
- onClick: (a) => {
320
- a.stopPropagation();
321
- }
322
- },
323
- {
324
- "menu-button": () => B(Z.FmButton, {
325
- icon: "more_vert",
326
- iconColor: "neutral-gray-400",
327
- variant: "tertiary"
328
- }),
329
- default: () => [
330
- B(
331
- Z.FmMenuItem,
332
- {
333
- onClick: async (a) => {
334
- a.stopPropagation(), Y(t.row.original);
335
- }
336
- },
337
- {
338
- label: B(
339
- "div",
340
- {
341
- class: "fm-typo-en-body-md-400"
342
- },
343
- "Export"
344
- )
345
- }
346
- ),
347
- B(
348
- Z.FmMenuItem,
349
- {
350
- onClick: async (a) => {
351
- a.stopPropagation(), I(t.row.original);
352
- }
353
- },
354
- {
355
- label: B(
356
- "div",
357
- {
358
- class: "text-fm-color-typo-error fm-typo-en-body-md-400"
359
- },
360
- "Remove"
361
- )
362
- }
363
- )
364
- ]
365
- }
366
- )
367
- ]);
368
- }
369
- }
370
- ], g = H(null), { tableMeta: s, rowData: n, debouncedFetchData: f } = pe(
371
- E.readAll
372
- );
373
- async function w() {
374
- await r(
375
- async () => {
376
- await E.refreshSegments(), await f({ pageSize: 10, pageIndex: 0 });
377
- },
378
- { message: "Refreshing segmentations" }
379
- );
380
- }
381
- async function I(t) {
382
- await xe.remove(`Are you sure you want to remove ${t.name}?`) && await r(
383
- async () => {
384
- await E.delete(t._id), await f({ pageSize: 10, pageIndex: 0 });
385
- },
386
- {
387
- message: `Removing ${t.name}`,
388
- successMessage: `Removed ${t.name} successfully`
389
- }
390
- );
391
- }
392
- async function Y(t) {
393
- const a = {
394
- sortBy: "_id",
395
- descending: !1,
396
- rowsPerPage: 1e3,
397
- page: 1,
398
- rowsNumber: 0
399
- }, F = new ke(), u = (await ce.read({
400
- limit: 1,
401
- skip: 0,
402
- sortBy: a.sortBy,
403
- descending: a.descending
404
- })).meta.totalResources ?? 0, y = a.rowsPerPage;
405
- await r(
406
- async () => {
407
- for (let P = 0; P < u; P += y) {
408
- const L = {
409
- ...a,
410
- limit: y,
411
- skip: a.page - 1,
412
- sortBy: a.sortBy,
413
- descending: a.descending
414
- }, T = await E.paginateSegmentUsers(
415
- t._id,
416
- L
417
- );
418
- for (const N of T.resources) {
419
- const V = c(N);
420
- F.addRecord(V);
421
- }
422
- a.page++;
423
- }
424
- await Ce(
425
- F.buildExcel(),
426
- `[${t.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
427
- {
428
- bookType: "xlsx",
429
- bookSST: !1,
430
- type: "array"
431
- }
432
- ), a.page = 1;
433
- },
434
- {
435
- message: "Exporting member...",
436
- successMessage: "Member exported successfully"
437
- }
438
- );
439
- }
440
- async function b(t) {
441
- await r(
442
- async () => {
443
- var a;
444
- if (t._id) {
445
- const { members: F, _id: u, ...y } = t;
446
- await E.update(t._id, y);
447
- } else
448
- await E.create(t);
449
- await f({ pageSize: 10, pageIndex: 0 }), (a = g.value) == null || a.hideSheet();
450
- },
451
- {
452
- message: "Saving segment",
453
- successMessage: "Segment saved"
454
- }
455
- );
456
- }
457
- function k(t) {
458
- var a;
459
- (a = g.value) == null || a.showSheet(t);
460
- }
461
- const v = X(() => _.isPremium ? [
462
- {
463
- label: "Refresh segments",
464
- value: "refresh"
465
- },
466
- {
467
- label: "Add segment",
468
- value: "add",
469
- isPrimary: !0,
470
- prependIcon: "add"
471
- }
472
- ] : []);
473
- return ve(async () => {
474
- const { meta: t } = await ce.read({
475
- limit: 1,
476
- skip: 0,
477
- sortBy: "_id",
478
- search: void 0,
479
- descending: !1
480
- });
481
- d.value = t.totalResources ?? 0, await f({ pageSize: 10, pageIndex: 0 }), await _.readPremium(), await _.readLocations();
482
- }), (t, a) => {
483
- const F = S("FmPill"), u = S("FmPageHead"), y = S("FmIcon"), P = S("FmMenuItem"), L = S("FmMenu"), T = S("FmListItem"), N = S("FmList"), V = S("FmButton"), J = S("FmCard");
484
- return x(), D(q, null, [
485
- l(u, {
486
- title: "Segments",
487
- actions: o(v),
488
- "onClick:action": a[0] || (a[0] = (p) => p === "add" ? k() : w())
489
- }, {
490
- title: C(() => [
491
- i("div", Xe, [
492
- i("span", et, $(o(h)("connect.loyalty.segment.title")), 1),
493
- l(F, { variant: "premium" })
494
- ])
495
- ]),
496
- _: 1
497
- }, 8, ["actions"]),
498
- i("div", tt, [
499
- o(n).length > 0 || o(s).searchValue || o(s).isLoading ? (x(), D(q, { key: 0 }, [
500
- l(me, {
501
- loading: o(s).isLoading,
502
- "row-data": o(n),
503
- "row-count": o(s).totalRows,
504
- "column-defs": M,
505
- "shrink-at": !1,
506
- "page-count": o(s).pageCount,
507
- "page-index": o(s).pageIndex,
508
- "page-size": o(s).pageSize,
509
- onRowClick: a[1] || (a[1] = (p) => {
510
- k(p.original);
511
- }),
512
- onPageChange: o(f)
513
- }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
514
- l(N, { class: "w-full hidden xs:block" }, {
515
- default: C(() => [
516
- (x(!0), D(q, null, he(o(n), (p) => (x(), W(T, {
517
- key: p._id.toString(),
518
- tag: "label",
519
- onClick: (A) => k(p)
520
- }, {
521
- default: C(() => [
522
- i("div", null, [
523
- i("div", ot, $((p.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
524
- i("div", at, $(p.name), 1),
525
- i("div", nt, $(((p.memberCount ?? 0) * 100 / o(d)).toFixed(2)) + "% of customers ", 1)
526
- ])
527
- ]),
528
- append: C(() => [
529
- l(L, { "stop-click-propagation": !0 }, {
530
- "menu-button": C(() => [
531
- l(y, { name: "more_vert" })
532
- ]),
533
- default: C(() => [
534
- l(P, {
535
- class: "text-fm-color-typo-error fm-typo-en-body-md-400",
536
- label: "Remove",
537
- "onUpdate:modelValue": (A) => A && I(p)
538
- }, null, 8, ["onUpdate:modelValue"])
539
- ]),
540
- _: 2
541
- }, 1024)
542
- ]),
543
- _: 2
544
- }, 1032, ["onClick"]))), 128))
545
- ]),
546
- _: 1
547
- })
548
- ], 64)) : (x(), W(J, {
549
- key: 1,
550
- variant: "outlined",
551
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
552
- }, {
553
- default: C(() => [
554
- st,
555
- it,
556
- l(V, {
557
- variant: "primary",
558
- label: "Create segment",
559
- disabled: !o(_).isPremium,
560
- icon: "add",
561
- onClick: a[2] || (a[2] = (p) => k())
562
- }, null, 8, ["disabled"])
563
- ]),
564
- _: 1
565
- })),
566
- l(We, {
567
- ref_key: "sheetRef",
568
- ref: g,
569
- "onUpdate:modelValue": b
570
- }, null, 512)
571
- ])
572
- ], 64);
573
- };
574
- }
575
- });
576
- export {
577
- Rt as default
578
- };