@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
@@ -0,0 +1,794 @@
1
+ import { defineComponent as K, ref as N, resolveComponent as h, openBlock as f, createElementBlock as C, createElementVNode as i, createVNode as d, unref as t, createCommentVNode as ye, createBlock as G, toDisplayString as $, normalizeClass as ne, onMounted as ve, Fragment as H, renderList as _e, withCtx as R, computed as se, isRef as be, createSlots as Ce, h as V, onBeforeMount as ke } from "vue";
2
+ import { _ as Me } from "./campaign-CpzFl8Vr.js";
3
+ import { p as Ie } from "./plugins-D9TQFKpf.js";
4
+ import { u as Re } from "./loading-YDhYfc7H.js";
5
+ import { FmButtonVariant as oe, useSnackbar as Ee, components as te } from "@feedmepos/ui-library";
6
+ import { u as xe, _ as Se } from "./usePagination-BeF5K3M7.js";
7
+ import { u as he } from "./vue-i18n-DpoLveH2.js";
8
+ import "./index-D7FRiYhm.js";
9
+ import { i as $e, c as de } from "./index-1xiBe8hf.js";
10
+ import "./index-bJ5pwQkB.js";
11
+ import "./index-CyLEADUO.js";
12
+ import "./index-Ccxk7UeG.js";
13
+ import { w as Te } from "./xlsx-3tdJPiTp.js";
14
+ import { e as Pe, M as De } from "./email-addresses-Ct53VAK9.js";
15
+ import { Z as Ae } from "./zod-Bg2FbC-D.js";
16
+ import { u as Be } from "./app-wDQR6dpb.js";
17
+ import { F as ue, z as Ve } from "./index-DfRmJZgk.js";
18
+ import { R as pe } from "./rule-builder-CC08hDgq.js";
19
+ import { _ as Ne } from "./ZodTextField.vue_vue_type_script_setup_true_lang-Byy8iIcw.js";
20
+ import { _ as Le } from "./RuleGroup.vue_vue_type_script_setup_true_lang-mHzVjK4_.js";
21
+ import { u as Ye, v as Ue, w as ze } from "./index.esm2017-CRGDx_au.js";
22
+ import { h as j } from "./moment-BWErdI6_.js";
23
+ import { s as P, u as Oe } from "./membership-BGin-J4X.js";
24
+ import { o as qe } from "./objectId-dwaoBfJX.js";
25
+ import { u as Fe } from "./business-DL7Au5Jd.js";
26
+ import { f as je } from "./number-BAIUanJl.js";
27
+ import { t as He } from "./money-Dy3hgkcf.js";
28
+ import "./index-DovTEaDP.js";
29
+ import { useRouter as Ge } from "vue-router";
30
+ import { m as me } from "./index-DVH42wjJ.js";
31
+ import { R as fe } from "./app-spXNxwIy.js";
32
+ const Je = $e.extend({
33
+ _id: ue.optional(),
34
+ business: ue.optional(),
35
+ file: Ve.any().nullish()
36
+ }), Qe = { class: "flex flex-col space-y-16" }, Ze = {
37
+ key: 0,
38
+ class: /* @__PURE__ */ ne([
39
+ "p-16 pl-24 space-x-8",
40
+ "bg-fm-color-primary-oats rounded-lg",
41
+ "flex items-center",
42
+ "justify-between"
43
+ ])
44
+ }, We = {
45
+ key: 2,
46
+ class: /* @__PURE__ */ ne([
47
+ "flex items-center",
48
+ "border border-fm-color-neutral-gray-300",
49
+ "p-16 space-x-16 rounded-md"
50
+ ])
51
+ }, Ke = { class: "fm-typo-en-body-lg-400 flex-1 truncate" }, Xe = /* @__PURE__ */ K({
52
+ __name: "ImportSegment",
53
+ props: {
54
+ importFile: {}
55
+ },
56
+ emits: ["update:file"],
57
+ setup(e, { emit: g }) {
58
+ const _ = e, x = g, { t: u } = he(), m = N(null), p = N(null);
59
+ async function S() {
60
+ if (_.importFile)
61
+ try {
62
+ const n = Ye(), c = Ue(n, _.importFile), y = await ze(c);
63
+ window.open(y, "_blank");
64
+ } catch (n) {
65
+ console.log(n);
66
+ }
67
+ }
68
+ function l(n) {
69
+ m.value = n, x("update:file", m.value);
70
+ }
71
+ function s(n) {
72
+ var y, I;
73
+ const c = ((I = (y = n.target) == null ? void 0 : y.files) == null ? void 0 : I[0]) ?? null;
74
+ l(c);
75
+ }
76
+ return (n, c) => {
77
+ const y = h("FmButton"), I = h("FmDropField");
78
+ return f(), C("div", Qe, [
79
+ c[2] || (c[2] = i("div", { class: "fm-typo-en-title-sm-800" }, "Upload File", -1)),
80
+ n.importFile ? (f(), C("div", Ze, [
81
+ d(y, {
82
+ label: t(u)("View uploaded file"),
83
+ variant: t(oe).Plain,
84
+ icon: "file_present",
85
+ onClick: S
86
+ }, null, 8, ["label", "variant"])
87
+ ])) : ye("", !0),
88
+ m.value ? (f(), C("div", We, [
89
+ d(y, {
90
+ variant: t(oe).Tertiary,
91
+ "prepend-icon": "attach_file"
92
+ }, null, 8, ["variant"]),
93
+ i("p", Ke, $(m.value.name), 1),
94
+ i("label", {
95
+ ref_key: "fileLabelRef",
96
+ ref: p,
97
+ htmlFor: "file"
98
+ }, [
99
+ d(y, {
100
+ variant: t(oe).Plain,
101
+ label: t(u)("Replace File"),
102
+ onClick: c[1] || (c[1] = () => {
103
+ var k;
104
+ return (k = p.value) == null ? void 0 : k.click();
105
+ })
106
+ }, null, 8, ["variant", "label"]),
107
+ i("input", {
108
+ id: "file",
109
+ accept: ".csv, .xlsx",
110
+ class: "hidden",
111
+ type: "file",
112
+ multiple: "",
113
+ onChange: s
114
+ }, null, 32)
115
+ ], 512)
116
+ ])) : (f(), G(I, {
117
+ key: 1,
118
+ onFileUpload: c[0] || (c[0] = (k) => l(k)),
119
+ accept: ".csv",
120
+ "max-file-size": 2e7
121
+ }))
122
+ ]);
123
+ };
124
+ }
125
+ }), et = { class: "space-y-16 pr-12" }, tt = { class: "fm-typo-en-title-md-800" }, ot = { class: "flex space-x-8" }, at = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, nt = { class: "text-fm-color-typo-secondary" }, st = /* @__PURE__ */ K({
126
+ __name: "ReviewSegment",
127
+ props: {
128
+ title: {},
129
+ segment: {}
130
+ },
131
+ setup(e) {
132
+ const g = e, _ = [
133
+ {
134
+ header: "Name",
135
+ accessorFn: (s) => s.name
136
+ },
137
+ {
138
+ header: "Id",
139
+ accessorFn: (s) => s._id
140
+ },
141
+ {
142
+ header: "Customer Since",
143
+ accessorFn: (s) => j(qe(s._id.toString())).format("DD MMM YYYY")
144
+ },
145
+ {
146
+ header: "Phone",
147
+ accessorFn: (s) => s.phoneNumber
148
+ },
149
+ {
150
+ header: "Birthday",
151
+ accessorFn: (s) => j(s.birthday).format("DD MMM YYYY")
152
+ },
153
+ {
154
+ header: "Last Visit",
155
+ accessorFn: (s) => j(s.stats.lastVisit).format("DD MMM YYYY")
156
+ }
157
+ ], x = async (s) => g.segment._id ? await P.paginateSegmentUsers(g.segment._id, {
158
+ limit: u.value.pageSize,
159
+ skip: s.pageIndex ?? 0,
160
+ sortBy: "_id",
161
+ search: s.searchValue,
162
+ descending: !0
163
+ }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: u, rowData: m, onSort: p, debouncedFetchData: S, onSearch: l } = xe(x);
164
+ return ve(async () => {
165
+ await S();
166
+ }), (s, n) => (f(), C("div", et, [
167
+ i("div", tt, $(g.title), 1),
168
+ i("div", ot, [
169
+ i("div", at, $(s.segment.members.length), 1),
170
+ i("div", nt, [
171
+ n[1] || (n[1] = i("div", null, "contacts in your segment", -1)),
172
+ i("div", null, "as of " + $(t(j)(s.segment.lastUpdated).format("DD MMM YYYY")), 1)
173
+ ])
174
+ ]),
175
+ d(Se, {
176
+ loading: t(u).isLoading,
177
+ "row-data": t(m),
178
+ "row-count": t(u).totalRows,
179
+ "column-defs": _,
180
+ "page-size": t(u).pageSize,
181
+ "page-count": t(u).pageCount,
182
+ "page-index": t(u).pageIndex,
183
+ onSortChange: t(p),
184
+ onPageChange: n[0] || (n[0] = (c) => t(S)({ pageSize: c.pageSize, pageIndex: c.pageIndex }))
185
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
186
+ ]));
187
+ }
188
+ }), it = { class: "space-y-24" }, lt = { class: "grid grid-cols-2 gap-16" }, rt = { class: "fm-typo-en-title-sm-800" }, ct = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, dt = /* @__PURE__ */ K({
189
+ __name: "SegmentRecalculationOption",
190
+ props: {
191
+ modelValue: { type: Boolean },
192
+ errorText: {}
193
+ },
194
+ emits: ["update:model-value"],
195
+ setup(e, { emit: g }) {
196
+ const _ = e, x = g, u = [
197
+ {
198
+ label: "Active",
199
+ sublabel: "Segment statistics are based on rules configured and will be recalculated automatically when rule changes.",
200
+ value: !0
201
+ },
202
+ {
203
+ label: "Inactive",
204
+ sublabel: "Segment statistics are based on imported data and will not be recalculated.",
205
+ value: !1
206
+ }
207
+ ];
208
+ function m(p) {
209
+ p !== _.modelValue && x("update:model-value", p);
210
+ }
211
+ return (p, S) => {
212
+ const l = h("FmCard"), s = h("FmHelperText");
213
+ return f(), C("div", it, [
214
+ i("div", lt, [
215
+ (f(), C(H, null, _e(u, (n) => d(l, {
216
+ variant: "outlined",
217
+ class: ne(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-2", {
218
+ "col-span-2": u.length == 1,
219
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": p.modelValue === n.value,
220
+ "hover:bg-fm-color-opacity-sm": p.modelValue !== n.value
221
+ }]),
222
+ onClick: (c) => m(n.value),
223
+ key: n.value
224
+ }, {
225
+ default: R(() => [
226
+ i("div", rt, $(n.label), 1),
227
+ i("div", ct, $(n.sublabel), 1)
228
+ ]),
229
+ _: 2
230
+ }, 1032, ["class", "onClick"])), 64))
231
+ ]),
232
+ p.errorText ? (f(), G(s, {
233
+ key: 0,
234
+ class: "!mt-4",
235
+ text: p.errorText,
236
+ state: "error"
237
+ }, null, 8, ["text"])) : ye("", !0)
238
+ ]);
239
+ };
240
+ }
241
+ }), ut = { class: "flex items-center gap-x-8" }, pt = {
242
+ key: 0,
243
+ class: "space-y-16 pr-12"
244
+ }, mt = { class: "flex flex-col space-y-16" }, ft = {
245
+ key: 0,
246
+ class: "flex flex-col space-y-16"
247
+ }, gt = {
248
+ key: 1,
249
+ class: "flex flex-col space-y-16"
250
+ }, yt = { class: "flex items-center gap-8" }, vt = /* @__PURE__ */ K({
251
+ __name: "SegmentSheet",
252
+ emits: ["update:model-value"],
253
+ setup(e, { expose: g, emit: _ }) {
254
+ const x = Be(), u = N(!1), m = N(!1), p = {
255
+ name: "",
256
+ isActive: !0,
257
+ rule: pe.scaffoldGroup(),
258
+ members: []
259
+ }, S = Je, l = N(p), s = se(() => {
260
+ const v = S.safeParse(l.value);
261
+ return v.success ? [] : v.error.errors;
262
+ });
263
+ function n(v) {
264
+ u.value = !0, m.value = !1, v ? l.value = {
265
+ ...v,
266
+ isActive: v.isActive !== !1
267
+ } : l.value = { ...p };
268
+ }
269
+ function c() {
270
+ u.value = !1;
271
+ }
272
+ async function y() {
273
+ S.safeParse(l.value).success && (m.value = !0);
274
+ }
275
+ function I() {
276
+ m.value = !1;
277
+ }
278
+ async function k() {
279
+ l.value.isActive === !1 ? l.value.rule = pe.scaffoldGroup() : l.value.file = void 0, Y("update:model-value", l.value);
280
+ }
281
+ async function L(v) {
282
+ l.value.isActive = v;
283
+ }
284
+ ve(async () => {
285
+ });
286
+ const Y = _;
287
+ return g({
288
+ showSheet: n,
289
+ hideSheet: c
290
+ }), (v, r) => {
291
+ const E = h("FmButton"), U = h("FmSideSheet");
292
+ return f(), G(U, {
293
+ modelValue: t(u),
294
+ "onUpdate:modelValue": r[7] || (r[7] = (o) => be(u) ? u.value = o : null),
295
+ header: "Add segment",
296
+ "dismiss-away": "",
297
+ "close-button": !0,
298
+ "max-width": 1100
299
+ }, Ce({
300
+ "side-sheet-footer": R(() => [
301
+ i("div", yt, [
302
+ t(m) || !t(l).isActive ? (f(), C(H, { key: 0 }, [
303
+ d(E, {
304
+ label: "Save Segment",
305
+ onClick: k,
306
+ loading: t(x).isLoading,
307
+ disabled: t(s).length > 0 || t(x).isLoading
308
+ }, null, 8, ["loading", "disabled"]),
309
+ d(E, {
310
+ label: "Cancel",
311
+ onClick: r[5] || (r[5] = (o) => I()),
312
+ variant: "tertiary"
313
+ })
314
+ ], 64)) : (f(), C(H, { key: 1 }, [
315
+ d(E, {
316
+ label: "Review Segment",
317
+ disabled: t(s).length > 0 || t(x).isLoading,
318
+ onClick: y
319
+ }, null, 8, ["disabled"]),
320
+ d(E, {
321
+ label: "Cancel",
322
+ onClick: r[6] || (r[6] = (o) => c()),
323
+ variant: "tertiary"
324
+ })
325
+ ], 64))
326
+ ])
327
+ ]),
328
+ default: R(() => {
329
+ var o;
330
+ return [
331
+ t(m) ? (f(), G(st, {
332
+ key: 1,
333
+ title: t(l).name,
334
+ segment: t(l)
335
+ }, null, 8, ["title", "segment"])) : (f(), C("div", pt, [
336
+ d(Ne, {
337
+ modelValue: t(l).name,
338
+ "onUpdate:modelValue": r[1] || (r[1] = (a) => t(l).name = a),
339
+ label: "Segment title",
340
+ schema: t(Ae).typeAtPath(t(S), "name")
341
+ }, null, 8, ["modelValue", "schema"]),
342
+ i("div", mt, [
343
+ r[9] || (r[9] = i("div", { class: "fm-typo-en-title-sm-800" }, "Segment Type", -1)),
344
+ d(dt, {
345
+ "model-value": t(l).isActive,
346
+ "onUpdate:modelValue": r[2] || (r[2] = (a) => {
347
+ L(a);
348
+ })
349
+ }, null, 8, ["model-value"])
350
+ ]),
351
+ t(l).isActive ? (f(), C("div", ft, [
352
+ r[10] || (r[10] = i("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
353
+ d(Le, {
354
+ "trigger-type": "MEMBERSHIP_JOINED",
355
+ includeOnly: "user",
356
+ "model-value": (o = t(l)) == null ? void 0 : o.rule,
357
+ "onUpdate:modelValue": r[3] || (r[3] = (a) => {
358
+ t(l).rule = a;
359
+ })
360
+ }, null, 8, ["model-value"])
361
+ ])) : (f(), C("div", gt, [
362
+ d(Xe, {
363
+ importFile: t(l).importFile,
364
+ "onUpdate:file": r[4] || (r[4] = (a) => {
365
+ t(l).file = a;
366
+ })
367
+ }, null, 8, ["importFile"])
368
+ ]))
369
+ ]))
370
+ ];
371
+ }),
372
+ _: 2
373
+ }, [
374
+ t(m) ? {
375
+ name: "side-sheet-header",
376
+ fn: R(() => [
377
+ i("div", ut, [
378
+ d(E, {
379
+ icon: "arrow_back",
380
+ variant: "tertiary",
381
+ onClick: r[0] || (r[0] = (o) => m.value = !1)
382
+ }),
383
+ r[8] || (r[8] = i("div", null, "Review segment", -1))
384
+ ])
385
+ ]),
386
+ key: "0"
387
+ } : void 0
388
+ ]), 1032, ["modelValue"]);
389
+ };
390
+ }
391
+ }), ge = Oe(), _t = Fe();
392
+ function ae(e) {
393
+ const g = j(e);
394
+ return g.isValid() ? g.format("DD/MM/YYYY") : "";
395
+ }
396
+ const xt = {
397
+ mapMemberExportRow: (e) => {
398
+ var s, n, c, y, I, k, L, Y, v, r, E, U, o, a, F, T, M, D, A, z, O, q, X, w, J, ie, le, re;
399
+ const g = se(() => _t.locations.map((b) => ({
400
+ label: b.name,
401
+ value: b._id
402
+ }))), _ = (s = Pe.parseOneAddress(
403
+ e == null ? void 0 : e.email
404
+ )) != null && s.domain.includes("feedmepos.com") ? void 0 : e.email, x = (c = ((n = e == null ? void 0 : e.collection) == null ? void 0 : n.TITLE) || []) == null ? void 0 : c.reduce(
405
+ (b, B) => {
406
+ var Z, W;
407
+ const Q = (W = (Z = ge.sortedTitles) == null ? void 0 : Z.find(
408
+ (ee) => ee._id === B.collectible
409
+ )) == null ? void 0 : W.name;
410
+ return !Q || B.balance <= 0 || b.push(Q), b;
411
+ },
412
+ []
413
+ ), u = (ge.sortedTitles || []).reduce(
414
+ (b, B) => {
415
+ var Z, W, ee, ce;
416
+ const Q = (ce = (ee = (W = (((Z = e == null ? void 0 : e.collection) == null ? void 0 : Z.TITLE) || []).find(
417
+ (we) => we.collectible === B._id
418
+ )) == null ? void 0 : W.expiryBalance) == null ? void 0 : ee[0]) == null ? void 0 : ce.expiredAt;
419
+ return b[B.name] = Q ? j(Q).format("DD/MM/YYYY") : "", b;
420
+ },
421
+ {}
422
+ ), m = ((k = (I = (y = e.collection) == null ? void 0 : y.CREDIT) == null ? void 0 : I.at(0)) == null ? void 0 : k.balance) || 0, p = ((r = (v = (Y = (L = e.collection) == null ? void 0 : L.CREDIT) == null ? void 0 : Y.at(0)) == null ? void 0 : v.expiryBalance) == null ? void 0 : r.reduce(
423
+ (b, B) => b + B.amount,
424
+ 0
425
+ )) || 0, S = je(m, 2);
426
+ return {
427
+ ID: e._id.toString(),
428
+ Name: ((E = e.name) == null ? void 0 : E.trim()) || "",
429
+ Phone: ((U = e == null ? void 0 : e.phoneNumber) == null ? void 0 : U.trim()) || "",
430
+ Email: _ || "",
431
+ Gender: e.gender || "",
432
+ CardNo: e.cardNo || "",
433
+ Birthday: e != null && e.birthday ? ae(e == null ? void 0 : e.birthday) : "",
434
+ Credit: parseFloat((Number(S) - Number(p)).toFixed(2)),
435
+ FreeCredit: Number(p.toFixed(2)),
436
+ TotalCredit: Number(S),
437
+ Exp: e != null && e.collection ? ((F = (a = (o = e.collection) == null ? void 0 : o.POINT) == null ? void 0 : a.at(0)) == null ? void 0 : F.balance) ?? 0 : 0,
438
+ Point: e != null && e.collection ? ((D = (M = (T = e.collection) == null ? void 0 : T.COIN) == null ? void 0 : M.at(0)) == null ? void 0 : D.balance) ?? 0 : 0,
439
+ Level: e != null && e.collection ? ((O = (z = (A = e.collection) == null ? void 0 : A.TIER) == null ? void 0 : z.at(0)) == null ? void 0 : O.balance) ?? 0 : 0,
440
+ Tier: e != null && e.collection ? ((w = (X = (q = e.collection) == null ? void 0 : q.TIER) == null ? void 0 : X.at(0)) == null ? void 0 : w.balance) ?? 0 : 0,
441
+ Titles: x.join(","),
442
+ ...u,
443
+ TotalTransaction: e.stats.visitCount,
444
+ AvgSpent: He(Number(e.stats.avgBillSize || 0)).toFormat(
445
+ !1
446
+ ),
447
+ TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
448
+ LastVisit: ae(e.stats.lastVisit),
449
+ Feedback: ((J = e.stats) == null ? void 0 : J.feedbackCount) || 0,
450
+ LastSeasonTierEarned: ((ie = e.stats) == null ? void 0 : ie.lastSeasonTierEarned) || 0,
451
+ LastSeasonPointEarned: ((le = e.stats) == null ? void 0 : le.lastSeasonPointEarned) || 0,
452
+ JoinedAt: ae(e.joinAt || void 0),
453
+ JoinedAtLocation: e.location && ((re = g.value.find((b) => b.value == e.location)) == null ? void 0 : re.label) || "-",
454
+ VisitFrequency: `${Number(
455
+ Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
456
+ )}`
457
+ };
458
+ }
459
+ }, St = { class: "flex items-center" }, ht = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Ft = { class: "px-24 flex flex-col gap-y-16" }, wt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, bt = { class: "fm-typo-en-body-md-600" }, Ct = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, ao = /* @__PURE__ */ K({
460
+ __name: "Segment",
461
+ setup(e) {
462
+ const { minor: g } = Re, { t: _ } = he(), x = Fe(), { mapMemberExportRow: u } = xt, m = Ee(), p = Ge(), S = N(0), l = [
463
+ {
464
+ header: _("connect.loyalty.segment.table.name"),
465
+ accessorFn: (o) => o.name
466
+ },
467
+ {
468
+ header: _("connect.loyalty.segment.table.total_customers"),
469
+ accessorFn: (o) => o.memberCount ?? 0
470
+ },
471
+ {
472
+ header: _("connect.loyalty.segment.table.customer_percentage"),
473
+ accessorFn: (o) => ((o.memberCount ?? 0) * 100 / S.value).toFixed(2)
474
+ },
475
+ {
476
+ header: _("connect.loyalty.segment.table.actions"),
477
+ meta: {
478
+ maxWidth: "100px"
479
+ },
480
+ cell(o) {
481
+ return V("div", { class: "flex items-center justify-end" }, [
482
+ V(
483
+ te.FmMenu,
484
+ {
485
+ placement: "bottom-end",
486
+ onClick: (a) => {
487
+ a.stopPropagation();
488
+ }
489
+ },
490
+ {
491
+ "menu-button": () => V(te.FmButton, {
492
+ icon: "more_vert",
493
+ iconColor: "neutral-gray-400",
494
+ variant: "tertiary"
495
+ }),
496
+ default: () => [
497
+ V(
498
+ te.FmMenuItem,
499
+ {
500
+ onClick: async (a) => {
501
+ a.stopPropagation(), L(o.row.original);
502
+ }
503
+ },
504
+ {
505
+ label: V(
506
+ "div",
507
+ {
508
+ class: "fm-typo-en-body-md-400"
509
+ },
510
+ "Export"
511
+ )
512
+ }
513
+ ),
514
+ V(
515
+ te.FmMenuItem,
516
+ {
517
+ onClick: async (a) => {
518
+ a.stopPropagation(), k(o.row.original);
519
+ }
520
+ },
521
+ {
522
+ label: V(
523
+ "div",
524
+ {
525
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
526
+ },
527
+ "Remove"
528
+ )
529
+ }
530
+ )
531
+ ]
532
+ }
533
+ )
534
+ ]);
535
+ }
536
+ }
537
+ ], s = N(null), { tableMeta: n, rowData: c, debouncedFetchData: y } = xe(
538
+ P.readAll
539
+ );
540
+ async function I() {
541
+ await g(
542
+ async () => {
543
+ await P.refreshSegments(), await y({ pageSize: 10, pageIndex: 0 });
544
+ },
545
+ { message: "Refreshing segmentations" }
546
+ );
547
+ }
548
+ async function k(o) {
549
+ await Ie.remove(`Are you sure you want to remove ${o.name}?`) && await g(
550
+ async () => {
551
+ await P.delete(o._id), await y({ pageSize: 10, pageIndex: 0 });
552
+ },
553
+ {
554
+ message: `Removing ${o.name}`,
555
+ successMessage: `Removed ${o.name} successfully`
556
+ }
557
+ );
558
+ }
559
+ async function L(o) {
560
+ const a = {
561
+ sortBy: "_id",
562
+ descending: !1,
563
+ rowsPerPage: 1e3,
564
+ page: 1,
565
+ rowsNumber: 0
566
+ }, F = new De(), T = (await me.read({
567
+ limit: 1,
568
+ skip: 0,
569
+ sortBy: a.sortBy,
570
+ descending: a.descending
571
+ })).meta.totalResources ?? 0, M = a.rowsPerPage;
572
+ await g(
573
+ async () => {
574
+ for (let D = 0; D < T; D += M) {
575
+ const A = {
576
+ ...a,
577
+ limit: M,
578
+ skip: a.page - 1,
579
+ sortBy: a.sortBy,
580
+ descending: a.descending
581
+ }, z = await P.paginateSegmentUsers(
582
+ o._id,
583
+ A
584
+ );
585
+ for (const O of z.resources) {
586
+ const q = u(O);
587
+ F.addRecord(q);
588
+ }
589
+ a.page++;
590
+ }
591
+ await Te(
592
+ F.buildExcel(),
593
+ `[${o.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
594
+ {
595
+ bookType: "xlsx",
596
+ bookSST: !1,
597
+ type: "array"
598
+ }
599
+ ), a.page = 1;
600
+ },
601
+ {
602
+ message: "Exporting member...",
603
+ successMessage: "Member exported successfully"
604
+ }
605
+ );
606
+ }
607
+ async function Y(o) {
608
+ await g(
609
+ async () => {
610
+ var a;
611
+ if (o.isActive === !1) {
612
+ const F = new FormData();
613
+ if (F.append("file", o.file), o._id) {
614
+ const { members: T, _id: M, file: D, ...A } = o;
615
+ F.append("segment", JSON.stringify(A)), await P.updateStatic(o._id, F);
616
+ } else {
617
+ const { file: T, ...M } = o;
618
+ F.append("segment", JSON.stringify(M)), await P.createStatic(F);
619
+ }
620
+ o.file && m.open({
621
+ type: "info",
622
+ title: "Import begins soon. Check Queue for updates.",
623
+ action: "View",
624
+ onAction: async () => {
625
+ await p.push({
626
+ name: fe["$connect-QUEUE"],
627
+ query: { type: [de.enum.SEGMENTATION_IMPORTED] }
628
+ });
629
+ }
630
+ });
631
+ } else if (o._id) {
632
+ const { members: F, _id: T, ...M } = o;
633
+ await P.update(o._id, M);
634
+ } else
635
+ await P.create(o);
636
+ await y({ pageSize: 10, pageIndex: 0 }), (a = s.value) == null || a.hideSheet();
637
+ },
638
+ {
639
+ message: "Saving segment",
640
+ successMessage: "Segment saved"
641
+ }
642
+ );
643
+ }
644
+ function v(o) {
645
+ var a;
646
+ (a = s.value) == null || a.showSheet(o);
647
+ }
648
+ const r = {
649
+ label: _("connect.navigation.queue"),
650
+ value: "queue",
651
+ isPrimary: !1,
652
+ prependIcon: "work_history"
653
+ }, E = se(() => x.isPremium ? [
654
+ r,
655
+ {
656
+ label: "Refresh segments",
657
+ value: "refresh",
658
+ prependIcon: "refresh"
659
+ },
660
+ {
661
+ label: "Add segment",
662
+ value: "add",
663
+ isPrimary: !0,
664
+ prependIcon: "add"
665
+ }
666
+ ] : []);
667
+ function U(o) {
668
+ switch (o) {
669
+ case "add":
670
+ v();
671
+ break;
672
+ case "refresh":
673
+ I();
674
+ break;
675
+ case "queue":
676
+ p.push({
677
+ name: fe["$connect-QUEUE"],
678
+ query: { type: [de.enum.SEGMENTATION_IMPORTED] }
679
+ });
680
+ break;
681
+ }
682
+ }
683
+ return ke(async () => {
684
+ const { meta: o } = await me.read({
685
+ limit: 1,
686
+ skip: 0,
687
+ sortBy: "_id",
688
+ search: void 0,
689
+ descending: !1
690
+ });
691
+ S.value = o.totalResources ?? 0, await y({ pageSize: 10, pageIndex: 0 }), await x.readPremium(), await x.readLocations();
692
+ }), (o, a) => {
693
+ const F = h("FmPill"), T = h("FmPageHead"), M = h("FmIcon"), D = h("FmMenuItem"), A = h("FmMenu"), z = h("FmListItem"), O = h("FmList"), q = h("FmButton"), X = h("FmCard");
694
+ return f(), C(H, null, [
695
+ d(T, {
696
+ title: "Segments",
697
+ actions: t(E),
698
+ "onClick:action": a[0] || (a[0] = (w) => U(w))
699
+ }, {
700
+ title: R(() => [
701
+ i("div", St, [
702
+ i("span", ht, $(t(_)("connect.loyalty.segment.title")), 1),
703
+ d(F, { variant: "premium" })
704
+ ])
705
+ ]),
706
+ _: 1
707
+ }, 8, ["actions"]),
708
+ i("div", Ft, [
709
+ t(c).length > 0 || t(n).searchValue || t(n).isLoading ? (f(), C(H, { key: 0 }, [
710
+ d(Se, {
711
+ loading: t(n).isLoading,
712
+ "row-data": t(c),
713
+ "row-count": t(n).totalRows,
714
+ "column-defs": l,
715
+ "shrink-at": !1,
716
+ "page-count": t(n).pageCount,
717
+ "page-index": t(n).pageIndex,
718
+ "page-size": t(n).pageSize,
719
+ onRowClick: a[1] || (a[1] = (w) => {
720
+ v(w.original);
721
+ }),
722
+ onPageChange: t(y)
723
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
724
+ d(O, { class: "w-full hidden xs:block" }, {
725
+ default: R(() => [
726
+ (f(!0), C(H, null, _e(t(c), (w) => (f(), G(z, {
727
+ key: w._id.toString(),
728
+ tag: "label",
729
+ onClick: (J) => v(w)
730
+ }, {
731
+ default: R(() => [
732
+ i("div", null, [
733
+ i("div", wt, $((w.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
734
+ i("div", bt, $(w.name), 1),
735
+ i("div", Ct, $(((w.memberCount ?? 0) * 100 / t(S)).toFixed(2)) + "% of customers ", 1)
736
+ ])
737
+ ]),
738
+ append: R(() => [
739
+ d(A, { "stop-click-propagation": !0 }, {
740
+ "menu-button": R(() => [
741
+ d(M, { name: "more_vert" })
742
+ ]),
743
+ default: R(() => [
744
+ d(D, {
745
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
746
+ label: "Remove",
747
+ "onUpdate:modelValue": (J) => J && k(w)
748
+ }, null, 8, ["onUpdate:modelValue"])
749
+ ]),
750
+ _: 2
751
+ }, 1024)
752
+ ]),
753
+ _: 2
754
+ }, 1032, ["onClick"]))), 128))
755
+ ]),
756
+ _: 1
757
+ })
758
+ ], 64)) : (f(), G(X, {
759
+ key: 1,
760
+ variant: "outlined",
761
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
762
+ }, {
763
+ default: R(() => [
764
+ a[3] || (a[3] = i("img", {
765
+ src: Me,
766
+ class: "aspect-square w-[150px]"
767
+ }, null, -1)),
768
+ a[4] || (a[4] = i("div", { class: "flex flex-col gap-16 text-center" }, [
769
+ i("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
770
+ 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. ")
771
+ ], -1)),
772
+ d(q, {
773
+ variant: "primary",
774
+ label: "Create segment",
775
+ disabled: !t(x).isPremium,
776
+ icon: "add",
777
+ onClick: a[2] || (a[2] = (w) => v())
778
+ }, null, 8, ["disabled"])
779
+ ]),
780
+ _: 1
781
+ })),
782
+ d(vt, {
783
+ ref_key: "sheetRef",
784
+ ref: s,
785
+ "onUpdate:modelValue": Y
786
+ }, null, 512)
787
+ ])
788
+ ], 64);
789
+ };
790
+ }
791
+ });
792
+ export {
793
+ ao as default
794
+ };