@feedmepos/mf-connect 0.1.0-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 (68) hide show
  1. package/dist/{Analytic-D1vIDmhJ.js → Analytic-AqWU_lJy.js} +7 -7
  2. package/dist/{App-DHrfWG8l.js → App-CRTD0U-N.js} +205 -205
  3. package/dist/{Broadcast-B2rxZAZi.js → Broadcast-utWSrzP9.js} +7 -7
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D2a9rcXK.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-C5zUv0Zx.js} +8 -8
  5. package/dist/{Card-Dr6pTTM0.js → Card-x6qnEaIt.js} +57 -58
  6. package/dist/{Collections-0tbg0MFt.js → Collections-BgbWoLWI.js} +11 -12
  7. package/dist/{Credit-KbB_7Jq-.js → Credit-CojzmUnh.js} +7 -7
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-we7ADwFk.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-C137bE1q.js} +36 -33
  9. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-VBNyvZCJ.js → EffectSheet.vue_vue_type_style_index_0_lang-8l3Dt_Lo.js} +5 -5
  10. package/dist/{Experience-C_Q9Iml8.js → Experience-CPjovKWF.js} +7 -7
  11. package/dist/{Game-BwODw7M6.js → Game-DWcjPfZP.js} +7 -7
  12. package/dist/{Marketing-QOKTAS_T.js → Marketing-CwoI0pFF.js} +4 -4
  13. package/dist/{Member-d7RIGRm1.js → Member-oRcVGr20.js} +3 -3
  14. package/dist/MemberList-ISy05wGZ.js +1040 -0
  15. package/dist/{MemberTransactions-D-pnlXiP.js → MemberTransactions-CXvhJngX.js} +1 -1
  16. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-3VS7JnK6.js → MessageInput.vue_vue_type_script_setup_true_lang-Ca1LO__F.js} +2 -2
  17. package/dist/{Mission-BAKDm4VZ.js → Mission-Y8s5MQIC.js} +7 -7
  18. package/dist/{Point-Puu0jKz0.js → Point-0Fw3qLIW.js} +7 -7
  19. package/dist/{Promotion-DRIaUvJi.js → Promotion-vqM23NPX.js} +8 -8
  20. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-DTdfYGya.js → RuleGroup.vue_vue_type_script_setup_true_lang-D1eQ3i5D.js} +86 -77
  21. package/dist/Segment-lgzMRCyd.js +564 -0
  22. package/dist/{Setting-DLB2ywCp.js → Setting-CFGB53S0.js} +7 -7
  23. package/dist/Store-fJlew3HJ.js +1533 -0
  24. package/dist/{StoreRewards-DZfqUeYR.js → StoreRewards-DWq34E4p.js} +10 -10
  25. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-RTfozD01.js → StoreTransactions.vue_vue_type_script_setup_true_lang-nhS5Dhhk.js} +10 -10
  26. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BGI78ycg.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DWlpmE56.js} +1 -1
  27. package/dist/{Tier-BnQRujpX.js → Tier-DLrOmrnK.js} +13 -13
  28. package/dist/{Title-BPf1tUFx.js → Title-MHQuel7h.js} +13 -13
  29. package/dist/{Transaction-ese0oNrz.js → Transaction-CYqMFEzc.js} +1 -1
  30. package/dist/{Voucher--gtOZQx1.js → Voucher-B0QCX_nG.js} +10 -10
  31. package/dist/{app-DHE61XdR.js → app-BjOpRVdv.js} +1 -1
  32. package/dist/{app-Bt59niI-.js → app-SOHUUM08.js} +24 -24
  33. package/dist/app.js +1 -1
  34. package/dist/{business-BSo7EPan.js → business-DveMDDHY.js} +1 -1
  35. package/dist/{campaign-CsOje3Ap.js → campaign-CMb05XLt.js} +2 -2
  36. package/dist/{collection.fn-BYQfFJOr.js → collection.fn-BjaBPYMU.js} +2 -2
  37. package/dist/{dto-CfEXSCq6.js → dto-CY7JrHkZ.js} +8 -8
  38. package/dist/{effect-Bn_ofYS3.js → effect-CxAdSlyD.js} +1 -1
  39. package/dist/email-addresses-Dtr5OALQ.js +705 -0
  40. package/dist/{export-CMR243CF.js → export-DuBekrcg.js} +3 -3
  41. package/dist/{helper-BqOQRtvW.js → helper-DL6hnmtJ.js} +1 -1
  42. package/dist/{index-CHO4_zsT.js → index-BBBytzpn.js} +1 -1
  43. package/dist/{index-DbP04yeg.js → index-BMxu_XL-.js} +1 -1
  44. package/dist/index-BSIUoSG3.js +28997 -0
  45. package/dist/{index-BaBNmzUb.js → index-BZAlqAaJ.js} +1 -1
  46. package/dist/{index-D_f2lmK2.js → index-CAQpU5Rv.js} +319 -304
  47. package/dist/{index-BWnFs-Cb.js → index-CGHNWhkM.js} +5 -5
  48. package/dist/{index-Boo5np6l.js → index-CgPlJqkX.js} +1 -1
  49. package/dist/{index-DtPe-TEm.js → index-Cibwzgac.js} +3 -3
  50. package/dist/{index-DEZsrQ2f.js → index-DISwCnfH.js} +3 -3
  51. package/dist/{index-CC1GV8OW.js → index-Dx4pkNRc.js} +1 -1
  52. package/dist/{index-Da142OER.js → index-gcsOy_cD.js} +34 -33
  53. package/dist/{index-FvlaxwGB.js → index-raYm7Ew2.js} +2 -2
  54. package/dist/{index.esm2017-ePm--Atp.js → index.esm2017-Bs9CWbrs.js} +1 -1
  55. package/dist/{loading-KNmEMBUB.js → loading-Dj5bx8fg.js} +4 -4
  56. package/dist/{membership-DKoVIS1a.js → membership-B2avlZoN.js} +3 -3
  57. package/dist/{money-CkD3zl5C.js → money-CNSWtAf-.js} +1 -1
  58. package/dist/{number-BDsGpOXm.js → number-BA58pjU6.js} +1 -1
  59. package/dist/{rule-CzamI50_.js → rule-BWazFYuZ.js} +179 -177
  60. package/dist/{rule-builder-DHf6wfaQ.js → rule-builder-RIloDQBn.js} +1 -1
  61. package/dist/{template-CFAIPoD7.js → template-u01r84LY.js} +4 -4
  62. package/dist/{xlsx-BDJMaozs.js → usePagination--B6Wt7C1.js} +3246 -3025
  63. package/package.json +2 -2
  64. package/dist/MemberList-CK9629ew.js +0 -1737
  65. package/dist/Segment-DpBxGuuu.js +0 -435
  66. package/dist/Store-8DO6ITWc.js +0 -1513
  67. package/dist/index-BLDYTxnc.js +0 -28058
  68. package/dist/usePagination-JoYaROkV.js +0 -223
@@ -0,0 +1,564 @@
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
+ };
@@ -1,15 +1,15 @@
1
1
  import { defineComponent as Re, ref as z, computed as ie, onMounted as De, resolveComponent as L, openBlock as V, createBlock as we, withCtx as G, createElementVNode as b, createVNode as M, unref as h, isRef as ke, createElementBlock as q, Fragment as fe, createTextVNode as Q, toDisplayString as k, renderList as Ie, createCommentVNode as Pe } from "vue";
2
2
  import { h as rt } from "./moment-BWErdI6_.js";
3
3
  import { useDialog as Ve } from "@feedmepos/ui-library";
4
- import { a as xe, u as it, p as st, f as K } from "./loading-KNmEMBUB.js";
4
+ import { a as xe, u as it, p as st, f as K } from "./loading-Dj5bx8fg.js";
5
5
  import { u as at } from "./app-wDQR6dpb.js";
6
- import { u as be, l as $e } from "./business-BSo7EPan.js";
7
- import { u as ze } from "./membership-DKoVIS1a.js";
8
- import { l as lt } from "./index-Da142OER.js";
6
+ import { u as be, l as $e } from "./business-DveMDDHY.js";
7
+ import { u as ze } from "./membership-B2avlZoN.js";
8
+ import { l as lt } from "./index-gcsOy_cD.js";
9
9
  import { _ as Ne } from "./ImageInput.vue_vue_type_script_setup_true_lang-ByhTB9Ie.js";
10
- import { _ as ct } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-BGI78ycg.js";
11
- import { _ as ut } from "./MessageInput.vue_vue_type_script_setup_true_lang-3VS7JnK6.js";
12
- import { m as dt } from "./index-CC1GV8OW.js";
10
+ import { _ as ct } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-DWlpmE56.js";
11
+ import { _ as ut } from "./MessageInput.vue_vue_type_script_setup_true_lang-Ca1LO__F.js";
12
+ import { m as dt } from "./index-Dx4pkNRc.js";
13
13
  import { o as ft } from "./objectId-dwaoBfJX.js";
14
14
  import { a as gt } from "./object-qECH92oz.js";
15
15
  var Z = {}, mt = function() {