@feedmepos/mf-connect 0.1.1-prod → 0.1.2-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 (64) hide show
  1. package/dist/{Analytic-C2etD-eu.js → Analytic-AqWU_lJy.js} +7 -7
  2. package/dist/{App-DlRvkDpN.js → App-CRTD0U-N.js} +5 -5
  3. package/dist/{Broadcast-DpCGUS6r.js → Broadcast-utWSrzP9.js} +7 -7
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Cj4IcH5D.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-C5zUv0Zx.js} +8 -8
  5. package/dist/{Card-DjGC6jmq.js → Card-x6qnEaIt.js} +30 -30
  6. package/dist/{Collections-Q2pYWnJF.js → Collections-BgbWoLWI.js} +4 -4
  7. package/dist/{Credit-DOIq2VYW.js → Credit-CojzmUnh.js} +7 -7
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-D7ML8ePp.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-C137bE1q.js} +22 -22
  9. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-CyxWG5I7.js → EffectSheet.vue_vue_type_style_index_0_lang-8l3Dt_Lo.js} +5 -5
  10. package/dist/{Experience-DUst4I0H.js → Experience-CPjovKWF.js} +7 -7
  11. package/dist/{Game-CXnQR-wV.js → Game-DWcjPfZP.js} +7 -7
  12. package/dist/{Marketing-CZfHsMFC.js → Marketing-CwoI0pFF.js} +4 -4
  13. package/dist/{Member-CX5Ohgeg.js → Member-oRcVGr20.js} +3 -3
  14. package/dist/{MemberList-D8I3SaAs.js → MemberList-ISy05wGZ.js} +84 -84
  15. package/dist/{MemberTransactions-DfZNbCHD.js → MemberTransactions-CXvhJngX.js} +1 -1
  16. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-BxFVEoBX.js → MessageInput.vue_vue_type_script_setup_true_lang-Ca1LO__F.js} +2 -2
  17. package/dist/{Mission-S1pwDbqp.js → Mission-Y8s5MQIC.js} +7 -7
  18. package/dist/{Point-BdLUcGZy.js → Point-0Fw3qLIW.js} +7 -7
  19. package/dist/{Promotion-DWAeQGkU.js → Promotion-vqM23NPX.js} +8 -8
  20. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-Dux_NMO5.js → RuleGroup.vue_vue_type_script_setup_true_lang-D1eQ3i5D.js} +14 -14
  21. package/dist/Segment-lgzMRCyd.js +564 -0
  22. package/dist/{Setting-CLuXuEId.js → Setting-CFGB53S0.js} +7 -7
  23. package/dist/{Store-Be3cui0S.js → Store-fJlew3HJ.js} +11 -11
  24. package/dist/{StoreRewards-zFy_w8p4.js → StoreRewards-DWq34E4p.js} +10 -10
  25. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-DxGJKgbc.js → StoreTransactions.vue_vue_type_script_setup_true_lang-nhS5Dhhk.js} +10 -10
  26. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-Dreo45H1.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DWlpmE56.js} +1 -1
  27. package/dist/{Tier-ChzcISYF.js → Tier-DLrOmrnK.js} +13 -13
  28. package/dist/{Title-DQSjhBkT.js → Title-MHQuel7h.js} +13 -13
  29. package/dist/{Transaction-CeWmWpN_.js → Transaction-CYqMFEzc.js} +1 -1
  30. package/dist/{Voucher-BkLIxiZN.js → Voucher-B0QCX_nG.js} +10 -10
  31. package/dist/{app-DuNsy0aC.js → app-BjOpRVdv.js} +1 -1
  32. package/dist/{app-CLNirPsB.js → app-SOHUUM08.js} +24 -24
  33. package/dist/app.js +1 -1
  34. package/dist/{business-COGiTmLD.js → business-DveMDDHY.js} +1 -1
  35. package/dist/{campaign-BHZMjQi5.js → campaign-CMb05XLt.js} +2 -2
  36. package/dist/{collection.fn-sAxtYO_r.js → collection.fn-BjaBPYMU.js} +2 -2
  37. package/dist/{dto-ndeeV_nc.js → dto-CY7JrHkZ.js} +50 -50
  38. package/dist/{effect-BQt0rkdT.js → effect-CxAdSlyD.js} +1 -1
  39. package/dist/{email-addresses-B3PazwKs.js → email-addresses-Dtr5OALQ.js} +1 -1
  40. package/dist/{export-D6r-xNji.js → export-DuBekrcg.js} +3 -3
  41. package/dist/{helper-CrjQw_Et.js → helper-DL6hnmtJ.js} +1 -1
  42. package/dist/{index-C3AAy__p.js → index-BBBytzpn.js} +1 -1
  43. package/dist/{index-CHAaFSD2.js → index-BMxu_XL-.js} +1 -1
  44. package/dist/{index-DGLmbBnE.js → index-BSIUoSG3.js} +3 -3
  45. package/dist/{index-Daax_BQa.js → index-BZAlqAaJ.js} +1 -1
  46. package/dist/{index-Buy-yvAZ.js → index-CAQpU5Rv.js} +1 -1
  47. package/dist/{index-DrLEuIe1.js → index-CGHNWhkM.js} +5 -5
  48. package/dist/{index-Btlj28Vg.js → index-CgPlJqkX.js} +1 -1
  49. package/dist/{index-tSEYvA-2.js → index-Cibwzgac.js} +3 -3
  50. package/dist/{index-CqpEhMr6.js → index-DISwCnfH.js} +2 -2
  51. package/dist/{index-CvHj-wYi.js → index-Dx4pkNRc.js} +1 -1
  52. package/dist/{index-Cg3RFxc9.js → index-gcsOy_cD.js} +5 -5
  53. package/dist/{index-DXpd07G3.js → index-raYm7Ew2.js} +2 -2
  54. package/dist/{index.esm2017-a5BlZ76G.js → index.esm2017-Bs9CWbrs.js} +1 -1
  55. package/dist/{loading-B3XGyQ8W.js → loading-Dj5bx8fg.js} +4 -4
  56. package/dist/{membership-GIOJ1ptN.js → membership-B2avlZoN.js} +3 -3
  57. package/dist/{money-z7VwzhZP.js → money-CNSWtAf-.js} +1 -1
  58. package/dist/{number-DHYb2ua_.js → number-BA58pjU6.js} +1 -1
  59. package/dist/{rule-iIEblTE4.js → rule-BWazFYuZ.js} +3 -3
  60. package/dist/{rule-builder-CcsWd5r9.js → rule-builder-RIloDQBn.js} +1 -1
  61. package/dist/{template-DMRMDZOW.js → template-u01r84LY.js} +4 -4
  62. package/dist/{usePagination-CNFe0T2B.js → usePagination--B6Wt7C1.js} +1 -1
  63. package/package.json +1 -1
  64. package/dist/Segment-CXSE8Bzf.js +0 -560
@@ -1,560 +0,0 @@
1
- import { defineComponent as K, onMounted as re, openBlock as h, createElementBlock as E, createElementVNode as s, toDisplayString as L, unref as o, createVNode as c, ref as j, computed as ce, resolveComponent as v, createBlock as Z, isRef as me, createSlots as ge, withCtx as S, Fragment as H, onBeforeMount as fe, renderList as ye, h as P } from "vue";
2
- import { _ as _e } from "./campaign-CpzFl8Vr.js";
3
- import { F as se, p as ve, u as he } from "./loading-B3XGyQ8W.js";
4
- import { components as J } from "@feedmepos/ui-library";
5
- import { a as de, _ as ue, w as Se } from "./usePagination-CNFe0T2B.js";
6
- import { e as xe, M as we } from "./email-addresses-B3PazwKs.js";
7
- import { _ as Fe, Z as Ce } from "./ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js";
8
- import { a as Me } from "./index-tSEYvA-2.js";
9
- import { u as ke } from "./app-wDQR6dpb.js";
10
- import { R as Ie } from "./rule-builder-CcsWd5r9.js";
11
- import { _ as Pe } from "./RuleGroup.vue_vue_type_script_setup_true_lang-Dux_NMO5.js";
12
- import { h as V } from "./moment-BWErdI6_.js";
13
- import { s as R, u as Re } from "./membership-GIOJ1ptN.js";
14
- import { o as Ee } from "./objectId-dwaoBfJX.js";
15
- import { u as $e } from "./business-COGiTmLD.js";
16
- import { f as Be } from "./number-DHYb2ua_.js";
17
- import { t as De } from "./money-z7VwzhZP.js";
18
- import { m as ie } from "./index-C3AAy__p.js";
19
- const Ye = Me.extend({
20
- _id: se.optional(),
21
- business: se.optional()
22
- }), be = { class: "space-y-16 pr-12" }, Te = { class: "fm-typo-en-title-md-800" }, Ne = { class: "flex space-x-8" }, Ve = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, Le = { class: "text-fm-color-typo-secondary" }, ze = /* @__PURE__ */ s("div", null, "contacts in your segment", -1), Ae = /* @__PURE__ */ K({
23
- __name: "ReviewSegment",
24
- props: {
25
- title: {},
26
- segment: {}
27
- },
28
- setup(e) {
29
- const d = e, x = [
30
- {
31
- header: "Name",
32
- accessorFn: (n) => n.name
33
- },
34
- {
35
- header: "Id",
36
- accessorFn: (n) => n._id
37
- },
38
- {
39
- header: "Customer Since",
40
- accessorFn: (n) => V(Ee(n._id.toString())).format("DD MMM YYYY")
41
- },
42
- {
43
- header: "Phone",
44
- accessorFn: (n) => n.phoneNumber
45
- },
46
- {
47
- header: "Birthday",
48
- accessorFn: (n) => V(n.birthday).format("DD MMM YYYY")
49
- },
50
- {
51
- header: "Last Visit",
52
- accessorFn: (n) => V(n.stats.lastVisit).format("DD MMM YYYY")
53
- }
54
- ], w = async (n) => d.segment._id ? await R.paginateSegmentUsers(d.segment._id, {
55
- limit: l.value.pageSize,
56
- skip: n.pageIndex ?? 0,
57
- sortBy: "_id",
58
- search: n.searchValue,
59
- descending: !0
60
- }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: l, rowData: p, onSort: f, debouncedFetchData: u, onSearch: i } = de(w);
61
- return re(async () => {
62
- await u();
63
- }), (n, F) => (h(), E("div", be, [
64
- s("div", Te, L(d.title), 1),
65
- s("div", Ne, [
66
- s("div", Ve, L(n.segment.members.length), 1),
67
- s("div", Le, [
68
- ze,
69
- s("div", null, "as of " + L(o(V)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
70
- ])
71
- ]),
72
- c(ue, {
73
- loading: o(l).isLoading,
74
- "row-data": o(p),
75
- "row-count": o(l).totalRows,
76
- "column-defs": x,
77
- "page-size": o(l).pageSize,
78
- "page-count": o(l).pageCount,
79
- "page-index": o(l).pageIndex,
80
- onSortChange: o(f),
81
- onPageChange: F[0] || (F[0] = (y) => o(u)({ pageSize: y.pageSize, pageIndex: y.pageIndex }))
82
- }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
83
- ]));
84
- }
85
- }), Ue = { class: "flex items-center gap-x-8" }, Oe = /* @__PURE__ */ s("div", null, "Review segment", -1), je = {
86
- key: 0,
87
- class: "space-y-16 pr-12"
88
- }, He = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1), qe = { class: "flex items-center gap-8" }, Ge = /* @__PURE__ */ K({
89
- __name: "SegmentSheet",
90
- emits: ["update:model-value"],
91
- setup(e, { expose: d, emit: x }) {
92
- const w = ke(), l = j(!1), p = j(!1), f = {
93
- name: "",
94
- rule: Ie.scaffoldGroup(),
95
- members: []
96
- }, u = Ye, i = j(f), n = ce(() => {
97
- const a = u.safeParse(i.value);
98
- return a.success ? [] : a.error.errors;
99
- });
100
- function F(a) {
101
- l.value = !0, p.value = !1, a ? i.value = { ...a } : i.value = { ...f };
102
- }
103
- function y() {
104
- l.value = !1;
105
- }
106
- async function $() {
107
- u.safeParse(i.value).success && (p.value = !0);
108
- }
109
- function B() {
110
- p.value = !1;
111
- }
112
- async function C() {
113
- D("update:model-value", i.value);
114
- }
115
- re(async () => {
116
- });
117
- const D = x;
118
- return d({
119
- showSheet: F,
120
- hideSheet: y
121
- }), (a, t) => {
122
- const m = v("FmButton"), M = v("FmSideSheet");
123
- return h(), Z(M, {
124
- modelValue: o(l),
125
- "onUpdate:modelValue": t[5] || (t[5] = (r) => me(l) ? l.value = r : null),
126
- header: "Add segment",
127
- "dismiss-away": "",
128
- "close-button": !0,
129
- "max-width": 1100
130
- }, ge({
131
- "side-sheet-footer": S(() => [
132
- s("div", qe, [
133
- o(p) ? (h(), E(H, { key: 0 }, [
134
- c(m, {
135
- label: "Save Segment",
136
- onClick: C,
137
- loading: o(w).isLoading,
138
- disabled: o(n).length > 0 || o(w).isLoading
139
- }, null, 8, ["loading", "disabled"]),
140
- c(m, {
141
- label: "Cancel",
142
- onClick: t[3] || (t[3] = (r) => B()),
143
- variant: "tertiary"
144
- })
145
- ], 64)) : (h(), E(H, { key: 1 }, [
146
- c(m, {
147
- label: "Review Segment",
148
- disabled: o(n).length > 0 || o(w).isLoading,
149
- onClick: $
150
- }, null, 8, ["disabled"]),
151
- c(m, {
152
- label: "Cancel",
153
- onClick: t[4] || (t[4] = (r) => y()),
154
- variant: "tertiary"
155
- })
156
- ], 64))
157
- ])
158
- ]),
159
- default: S(() => {
160
- var r;
161
- return [
162
- o(p) ? (h(), Z(Ae, {
163
- key: 1,
164
- title: o(i).name,
165
- segment: o(i)
166
- }, null, 8, ["title", "segment"])) : (h(), E("div", je, [
167
- c(Fe, {
168
- modelValue: o(i).name,
169
- "onUpdate:modelValue": t[1] || (t[1] = (_) => o(i).name = _),
170
- label: "Segment title",
171
- schema: o(Ce).typeAtPath(o(u), "name")
172
- }, null, 8, ["modelValue", "schema"]),
173
- He,
174
- c(Pe, {
175
- "trigger-type": "MEMBERSHIP_JOINED",
176
- includeOnly: "user",
177
- "model-value": (r = o(i)) == null ? void 0 : r.rule,
178
- "onUpdate:modelValue": t[2] || (t[2] = (_) => {
179
- o(i).rule = _;
180
- })
181
- }, null, 8, ["model-value"])
182
- ]))
183
- ];
184
- }),
185
- _: 2
186
- }, [
187
- o(p) ? {
188
- name: "side-sheet-header",
189
- fn: S(() => [
190
- s("div", Ue, [
191
- c(m, {
192
- icon: "arrow_back",
193
- variant: "tertiary",
194
- onClick: t[0] || (t[0] = (r) => p.value = !1)
195
- }),
196
- Oe
197
- ])
198
- ]),
199
- key: "0"
200
- } : void 0
201
- ]), 1032, ["modelValue"]);
202
- };
203
- }
204
- }), le = Re();
205
- function W(e) {
206
- const d = V(e);
207
- return d.isValid() ? d.format("DD/MM/YYYY") : "";
208
- }
209
- const Je = {
210
- mapMemberExportRow: (e) => {
211
- var i, n, F, y, $, B, C, D, a, t, m, M, r, _, Y, b, T, N, q, g, z, Q, X, ee, te, oe, ae;
212
- const d = (i = xe.parseOneAddress(
213
- e == null ? void 0 : e.email
214
- )) != null && i.domain.includes("feedmepos.com") ? void 0 : e.email, x = (F = ((n = e == null ? void 0 : e.collection) == null ? void 0 : n.TITLE) || []) == null ? void 0 : F.reduce(
215
- (k, I) => {
216
- var U, O;
217
- const A = (O = (U = le.sortedTitles) == null ? void 0 : U.find(
218
- (G) => G._id === I.collectible
219
- )) == null ? void 0 : O.name;
220
- return !A || I.balance <= 0 || k.push(A), k;
221
- },
222
- []
223
- ), w = (le.sortedTitles || []).reduce(
224
- (k, I) => {
225
- var U, O, G, ne;
226
- const A = (ne = (G = (O = (((U = e == null ? void 0 : e.collection) == null ? void 0 : U.TITLE) || []).find(
227
- (pe) => pe.collectible === I._id
228
- )) == null ? void 0 : O.expiryBalance) == null ? void 0 : G[0]) == null ? void 0 : ne.expiredAt;
229
- return k[I.name] = A ? V(A).format("DD/MM/YYYY") : "", k;
230
- },
231
- {}
232
- ), l = ((B = ($ = (y = e.collection) == null ? void 0 : y.CREDIT) == null ? void 0 : $.at(0)) == null ? void 0 : B.balance) || 0, p = ((t = (a = (D = (C = e.collection) == null ? void 0 : C.CREDIT) == null ? void 0 : D.at(0)) == null ? void 0 : a.expiryBalance) == null ? void 0 : t.reduce(
233
- (k, I) => k + I.amount,
234
- 0
235
- )) || 0, f = Be(l, 2);
236
- return {
237
- ID: e._id.toString(),
238
- Name: ((m = e.name) == null ? void 0 : m.trim()) || "",
239
- Phone: ((M = e == null ? void 0 : e.phoneNumber) == null ? void 0 : M.trim()) || "",
240
- Email: d || "",
241
- Gender: e.gender || "",
242
- CardNo: e.cardNo || "",
243
- Birthday: W((e == null ? void 0 : e.birthday) || void 0),
244
- Credit: parseFloat((Number(f) - Number(p)).toFixed(2)),
245
- FreeCredit: Number(p.toFixed(2)),
246
- TotalCredit: Number(f),
247
- Exp: e != null && e.collection ? ((Y = (_ = (r = e.collection) == null ? void 0 : r.POINT) == null ? void 0 : _.at(0)) == null ? void 0 : Y.balance) ?? 0 : 0,
248
- Point: e != null && e.collection ? ((N = (T = (b = e.collection) == null ? void 0 : b.COIN) == null ? void 0 : T.at(0)) == null ? void 0 : N.balance) ?? 0 : 0,
249
- Level: e != null && e.collection ? ((z = (g = (q = e.collection) == null ? void 0 : q.TIER) == null ? void 0 : g.at(0)) == null ? void 0 : z.balance) ?? 0 : 0,
250
- Tier: e != null && e.collection ? ((ee = (X = (Q = e.collection) == null ? void 0 : Q.TIER) == null ? void 0 : X.at(0)) == null ? void 0 : ee.balance) ?? 0 : 0,
251
- Titles: x.join(","),
252
- ...w,
253
- TotalTransaction: e.stats.visitCount,
254
- AvgSpent: De(Number(e.stats.avgBillSize || 0)).toFormat(
255
- !1
256
- ),
257
- TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
258
- LastVisit: W(e.stats.lastVisit),
259
- Feedback: ((te = e.stats) == null ? void 0 : te.feedbackCount) || 0,
260
- LastSeasonTierEarned: ((oe = e.stats) == null ? void 0 : oe.lastSeasonTierEarned) || 0,
261
- LastSeasonPointEarned: ((ae = e.stats) == null ? void 0 : ae.lastSeasonPointEarned) || 0,
262
- JoinedAt: W(e.joinAt || void 0),
263
- VisitFrequency: `${Number(
264
- Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
265
- )}`
266
- };
267
- }
268
- }, Ze = { class: "flex items-center" }, We = /* @__PURE__ */ s("span", { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, " Segments ", -1), Ke = { class: "px-24 flex flex-col gap-y-16" }, Qe = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Xe = { class: "fm-typo-en-body-md-600" }, et = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, tt = /* @__PURE__ */ s("img", {
269
- src: _e,
270
- class: "aspect-square w-[150px]"
271
- }, null, -1), ot = /* @__PURE__ */ s("div", { class: "flex flex-col gap-16 text-center" }, [
272
- /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
273
- /* @__PURE__ */ s("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. ")
274
- ], -1), xt = /* @__PURE__ */ K({
275
- __name: "Segment",
276
- setup(e) {
277
- const { minor: d } = he, x = $e(), { mapMemberExportRow: w } = Je, l = j(0), p = [
278
- {
279
- header: "Name",
280
- accessorFn: (a) => a.name
281
- },
282
- {
283
- header: "Total Customers in this Segment",
284
- accessorFn: (a) => a.memberCount ?? 0
285
- },
286
- {
287
- header: "% of customers",
288
- accessorFn: (a) => ((a.memberCount ?? 0) * 100 / l.value).toFixed(2)
289
- },
290
- {
291
- header: "Actions",
292
- meta: {
293
- maxWidth: "100px"
294
- },
295
- cell(a) {
296
- return P("div", { class: "flex items-center justify-end" }, [
297
- P(
298
- J.FmMenu,
299
- {
300
- placement: "bottom-end",
301
- onClick: (t) => {
302
- t.stopPropagation();
303
- }
304
- },
305
- {
306
- "menu-button": () => P(J.FmButton, {
307
- icon: "more_vert",
308
- iconColor: "neutral-gray-400",
309
- variant: "tertiary"
310
- }),
311
- default: () => [
312
- P(
313
- J.FmMenuItem,
314
- {
315
- onClick: async (t) => {
316
- t.stopPropagation(), $(a.row.original);
317
- }
318
- },
319
- {
320
- label: P(
321
- "div",
322
- {
323
- class: "fm-typo-en-body-md-400"
324
- },
325
- "Export"
326
- )
327
- }
328
- ),
329
- P(
330
- J.FmMenuItem,
331
- {
332
- onClick: async (t) => {
333
- t.stopPropagation(), y(a.row.original);
334
- }
335
- },
336
- {
337
- label: P(
338
- "div",
339
- {
340
- class: "text-fm-color-typo-error fm-typo-en-body-md-400"
341
- },
342
- "Remove"
343
- )
344
- }
345
- )
346
- ]
347
- }
348
- )
349
- ]);
350
- }
351
- }
352
- ], f = j(null), { tableMeta: u, rowData: i, debouncedFetchData: n } = de(
353
- R.readAll
354
- );
355
- async function F() {
356
- await d(
357
- async () => {
358
- await R.refreshSegments(), await n({ pageSize: 10, pageIndex: 0 });
359
- },
360
- { message: "Refreshing segmentations" }
361
- );
362
- }
363
- async function y(a) {
364
- await ve.remove(`Are you sure you want to remove ${a.name}?`) && await d(
365
- async () => {
366
- await R.delete(a._id), await n({ pageSize: 10, pageIndex: 0 });
367
- },
368
- {
369
- message: `Removing ${a.name}`,
370
- successMessage: `Removed ${a.name} successfully`
371
- }
372
- );
373
- }
374
- async function $(a) {
375
- const t = {
376
- sortBy: "_id",
377
- descending: !1,
378
- rowsPerPage: 1e3,
379
- page: 1,
380
- rowsNumber: 0
381
- }, m = new we(), M = (await ie.read({
382
- limit: 1,
383
- skip: 0,
384
- sortBy: t.sortBy,
385
- descending: t.descending
386
- })).meta.totalResources ?? 0, r = t.rowsPerPage;
387
- await d(
388
- async () => {
389
- for (let _ = 0; _ < M; _ += r) {
390
- const Y = {
391
- ...t,
392
- limit: r,
393
- skip: t.page - 1,
394
- sortBy: t.sortBy,
395
- descending: t.descending
396
- }, b = await R.paginateSegmentUsers(
397
- a._id,
398
- Y
399
- );
400
- for (const T of b.resources) {
401
- const N = w(T);
402
- m.addRecord(N);
403
- }
404
- t.page++;
405
- }
406
- await Se(
407
- m.buildExcel(),
408
- `[${a.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
409
- {
410
- bookType: "xlsx",
411
- bookSST: !1,
412
- type: "array"
413
- }
414
- ), t.page = 1;
415
- },
416
- {
417
- message: "Exporting member...",
418
- successMessage: "Member exported successfully"
419
- }
420
- );
421
- }
422
- async function B(a) {
423
- await d(
424
- async () => {
425
- var t;
426
- if (a._id) {
427
- const { members: m, _id: M, ...r } = a;
428
- await R.update(a._id, r);
429
- } else
430
- await R.create(a);
431
- await n({ pageSize: 10, pageIndex: 0 }), (t = f.value) == null || t.hideSheet();
432
- },
433
- {
434
- message: "Saving segment",
435
- successMessage: "Segment saved"
436
- }
437
- );
438
- }
439
- function C(a) {
440
- var t;
441
- (t = f.value) == null || t.showSheet(a);
442
- }
443
- const D = ce(() => x.isPremium ? [
444
- {
445
- label: "Refresh segments",
446
- value: "refresh"
447
- },
448
- {
449
- label: "Add segment",
450
- value: "add",
451
- isPrimary: !0,
452
- prependIcon: "add"
453
- }
454
- ] : []);
455
- return fe(async () => {
456
- const { meta: a } = await ie.read({
457
- limit: 1,
458
- skip: 0,
459
- sortBy: "_id",
460
- search: void 0,
461
- descending: !1
462
- });
463
- l.value = a.totalResources ?? 0, await n({ pageSize: 10, pageIndex: 0 }), await x.readPremium();
464
- }), (a, t) => {
465
- const m = v("FmPill"), M = v("FmPageHead"), r = v("FmIcon"), _ = v("FmMenuItem"), Y = v("FmMenu"), b = v("FmListItem"), T = v("FmList"), N = v("FmButton"), q = v("FmCard");
466
- return h(), E(H, null, [
467
- c(M, {
468
- title: "Segments",
469
- actions: o(D),
470
- "onClick:action": t[0] || (t[0] = (g) => g === "add" ? C() : F())
471
- }, {
472
- title: S(() => [
473
- s("div", Ze, [
474
- We,
475
- c(m, { variant: "premium" })
476
- ])
477
- ]),
478
- _: 1
479
- }, 8, ["actions"]),
480
- s("div", Ke, [
481
- o(i).length > 0 || o(u).searchValue || o(u).isLoading ? (h(), E(H, { key: 0 }, [
482
- c(ue, {
483
- loading: o(u).isLoading,
484
- "row-data": o(i),
485
- "row-count": o(u).totalRows,
486
- "column-defs": p,
487
- "shrink-at": !1,
488
- "page-count": o(u).pageCount,
489
- "page-index": o(u).pageIndex,
490
- "page-size": o(u).pageSize,
491
- onRowClick: t[1] || (t[1] = (g) => {
492
- C(g.original);
493
- }),
494
- onPageChange: o(n)
495
- }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
496
- c(T, { class: "w-full hidden xs:block" }, {
497
- default: S(() => [
498
- (h(!0), E(H, null, ye(o(i), (g) => (h(), Z(b, {
499
- key: g._id.toString(),
500
- tag: "label",
501
- onClick: (z) => C(g)
502
- }, {
503
- default: S(() => [
504
- s("div", null, [
505
- s("div", Qe, L((g.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
506
- s("div", Xe, L(g.name), 1),
507
- s("div", et, L(((g.memberCount ?? 0) * 100 / o(l)).toFixed(2)) + "% of customers ", 1)
508
- ])
509
- ]),
510
- append: S(() => [
511
- c(Y, { "stop-click-propagation": !0 }, {
512
- "menu-button": S(() => [
513
- c(r, { name: "more_vert" })
514
- ]),
515
- default: S(() => [
516
- c(_, {
517
- class: "text-fm-color-typo-error fm-typo-en-body-md-400",
518
- label: "Remove",
519
- "onUpdate:modelValue": (z) => z && y(g)
520
- }, null, 8, ["onUpdate:modelValue"])
521
- ]),
522
- _: 2
523
- }, 1024)
524
- ]),
525
- _: 2
526
- }, 1032, ["onClick"]))), 128))
527
- ]),
528
- _: 1
529
- })
530
- ], 64)) : (h(), Z(q, {
531
- key: 1,
532
- variant: "outlined",
533
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
534
- }, {
535
- default: S(() => [
536
- tt,
537
- ot,
538
- c(N, {
539
- variant: "primary",
540
- label: "Create segment",
541
- disabled: !o(x).isPremium,
542
- icon: "add",
543
- onClick: t[2] || (t[2] = (g) => C())
544
- }, null, 8, ["disabled"])
545
- ]),
546
- _: 1
547
- })),
548
- c(Ge, {
549
- ref_key: "sheetRef",
550
- ref: f,
551
- "onUpdate:modelValue": B
552
- }, null, 512)
553
- ])
554
- ], 64);
555
- };
556
- }
557
- });
558
- export {
559
- xt as default
560
- };