@feedmepos/mf-connect 0.1.0-beta.4 → 0.1.0-beta.40

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 (106) hide show
  1. package/dist/Analytic-DArrGnk-.js +426 -0
  2. package/dist/{App-BnQwjxIr.js → App-CxJaPSSE.js} +397 -384
  3. package/dist/{Broadcast-y1kP18mo.js → Broadcast-C5CtxHYC.js} +32 -32
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Dj0JUMOk.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DJAGRlyI.js} +6 -8
  5. package/dist/Card-ZsgNMrz5.js +894 -0
  6. package/dist/{Collections-DPfbZMg1.js → Collections-CodLm2hP.js} +28 -34
  7. package/dist/{Credit-QleM_b6q.js → Credit-8qliEPqA.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-DZOeB8YS.js +2209 -0
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-2hRTF1EJ.js → EffectSheet.vue_vue_type_style_index_0_lang-Cf4nXUmp.js} +8 -8
  11. package/dist/{Experience-DGKj8ChY.js → Experience-DR0_RUqZ.js} +8 -8
  12. package/dist/{Game-BxRdzSma.js → Game-BZkQZDV_.js} +15 -15
  13. package/dist/Index-BP9YGCex.js +255 -0
  14. package/dist/Marketing-Bt-ViwTP.js +20070 -0
  15. package/dist/{Member-CteeBDi2.js → Member-DW_uVRyE.js} +4 -4
  16. package/dist/MemberList-BQcsV-Bz.js +1554 -0
  17. package/dist/MemberTransactions-xJaYPP7W.js +45 -0
  18. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-CZ2M8huU.js → MessageInput.vue_vue_type_script_setup_true_lang-Txp1lndf.js} +2 -2
  19. package/dist/{Mission-CZgXBa09.js → Mission-CQ2PlxLv.js} +98 -86
  20. package/dist/Overview-CWhTf5Tz.js +1063 -0
  21. package/dist/{Point-C2vzEfRP.js → Point-BCvUsXLl.js} +23 -23
  22. package/dist/{Promotion-337OT0sP.js → Promotion-CrROpksP.js} +53 -47
  23. package/dist/Record-B6RRMDQn.js +337 -0
  24. package/dist/Reward-CTZ3IllK.js +432 -0
  25. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-C19vRccs.js +149 -0
  26. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-C3irbjUK.js +1637 -0
  27. package/dist/Segment-h-HRoL19.js +566 -0
  28. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-D5kijSzp.js +181 -0
  29. package/dist/{Setting-DVK2594u.js → Setting-CZIFruFT.js} +8 -8
  30. package/dist/Store-CbjSMVfb.js +1743 -0
  31. package/dist/{StoreRewards-BpEmNueE.js → StoreRewards-zkEVickE.js} +12 -12
  32. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-DU5v6oro.js +1099 -0
  33. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DT48bSiH.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-i_y1gFyL.js} +1 -1
  34. package/dist/{Tier-BwvOhyXR.js → Tier-BCgp2Ngt.js} +325 -317
  35. package/dist/{Title-DRPdKYRO.js → Title-CJNx0TkK.js} +197 -183
  36. package/dist/{Transaction-BnLvacwW.js → Transaction-DWvfvfsk.js} +2 -2
  37. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-Dkln_L8k.js +130 -0
  38. package/dist/{Voucher-BQL8J_EA.js → Voucher-bYVNHe4l.js} +31 -31
  39. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-BX0Fo_5O.js +419 -0
  40. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-B316b_ta.js → ZodTextField.vue_vue_type_script_setup_true_lang-D5Idn8So.js} +1 -1
  41. package/dist/{app-BVaQwBvq.js → app-CdJSO9Ad.js} +1 -1
  42. package/dist/{app-zO552-Dl.js → app-fsxaQBSg.js} +1183 -1154
  43. package/dist/app.js +1 -1
  44. package/dist/{business-BSl6NSdS.js → business-CDeQ06qx.js} +1 -1
  45. package/dist/{campaign-CxN6mq_l.js → campaign-D8lQOOTp.js} +2 -2
  46. package/dist/campaign-Dwea7uho.js +1810 -0
  47. package/dist/campaign.enum-CF_gt52u.js +20 -0
  48. package/dist/campaign.fn-BavlaqB6.js +758 -0
  49. package/dist/collectible.enum-DVZRkRwR.js +19 -0
  50. package/dist/{collection.fn-C-2dyWp9.js → collection.fn-CIicjfIz.js} +2 -2
  51. package/dist/dto-CMkenMV_.js +214 -0
  52. package/dist/{effect-D8y0J47O.js → effect-IbJ225qB.js} +9 -9
  53. package/dist/email-addresses-LDTzLm79.js +705 -0
  54. package/dist/{export-BxTrifKO.js → export-BCSOuQ5g.js} +3 -3
  55. package/dist/{helper-bEmZlTwA.js → helper-BZxLzAuG.js} +1 -1
  56. package/dist/{index-B2qriSSk.js → index-0Lmb_8CU.js} +1 -1
  57. package/dist/{index-JBp0chol.js → index-B3r9-9qd.js} +1500 -1479
  58. package/dist/{index-BFWCbVq2.js → index-BVd0uPuT.js} +1 -1
  59. package/dist/{index-Dnv999nc.js → index-BtFnlSuJ.js} +1 -1
  60. package/dist/{index-Ckz-D_AP.js → index-BxrHVPJL.js} +2188 -931
  61. package/dist/index-C0VSGU1p.js +32 -0
  62. package/dist/{index-DuYb25dY.js → index-CYLAuP7e.js} +34 -4
  63. package/dist/index-CcpRLc8R.js +44 -0
  64. package/dist/index-CsaQJMAR.js +66 -0
  65. package/dist/index-CvW4f2DA.js +29000 -0
  66. package/dist/{index-DHTYWfTs.js → index-DG0LFjr2.js} +207 -195
  67. package/dist/index-DbmWadFy.js +54 -0
  68. package/dist/index-vh86FiIQ.js +10 -0
  69. package/dist/{index-C_WyKCqN.js → index-xoJ0Hv7u.js} +1 -1
  70. package/dist/{index.esm2017-Tw7KabwI.js → index.esm2017-CaKC72Zr.js} +33 -33
  71. package/dist/{loading-60xYxow_.js → loading-CmdIDK9W.js} +591 -597
  72. package/dist/{membership-43FU3EmV.js → membership-BKNbXD5h.js} +52 -44
  73. package/dist/money-DbuB1-Ff.js +15 -0
  74. package/dist/number-CJ4JetR2.js +12 -0
  75. package/dist/objectid-CSzIZWFn.js +145 -0
  76. package/dist/remy-vue-client-Cpppk9h-.js +1693 -0
  77. package/dist/reward-BlvDqH4n.js +36 -0
  78. package/dist/{rule-DlHrKp8K.js → rule-Csn-Prz_.js} +180 -177
  79. package/dist/{rule-builder-CU8P8b8U.js → rule-builder-BKMY8R7O.js} +1 -1
  80. package/dist/style.css +1 -1
  81. package/dist/{template-9StyN-b7.js → template-DyhD97jJ.js} +5 -5
  82. package/dist/trigger-Cb8-87Qi.js +114 -0
  83. package/dist/{xlsx-CrRvm5Vs.js → usePagination-9TxpwvcN.js} +3183 -2962
  84. package/dist/user-Drjp-FP9.js +54 -0
  85. package/dist/{vue-i18n-UKlvivrG.js → vue-i18n-CDCNED_Y.js} +155 -155
  86. package/package.json +8 -7
  87. package/dist/Analytic-BtldByrt.js +0 -622
  88. package/dist/Card-kW7k8kOl.js +0 -825
  89. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-BtI2rY4y.js +0 -2813
  90. package/dist/Marketing-CG4GQdax.js +0 -316
  91. package/dist/MemberList-CANkPyR0.js +0 -1733
  92. package/dist/MemberTransactions-CcCa21fY.js +0 -38
  93. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Dh3naMXv.js +0 -1753
  94. package/dist/Segment-Clstp5D-.js +0 -437
  95. package/dist/Store-PnpBvIoo.js +0 -1511
  96. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CrDhK2dt.js +0 -890
  97. package/dist/dto-B20bsdh6.js +0 -2770
  98. package/dist/index-BUCjM4jq.js +0 -29193
  99. package/dist/index-Ceu2PcnH.js +0 -206
  100. package/dist/index-CuvNtC_M.js +0 -61
  101. package/dist/index-D3DAgTFI.js +0 -762
  102. package/dist/index-Kjelmo0Y.js +0 -298
  103. package/dist/money-CmR3-qMz.js +0 -15
  104. package/dist/number-CZlrO6Sq.js +0 -12
  105. package/dist/usePagination-BeF5K3M7.js +0 -223
  106. package/dist/user-Bm4KttFq.js +0 -37
@@ -0,0 +1,566 @@
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-CmdIDK9W.js";
4
+ import { components as Z } from "@feedmepos/ui-library";
5
+ import { a as pe, _ as me, w as Fe } from "./usePagination-9TxpwvcN.js";
6
+ import { u as Ce } from "./vue-i18n-CDCNED_Y.js";
7
+ import { e as Me, M as ke } from "./email-addresses-LDTzLm79.js";
8
+ import { Z as Ie } from "./zod-Bg2FbC-D.js";
9
+ import { o as Pe } from "./index-BxrHVPJL.js";
10
+ import { u as Re } from "./app-wDQR6dpb.js";
11
+ import { R as Be } from "./rule-builder-BKMY8R7O.js";
12
+ import { _ as Ee } from "./ZodTextField.vue_vue_type_script_setup_true_lang-D5Idn8So.js";
13
+ import { _ as De } from "./RuleGroup.vue_vue_type_script_setup_true_lang-C3irbjUK.js";
14
+ import { h as z } from "./moment-BWErdI6_.js";
15
+ import { s as E, u as Ye } from "./membership-BKNbXD5h.js";
16
+ import { o as $e } from "./objectId-dwaoBfJX.js";
17
+ import { u as ge } from "./business-CDeQ06qx.js";
18
+ import { f as be } from "./number-CJ4JetR2.js";
19
+ import { t as Le } from "./money-DbuB1-Ff.js";
20
+ import { m as ce } from "./index-BtFnlSuJ.js";
21
+ const Te = Pe.extend({
22
+ _id: re.optional(),
23
+ business: re.optional()
24
+ }), 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({
25
+ __name: "ReviewSegment",
26
+ props: {
27
+ title: {},
28
+ segment: {}
29
+ },
30
+ setup(e) {
31
+ const c = e, S = [
32
+ {
33
+ header: "Name",
34
+ accessorFn: (n) => n.name
35
+ },
36
+ {
37
+ header: "Id",
38
+ accessorFn: (n) => n._id
39
+ },
40
+ {
41
+ header: "Customer Since",
42
+ accessorFn: (n) => z($e(n._id.toString())).format("DD MMM YYYY")
43
+ },
44
+ {
45
+ header: "Phone",
46
+ accessorFn: (n) => n.phoneNumber
47
+ },
48
+ {
49
+ header: "Birthday",
50
+ accessorFn: (n) => z(n.birthday).format("DD MMM YYYY")
51
+ },
52
+ {
53
+ header: "Last Visit",
54
+ accessorFn: (n) => z(n.stats.lastVisit).format("DD MMM YYYY")
55
+ }
56
+ ], v = async (n) => c.segment._id ? await E.paginateSegmentUsers(c.segment._id, {
57
+ limit: r.value.pageSize,
58
+ skip: n.pageIndex ?? 0,
59
+ sortBy: "_id",
60
+ search: n.searchValue,
61
+ descending: !0
62
+ }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: r, rowData: d, onSort: M, debouncedFetchData: f, onSearch: s } = pe(v);
63
+ return ue(async () => {
64
+ await f();
65
+ }), (n, u) => (h(), Y("div", Ve, [
66
+ i("div", Ne, D(c.title), 1),
67
+ i("div", ze, [
68
+ i("div", Ae, D(n.segment.members.length), 1),
69
+ i("div", Ue, [
70
+ u[1] || (u[1] = i("div", null, "contacts in your segment", -1)),
71
+ i("div", null, "as of " + D(a(z)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
72
+ ])
73
+ ]),
74
+ l(me, {
75
+ loading: a(r).isLoading,
76
+ "row-data": a(d),
77
+ "row-count": a(r).totalRows,
78
+ "column-defs": S,
79
+ "page-size": a(r).pageSize,
80
+ "page-count": a(r).pageCount,
81
+ "page-index": a(r).pageIndex,
82
+ onSortChange: a(M),
83
+ onPageChange: u[0] || (u[0] = (w) => a(f)({ pageSize: w.pageSize, pageIndex: w.pageIndex }))
84
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
85
+ ]));
86
+ }
87
+ }), je = { class: "flex items-center gap-x-8" }, He = {
88
+ key: 0,
89
+ class: "space-y-16 pr-12"
90
+ }, qe = { class: "flex items-center gap-8" }, Je = /* @__PURE__ */ Q({
91
+ __name: "SegmentSheet",
92
+ emits: ["update:model-value"],
93
+ setup(e, { expose: c, emit: S }) {
94
+ const v = Re(), r = H(!1), d = H(!1), M = {
95
+ name: "",
96
+ rule: Be.scaffoldGroup(),
97
+ members: []
98
+ }, f = Te, s = H(M), n = X(() => {
99
+ const _ = f.safeParse(s.value);
100
+ return _.success ? [] : _.error.errors;
101
+ });
102
+ function u(_) {
103
+ r.value = !0, d.value = !1, _ ? s.value = { ..._ } : s.value = { ...M };
104
+ }
105
+ function w() {
106
+ r.value = !1;
107
+ }
108
+ async function I() {
109
+ f.safeParse(s.value).success && (d.value = !0);
110
+ }
111
+ function $() {
112
+ d.value = !1;
113
+ }
114
+ async function b() {
115
+ k("update:model-value", s.value);
116
+ }
117
+ ue(async () => {
118
+ });
119
+ const k = S;
120
+ return c({
121
+ showSheet: u,
122
+ hideSheet: w
123
+ }), (_, t) => {
124
+ const o = x("FmButton"), F = x("FmSideSheet");
125
+ return h(), W(F, {
126
+ modelValue: a(r),
127
+ "onUpdate:modelValue": t[5] || (t[5] = (p) => ye(r) ? r.value = p : null),
128
+ header: "Add segment",
129
+ "dismiss-away": "",
130
+ "close-button": !0,
131
+ "max-width": 1100
132
+ }, ve({
133
+ "side-sheet-footer": C(() => [
134
+ i("div", qe, [
135
+ a(d) ? (h(), Y(q, { key: 0 }, [
136
+ l(o, {
137
+ label: "Save Segment",
138
+ onClick: b,
139
+ loading: a(v).isLoading,
140
+ disabled: a(n).length > 0 || a(v).isLoading
141
+ }, null, 8, ["loading", "disabled"]),
142
+ l(o, {
143
+ label: "Cancel",
144
+ onClick: t[3] || (t[3] = (p) => $()),
145
+ variant: "tertiary"
146
+ })
147
+ ], 64)) : (h(), Y(q, { key: 1 }, [
148
+ l(o, {
149
+ label: "Review Segment",
150
+ disabled: a(n).length > 0 || a(v).isLoading,
151
+ onClick: I
152
+ }, null, 8, ["disabled"]),
153
+ l(o, {
154
+ label: "Cancel",
155
+ onClick: t[4] || (t[4] = (p) => w()),
156
+ variant: "tertiary"
157
+ })
158
+ ], 64))
159
+ ])
160
+ ]),
161
+ default: C(() => {
162
+ var p;
163
+ return [
164
+ a(d) ? (h(), W(Oe, {
165
+ key: 1,
166
+ title: a(s).name,
167
+ segment: a(s)
168
+ }, null, 8, ["title", "segment"])) : (h(), Y("div", He, [
169
+ l(Ee, {
170
+ modelValue: a(s).name,
171
+ "onUpdate:modelValue": t[1] || (t[1] = (y) => a(s).name = y),
172
+ label: "Segment title",
173
+ schema: a(Ie).typeAtPath(a(f), "name")
174
+ }, null, 8, ["modelValue", "schema"]),
175
+ t[7] || (t[7] = i("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
176
+ l(De, {
177
+ "trigger-type": "MEMBERSHIP_JOINED",
178
+ includeOnly: "user",
179
+ "model-value": (p = a(s)) == null ? void 0 : p.rule,
180
+ "onUpdate:modelValue": t[2] || (t[2] = (y) => {
181
+ a(s).rule = y;
182
+ })
183
+ }, null, 8, ["model-value"])
184
+ ]))
185
+ ];
186
+ }),
187
+ _: 2
188
+ }, [
189
+ a(d) ? {
190
+ name: "side-sheet-header",
191
+ fn: C(() => [
192
+ i("div", je, [
193
+ l(o, {
194
+ icon: "arrow_back",
195
+ variant: "tertiary",
196
+ onClick: t[0] || (t[0] = (p) => d.value = !1)
197
+ }),
198
+ t[6] || (t[6] = i("div", null, "Review segment", -1))
199
+ ])
200
+ ]),
201
+ key: "0"
202
+ } : void 0
203
+ ]), 1032, ["modelValue"]);
204
+ };
205
+ }
206
+ }), de = Ye(), Ge = ge();
207
+ function K(e) {
208
+ const c = z(e);
209
+ return c.isValid() ? c.format("DD/MM/YYYY") : "";
210
+ }
211
+ const Ze = {
212
+ mapMemberExportRow: (e) => {
213
+ 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;
214
+ const c = X(() => Ge.locations.map((g) => ({
215
+ label: g.name,
216
+ value: g._id
217
+ }))), S = (n = Me.parseOneAddress(
218
+ e == null ? void 0 : e.email
219
+ )) != 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(
220
+ (g, R) => {
221
+ var O, j;
222
+ const U = (j = (O = de.sortedTitles) == null ? void 0 : O.find(
223
+ (G) => G._id === R.collectible
224
+ )) == null ? void 0 : j.name;
225
+ return !U || R.balance <= 0 || g.push(U), g;
226
+ },
227
+ []
228
+ ), r = (de.sortedTitles || []).reduce(
229
+ (g, R) => {
230
+ var O, j, G, le;
231
+ const U = (le = (G = (j = (((O = e == null ? void 0 : e.collection) == null ? void 0 : O.TITLE) || []).find(
232
+ (fe) => fe.collectible === R._id
233
+ )) == null ? void 0 : j.expiryBalance) == null ? void 0 : G[0]) == null ? void 0 : le.expiredAt;
234
+ return g[R.name] = U ? z(U).format("DD/MM/YYYY") : "", g;
235
+ },
236
+ {}
237
+ ), 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(
238
+ (g, R) => g + R.amount,
239
+ 0
240
+ )) || 0, f = be(d, 2);
241
+ return {
242
+ ID: e._id.toString(),
243
+ Name: ((F = e.name) == null ? void 0 : F.trim()) || "",
244
+ Phone: ((p = e == null ? void 0 : e.phoneNumber) == null ? void 0 : p.trim()) || "",
245
+ Email: S || "",
246
+ Gender: e.gender || "",
247
+ CardNo: e.cardNo || "",
248
+ Birthday: e != null && e.birthday ? K(e == null ? void 0 : e.birthday) : "",
249
+ Credit: parseFloat((Number(f) - Number(M)).toFixed(2)),
250
+ FreeCredit: Number(M.toFixed(2)),
251
+ TotalCredit: Number(f),
252
+ 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,
253
+ 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,
254
+ 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,
255
+ 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,
256
+ Titles: v.join(","),
257
+ ...r,
258
+ TotalTransaction: e.stats.visitCount,
259
+ AvgSpent: Le(Number(e.stats.avgBillSize || 0)).toFormat(
260
+ !1
261
+ ),
262
+ TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
263
+ LastVisit: K(e.stats.lastVisit),
264
+ Feedback: ((ae = e.stats) == null ? void 0 : ae.feedbackCount) || 0,
265
+ LastSeasonTierEarned: ((ne = e.stats) == null ? void 0 : ne.lastSeasonTierEarned) || 0,
266
+ LastSeasonPointEarned: ((se = e.stats) == null ? void 0 : se.lastSeasonPointEarned) || 0,
267
+ JoinedAt: K(e.joinAt || void 0),
268
+ JoinedAtLocation: e.location && ((ie = c.value.find((g) => g.value == e.location)) == null ? void 0 : ie.label) || "-",
269
+ VisitFrequency: `${Number(
270
+ Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
271
+ )}`
272
+ };
273
+ }
274
+ }, 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" }, wt = /* @__PURE__ */ Q({
275
+ __name: "Segment",
276
+ setup(e) {
277
+ const { minor: c } = we, { t: S } = Ce(), v = ge(), { mapMemberExportRow: r } = Ze, d = H(0), M = [
278
+ {
279
+ header: S("connect.loyalty.segment.table.name"),
280
+ accessorFn: (t) => t.name
281
+ },
282
+ {
283
+ header: S("connect.loyalty.segment.table.total_customers"),
284
+ accessorFn: (t) => t.memberCount ?? 0
285
+ },
286
+ {
287
+ header: S("connect.loyalty.segment.table.customer_percentage"),
288
+ accessorFn: (t) => ((t.memberCount ?? 0) * 100 / d.value).toFixed(2)
289
+ },
290
+ {
291
+ header: S("connect.loyalty.segment.table.actions"),
292
+ meta: {
293
+ maxWidth: "100px"
294
+ },
295
+ cell(t) {
296
+ return B("div", { class: "flex items-center justify-end" }, [
297
+ B(
298
+ Z.FmMenu,
299
+ {
300
+ placement: "bottom-end",
301
+ onClick: (o) => {
302
+ o.stopPropagation();
303
+ }
304
+ },
305
+ {
306
+ "menu-button": () => B(Z.FmButton, {
307
+ icon: "more_vert",
308
+ iconColor: "neutral-gray-400",
309
+ variant: "tertiary"
310
+ }),
311
+ default: () => [
312
+ B(
313
+ Z.FmMenuItem,
314
+ {
315
+ onClick: async (o) => {
316
+ o.stopPropagation(), $(t.row.original);
317
+ }
318
+ },
319
+ {
320
+ label: B(
321
+ "div",
322
+ {
323
+ class: "fm-typo-en-body-md-400"
324
+ },
325
+ "Export"
326
+ )
327
+ }
328
+ ),
329
+ B(
330
+ Z.FmMenuItem,
331
+ {
332
+ onClick: async (o) => {
333
+ o.stopPropagation(), I(t.row.original);
334
+ }
335
+ },
336
+ {
337
+ label: B(
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 = H(null), { tableMeta: s, rowData: n, debouncedFetchData: u } = pe(
353
+ E.readAll
354
+ );
355
+ async function w() {
356
+ await c(
357
+ async () => {
358
+ await E.refreshSegments(), await u({ pageSize: 10, pageIndex: 0 });
359
+ },
360
+ { message: "Refreshing segmentations" }
361
+ );
362
+ }
363
+ async function I(t) {
364
+ await he.remove(`Are you sure you want to remove ${t.name}?`) && await c(
365
+ async () => {
366
+ await E.delete(t._id), await u({ pageSize: 10, pageIndex: 0 });
367
+ },
368
+ {
369
+ message: `Removing ${t.name}`,
370
+ successMessage: `Removed ${t.name} successfully`
371
+ }
372
+ );
373
+ }
374
+ async function $(t) {
375
+ const o = {
376
+ sortBy: "_id",
377
+ descending: !1,
378
+ rowsPerPage: 1e3,
379
+ page: 1,
380
+ rowsNumber: 0
381
+ }, F = new ke(), p = (await ce.read({
382
+ limit: 1,
383
+ skip: 0,
384
+ sortBy: o.sortBy,
385
+ descending: o.descending
386
+ })).meta.totalResources ?? 0, y = o.rowsPerPage;
387
+ await c(
388
+ async () => {
389
+ for (let P = 0; P < p; P += y) {
390
+ const L = {
391
+ ...o,
392
+ limit: y,
393
+ skip: o.page - 1,
394
+ sortBy: o.sortBy,
395
+ descending: o.descending
396
+ }, T = await E.paginateSegmentUsers(
397
+ t._id,
398
+ L
399
+ );
400
+ for (const V of T.resources) {
401
+ const N = r(V);
402
+ F.addRecord(N);
403
+ }
404
+ o.page++;
405
+ }
406
+ await Fe(
407
+ F.buildExcel(),
408
+ `[${t.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
409
+ {
410
+ bookType: "xlsx",
411
+ bookSST: !1,
412
+ type: "array"
413
+ }
414
+ ), o.page = 1;
415
+ },
416
+ {
417
+ message: "Exporting member...",
418
+ successMessage: "Member exported successfully"
419
+ }
420
+ );
421
+ }
422
+ async function b(t) {
423
+ await c(
424
+ async () => {
425
+ var o;
426
+ if (t._id) {
427
+ const { members: F, _id: p, ...y } = t;
428
+ await E.update(t._id, y);
429
+ } else
430
+ await E.create(t);
431
+ await u({ pageSize: 10, pageIndex: 0 }), (o = f.value) == null || o.hideSheet();
432
+ },
433
+ {
434
+ message: "Saving segment",
435
+ successMessage: "Segment saved"
436
+ }
437
+ );
438
+ }
439
+ function k(t) {
440
+ var o;
441
+ (o = f.value) == null || o.showSheet(t);
442
+ }
443
+ const _ = X(() => v.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 _e(async () => {
456
+ const { meta: t } = await ce.read({
457
+ limit: 1,
458
+ skip: 0,
459
+ sortBy: "_id",
460
+ search: void 0,
461
+ descending: !1
462
+ });
463
+ d.value = t.totalResources ?? 0, await u({ pageSize: 10, pageIndex: 0 }), await v.readPremium(), await v.readLocations();
464
+ }), (t, o) => {
465
+ 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");
466
+ return h(), Y(q, null, [
467
+ l(p, {
468
+ title: "Segments",
469
+ actions: a(_),
470
+ "onClick:action": o[0] || (o[0] = (m) => m === "add" ? k() : w())
471
+ }, {
472
+ title: C(() => [
473
+ i("div", We, [
474
+ i("span", Ke, D(a(S)("connect.loyalty.segment.title")), 1),
475
+ l(F, { variant: "premium" })
476
+ ])
477
+ ]),
478
+ _: 1
479
+ }, 8, ["actions"]),
480
+ i("div", Qe, [
481
+ a(n).length > 0 || a(s).searchValue || a(s).isLoading ? (h(), Y(q, { key: 0 }, [
482
+ l(me, {
483
+ loading: a(s).isLoading,
484
+ "row-data": a(n),
485
+ "row-count": a(s).totalRows,
486
+ "column-defs": M,
487
+ "shrink-at": !1,
488
+ "page-count": a(s).pageCount,
489
+ "page-index": a(s).pageIndex,
490
+ "page-size": a(s).pageSize,
491
+ onRowClick: o[1] || (o[1] = (m) => {
492
+ k(m.original);
493
+ }),
494
+ onPageChange: a(u)
495
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
496
+ l(V, { class: "w-full hidden xs:block" }, {
497
+ default: C(() => [
498
+ (h(!0), Y(q, null, Se(a(n), (m) => (h(), W(T, {
499
+ key: m._id.toString(),
500
+ tag: "label",
501
+ onClick: (A) => k(m)
502
+ }, {
503
+ default: C(() => [
504
+ i("div", null, [
505
+ i("div", Xe, D((m.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
506
+ i("div", et, D(m.name), 1),
507
+ i("div", tt, D(((m.memberCount ?? 0) * 100 / a(d)).toFixed(2)) + "% of customers ", 1)
508
+ ])
509
+ ]),
510
+ append: C(() => [
511
+ l(L, { "stop-click-propagation": !0 }, {
512
+ "menu-button": C(() => [
513
+ l(y, { name: "more_vert" })
514
+ ]),
515
+ default: C(() => [
516
+ l(P, {
517
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
518
+ label: "Remove",
519
+ "onUpdate:modelValue": (A) => A && I(m)
520
+ }, null, 8, ["onUpdate:modelValue"])
521
+ ]),
522
+ _: 2
523
+ }, 1024)
524
+ ]),
525
+ _: 2
526
+ }, 1032, ["onClick"]))), 128))
527
+ ]),
528
+ _: 1
529
+ })
530
+ ], 64)) : (h(), W(J, {
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: C(() => [
536
+ o[3] || (o[3] = i("img", {
537
+ src: xe,
538
+ class: "aspect-square w-[150px]"
539
+ }, null, -1)),
540
+ o[4] || (o[4] = i("div", { class: "flex flex-col gap-16 text-center" }, [
541
+ i("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
542
+ 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. ")
543
+ ], -1)),
544
+ l(N, {
545
+ variant: "primary",
546
+ label: "Create segment",
547
+ disabled: !a(v).isPremium,
548
+ icon: "add",
549
+ onClick: o[2] || (o[2] = (m) => k())
550
+ }, null, 8, ["disabled"])
551
+ ]),
552
+ _: 1
553
+ })),
554
+ l(Je, {
555
+ ref_key: "sheetRef",
556
+ ref: f,
557
+ "onUpdate:modelValue": b
558
+ }, null, 512)
559
+ ])
560
+ ], 64);
561
+ };
562
+ }
563
+ });
564
+ export {
565
+ wt as default
566
+ };