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