@feedmepos/mf-connect 0.1.0-beta.3 → 0.1.0-beta.30

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 (99) hide show
  1. package/dist/Analytic-DLez3H4H.js +424 -0
  2. package/dist/{App-gzbM97vW.js → App-dkNRyYLR.js} +397 -384
  3. package/dist/{Broadcast-BwYZkTs0.js → Broadcast-DlAaBitD.js} +32 -32
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DIh9rz6T.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BtpiGQEs.js} +8 -8
  5. package/dist/Card-JpWEjzjP.js +897 -0
  6. package/dist/{Collections-Df6tlo8S.js → Collections-D5hUfDJo.js} +4 -4
  7. package/dist/{Credit-BPel8vA9.js → Credit-v3KdCFwT.js} +14 -14
  8. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-DLnvDVgf.js +108 -0
  9. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CE2Ar-Ll.js +2198 -0
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BT8ucS5G.js → EffectSheet.vue_vue_type_style_index_0_lang-C12m8EXP.js} +8 -8
  11. package/dist/{Experience-CPpz1Zwx.js → Experience-9A41fyZO.js} +8 -8
  12. package/dist/{Game-ByLblISC.js → Game-l1tUsePJ.js} +15 -15
  13. package/dist/Index-rF6OzGw_.js +255 -0
  14. package/dist/Marketing-6zS-6CS3.js +20070 -0
  15. package/dist/{Member-CCc_FEZY.js → Member-B5jPh0DM.js} +4 -4
  16. package/dist/MemberList-c2P1lToO.js +1045 -0
  17. package/dist/{MemberTransactions-DD5ahSbY.js → MemberTransactions-BiwAZyCP.js} +1 -1
  18. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-DSPvWk4C.js → MessageInput.vue_vue_type_script_setup_true_lang-CYVOCazs.js} +2 -2
  19. package/dist/{Mission-VH4057I-.js → Mission-BM7abR6J.js} +98 -86
  20. package/dist/Overview-Drjb4oAW.js +1024 -0
  21. package/dist/{Point-Bu3IlpH4.js → Point-BP9YezdW.js} +23 -23
  22. package/dist/{Promotion-B45AOHis.js → Promotion-DiqlNOWk.js} +53 -47
  23. package/dist/Record-DJ2A1L-C.js +209 -0
  24. package/dist/Reward-DN6z6LXf.js +411 -0
  25. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-CcbzCFUg.js +151 -0
  26. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-CFD10xnG.js +1639 -0
  27. package/dist/Segment-Cm48eZrS.js +567 -0
  28. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-6XokSm7W.js +181 -0
  29. package/dist/{Setting-CF09eRQJ.js → Setting-3jXUi2cS.js} +8 -8
  30. package/dist/Store-Csditfe8.js +1745 -0
  31. package/dist/{StoreRewards-0iGExjqQ.js → StoreRewards-DOMxpeaj.js} +12 -12
  32. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Csoobxol.js +957 -0
  33. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BEfxin47.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-C8UhKTgD.js} +1 -1
  34. package/dist/{Tier-IaeWe7rM.js → Tier-BmhQYaPz.js} +318 -306
  35. package/dist/{Title-DD67Zxh5.js → Title-BJV4yLCu.js} +199 -183
  36. package/dist/{Transaction-BsPDnLzB.js → Transaction-DB81PNYL.js} +2 -2
  37. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-wyCBPQRj.js +130 -0
  38. package/dist/{Voucher-M7JfcKo0.js → Voucher-B8nnAIUZ.js} +31 -31
  39. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-B4zIOBh0.js +419 -0
  40. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-k0lprU2i.js → ZodTextField.vue_vue_type_script_setup_true_lang-DvfcNsj9.js} +1 -1
  41. package/dist/{app-DwujUNP-.js → app-BYTkNtdY.js} +1 -1
  42. package/dist/{app-HFICF0vL.js → app-sD3N1iqR.js} +1285 -1283
  43. package/dist/app.js +1 -1
  44. package/dist/{business-BaF1QJXa.js → business-B6OFKNz4.js} +1 -1
  45. package/dist/{campaign-CTDtmAE9.js → campaign-DhumfBC6.js} +2 -2
  46. package/dist/collectible.enum-4Gywgj__.js +19 -0
  47. package/dist/{collection.fn-DMW03W4R.js → collection.fn-D-uexOQL.js} +2 -2
  48. package/dist/{dto-gpaNZHzQ.js → dto-b9jcbMWA.js} +78 -86
  49. package/dist/{effect-CBUmtwet.js → effect-CBN4vtSi.js} +9 -9
  50. package/dist/email-addresses-BqgJVUoG.js +705 -0
  51. package/dist/{export-Bdh_PbsW.js → export-D1kS_vMc.js} +3 -3
  52. package/dist/{helper-Cu9elRvl.js → helper-SbkTJZDm.js} +1 -1
  53. package/dist/index-BBBSm4kr.js +54 -0
  54. package/dist/index-BIs-Ed1-.js +29000 -0
  55. package/dist/{index-ogzk-Mj4.js → index-CBwwTcb5.js} +1 -1
  56. package/dist/{index-At6yms5t.js → index-CHg2swyg.js} +30 -26
  57. package/dist/index-Cd94xjeo.js +38 -0
  58. package/dist/{index-CArqG03W.js → index-Cehc8dyz.js} +39 -35
  59. package/dist/index-CsaQJMAR.js +66 -0
  60. package/dist/{index-CtH2S49l.js → index-CxBG7i3n.js} +203 -195
  61. package/dist/{index-DrGrOgZB.js → index-DgJVPeks.js} +13 -1
  62. package/dist/{index-NXiDu42U.js → index-Dp-5hs3q.js} +1 -1
  63. package/dist/{index-Crw-Vgo5.js → index-DtX7V_mF.js} +1500 -1479
  64. package/dist/index-Hhxoo_Eg.js +1067 -0
  65. package/dist/{index-Ch6XwPzF.js → index-OCIxZJKd.js} +1 -1
  66. package/dist/{index-Dfdg2Q3E.js → index-wJ5e3mQa.js} +1 -1
  67. package/dist/{index.esm2017-CeJpvUbA.js → index.esm2017-Bl1OPd9N.js} +33 -33
  68. package/dist/{loading-Cn8ml_vy.js → loading-BghJIv3w.js} +591 -597
  69. package/dist/{membership-CX4AKMlH.js → membership-D532uzUJ.js} +51 -43
  70. package/dist/money-BJmDeENN.js +15 -0
  71. package/dist/number-E_LdkU9a.js +12 -0
  72. package/dist/objectid-DSB8jlsT.js +145 -0
  73. package/dist/remy-vue-client-Cpppk9h-.js +1693 -0
  74. package/dist/reward-CiTzAsCd.js +36 -0
  75. package/dist/{rule-Cv83Y59R.js → rule-0MEHUef9.js} +180 -177
  76. package/dist/{rule-builder-Dew4yB5Q.js → rule-builder-BQZN0Bi4.js} +1 -1
  77. package/dist/style.css +1 -1
  78. package/dist/{template-CSnbgM1o.js → template-2xDKWfij.js} +5 -5
  79. package/dist/trigger-BFmJQkCL.js +114 -0
  80. package/dist/user-B_diJ-ER.js +54 -0
  81. package/dist/{vue-i18n-CNH_IhVd.js → vue-i18n-D0S05G9j.js} +408 -408
  82. package/dist/{xlsx-D4DUZHix.js → xlsx-9pjTnN_k.js} +1 -1
  83. package/package.json +8 -7
  84. package/dist/Analytic-BC5BA6pN.js +0 -622
  85. package/dist/Card-CBYQGKwY.js +0 -825
  86. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-PsrS7I0r.js +0 -2809
  87. package/dist/Marketing-D0vm80e_.js +0 -316
  88. package/dist/MemberList-CrnipE9y.js +0 -1733
  89. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Ijc2OYh9.js +0 -1753
  90. package/dist/Segment-ZWsp48aC.js +0 -437
  91. package/dist/Store-B_G6Dhmq.js +0 -1511
  92. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CaxUr9zl.js +0 -890
  93. package/dist/index-8MaN7rez.js +0 -762
  94. package/dist/index-BjdHxGDn.js +0 -298
  95. package/dist/index-CuvNtC_M.js +0 -61
  96. package/dist/index-RP0XOPRL.js +0 -29193
  97. package/dist/money-BTejgvKu.js +0 -15
  98. package/dist/number-Cen5TucC.js +0 -12
  99. package/dist/user-Bm4KttFq.js +0 -37
@@ -0,0 +1,567 @@
1
+ import { defineComponent as Q, onMounted as ue, openBlock as h, createElementBlock as Y, createElementVNode as i, toDisplayString as D, unref as a, createVNode as l, ref as H, computed as X, resolveComponent as x, createBlock as W, isRef as ye, createSlots as ve, withCtx as C, Fragment as q, h as B, onBeforeMount as _e, renderList as Se } from "vue";
2
+ import { _ as xe } from "./campaign-CpzFl8Vr.js";
3
+ import { F as re, p as he, u as we } from "./loading-BghJIv3w.js";
4
+ import { components as Z } from "@feedmepos/ui-library";
5
+ import { u as pe, _ as me } from "./usePagination-BeF5K3M7.js";
6
+ import { u as Fe } from "./vue-i18n-D0S05G9j.js";
7
+ import { w as Ce } from "./xlsx-9pjTnN_k.js";
8
+ import { e as Me, M as ke } from "./email-addresses-BqgJVUoG.js";
9
+ import { Z as Ie } from "./zod-Bg2FbC-D.js";
10
+ import { a as Pe } from "./index-Cehc8dyz.js";
11
+ import { u as Re } from "./app-wDQR6dpb.js";
12
+ import { R as Be } from "./rule-builder-BQZN0Bi4.js";
13
+ import { _ as Ee } from "./ZodTextField.vue_vue_type_script_setup_true_lang-DvfcNsj9.js";
14
+ import { _ as De } from "./RuleGroup.vue_vue_type_script_setup_true_lang-CFD10xnG.js";
15
+ import { h as z } from "./moment-BWErdI6_.js";
16
+ import { s as E, u as Ye } from "./membership-D532uzUJ.js";
17
+ import { o as $e } from "./objectId-dwaoBfJX.js";
18
+ import { u as ge } from "./business-B6OFKNz4.js";
19
+ import { f as be } from "./number-E_LdkU9a.js";
20
+ import { t as Le } from "./money-BJmDeENN.js";
21
+ import { m as ce } from "./index-OCIxZJKd.js";
22
+ const Te = Pe.extend({
23
+ _id: re.optional(),
24
+ business: re.optional()
25
+ }), Ve = { class: "space-y-16 pr-12" }, Ne = { 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__ */ Q({
26
+ __name: "ReviewSegment",
27
+ props: {
28
+ title: {},
29
+ segment: {}
30
+ },
31
+ setup(e) {
32
+ const c = e, S = [
33
+ {
34
+ header: "Name",
35
+ accessorFn: (n) => n.name
36
+ },
37
+ {
38
+ header: "Id",
39
+ accessorFn: (n) => n._id
40
+ },
41
+ {
42
+ header: "Customer Since",
43
+ accessorFn: (n) => z($e(n._id.toString())).format("DD MMM YYYY")
44
+ },
45
+ {
46
+ header: "Phone",
47
+ accessorFn: (n) => n.phoneNumber
48
+ },
49
+ {
50
+ header: "Birthday",
51
+ accessorFn: (n) => z(n.birthday).format("DD MMM YYYY")
52
+ },
53
+ {
54
+ header: "Last Visit",
55
+ accessorFn: (n) => z(n.stats.lastVisit).format("DD MMM YYYY")
56
+ }
57
+ ], v = async (n) => c.segment._id ? await E.paginateSegmentUsers(c.segment._id, {
58
+ limit: r.value.pageSize,
59
+ skip: n.pageIndex ?? 0,
60
+ sortBy: "_id",
61
+ search: n.searchValue,
62
+ descending: !0
63
+ }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: r, rowData: d, onSort: M, debouncedFetchData: f, onSearch: s } = pe(v);
64
+ return ue(async () => {
65
+ await f();
66
+ }), (n, u) => (h(), Y("div", Ve, [
67
+ i("div", Ne, D(c.title), 1),
68
+ i("div", ze, [
69
+ i("div", Ae, D(n.segment.members.length), 1),
70
+ i("div", Ue, [
71
+ u[1] || (u[1] = i("div", null, "contacts in your segment", -1)),
72
+ i("div", null, "as of " + D(a(z)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
73
+ ])
74
+ ]),
75
+ l(me, {
76
+ loading: a(r).isLoading,
77
+ "row-data": a(d),
78
+ "row-count": a(r).totalRows,
79
+ "column-defs": S,
80
+ "page-size": a(r).pageSize,
81
+ "page-count": a(r).pageCount,
82
+ "page-index": a(r).pageIndex,
83
+ onSortChange: a(M),
84
+ onPageChange: u[0] || (u[0] = (w) => a(f)({ pageSize: w.pageSize, pageIndex: w.pageIndex }))
85
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
86
+ ]));
87
+ }
88
+ }), je = { class: "flex items-center gap-x-8" }, He = {
89
+ key: 0,
90
+ class: "space-y-16 pr-12"
91
+ }, qe = { class: "flex items-center gap-8" }, Je = /* @__PURE__ */ Q({
92
+ __name: "SegmentSheet",
93
+ emits: ["update:model-value"],
94
+ setup(e, { expose: c, emit: S }) {
95
+ const v = Re(), r = H(!1), d = H(!1), M = {
96
+ name: "",
97
+ rule: Be.scaffoldGroup(),
98
+ members: []
99
+ }, f = Te, s = H(M), n = X(() => {
100
+ const _ = f.safeParse(s.value);
101
+ return _.success ? [] : _.error.errors;
102
+ });
103
+ function u(_) {
104
+ r.value = !0, d.value = !1, _ ? s.value = { ..._ } : s.value = { ...M };
105
+ }
106
+ function w() {
107
+ r.value = !1;
108
+ }
109
+ async function I() {
110
+ f.safeParse(s.value).success && (d.value = !0);
111
+ }
112
+ function $() {
113
+ d.value = !1;
114
+ }
115
+ async function b() {
116
+ k("update:model-value", s.value);
117
+ }
118
+ ue(async () => {
119
+ });
120
+ const k = S;
121
+ return c({
122
+ showSheet: u,
123
+ hideSheet: w
124
+ }), (_, t) => {
125
+ const o = x("FmButton"), F = x("FmSideSheet");
126
+ return h(), W(F, {
127
+ modelValue: a(r),
128
+ "onUpdate:modelValue": t[5] || (t[5] = (p) => ye(r) ? r.value = p : null),
129
+ header: "Add segment",
130
+ "dismiss-away": "",
131
+ "close-button": !0,
132
+ "max-width": 1100
133
+ }, ve({
134
+ "side-sheet-footer": C(() => [
135
+ i("div", qe, [
136
+ a(d) ? (h(), Y(q, { key: 0 }, [
137
+ l(o, {
138
+ label: "Save Segment",
139
+ onClick: b,
140
+ loading: a(v).isLoading,
141
+ disabled: a(n).length > 0 || a(v).isLoading
142
+ }, null, 8, ["loading", "disabled"]),
143
+ l(o, {
144
+ label: "Cancel",
145
+ onClick: t[3] || (t[3] = (p) => $()),
146
+ variant: "tertiary"
147
+ })
148
+ ], 64)) : (h(), Y(q, { key: 1 }, [
149
+ l(o, {
150
+ label: "Review Segment",
151
+ disabled: a(n).length > 0 || a(v).isLoading,
152
+ onClick: I
153
+ }, null, 8, ["disabled"]),
154
+ l(o, {
155
+ label: "Cancel",
156
+ onClick: t[4] || (t[4] = (p) => w()),
157
+ variant: "tertiary"
158
+ })
159
+ ], 64))
160
+ ])
161
+ ]),
162
+ default: C(() => {
163
+ var p;
164
+ return [
165
+ a(d) ? (h(), W(Oe, {
166
+ key: 1,
167
+ title: a(s).name,
168
+ segment: a(s)
169
+ }, null, 8, ["title", "segment"])) : (h(), Y("div", He, [
170
+ l(Ee, {
171
+ modelValue: a(s).name,
172
+ "onUpdate:modelValue": t[1] || (t[1] = (y) => a(s).name = y),
173
+ label: "Segment title",
174
+ schema: a(Ie).typeAtPath(a(f), "name")
175
+ }, null, 8, ["modelValue", "schema"]),
176
+ t[7] || (t[7] = i("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
177
+ l(De, {
178
+ "trigger-type": "MEMBERSHIP_JOINED",
179
+ includeOnly: "user",
180
+ "model-value": (p = a(s)) == null ? void 0 : p.rule,
181
+ "onUpdate:modelValue": t[2] || (t[2] = (y) => {
182
+ a(s).rule = y;
183
+ })
184
+ }, null, 8, ["model-value"])
185
+ ]))
186
+ ];
187
+ }),
188
+ _: 2
189
+ }, [
190
+ a(d) ? {
191
+ name: "side-sheet-header",
192
+ fn: C(() => [
193
+ i("div", je, [
194
+ l(o, {
195
+ icon: "arrow_back",
196
+ variant: "tertiary",
197
+ onClick: t[0] || (t[0] = (p) => d.value = !1)
198
+ }),
199
+ t[6] || (t[6] = i("div", null, "Review segment", -1))
200
+ ])
201
+ ]),
202
+ key: "0"
203
+ } : void 0
204
+ ]), 1032, ["modelValue"]);
205
+ };
206
+ }
207
+ }), de = Ye(), Ge = ge();
208
+ function K(e) {
209
+ const c = z(e);
210
+ return c.isValid() ? c.format("DD/MM/YYYY") : "";
211
+ }
212
+ const Ze = {
213
+ mapMemberExportRow: (e) => {
214
+ var n, u, w, I, $, b, k, _, t, o, F, p, y, P, L, T, V, N, J, m, A, ee, te, oe, ae, ne, se, ie;
215
+ const c = X(() => Ge.locations.map((g) => ({
216
+ label: g.name,
217
+ value: g._id
218
+ }))), S = (n = Me.parseOneAddress(
219
+ e == null ? void 0 : e.email
220
+ )) != null && n.domain.includes("feedmepos.com") ? void 0 : e.email, v = (w = ((u = e == null ? void 0 : e.collection) == null ? void 0 : u.TITLE) || []) == null ? void 0 : w.reduce(
221
+ (g, R) => {
222
+ var O, j;
223
+ const U = (j = (O = de.sortedTitles) == null ? void 0 : O.find(
224
+ (G) => G._id === R.collectible
225
+ )) == null ? void 0 : j.name;
226
+ return !U || R.balance <= 0 || g.push(U), g;
227
+ },
228
+ []
229
+ ), r = (de.sortedTitles || []).reduce(
230
+ (g, R) => {
231
+ var O, j, G, le;
232
+ const U = (le = (G = (j = (((O = e == null ? void 0 : e.collection) == null ? void 0 : O.TITLE) || []).find(
233
+ (fe) => fe.collectible === R._id
234
+ )) == null ? void 0 : j.expiryBalance) == null ? void 0 : G[0]) == null ? void 0 : le.expiredAt;
235
+ return g[R.name] = U ? z(U).format("DD/MM/YYYY") : "", g;
236
+ },
237
+ {}
238
+ ), d = ((b = ($ = (I = e.collection) == null ? void 0 : I.CREDIT) == null ? void 0 : $.at(0)) == null ? void 0 : b.balance) || 0, M = ((o = (t = (_ = (k = e.collection) == null ? void 0 : k.CREDIT) == null ? void 0 : _.at(0)) == null ? void 0 : t.expiryBalance) == null ? void 0 : o.reduce(
239
+ (g, R) => g + R.amount,
240
+ 0
241
+ )) || 0, f = be(d, 2);
242
+ return {
243
+ ID: e._id.toString(),
244
+ Name: ((F = e.name) == null ? void 0 : F.trim()) || "",
245
+ Phone: ((p = e == null ? void 0 : e.phoneNumber) == null ? void 0 : p.trim()) || "",
246
+ Email: S || "",
247
+ Gender: e.gender || "",
248
+ CardNo: e.cardNo || "",
249
+ Birthday: e != null && e.birthday ? K(e == null ? void 0 : e.birthday) : "",
250
+ Credit: parseFloat((Number(f) - Number(M)).toFixed(2)),
251
+ FreeCredit: Number(M.toFixed(2)),
252
+ TotalCredit: Number(f),
253
+ 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,
254
+ Point: e != null && e.collection ? ((N = (V = (T = e.collection) == null ? void 0 : T.COIN) == null ? void 0 : V.at(0)) == null ? void 0 : N.balance) ?? 0 : 0,
255
+ Level: e != null && e.collection ? ((A = (m = (J = e.collection) == null ? void 0 : J.TIER) == null ? void 0 : m.at(0)) == null ? void 0 : A.balance) ?? 0 : 0,
256
+ 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,
257
+ Titles: v.join(","),
258
+ ...r,
259
+ TotalTransaction: e.stats.visitCount,
260
+ AvgSpent: Le(Number(e.stats.avgBillSize || 0)).toFormat(
261
+ !1
262
+ ),
263
+ TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
264
+ LastVisit: K(e.stats.lastVisit),
265
+ Feedback: ((ae = e.stats) == null ? void 0 : ae.feedbackCount) || 0,
266
+ LastSeasonTierEarned: ((ne = e.stats) == null ? void 0 : ne.lastSeasonTierEarned) || 0,
267
+ LastSeasonPointEarned: ((se = e.stats) == null ? void 0 : se.lastSeasonPointEarned) || 0,
268
+ JoinedAt: K(e.joinAt || void 0),
269
+ JoinedAtLocation: e.location && ((ie = c.value.find((g) => g.value == e.location)) == null ? void 0 : ie.label) || "-",
270
+ VisitFrequency: `${Number(
271
+ Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
272
+ )}`
273
+ };
274
+ }
275
+ }, We = { class: "flex items-center" }, Ke = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Qe = { class: "px-24 flex flex-col gap-y-16" }, Xe = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, et = { class: "fm-typo-en-body-md-600" }, tt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Ft = /* @__PURE__ */ Q({
276
+ __name: "Segment",
277
+ setup(e) {
278
+ const { minor: c } = we, { t: S } = Fe(), v = ge(), { mapMemberExportRow: r } = Ze, d = H(0), M = [
279
+ {
280
+ header: S("connect.loyalty.segment.table.name"),
281
+ accessorFn: (t) => t.name
282
+ },
283
+ {
284
+ header: S("connect.loyalty.segment.table.total_customers"),
285
+ accessorFn: (t) => t.memberCount ?? 0
286
+ },
287
+ {
288
+ header: S("connect.loyalty.segment.table.customer_percentage"),
289
+ accessorFn: (t) => ((t.memberCount ?? 0) * 100 / d.value).toFixed(2)
290
+ },
291
+ {
292
+ header: S("connect.loyalty.segment.table.actions"),
293
+ meta: {
294
+ maxWidth: "100px"
295
+ },
296
+ cell(t) {
297
+ return B("div", { class: "flex items-center justify-end" }, [
298
+ B(
299
+ Z.FmMenu,
300
+ {
301
+ placement: "bottom-end",
302
+ onClick: (o) => {
303
+ o.stopPropagation();
304
+ }
305
+ },
306
+ {
307
+ "menu-button": () => B(Z.FmButton, {
308
+ icon: "more_vert",
309
+ iconColor: "neutral-gray-400",
310
+ variant: "tertiary"
311
+ }),
312
+ default: () => [
313
+ B(
314
+ Z.FmMenuItem,
315
+ {
316
+ onClick: async (o) => {
317
+ o.stopPropagation(), $(t.row.original);
318
+ }
319
+ },
320
+ {
321
+ label: B(
322
+ "div",
323
+ {
324
+ class: "fm-typo-en-body-md-400"
325
+ },
326
+ "Export"
327
+ )
328
+ }
329
+ ),
330
+ B(
331
+ Z.FmMenuItem,
332
+ {
333
+ onClick: async (o) => {
334
+ o.stopPropagation(), I(t.row.original);
335
+ }
336
+ },
337
+ {
338
+ label: B(
339
+ "div",
340
+ {
341
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
342
+ },
343
+ "Remove"
344
+ )
345
+ }
346
+ )
347
+ ]
348
+ }
349
+ )
350
+ ]);
351
+ }
352
+ }
353
+ ], f = H(null), { tableMeta: s, rowData: n, debouncedFetchData: u } = pe(
354
+ E.readAll
355
+ );
356
+ async function w() {
357
+ await c(
358
+ async () => {
359
+ await E.refreshSegments(), await u({ pageSize: 10, pageIndex: 0 });
360
+ },
361
+ { message: "Refreshing segmentations" }
362
+ );
363
+ }
364
+ async function I(t) {
365
+ await he.remove(`Are you sure you want to remove ${t.name}?`) && await c(
366
+ async () => {
367
+ await E.delete(t._id), await u({ pageSize: 10, pageIndex: 0 });
368
+ },
369
+ {
370
+ message: `Removing ${t.name}`,
371
+ successMessage: `Removed ${t.name} successfully`
372
+ }
373
+ );
374
+ }
375
+ async function $(t) {
376
+ const o = {
377
+ sortBy: "_id",
378
+ descending: !1,
379
+ rowsPerPage: 1e3,
380
+ page: 1,
381
+ rowsNumber: 0
382
+ }, F = new ke(), p = (await ce.read({
383
+ limit: 1,
384
+ skip: 0,
385
+ sortBy: o.sortBy,
386
+ descending: o.descending
387
+ })).meta.totalResources ?? 0, y = o.rowsPerPage;
388
+ await c(
389
+ async () => {
390
+ for (let P = 0; P < p; P += y) {
391
+ const L = {
392
+ ...o,
393
+ limit: y,
394
+ skip: o.page - 1,
395
+ sortBy: o.sortBy,
396
+ descending: o.descending
397
+ }, T = await E.paginateSegmentUsers(
398
+ t._id,
399
+ L
400
+ );
401
+ for (const V of T.resources) {
402
+ const N = r(V);
403
+ F.addRecord(N);
404
+ }
405
+ o.page++;
406
+ }
407
+ await Ce(
408
+ F.buildExcel(),
409
+ `[${t.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
410
+ {
411
+ bookType: "xlsx",
412
+ bookSST: !1,
413
+ type: "array"
414
+ }
415
+ ), o.page = 1;
416
+ },
417
+ {
418
+ message: "Exporting member...",
419
+ successMessage: "Member exported successfully"
420
+ }
421
+ );
422
+ }
423
+ async function b(t) {
424
+ await c(
425
+ async () => {
426
+ var o;
427
+ if (t._id) {
428
+ const { members: F, _id: p, ...y } = t;
429
+ await E.update(t._id, y);
430
+ } else
431
+ await E.create(t);
432
+ await u({ pageSize: 10, pageIndex: 0 }), (o = f.value) == null || o.hideSheet();
433
+ },
434
+ {
435
+ message: "Saving segment",
436
+ successMessage: "Segment saved"
437
+ }
438
+ );
439
+ }
440
+ function k(t) {
441
+ var o;
442
+ (o = f.value) == null || o.showSheet(t);
443
+ }
444
+ const _ = X(() => v.isPremium ? [
445
+ {
446
+ label: "Refresh segments",
447
+ value: "refresh"
448
+ },
449
+ {
450
+ label: "Add segment",
451
+ value: "add",
452
+ isPrimary: !0,
453
+ prependIcon: "add"
454
+ }
455
+ ] : []);
456
+ return _e(async () => {
457
+ const { meta: t } = await ce.read({
458
+ limit: 1,
459
+ skip: 0,
460
+ sortBy: "_id",
461
+ search: void 0,
462
+ descending: !1
463
+ });
464
+ d.value = t.totalResources ?? 0, await u({ pageSize: 10, pageIndex: 0 }), await v.readPremium(), await v.readLocations();
465
+ }), (t, o) => {
466
+ const F = x("FmPill"), p = x("FmPageHead"), y = x("FmIcon"), P = x("FmMenuItem"), L = x("FmMenu"), T = x("FmListItem"), V = x("FmList"), N = x("FmButton"), J = x("FmCard");
467
+ return h(), Y(q, null, [
468
+ l(p, {
469
+ title: "Segments",
470
+ actions: a(_),
471
+ "onClick:action": o[0] || (o[0] = (m) => m === "add" ? k() : w())
472
+ }, {
473
+ title: C(() => [
474
+ i("div", We, [
475
+ i("span", Ke, D(a(S)("connect.loyalty.segment.title")), 1),
476
+ l(F, { variant: "premium" })
477
+ ])
478
+ ]),
479
+ _: 1
480
+ }, 8, ["actions"]),
481
+ i("div", Qe, [
482
+ a(n).length > 0 || a(s).searchValue || a(s).isLoading ? (h(), Y(q, { key: 0 }, [
483
+ l(me, {
484
+ loading: a(s).isLoading,
485
+ "row-data": a(n),
486
+ "row-count": a(s).totalRows,
487
+ "column-defs": M,
488
+ "shrink-at": !1,
489
+ "page-count": a(s).pageCount,
490
+ "page-index": a(s).pageIndex,
491
+ "page-size": a(s).pageSize,
492
+ onRowClick: o[1] || (o[1] = (m) => {
493
+ k(m.original);
494
+ }),
495
+ onPageChange: a(u)
496
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
497
+ l(V, { class: "w-full hidden xs:block" }, {
498
+ default: C(() => [
499
+ (h(!0), Y(q, null, Se(a(n), (m) => (h(), W(T, {
500
+ key: m._id.toString(),
501
+ tag: "label",
502
+ onClick: (A) => k(m)
503
+ }, {
504
+ default: C(() => [
505
+ i("div", null, [
506
+ i("div", Xe, D((m.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
507
+ i("div", et, D(m.name), 1),
508
+ i("div", tt, D(((m.memberCount ?? 0) * 100 / a(d)).toFixed(2)) + "% of customers ", 1)
509
+ ])
510
+ ]),
511
+ append: C(() => [
512
+ l(L, { "stop-click-propagation": !0 }, {
513
+ "menu-button": C(() => [
514
+ l(y, { name: "more_vert" })
515
+ ]),
516
+ default: C(() => [
517
+ l(P, {
518
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
519
+ label: "Remove",
520
+ "onUpdate:modelValue": (A) => A && I(m)
521
+ }, null, 8, ["onUpdate:modelValue"])
522
+ ]),
523
+ _: 2
524
+ }, 1024)
525
+ ]),
526
+ _: 2
527
+ }, 1032, ["onClick"]))), 128))
528
+ ]),
529
+ _: 1
530
+ })
531
+ ], 64)) : (h(), W(J, {
532
+ key: 1,
533
+ variant: "outlined",
534
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
535
+ }, {
536
+ default: C(() => [
537
+ o[3] || (o[3] = i("img", {
538
+ src: xe,
539
+ class: "aspect-square w-[150px]"
540
+ }, null, -1)),
541
+ o[4] || (o[4] = i("div", { class: "flex flex-col gap-16 text-center" }, [
542
+ i("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
543
+ 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. ")
544
+ ], -1)),
545
+ l(N, {
546
+ variant: "primary",
547
+ label: "Create segment",
548
+ disabled: !a(v).isPremium,
549
+ icon: "add",
550
+ onClick: o[2] || (o[2] = (m) => k())
551
+ }, null, 8, ["disabled"])
552
+ ]),
553
+ _: 1
554
+ })),
555
+ l(Je, {
556
+ ref_key: "sheetRef",
557
+ ref: f,
558
+ "onUpdate:modelValue": b
559
+ }, null, 512)
560
+ ])
561
+ ], 64);
562
+ };
563
+ }
564
+ });
565
+ export {
566
+ Ft as default
567
+ };