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