@feedmepos/mf-connect 0.1.0-beta.71 → 0.1.0-beta.73

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 (91) hide show
  1. package/dist/{Analytic-CnF_WeRZ.js → Analytic-DuF55WBS.js} +11 -11
  2. package/dist/{App-DJwSTuRa.js → App-CeGsq1NM.js} +6 -10
  3. package/dist/{AuditLogs-RarW2PHL.js → AuditLogs-B34wZMVU.js} +16 -15
  4. package/dist/{Bin-BaixTvHW.js → Bin-DLoneNTA.js} +8 -8
  5. package/dist/{Broadcast-8DEAMhyM.js → Broadcast-CoOqhL7m.js} +9 -9
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DPXoOupI.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CE20HRMJ.js} +14 -8
  7. package/dist/{Card-DRwLZ-Mn.js → Card-BpvNfVGg.js} +124 -123
  8. package/dist/{Collections-WsPM9v03.js → Collections-CQHKFHzT.js} +19 -18
  9. package/dist/{Credit-DMxRdTzt.js → Credit-CU9Rq52D.js} +9 -9
  10. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-Bcj6o4Xi.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-thu_Lazd.js} +29 -28
  11. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-CuJ8curT.js → EffectSheet.vue_vue_type_style_index_0_lang-BV3itQrT.js} +6 -6
  12. package/dist/{Experience-B0BV4Tc_.js → Experience-ClcvzpZh.js} +9 -9
  13. package/dist/{Game-Bu6kJJHx.js → Game-B-3gd3F2.js} +10 -10
  14. package/dist/{Index-CX-aPFQt.js → Index-BUgF1mCN.js} +10 -10
  15. package/dist/{Marketing-CiVFwl6S.js → Marketing-BmaJH7Sb.js} +6 -6
  16. package/dist/Member-Bx61ZEO0.js +357 -0
  17. package/dist/{MemberList-CscwsZnv.js → MemberList-BzKysKUq.js} +282 -282
  18. package/dist/{MemberTransactions-BWNs6bUm.js → MemberTransactions-CXGW_Cb5.js} +1 -1
  19. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-BrbRudIU.js → MessageInput.vue_vue_type_script_setup_true_lang-Cz8rnRI5.js} +7 -6
  20. package/dist/{Mission-CyJ-9Qfl.js → Mission-DjJFBLUZ.js} +10 -10
  21. package/dist/{Overview-DLyt6VId.js → Overview-DY0s8qOT.js} +20 -19
  22. package/dist/{Point-Cc_0-RKm.js → Point-Ci76W501.js} +9 -9
  23. package/dist/{Promotion-KqA8nev2.js → Promotion-_GsyimeM.js} +10 -10
  24. package/dist/{Queue-i8--zps9.js → Queue-yUE7VTjr.js} +86 -77
  25. package/dist/{Record-CLUO1JVc.js → Record-BWE8pJwB.js} +17 -16
  26. package/dist/{Reward-BEdUKQ3M.js → Reward-CLjRxvkB.js} +15 -15
  27. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-B9vnSbWj.js → RewardGroup.vue_vue_type_script_setup_true_lang-NhHHUjBT.js} +11 -11
  28. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-B8zw1TmO.js → RuleGroup.vue_vue_type_script_setup_true_lang-mHzVjK4_.js} +15 -14
  29. package/dist/Segment-B5X395PR.js +794 -0
  30. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-CmmI5Vwl.js → SelectItems.vue_vue_type_script_setup_true_lang-Et0B0kkB.js} +2 -2
  31. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-CTuiaF91.js +188 -0
  32. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-DY3FMuIf.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-h0OGy6PZ.js} +3 -3
  33. package/dist/{Setting-DT8dRb2A.js → Setting-DKNukqej.js} +16 -15
  34. package/dist/{Store-BhsPWRkR.js → Store-pVnRDIWv.js} +28 -27
  35. package/dist/{StoreRewards-Cx2WDZ3p.js → StoreRewards-Dta8iaG3.js} +13 -13
  36. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-Byb7GOoh.js → StoreTransactions.vue_vue_type_script_setup_true_lang-C4FK2Hhc.js} +27 -26
  37. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-Cb-FGTO9.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-D5tEPJlH.js} +1 -1
  38. package/dist/{Tier-kQy1vGwo.js → Tier-b3qzb85f.js} +22 -21
  39. package/dist/{Title-DKv8FqpX.js → Title-BEPkkALw.js} +19 -19
  40. package/dist/{Transaction-CSLllOgl.js → Transaction-CX5bz-8R.js} +2 -2
  41. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-CvpBdNBn.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-J7JgL3ZE.js} +6 -6
  42. package/dist/{Voucher-BP6fmSwu.js → Voucher-B9WhyNoJ.js} +12 -12
  43. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-CxQEg_HW.js → VoucherEditor.vue_vue_type_script_setup_true_lang-CpdJV-JH.js} +10 -10
  44. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-aurdXO2X.js → ZodTextField.vue_vue_type_script_setup_true_lang-Byy8iIcw.js} +1 -1
  45. package/dist/{app-s3iL79De.js → app-BwuFlP4U.js} +1 -1
  46. package/dist/{app-B3qgrQOd.js → app-spXNxwIy.js} +31 -31
  47. package/dist/app.js +1 -1
  48. package/dist/{business-DG2w8U-i.js → business-DL7Au5Jd.js} +1 -1
  49. package/dist/{campaign-BP6Rz-AH.js → campaign-BNZ7-HOT.js} +9 -9
  50. package/dist/{campaign-WPRZ4BRF.js → campaign-CdAByh1F.js} +2 -2
  51. package/dist/{campaign.enum-CoqrWNTZ.js → campaign.enum-BUoLAvv9.js} +1 -1
  52. package/dist/{campaign.fn-BRPigTOA.js → campaign.fn-Vhk4colm.js} +29 -29
  53. package/dist/{collectible.enum-Dy4sxF43.js → collectible.enum-Bj9M_woV.js} +1 -1
  54. package/dist/{collection.fn-DGnLyYgV.js → collection.fn-Cd5Ot0j-.js} +2 -2
  55. package/dist/{dto-xZ9I6-Jr.js → dto-ClbqdGxX.js} +4 -4
  56. package/dist/{effect-C0XoYTus.js → effect-DIJB9gNc.js} +1 -1
  57. package/dist/{email-addresses-CJ87c7W1.js → email-addresses-Ct53VAK9.js} +1 -1
  58. package/dist/{export-qlV-AbEl.js → export-CoufQpmw.js} +3 -3
  59. package/dist/{helper-DzYe8aNx.js → helper-BiWgv5uK.js} +1 -1
  60. package/dist/{index-DReysUPw.js → index-1xiBe8hf.js} +437 -426
  61. package/dist/{index-BnZ4yaMH.js → index-CC4x--Wj.js} +1 -1
  62. package/dist/{index-DgCjRb3o.js → index-CGC8OuAU.js} +1 -1
  63. package/dist/{index-Bo5DJXxs.js → index-Ccxk7UeG.js} +3 -3
  64. package/dist/{index-BfSj7cUl.js → index-CyLEADUO.js} +1 -1
  65. package/dist/{index-4vdSri7m.js → index-D7FRiYhm.js} +6 -6
  66. package/dist/{index-BuvJH6SU.js → index-DVH42wjJ.js} +1 -1
  67. package/dist/{plugins-D20keyDW.js → index-DfRmJZgk.js} +2606 -2811
  68. package/dist/{index-IwITtvVu.js → index-DmakIEWL.js} +1 -1
  69. package/dist/{index-CJuOTcCE.js → index-DovTEaDP.js} +1 -1
  70. package/dist/{index-C2GEs8di.js → index-LFo6ZYQL.js} +1 -1
  71. package/dist/{index-n3wiQlbk.js → index-bJ5pwQkB.js} +2 -2
  72. package/dist/{index-Bj0ULpXi.js → index-qjlKvnh6.js} +3 -3
  73. package/dist/{index.esm2017-CkJhTmme.js → index.esm2017-CRGDx_au.js} +3 -3
  74. package/dist/{loading-DwJdwl4G.js → loading-YDhYfc7H.js} +1 -1
  75. package/dist/{membership-DvPK3h8f.js → membership-BGin-J4X.js} +54 -48
  76. package/dist/{money-C_WIbr_x.js → money-Dy3hgkcf.js} +1 -1
  77. package/dist/{number-ZeVoGhzP.js → number-BAIUanJl.js} +1 -1
  78. package/dist/{objectid-8lkX6otO.js → objectid-Cw3dF6mj.js} +5 -5
  79. package/dist/plugins-D9TQFKpf.js +208 -0
  80. package/dist/{reward-CqnMEq_w.js → reward-DB1n0glJ.js} +1 -1
  81. package/dist/{rule-D7htGgWz.js → rule-BrRyZfJJ.js} +3 -3
  82. package/dist/{rule-builder-BbJpYQ0n.js → rule-builder-CC08hDgq.js} +1 -1
  83. package/dist/{template-BWQCVHm7.js → template-DJlxZIjZ.js} +4 -4
  84. package/dist/{trigger-DMuv0_O7.js → trigger-Dz5Fd0Hc.js} +4 -4
  85. package/dist/{user-C_v2C0qN.js → user-BAE-TiCB.js} +1 -1
  86. package/dist/{vue-i18n-N8_TEEd0.js → vue-i18n-DpoLveH2.js} +158 -158
  87. package/dist/{xlsx-CsPDNSTo.js → xlsx-3tdJPiTp.js} +1 -1
  88. package/package.json +1 -1
  89. package/dist/Member-DZfTtt13.js +0 -333
  90. package/dist/Segment-B8sYajZG.js +0 -568
  91. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-CIcXjbJG.js +0 -186
@@ -1,568 +0,0 @@
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 } from "./plugins-D20keyDW.js";
4
- import { u as we } from "./loading-DwJdwl4G.js";
5
- import { components as Z } from "@feedmepos/ui-library";
6
- import { u as pe, _ as me } from "./usePagination-BeF5K3M7.js";
7
- import { u as Fe } from "./vue-i18n-N8_TEEd0.js";
8
- import { w as Ce } from "./xlsx-CsPDNSTo.js";
9
- import { e as Me, M as ke } from "./email-addresses-CJ87c7W1.js";
10
- import { Z as Ie } from "./zod-Bg2FbC-D.js";
11
- import { h as Pe } from "./index-DReysUPw.js";
12
- import { u as Re } from "./app-wDQR6dpb.js";
13
- import { R as Be } from "./rule-builder-BbJpYQ0n.js";
14
- import { _ as Ee } from "./ZodTextField.vue_vue_type_script_setup_true_lang-aurdXO2X.js";
15
- import { _ as De } from "./RuleGroup.vue_vue_type_script_setup_true_lang-B8zw1TmO.js";
16
- import { h as z } from "./moment-BWErdI6_.js";
17
- import { s as E, u as Ye } from "./membership-DvPK3h8f.js";
18
- import { o as $e } from "./objectId-dwaoBfJX.js";
19
- import { u as ge } from "./business-DG2w8U-i.js";
20
- import { f as be } from "./number-ZeVoGhzP.js";
21
- import { t as Le } from "./money-C_WIbr_x.js";
22
- import { m as ce } from "./index-BuvJH6SU.js";
23
- const Te = Pe.extend({
24
- _id: re.optional(),
25
- business: re.optional()
26
- }), 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({
27
- __name: "ReviewSegment",
28
- props: {
29
- title: {},
30
- segment: {}
31
- },
32
- setup(e) {
33
- const c = e, S = [
34
- {
35
- header: "Name",
36
- accessorFn: (n) => n.name
37
- },
38
- {
39
- header: "Id",
40
- accessorFn: (n) => n._id
41
- },
42
- {
43
- header: "Customer Since",
44
- accessorFn: (n) => z($e(n._id.toString())).format("DD MMM YYYY")
45
- },
46
- {
47
- header: "Phone",
48
- accessorFn: (n) => n.phoneNumber
49
- },
50
- {
51
- header: "Birthday",
52
- accessorFn: (n) => z(n.birthday).format("DD MMM YYYY")
53
- },
54
- {
55
- header: "Last Visit",
56
- accessorFn: (n) => z(n.stats.lastVisit).format("DD MMM YYYY")
57
- }
58
- ], v = async (n) => c.segment._id ? await E.paginateSegmentUsers(c.segment._id, {
59
- limit: r.value.pageSize,
60
- skip: n.pageIndex ?? 0,
61
- sortBy: "_id",
62
- search: n.searchValue,
63
- descending: !0
64
- }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: r, rowData: d, onSort: M, debouncedFetchData: f, onSearch: s } = pe(v);
65
- return ue(async () => {
66
- await f();
67
- }), (n, u) => (h(), Y("div", Ve, [
68
- i("div", Ne, D(c.title), 1),
69
- i("div", ze, [
70
- i("div", Ae, D(n.segment.members.length), 1),
71
- i("div", Ue, [
72
- u[1] || (u[1] = i("div", null, "contacts in your segment", -1)),
73
- i("div", null, "as of " + D(a(z)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
74
- ])
75
- ]),
76
- l(me, {
77
- loading: a(r).isLoading,
78
- "row-data": a(d),
79
- "row-count": a(r).totalRows,
80
- "column-defs": S,
81
- "page-size": a(r).pageSize,
82
- "page-count": a(r).pageCount,
83
- "page-index": a(r).pageIndex,
84
- onSortChange: a(M),
85
- onPageChange: u[0] || (u[0] = (w) => a(f)({ pageSize: w.pageSize, pageIndex: w.pageIndex }))
86
- }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
87
- ]));
88
- }
89
- }), je = { class: "flex items-center gap-x-8" }, He = {
90
- key: 0,
91
- class: "space-y-16 pr-12"
92
- }, qe = { class: "flex items-center gap-8" }, Je = /* @__PURE__ */ Q({
93
- __name: "SegmentSheet",
94
- emits: ["update:model-value"],
95
- setup(e, { expose: c, emit: S }) {
96
- const v = Re(), r = H(!1), d = H(!1), M = {
97
- name: "",
98
- rule: Be.scaffoldGroup(),
99
- members: []
100
- }, f = Te, s = H(M), n = X(() => {
101
- const _ = f.safeParse(s.value);
102
- return _.success ? [] : _.error.errors;
103
- });
104
- function u(_) {
105
- r.value = !0, d.value = !1, _ ? s.value = { ..._ } : s.value = { ...M };
106
- }
107
- function w() {
108
- r.value = !1;
109
- }
110
- async function I() {
111
- f.safeParse(s.value).success && (d.value = !0);
112
- }
113
- function $() {
114
- d.value = !1;
115
- }
116
- async function b() {
117
- k("update:model-value", s.value);
118
- }
119
- ue(async () => {
120
- });
121
- const k = S;
122
- return c({
123
- showSheet: u,
124
- hideSheet: w
125
- }), (_, t) => {
126
- const o = x("FmButton"), F = x("FmSideSheet");
127
- return h(), W(F, {
128
- modelValue: a(r),
129
- "onUpdate:modelValue": t[5] || (t[5] = (p) => ye(r) ? r.value = p : null),
130
- header: "Add segment",
131
- "dismiss-away": "",
132
- "close-button": !0,
133
- "max-width": 1100
134
- }, ve({
135
- "side-sheet-footer": C(() => [
136
- i("div", qe, [
137
- a(d) ? (h(), Y(q, { key: 0 }, [
138
- l(o, {
139
- label: "Save Segment",
140
- onClick: b,
141
- loading: a(v).isLoading,
142
- disabled: a(n).length > 0 || a(v).isLoading
143
- }, null, 8, ["loading", "disabled"]),
144
- l(o, {
145
- label: "Cancel",
146
- onClick: t[3] || (t[3] = (p) => $()),
147
- variant: "tertiary"
148
- })
149
- ], 64)) : (h(), Y(q, { key: 1 }, [
150
- l(o, {
151
- label: "Review Segment",
152
- disabled: a(n).length > 0 || a(v).isLoading,
153
- onClick: I
154
- }, null, 8, ["disabled"]),
155
- l(o, {
156
- label: "Cancel",
157
- onClick: t[4] || (t[4] = (p) => w()),
158
- variant: "tertiary"
159
- })
160
- ], 64))
161
- ])
162
- ]),
163
- default: C(() => {
164
- var p;
165
- return [
166
- a(d) ? (h(), W(Oe, {
167
- key: 1,
168
- title: a(s).name,
169
- segment: a(s)
170
- }, null, 8, ["title", "segment"])) : (h(), Y("div", He, [
171
- l(Ee, {
172
- modelValue: a(s).name,
173
- "onUpdate:modelValue": t[1] || (t[1] = (y) => a(s).name = y),
174
- label: "Segment title",
175
- schema: a(Ie).typeAtPath(a(f), "name")
176
- }, null, 8, ["modelValue", "schema"]),
177
- t[7] || (t[7] = i("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
178
- l(De, {
179
- "trigger-type": "MEMBERSHIP_JOINED",
180
- includeOnly: "user",
181
- "model-value": (p = a(s)) == null ? void 0 : p.rule,
182
- "onUpdate:modelValue": t[2] || (t[2] = (y) => {
183
- a(s).rule = y;
184
- })
185
- }, null, 8, ["model-value"])
186
- ]))
187
- ];
188
- }),
189
- _: 2
190
- }, [
191
- a(d) ? {
192
- name: "side-sheet-header",
193
- fn: C(() => [
194
- i("div", je, [
195
- l(o, {
196
- icon: "arrow_back",
197
- variant: "tertiary",
198
- onClick: t[0] || (t[0] = (p) => d.value = !1)
199
- }),
200
- t[6] || (t[6] = i("div", null, "Review segment", -1))
201
- ])
202
- ]),
203
- key: "0"
204
- } : void 0
205
- ]), 1032, ["modelValue"]);
206
- };
207
- }
208
- }), de = Ye(), Ge = ge();
209
- function K(e) {
210
- const c = z(e);
211
- return c.isValid() ? c.format("DD/MM/YYYY") : "";
212
- }
213
- const Ze = {
214
- mapMemberExportRow: (e) => {
215
- 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;
216
- const c = X(() => Ge.locations.map((g) => ({
217
- label: g.name,
218
- value: g._id
219
- }))), S = (n = Me.parseOneAddress(
220
- e == null ? void 0 : e.email
221
- )) != 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(
222
- (g, R) => {
223
- var O, j;
224
- const U = (j = (O = de.sortedTitles) == null ? void 0 : O.find(
225
- (G) => G._id === R.collectible
226
- )) == null ? void 0 : j.name;
227
- return !U || R.balance <= 0 || g.push(U), g;
228
- },
229
- []
230
- ), r = (de.sortedTitles || []).reduce(
231
- (g, R) => {
232
- var O, j, G, le;
233
- const U = (le = (G = (j = (((O = e == null ? void 0 : e.collection) == null ? void 0 : O.TITLE) || []).find(
234
- (fe) => fe.collectible === R._id
235
- )) == null ? void 0 : j.expiryBalance) == null ? void 0 : G[0]) == null ? void 0 : le.expiredAt;
236
- return g[R.name] = U ? z(U).format("DD/MM/YYYY") : "", g;
237
- },
238
- {}
239
- ), 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(
240
- (g, R) => g + R.amount,
241
- 0
242
- )) || 0, f = be(d, 2);
243
- return {
244
- ID: e._id.toString(),
245
- Name: ((F = e.name) == null ? void 0 : F.trim()) || "",
246
- Phone: ((p = e == null ? void 0 : e.phoneNumber) == null ? void 0 : p.trim()) || "",
247
- Email: S || "",
248
- Gender: e.gender || "",
249
- CardNo: e.cardNo || "",
250
- Birthday: e != null && e.birthday ? K(e == null ? void 0 : e.birthday) : "",
251
- Credit: parseFloat((Number(f) - Number(M)).toFixed(2)),
252
- FreeCredit: Number(M.toFixed(2)),
253
- TotalCredit: Number(f),
254
- 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,
255
- 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,
256
- 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,
257
- 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,
258
- Titles: v.join(","),
259
- ...r,
260
- TotalTransaction: e.stats.visitCount,
261
- AvgSpent: Le(Number(e.stats.avgBillSize || 0)).toFormat(
262
- !1
263
- ),
264
- TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
265
- LastVisit: K(e.stats.lastVisit),
266
- Feedback: ((ae = e.stats) == null ? void 0 : ae.feedbackCount) || 0,
267
- LastSeasonTierEarned: ((ne = e.stats) == null ? void 0 : ne.lastSeasonTierEarned) || 0,
268
- LastSeasonPointEarned: ((se = e.stats) == null ? void 0 : se.lastSeasonPointEarned) || 0,
269
- JoinedAt: K(e.joinAt || void 0),
270
- JoinedAtLocation: e.location && ((ie = c.value.find((g) => g.value == e.location)) == null ? void 0 : ie.label) || "-",
271
- VisitFrequency: `${Number(
272
- Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
273
- )}`
274
- };
275
- }
276
- }, 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" }, Ct = /* @__PURE__ */ Q({
277
- __name: "Segment",
278
- setup(e) {
279
- const { minor: c } = we, { t: S } = Fe(), v = ge(), { mapMemberExportRow: r } = Ze, d = H(0), M = [
280
- {
281
- header: S("connect.loyalty.segment.table.name"),
282
- accessorFn: (t) => t.name
283
- },
284
- {
285
- header: S("connect.loyalty.segment.table.total_customers"),
286
- accessorFn: (t) => t.memberCount ?? 0
287
- },
288
- {
289
- header: S("connect.loyalty.segment.table.customer_percentage"),
290
- accessorFn: (t) => ((t.memberCount ?? 0) * 100 / d.value).toFixed(2)
291
- },
292
- {
293
- header: S("connect.loyalty.segment.table.actions"),
294
- meta: {
295
- maxWidth: "100px"
296
- },
297
- cell(t) {
298
- return B("div", { class: "flex items-center justify-end" }, [
299
- B(
300
- Z.FmMenu,
301
- {
302
- placement: "bottom-end",
303
- onClick: (o) => {
304
- o.stopPropagation();
305
- }
306
- },
307
- {
308
- "menu-button": () => B(Z.FmButton, {
309
- icon: "more_vert",
310
- iconColor: "neutral-gray-400",
311
- variant: "tertiary"
312
- }),
313
- default: () => [
314
- B(
315
- Z.FmMenuItem,
316
- {
317
- onClick: async (o) => {
318
- o.stopPropagation(), $(t.row.original);
319
- }
320
- },
321
- {
322
- label: B(
323
- "div",
324
- {
325
- class: "fm-typo-en-body-md-400"
326
- },
327
- "Export"
328
- )
329
- }
330
- ),
331
- B(
332
- Z.FmMenuItem,
333
- {
334
- onClick: async (o) => {
335
- o.stopPropagation(), I(t.row.original);
336
- }
337
- },
338
- {
339
- label: B(
340
- "div",
341
- {
342
- class: "text-fm-color-typo-error fm-typo-en-body-md-400"
343
- },
344
- "Remove"
345
- )
346
- }
347
- )
348
- ]
349
- }
350
- )
351
- ]);
352
- }
353
- }
354
- ], f = H(null), { tableMeta: s, rowData: n, debouncedFetchData: u } = pe(
355
- E.readAll
356
- );
357
- async function w() {
358
- await c(
359
- async () => {
360
- await E.refreshSegments(), await u({ pageSize: 10, pageIndex: 0 });
361
- },
362
- { message: "Refreshing segmentations" }
363
- );
364
- }
365
- async function I(t) {
366
- await he.remove(`Are you sure you want to remove ${t.name}?`) && await c(
367
- async () => {
368
- await E.delete(t._id), await u({ pageSize: 10, pageIndex: 0 });
369
- },
370
- {
371
- message: `Removing ${t.name}`,
372
- successMessage: `Removed ${t.name} successfully`
373
- }
374
- );
375
- }
376
- async function $(t) {
377
- const o = {
378
- sortBy: "_id",
379
- descending: !1,
380
- rowsPerPage: 1e3,
381
- page: 1,
382
- rowsNumber: 0
383
- }, F = new ke(), p = (await ce.read({
384
- limit: 1,
385
- skip: 0,
386
- sortBy: o.sortBy,
387
- descending: o.descending
388
- })).meta.totalResources ?? 0, y = o.rowsPerPage;
389
- await c(
390
- async () => {
391
- for (let P = 0; P < p; P += y) {
392
- const L = {
393
- ...o,
394
- limit: y,
395
- skip: o.page - 1,
396
- sortBy: o.sortBy,
397
- descending: o.descending
398
- }, T = await E.paginateSegmentUsers(
399
- t._id,
400
- L
401
- );
402
- for (const V of T.resources) {
403
- const N = r(V);
404
- F.addRecord(N);
405
- }
406
- o.page++;
407
- }
408
- await Ce(
409
- F.buildExcel(),
410
- `[${t.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
411
- {
412
- bookType: "xlsx",
413
- bookSST: !1,
414
- type: "array"
415
- }
416
- ), o.page = 1;
417
- },
418
- {
419
- message: "Exporting member...",
420
- successMessage: "Member exported successfully"
421
- }
422
- );
423
- }
424
- async function b(t) {
425
- await c(
426
- async () => {
427
- var o;
428
- if (t._id) {
429
- const { members: F, _id: p, ...y } = t;
430
- await E.update(t._id, y);
431
- } else
432
- await E.create(t);
433
- await u({ pageSize: 10, pageIndex: 0 }), (o = f.value) == null || o.hideSheet();
434
- },
435
- {
436
- message: "Saving segment",
437
- successMessage: "Segment saved"
438
- }
439
- );
440
- }
441
- function k(t) {
442
- var o;
443
- (o = f.value) == null || o.showSheet(t);
444
- }
445
- const _ = X(() => v.isPremium ? [
446
- {
447
- label: "Refresh segments",
448
- value: "refresh"
449
- },
450
- {
451
- label: "Add segment",
452
- value: "add",
453
- isPrimary: !0,
454
- prependIcon: "add"
455
- }
456
- ] : []);
457
- return _e(async () => {
458
- const { meta: t } = await ce.read({
459
- limit: 1,
460
- skip: 0,
461
- sortBy: "_id",
462
- search: void 0,
463
- descending: !1
464
- });
465
- d.value = t.totalResources ?? 0, await u({ pageSize: 10, pageIndex: 0 }), await v.readPremium(), await v.readLocations();
466
- }), (t, o) => {
467
- 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");
468
- return h(), Y(q, null, [
469
- l(p, {
470
- title: "Segments",
471
- actions: a(_),
472
- "onClick:action": o[0] || (o[0] = (m) => m === "add" ? k() : w())
473
- }, {
474
- title: C(() => [
475
- i("div", We, [
476
- i("span", Ke, D(a(S)("connect.loyalty.segment.title")), 1),
477
- l(F, { variant: "premium" })
478
- ])
479
- ]),
480
- _: 1
481
- }, 8, ["actions"]),
482
- i("div", Qe, [
483
- a(n).length > 0 || a(s).searchValue || a(s).isLoading ? (h(), Y(q, { key: 0 }, [
484
- l(me, {
485
- loading: a(s).isLoading,
486
- "row-data": a(n),
487
- "row-count": a(s).totalRows,
488
- "column-defs": M,
489
- "shrink-at": !1,
490
- "page-count": a(s).pageCount,
491
- "page-index": a(s).pageIndex,
492
- "page-size": a(s).pageSize,
493
- onRowClick: o[1] || (o[1] = (m) => {
494
- k(m.original);
495
- }),
496
- onPageChange: a(u)
497
- }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
498
- l(V, { class: "w-full hidden xs:block" }, {
499
- default: C(() => [
500
- (h(!0), Y(q, null, Se(a(n), (m) => (h(), W(T, {
501
- key: m._id.toString(),
502
- tag: "label",
503
- onClick: (A) => k(m)
504
- }, {
505
- default: C(() => [
506
- i("div", null, [
507
- i("div", Xe, D((m.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
508
- i("div", et, D(m.name), 1),
509
- i("div", tt, D(((m.memberCount ?? 0) * 100 / a(d)).toFixed(2)) + "% of customers ", 1)
510
- ])
511
- ]),
512
- append: C(() => [
513
- l(L, { "stop-click-propagation": !0 }, {
514
- "menu-button": C(() => [
515
- l(y, { name: "more_vert" })
516
- ]),
517
- default: C(() => [
518
- l(P, {
519
- class: "text-fm-color-typo-error fm-typo-en-body-md-400",
520
- label: "Remove",
521
- "onUpdate:modelValue": (A) => A && I(m)
522
- }, null, 8, ["onUpdate:modelValue"])
523
- ]),
524
- _: 2
525
- }, 1024)
526
- ]),
527
- _: 2
528
- }, 1032, ["onClick"]))), 128))
529
- ]),
530
- _: 1
531
- })
532
- ], 64)) : (h(), W(J, {
533
- key: 1,
534
- variant: "outlined",
535
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
536
- }, {
537
- default: C(() => [
538
- o[3] || (o[3] = i("img", {
539
- src: xe,
540
- class: "aspect-square w-[150px]"
541
- }, null, -1)),
542
- o[4] || (o[4] = i("div", { class: "flex flex-col gap-16 text-center" }, [
543
- i("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
544
- 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. ")
545
- ], -1)),
546
- l(N, {
547
- variant: "primary",
548
- label: "Create segment",
549
- disabled: !a(v).isPremium,
550
- icon: "add",
551
- onClick: o[2] || (o[2] = (m) => k())
552
- }, null, 8, ["disabled"])
553
- ]),
554
- _: 1
555
- })),
556
- l(Je, {
557
- ref_key: "sheetRef",
558
- ref: f,
559
- "onUpdate:modelValue": b
560
- }, null, 512)
561
- ])
562
- ], 64);
563
- };
564
- }
565
- });
566
- export {
567
- Ct as default
568
- };