@feedmepos/mf-connect 0.1.0-beta.79 → 0.1.0-beta.80

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 (90) hide show
  1. package/dist/{Analytic-BWPlfRv_.js → Analytic-C84B4MSt.js} +11 -11
  2. package/dist/{App-rVXsAZf4.js → App-CnbbBVSn.js} +7 -7
  3. package/dist/{AuditLogs-DRWL0LCg.js → AuditLogs-KOxiG5Q0.js} +9 -9
  4. package/dist/{Bin-B0eBqJEL.js → Bin-BBSQDzD4.js} +8 -8
  5. package/dist/{Broadcast-BGD2QAWy.js → Broadcast-DlvPEqW7.js} +9 -9
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CFGFE3dX.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-M1Za3MaN.js} +6 -6
  7. package/dist/{Card-BoTXQTJt.js → Card-BluWm_EY.js} +16 -16
  8. package/dist/{Collections-CyaCOVDA.js → Collections-DtHJpxRT.js} +6 -6
  9. package/dist/{Credit-BdNcZU2N.js → Credit-Be2pcBVn.js} +9 -9
  10. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-BsY5yaIy.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-sqq_sO_a.js} +29 -29
  11. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BkusmLGQ.js → EffectSheet.vue_vue_type_style_index_0_lang-CBsYx54P.js} +6 -6
  12. package/dist/{Experience-BJDDkXOZ.js → Experience-CLPyvgs0.js} +9 -9
  13. package/dist/{Game-DFG3vLk8.js → Game-5kEG7o4J.js} +10 -10
  14. package/dist/{Index-qy3Tz0xK.js → Index-BSZi21Wo.js} +10 -10
  15. package/dist/{Marketing-DUku6XD4.js → Marketing-CE1Sq3Pb.js} +6 -6
  16. package/dist/{Member-CUQchnW7.js → Member-DaBqmOYX.js} +10 -10
  17. package/dist/{MemberList-B1oJ-Xru.js → MemberList-jIriR6B0.js} +25 -25
  18. package/dist/{MemberTransactions-DX6HUrmE.js → MemberTransactions-BGEZwpPO.js} +1 -1
  19. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-Cm_UWM1t.js → MessageInput.vue_vue_type_script_setup_true_lang-CSlafowP.js} +4 -4
  20. package/dist/{Mission-CUnD9rnL.js → Mission-BOByUsYC.js} +10 -10
  21. package/dist/{Overview-DlwndyOR.js → Overview-BQQs8TsL.js} +18 -18
  22. package/dist/{Point-BAfX7S-7.js → Point-BuRBh_HC.js} +9 -9
  23. package/dist/{Promotion-Dz1zKQfN.js → Promotion-Py2WWNt0.js} +10 -10
  24. package/dist/{Queue-CSy1dZsH.js → Queue-On8_svkl.js} +57 -55
  25. package/dist/{Record-B6FL3ib9.js → Record-CSWkHs9Y.js} +8 -8
  26. package/dist/{Reward-CIAJjJIC.js → Reward-BLVyFkAH.js} +15 -15
  27. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-BUgkWq0y.js → RewardGroup.vue_vue_type_script_setup_true_lang-BW8kuoLt.js} +11 -11
  28. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-DuszU35b.js → RuleGroup.vue_vue_type_script_setup_true_lang-DC8JEmEC.js} +13 -13
  29. package/dist/Segment-BjBskgf9.js +880 -0
  30. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-DGVFIzqN.js → SelectItems.vue_vue_type_script_setup_true_lang-CrVw6j2M.js} +2 -2
  31. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-BrCH4DYt.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-oaAVUxO4.js} +11 -11
  32. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-BmJqWPLB.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-CKOTgzL-.js} +3 -3
  33. package/dist/{Setting-fXLJxGqb.js → Setting-CAMlhgGd.js} +11 -11
  34. package/dist/{Store-BRZ_yflw.js → Store-0qvNbHne.js} +19 -19
  35. package/dist/{StoreRewards-D-xgOre4.js → StoreRewards-CjcHvUNa.js} +13 -13
  36. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-CmPDB7ft.js → StoreTransactions.vue_vue_type_script_setup_true_lang-CdZ7QIaf.js} +19 -19
  37. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DnpINp6a.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-vJaZIDrx.js} +1 -1
  38. package/dist/{Tier-CFiP5vfN.js → Tier-D_pHKGSv.js} +20 -20
  39. package/dist/{Title-CvCgJZnV.js → Title-DgdtJ87h.js} +19 -19
  40. package/dist/{Transaction-VnHxUgzd.js → Transaction-CKlLWcjS.js} +2 -2
  41. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-D-iUg0-J.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-2GOvljvv.js} +6 -6
  42. package/dist/{Voucher-lWrBdvbs.js → Voucher-Cg6zQSAy.js} +12 -12
  43. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-CL3vNkAC.js → VoucherEditor.vue_vue_type_script_setup_true_lang-rpjQkheM.js} +10 -10
  44. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-8R1a1fYC.js → ZodTextField.vue_vue_type_script_setup_true_lang-BRdY-P8U.js} +1 -1
  45. package/dist/{app-CYn3xXTv.js → app-CScRp4SA.js} +31 -31
  46. package/dist/{app-BC1zkBVg.js → app-jGYefKeR.js} +1 -1
  47. package/dist/app.js +1 -1
  48. package/dist/{business-B2Pmp9hr.js → business-DYhO4gjc.js} +1 -1
  49. package/dist/{campaign-BhGY0Npy.js → campaign-BgXy1Ngd.js} +9 -9
  50. package/dist/{campaign-b6acZvTb.js → campaign-CZ5pMrUu.js} +2 -2
  51. package/dist/{campaign.enum-B0h5hjf7.js → campaign.enum-CWBDlzqp.js} +1 -1
  52. package/dist/{campaign.fn-DpmkYlif.js → campaign.fn-HHZ5mQKe.js} +126 -126
  53. package/dist/{collectible.enum-BK_I7wtJ.js → collectible.enum-MvoLHpuA.js} +1 -1
  54. package/dist/{collection.fn-b4afEpgK.js → collection.fn-BHUoLJPj.js} +2 -2
  55. package/dist/{dto-DE1vDARL.js → dto-DXdR0em1.js} +4 -4
  56. package/dist/{effect-HxmvYGZx.js → effect-HLuo1A_f.js} +1 -1
  57. package/dist/{email-addresses-DAiJ0HFK.js → email-addresses-DU4ehcHM.js} +1 -1
  58. package/dist/{export-CDUkyOe3.js → export-BDRHAxZr.js} +3 -3
  59. package/dist/{helper-C4YKXYXc.js → helper-JhFOw8n-.js} +1 -1
  60. package/dist/{index-CFX6FmLw.js → index-BG_GpbnZ.js} +1 -1
  61. package/dist/{index-DosoXjre.js → index-BZWr1bgh.js} +6 -6
  62. package/dist/{index-CNkXIOMF.js → index-Bs-tzd5F.js} +3 -3
  63. package/dist/{index-C_Dby4Ky.js → index-C2nNcNjw.js} +1 -1
  64. package/dist/{index-B9nRh1fm.js → index-CIF8DeC8.js} +3 -3
  65. package/dist/{index-B5bK-QSA.js → index-CqT8uK3R.js} +1 -1
  66. package/dist/{index-CfrYjXcx.js → index-DVj1MyZp.js} +2 -2
  67. package/dist/{index-D0VhsFgt.js → index-GmHsjd7O.js} +1 -1
  68. package/dist/{index-DGM2sRoH.js → index-QDEKR2Rj.js} +1 -1
  69. package/dist/{index-ngiKVXwW.js → index-cYKPj4fA.js} +4 -4
  70. package/dist/{index-6V4Fjsrp.js → index-eRBO4PzZ.js} +1 -1
  71. package/dist/{index-zMmkQ7LH.js → index-fS6fmvFv.js} +3 -3
  72. package/dist/{index-BIKB8JEn.js → index-l8E6r07W.js} +1 -1
  73. package/dist/{index.esm2017-CIVoAkER.js → index.esm2017-B-YrQ0sw.js} +59 -59
  74. package/dist/{loading-C8cugjI2.js → loading-C09t0mFj.js} +1 -1
  75. package/dist/{membership-Bi2PPlT2.js → membership-tHAn3VRs.js} +3 -3
  76. package/dist/{money-BhmMTa3K.js → money-DYVCca49.js} +1 -1
  77. package/dist/{number-BLa-XtLl.js → number-VYuUME2F.js} +1 -1
  78. package/dist/objectid-BTO4csVa.js +145 -0
  79. package/dist/{plugins-C4CRYHfI.js → plugins-CXgvBDMF.js} +2 -2
  80. package/dist/{reward-B5zrbtdh.js → reward-DX9TZrk4.js} +1 -1
  81. package/dist/{rule-CusKNV3u.js → rule-CbCZqulx.js} +3 -3
  82. package/dist/{rule-builder-DZ3ft0wv.js → rule-builder-J8K_fjI-.js} +1 -1
  83. package/dist/{template-DkjiuYnZ.js → template-BtYJpEBa.js} +4 -4
  84. package/dist/{trigger-CC4M7Jea.js → trigger-D6dpZFSN.js} +4 -4
  85. package/dist/{user-DzvUhlhq.js → user-C0QvWk-o.js} +1 -1
  86. package/dist/{vue-i18n-7kseAFxN.js → vue-i18n-cz2_cPSz.js} +201 -201
  87. package/dist/{xlsx-D4dOKrKC.js → xlsx-BIPQrY49.js} +1 -1
  88. package/package.json +1 -1
  89. package/dist/Segment-jwXRRJfP.js +0 -847
  90. package/dist/objectid-d0ka3cMS.js +0 -145
@@ -0,0 +1,880 @@
1
+ import { defineComponent as ee, ref as z, resolveComponent as F, openBlock as p, createElementBlock as k, createElementVNode as l, createVNode as r, unref as t, createCommentVNode as le, withCtx as E, Fragment as O, renderList as ie, createBlock as J, toDisplayString as D, normalizeClass as re, onMounted as Se, computed as ce, isRef as Me, createSlots as Ie, h as Y, onBeforeMount as Te } from "vue";
2
+ import { _ as Ee } from "./campaign-CpzFl8Vr.js";
3
+ import { p as $e } from "./plugins-CXgvBDMF.js";
4
+ import { u as Ae } from "./loading-C09t0mFj.js";
5
+ import { FmButtonVariant as ne, useSnackbar as Re, components as X } from "@feedmepos/ui-library";
6
+ import { u as we, _ as Fe } from "./usePagination-BeF5K3M7.js";
7
+ import { u as he } from "./vue-i18n-cz2_cPSz.js";
8
+ import "./index-BZWr1bgh.js";
9
+ import { i as De, j as R, c as fe } from "./index-cYKPj4fA.js";
10
+ import "./index-DVj1MyZp.js";
11
+ import "./index-C2nNcNjw.js";
12
+ import "./index-CIF8DeC8.js";
13
+ import { u as ae, w as be } from "./xlsx-BIPQrY49.js";
14
+ import { e as Pe, M as Ne } from "./email-addresses-DU4ehcHM.js";
15
+ import { Z as Be } from "./zod-Bg2FbC-D.js";
16
+ import { u as Ve } from "./app-wDQR6dpb.js";
17
+ import { F as ye, z as Ye } from "./index-Bs-tzd5F.js";
18
+ import { R as ge } from "./rule-builder-J8K_fjI-.js";
19
+ import { _ as Le } from "./ZodTextField.vue_vue_type_script_setup_true_lang-BRdY-P8U.js";
20
+ import { _ as Ue } from "./RuleGroup.vue_vue_type_script_setup_true_lang-DC8JEmEC.js";
21
+ import { u as ze, v as Oe, w as je } from "./index.esm2017-B-YrQ0sw.js";
22
+ import { F as qe } from "./FileSaver.min-NlMItPOc.js";
23
+ import { h as G } from "./moment-BWErdI6_.js";
24
+ import { s as N, u as He } from "./membership-tHAn3VRs.js";
25
+ import { o as Ge } from "./objectId-dwaoBfJX.js";
26
+ import { u as Ce } from "./business-DYhO4gjc.js";
27
+ import { f as Je } from "./number-VYuUME2F.js";
28
+ import { t as Qe } from "./money-DYVCca49.js";
29
+ import "./index-GmHsjd7O.js";
30
+ import { useRouter as We } from "vue-router";
31
+ import { m as ve } from "./index-BG_GpbnZ.js";
32
+ import { R as _e } from "./app-CScRp4SA.js";
33
+ const Ze = De.extend({
34
+ _id: ye.optional(),
35
+ business: ye.optional(),
36
+ file: Ye.any().nullish()
37
+ }), Ke = { class: "flex flex-col space-y-16" }, Xe = {
38
+ key: 0,
39
+ class: /* @__PURE__ */ re([
40
+ "p-16 pl-24 space-x-8",
41
+ "bg-fm-color-primary-oats rounded-lg",
42
+ "flex items-center",
43
+ "justify-between"
44
+ ])
45
+ }, et = { class: "flex justify-end" }, tt = {
46
+ key: 1,
47
+ class: /* @__PURE__ */ re([
48
+ "flex items-center",
49
+ "border border-fm-color-neutral-gray-300",
50
+ "p-16 space-x-16 rounded-md"
51
+ ])
52
+ }, ot = { class: "fm-typo-en-body-lg-400 flex-1 truncate" }, nt = /* @__PURE__ */ ee({
53
+ __name: "ImportSegment",
54
+ props: {
55
+ importFile: {}
56
+ },
57
+ emits: ["update:file"],
58
+ setup(e, { emit: _ }) {
59
+ const x = e, b = _, { t: m } = he(), y = z(null), f = z(null), h = ["Id"], i = [
60
+ {
61
+ label: "CSV",
62
+ icon: "csv",
63
+ value: "csv"
64
+ },
65
+ {
66
+ label: "Excel",
67
+ icon: "description",
68
+ value: "xlsx"
69
+ }
70
+ ];
71
+ async function a() {
72
+ if (x.importFile)
73
+ try {
74
+ const S = ze(), g = Oe(S, x.importFile), w = await je(g);
75
+ window.open(w, "_blank");
76
+ } catch (S) {
77
+ console.log(S);
78
+ }
79
+ }
80
+ async function c(S) {
81
+ switch (S) {
82
+ case "csv":
83
+ const g = new Blob([h.join(",")], {
84
+ type: "text/csv;charset=utf-8;"
85
+ });
86
+ qe.saveAs(g, "ImportSegmentTemplate.csv");
87
+ break;
88
+ case "xlsx":
89
+ const w = ae.aoa_to_sheet([h]), M = ae.book_new();
90
+ ae.book_append_sheet(M, w, "Sheet1"), be(M, "ImportSegmentTemplate.xlsx");
91
+ break;
92
+ }
93
+ }
94
+ function C(S) {
95
+ y.value = S, b("update:file", y.value);
96
+ }
97
+ function $(S) {
98
+ var w, M;
99
+ const g = ((M = (w = S.target) == null ? void 0 : w.files) == null ? void 0 : M[0]) ?? null;
100
+ C(g);
101
+ }
102
+ return (S, g) => {
103
+ const w = F("FmButton"), M = F("FmMenuItem"), u = F("FmMenu"), s = F("FmDropField");
104
+ return p(), k("div", Ke, [
105
+ g[2] || (g[2] = l("div", { class: "fm-typo-en-title-sm-800" }, "Upload File", -1)),
106
+ S.importFile ? (p(), k("div", Xe, [
107
+ r(w, {
108
+ label: t(m)("View uploaded file"),
109
+ variant: t(ne).Plain,
110
+ icon: "file_present",
111
+ onClick: a
112
+ }, null, 8, ["label", "variant"])
113
+ ])) : le("", !0),
114
+ l("div", null, [
115
+ l("div", et, [
116
+ r(u, { class: "" }, {
117
+ "menu-button": E(() => [
118
+ r(w, {
119
+ variant: "tertiary",
120
+ icon: "download",
121
+ label: "Download Template"
122
+ })
123
+ ]),
124
+ default: E(() => [
125
+ (p(), k(O, null, ie(i, (v) => r(M, {
126
+ key: v.value,
127
+ icon: v.icon,
128
+ label: v.label,
129
+ onClick: (L) => c(v.value),
130
+ selectable: ""
131
+ }, null, 8, ["icon", "label", "onClick"])), 64))
132
+ ]),
133
+ _: 1
134
+ })
135
+ ]),
136
+ y.value ? (p(), k("div", tt, [
137
+ r(w, {
138
+ variant: t(ne).Tertiary,
139
+ "prepend-icon": "attach_file"
140
+ }, null, 8, ["variant"]),
141
+ l("p", ot, D(y.value.name), 1),
142
+ l("label", {
143
+ ref_key: "fileLabelRef",
144
+ ref: f,
145
+ htmlFor: "file"
146
+ }, [
147
+ r(w, {
148
+ variant: t(ne).Plain,
149
+ label: t(m)("Replace File"),
150
+ onClick: g[1] || (g[1] = () => {
151
+ var v;
152
+ return (v = f.value) == null ? void 0 : v.click();
153
+ })
154
+ }, null, 8, ["variant", "label"]),
155
+ l("input", {
156
+ id: "file",
157
+ accept: ".csv",
158
+ class: "hidden",
159
+ type: "file",
160
+ multiple: "",
161
+ onChange: $
162
+ }, null, 32)
163
+ ], 512)
164
+ ])) : (p(), J(s, {
165
+ key: 0,
166
+ onFileUpload: g[0] || (g[0] = (v) => C(v)),
167
+ accept: ".csv, .xlsx",
168
+ "max-file-size": 2e7
169
+ }))
170
+ ])
171
+ ]);
172
+ };
173
+ }
174
+ }), at = { class: "space-y-16 pr-12" }, st = { class: "fm-typo-en-title-md-800" }, lt = { class: "flex space-x-8" }, it = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, rt = { class: "text-fm-color-typo-secondary" }, ct = /* @__PURE__ */ ee({
175
+ __name: "ReviewSegment",
176
+ props: {
177
+ title: {},
178
+ segment: {}
179
+ },
180
+ setup(e) {
181
+ const _ = e, x = [
182
+ {
183
+ header: "Name",
184
+ accessorFn: (a) => a.name
185
+ },
186
+ {
187
+ header: "Id",
188
+ accessorFn: (a) => a._id
189
+ },
190
+ {
191
+ header: "Customer Since",
192
+ accessorFn: (a) => G(Ge(a._id.toString())).format("DD MMM YYYY")
193
+ },
194
+ {
195
+ header: "Phone",
196
+ accessorFn: (a) => a.phoneNumber
197
+ },
198
+ {
199
+ header: "Birthday",
200
+ accessorFn: (a) => G(a.birthday).format("DD MMM YYYY")
201
+ },
202
+ {
203
+ header: "Last Visit",
204
+ accessorFn: (a) => G(a.stats.lastVisit).format("DD MMM YYYY")
205
+ }
206
+ ];
207
+ async function b(a) {
208
+ return _.segment._id ? (console.log(a), await N.paginateSegmentUsers(
209
+ _.segment._id,
210
+ a
211
+ )) : {
212
+ resources: [],
213
+ meta: {
214
+ totalResources: 0,
215
+ totalPages: 0,
216
+ skip: a.skip,
217
+ limit: a.limit,
218
+ sortBy: a.sortBy
219
+ }
220
+ };
221
+ }
222
+ const { tableMeta: m, rowData: y, onSort: f, debouncedFetchData: h, onSearch: i } = we(b);
223
+ return Se(async () => {
224
+ await h();
225
+ }), (a, c) => (p(), k("div", at, [
226
+ l("div", st, D(_.title), 1),
227
+ l("div", lt, [
228
+ l("div", it, D(a.segment.members.length), 1),
229
+ l("div", rt, [
230
+ c[1] || (c[1] = l("div", null, "contacts in your segment", -1)),
231
+ l("div", null, "as of " + D(t(G)(a.segment.lastUpdated).format("DD MMM YYYY")), 1)
232
+ ])
233
+ ]),
234
+ r(Fe, {
235
+ loading: t(m).isLoading,
236
+ "row-data": t(y),
237
+ "row-count": t(m).totalRows,
238
+ "column-defs": x,
239
+ "page-size": t(m).pageSize,
240
+ "page-count": t(m).pageCount,
241
+ "page-index": t(m).pageIndex,
242
+ onSortChange: t(f),
243
+ onPageChange: c[0] || (c[0] = (C) => t(h)({ pageSize: C.pageSize, pageIndex: C.pageIndex }))
244
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
245
+ ]));
246
+ }
247
+ }), dt = { class: "space-y-24" }, ut = { class: "grid grid-cols-2 gap-16" }, pt = { class: "fm-typo-en-title-sm-800" }, mt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ft = /* @__PURE__ */ ee({
248
+ __name: "SegmentTypeOption",
249
+ props: {
250
+ modelValue: {},
251
+ errorText: {}
252
+ },
253
+ emits: ["update:model-value"],
254
+ setup(e, { emit: _ }) {
255
+ const x = e, b = _, m = [
256
+ {
257
+ label: "Dynamic",
258
+ sublabel: "Segment statistics are based on rules configured and will be recalculated automatically when rule changes.",
259
+ value: R.enum.DYNAMIC
260
+ },
261
+ {
262
+ label: "Static",
263
+ sublabel: "Segment statistics are based on imported data and will not be recalculated.",
264
+ value: R.enum.STATIC
265
+ }
266
+ ];
267
+ function y(f) {
268
+ f !== x.modelValue && b("update:model-value", f);
269
+ }
270
+ return (f, h) => {
271
+ const i = F("FmCard"), a = F("FmHelperText");
272
+ return p(), k("div", dt, [
273
+ l("div", ut, [
274
+ (p(), k(O, null, ie(m, (c) => r(i, {
275
+ variant: "outlined",
276
+ class: re(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-2", {
277
+ "col-span-2": m.length == 1,
278
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": f.modelValue === c.value,
279
+ "hover:bg-fm-color-opacity-sm": f.modelValue !== c.value
280
+ }]),
281
+ onClick: (C) => y(c.value),
282
+ key: c.value
283
+ }, {
284
+ default: E(() => [
285
+ l("div", pt, D(c.label), 1),
286
+ l("div", mt, D(c.sublabel), 1)
287
+ ]),
288
+ _: 2
289
+ }, 1032, ["class", "onClick"])), 64))
290
+ ]),
291
+ f.errorText ? (p(), J(a, {
292
+ key: 0,
293
+ class: "!mt-4",
294
+ text: f.errorText,
295
+ state: "error"
296
+ }, null, 8, ["text"])) : le("", !0)
297
+ ]);
298
+ };
299
+ }
300
+ }), yt = { class: "flex items-center gap-x-8" }, gt = {
301
+ key: 0,
302
+ class: "space-y-16 pr-12"
303
+ }, vt = { class: "flex flex-col space-y-16" }, _t = {
304
+ key: 0,
305
+ class: "flex flex-col space-y-16"
306
+ }, xt = {
307
+ key: 1,
308
+ class: "flex flex-col space-y-16"
309
+ }, St = {
310
+ key: 2,
311
+ class: "flex flex-col space-y-16"
312
+ }, wt = { class: "flex items-center gap-8" }, Ft = /* @__PURE__ */ ee({
313
+ __name: "SegmentSheet",
314
+ emits: ["update:model-value"],
315
+ setup(e, { expose: _, emit: x }) {
316
+ const b = Ve(), m = z(!1), y = z(!1), f = {
317
+ name: "",
318
+ isActive: !0,
319
+ type: R.enum.DYNAMIC,
320
+ rule: ge.scaffoldGroup(),
321
+ members: []
322
+ }, h = Ze, i = z(f), a = ce(() => {
323
+ const u = h.safeParse(i.value);
324
+ return u.success ? [] : u.error.errors;
325
+ });
326
+ function c(u) {
327
+ m.value = !0, y.value = !1, u ? i.value = {
328
+ ...u,
329
+ isActive: u.isActive !== !1,
330
+ type: u.type ?? (u.importFile ? R.enum.STATIC : R.enum.DYNAMIC)
331
+ } : i.value = { ...f };
332
+ }
333
+ function C() {
334
+ m.value = !1;
335
+ }
336
+ async function $() {
337
+ h.safeParse(i.value).success && (y.value = !0);
338
+ }
339
+ function S() {
340
+ y.value = !1;
341
+ }
342
+ async function g() {
343
+ i.value.type === R.enum.STATIC ? (i.value.rule = ge.scaffoldGroup(), i.value.isActive = !0) : i.value.file = void 0, M("update:model-value", i.value);
344
+ }
345
+ async function w(u) {
346
+ i.value.type = u;
347
+ }
348
+ Se(async () => {
349
+ });
350
+ const M = x;
351
+ return _({
352
+ showSheet: c,
353
+ hideSheet: C
354
+ }), (u, s) => {
355
+ const v = F("FmButton"), L = F("FmSwitch"), n = F("FmSideSheet");
356
+ return p(), J(n, {
357
+ modelValue: t(m),
358
+ "onUpdate:modelValue": s[8] || (s[8] = (o) => Me(m) ? m.value = o : null),
359
+ header: "Add segment",
360
+ "dismiss-away": "",
361
+ "close-button": !0,
362
+ "max-width": 1100
363
+ }, Ie({
364
+ "side-sheet-footer": E(() => [
365
+ l("div", wt, [
366
+ t(y) || t(i).type === t(R).enum.STATIC ? (p(), k(O, { key: 0 }, [
367
+ r(v, {
368
+ label: "Save Segment",
369
+ onClick: g,
370
+ loading: t(b).isLoading,
371
+ disabled: t(a).length > 0 || t(b).isLoading
372
+ }, null, 8, ["loading", "disabled"]),
373
+ r(v, {
374
+ label: "Cancel",
375
+ onClick: s[6] || (s[6] = (o) => S()),
376
+ variant: "tertiary"
377
+ })
378
+ ], 64)) : (p(), k(O, { key: 1 }, [
379
+ r(v, {
380
+ label: "Review Segment",
381
+ disabled: t(a).length > 0 || t(b).isLoading,
382
+ onClick: $
383
+ }, null, 8, ["disabled"]),
384
+ r(v, {
385
+ label: "Cancel",
386
+ onClick: s[7] || (s[7] = (o) => C()),
387
+ variant: "tertiary"
388
+ })
389
+ ], 64))
390
+ ])
391
+ ]),
392
+ default: E(() => {
393
+ var o;
394
+ return [
395
+ t(y) ? (p(), J(ct, {
396
+ key: 1,
397
+ title: t(i).name,
398
+ segment: t(i)
399
+ }, null, 8, ["title", "segment"])) : (p(), k("div", gt, [
400
+ r(Le, {
401
+ modelValue: t(i).name,
402
+ "onUpdate:modelValue": s[1] || (s[1] = (d) => t(i).name = d),
403
+ label: "Segment title",
404
+ schema: t(Be).typeAtPath(t(h), "name")
405
+ }, null, 8, ["modelValue", "schema"]),
406
+ l("div", vt, [
407
+ s[10] || (s[10] = l("div", { class: "fm-typo-en-title-sm-800" }, "Segment Type", -1)),
408
+ r(ft, {
409
+ "model-value": t(i).type,
410
+ "onUpdate:modelValue": s[2] || (s[2] = (d) => {
411
+ w(d);
412
+ })
413
+ }, null, 8, ["model-value"])
414
+ ]),
415
+ t(i).type === t(R).enum.DYNAMIC ? (p(), k("div", _t, [
416
+ s[11] || (s[11] = l("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
417
+ r(Ue, {
418
+ "trigger-type": "MEMBERSHIP_JOINED",
419
+ includeOnly: "user",
420
+ "model-value": (o = t(i)) == null ? void 0 : o.rule,
421
+ "onUpdate:modelValue": s[3] || (s[3] = (d) => {
422
+ t(i).rule = d;
423
+ })
424
+ }, null, 8, ["model-value"])
425
+ ])) : (p(), k("div", xt, [
426
+ r(nt, {
427
+ importFile: t(i).importFile,
428
+ "onUpdate:file": s[4] || (s[4] = (d) => {
429
+ t(i).file = d;
430
+ })
431
+ }, null, 8, ["importFile"])
432
+ ])),
433
+ t(i).type === t(R).enum.DYNAMIC ? (p(), k("div", St, [
434
+ s[12] || (s[12] = l("div", { class: "fm-typo-en-title-sm-800" }, "Segment Status", -1)),
435
+ r(L, {
436
+ "model-value": t(i).isActive ?? !0,
437
+ "onUpdate:modelValue": s[5] || (s[5] = (d) => t(i).isActive = d),
438
+ label: "Active",
439
+ sublabel: "When enabled, this will recalculate the segment statistics daily.",
440
+ "label-placement": "right"
441
+ }, null, 8, ["model-value"])
442
+ ])) : le("", !0)
443
+ ]))
444
+ ];
445
+ }),
446
+ _: 2
447
+ }, [
448
+ t(y) ? {
449
+ name: "side-sheet-header",
450
+ fn: E(() => [
451
+ l("div", yt, [
452
+ r(v, {
453
+ icon: "arrow_back",
454
+ variant: "tertiary",
455
+ onClick: s[0] || (s[0] = (o) => y.value = !1)
456
+ }),
457
+ s[9] || (s[9] = l("div", null, "Review segment", -1))
458
+ ])
459
+ ]),
460
+ key: "0"
461
+ } : void 0
462
+ ]), 1032, ["modelValue"]);
463
+ };
464
+ }
465
+ }), xe = He(), ht = Ce();
466
+ function se(e) {
467
+ const _ = G(e);
468
+ return _.isValid() ? _.format("DD/MM/YYYY") : "";
469
+ }
470
+ const bt = {
471
+ mapMemberExportRow: (e) => {
472
+ var a, c, C, $, S, g, w, M, u, s, v, L, n, o, d, P, A, B, V, j, q, H, te, I, Q, de, ue, pe;
473
+ const _ = ce(() => ht.locations.map((T) => ({
474
+ label: T.name,
475
+ value: T._id
476
+ }))), x = (a = Pe.parseOneAddress(
477
+ e == null ? void 0 : e.email
478
+ )) != null && a.domain.includes("feedmepos.com") ? void 0 : e.email, b = (C = ((c = e == null ? void 0 : e.collection) == null ? void 0 : c.TITLE) || []) == null ? void 0 : C.reduce(
479
+ (T, U) => {
480
+ var Z, K;
481
+ const W = (K = (Z = xe.sortedTitles) == null ? void 0 : Z.find(
482
+ (oe) => oe._id === U.collectible
483
+ )) == null ? void 0 : K.name;
484
+ return !W || U.balance <= 0 || T.push(W), T;
485
+ },
486
+ []
487
+ ), m = (xe.sortedTitles || []).reduce(
488
+ (T, U) => {
489
+ var Z, K, oe, me;
490
+ const W = (me = (oe = (K = (((Z = e == null ? void 0 : e.collection) == null ? void 0 : Z.TITLE) || []).find(
491
+ (ke) => ke.collectible === U._id
492
+ )) == null ? void 0 : K.expiryBalance) == null ? void 0 : oe[0]) == null ? void 0 : me.expiredAt;
493
+ return T[U.name] = W ? G(W).format("DD/MM/YYYY") : "", T;
494
+ },
495
+ {}
496
+ ), y = ((g = (S = ($ = e.collection) == null ? void 0 : $.CREDIT) == null ? void 0 : S.at(0)) == null ? void 0 : g.balance) || 0, f = ((s = (u = (M = (w = e.collection) == null ? void 0 : w.CREDIT) == null ? void 0 : M.at(0)) == null ? void 0 : u.expiryBalance) == null ? void 0 : s.reduce(
497
+ (T, U) => T + U.amount,
498
+ 0
499
+ )) || 0, h = Je(y, 2);
500
+ return {
501
+ ID: e._id.toString(),
502
+ Name: ((v = e.name) == null ? void 0 : v.trim()) || "",
503
+ Phone: ((L = e == null ? void 0 : e.phoneNumber) == null ? void 0 : L.trim()) || "",
504
+ Email: x || "",
505
+ Gender: e.gender || "",
506
+ CardNo: e.cardNo || "",
507
+ Birthday: e != null && e.birthday ? se(e == null ? void 0 : e.birthday) : "",
508
+ Credit: parseFloat((Number(h) - Number(f)).toFixed(2)),
509
+ FreeCredit: Number(f.toFixed(2)),
510
+ TotalCredit: Number(h),
511
+ Exp: e != null && e.collection ? ((d = (o = (n = e.collection) == null ? void 0 : n.POINT) == null ? void 0 : o.at(0)) == null ? void 0 : d.balance) ?? 0 : 0,
512
+ Point: e != null && e.collection ? ((B = (A = (P = e.collection) == null ? void 0 : P.COIN) == null ? void 0 : A.at(0)) == null ? void 0 : B.balance) ?? 0 : 0,
513
+ Level: e != null && e.collection ? ((q = (j = (V = e.collection) == null ? void 0 : V.TIER) == null ? void 0 : j.at(0)) == null ? void 0 : q.balance) ?? 0 : 0,
514
+ Tier: e != null && e.collection ? ((I = (te = (H = e.collection) == null ? void 0 : H.TIER) == null ? void 0 : te.at(0)) == null ? void 0 : I.balance) ?? 0 : 0,
515
+ Titles: b.join(","),
516
+ ...m,
517
+ TotalTransaction: e.stats.visitCount,
518
+ AvgSpent: Qe(Number(e.stats.avgBillSize || 0)).toFormat(
519
+ !1
520
+ ),
521
+ TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
522
+ LastVisit: se(e.stats.lastVisit),
523
+ Feedback: ((Q = e.stats) == null ? void 0 : Q.feedbackCount) || 0,
524
+ LastSeasonTierEarned: ((de = e.stats) == null ? void 0 : de.lastSeasonTierEarned) || 0,
525
+ LastSeasonPointEarned: ((ue = e.stats) == null ? void 0 : ue.lastSeasonPointEarned) || 0,
526
+ JoinedAt: se(e.joinAt || void 0),
527
+ JoinedAtLocation: e.location && ((pe = _.value.find((T) => T.value == e.location)) == null ? void 0 : pe.label) || "-",
528
+ VisitFrequency: `${Number(
529
+ Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
530
+ )}`
531
+ };
532
+ }
533
+ }, Ct = { class: "flex items-center" }, kt = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Mt = { class: "px-24 flex flex-col gap-y-16" }, It = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Tt = { class: "fm-typo-en-body-md-600" }, Et = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, co = /* @__PURE__ */ ee({
534
+ __name: "Segment",
535
+ setup(e) {
536
+ const { minor: _ } = Ae, { t: x } = he(), b = Ce(), { mapMemberExportRow: m } = bt, y = Re(), f = We(), h = z(0), i = [
537
+ {
538
+ header: x("connect.loyalty.segment.table.name"),
539
+ accessorFn: (n) => n.name
540
+ },
541
+ {
542
+ header: x("connect.loyalty.segment.table.status"),
543
+ enableSorting: !1,
544
+ cell(n) {
545
+ const o = n.row.original.isActive === !1 ? "Inactive" : "Active";
546
+ return Y(X.FmChip, {
547
+ class: n.row.original.isActive === !1 ? "text-fm-color-typo-error bg-fm-color-system-error-100" : "text-fm-color-typo-success bg-fm-color-system-success-100",
548
+ label: o,
549
+ compact: !0
550
+ });
551
+ }
552
+ },
553
+ {
554
+ header: x("connect.loyalty.segment.table.total_customers"),
555
+ accessorFn: (n) => n.memberCount ?? 0
556
+ },
557
+ {
558
+ header: x("connect.loyalty.segment.table.customer_percentage"),
559
+ accessorFn: (n) => ((n.memberCount ?? 0) * 100 / h.value).toFixed(2)
560
+ },
561
+ {
562
+ header: x("connect.loyalty.segment.table.actions"),
563
+ meta: {
564
+ maxWidth: "100px"
565
+ },
566
+ cell(n) {
567
+ return Y("div", { class: "flex items-center justify-end" }, [
568
+ Y(
569
+ X.FmMenu,
570
+ {
571
+ placement: "bottom-end",
572
+ onClick: (o) => {
573
+ o.stopPropagation();
574
+ }
575
+ },
576
+ {
577
+ "menu-button": () => Y(X.FmButton, {
578
+ icon: "more_vert",
579
+ iconColor: "neutral-gray-400",
580
+ variant: "tertiary"
581
+ }),
582
+ default: () => [
583
+ Y(
584
+ X.FmMenuItem,
585
+ {
586
+ onClick: async (o) => {
587
+ o.stopPropagation(), w(n.row.original);
588
+ }
589
+ },
590
+ {
591
+ label: Y(
592
+ "div",
593
+ {
594
+ class: "fm-typo-en-body-md-400"
595
+ },
596
+ "Export"
597
+ )
598
+ }
599
+ ),
600
+ Y(
601
+ X.FmMenuItem,
602
+ {
603
+ onClick: async (o) => {
604
+ o.stopPropagation(), g(n.row.original);
605
+ }
606
+ },
607
+ {
608
+ label: Y(
609
+ "div",
610
+ {
611
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
612
+ },
613
+ "Remove"
614
+ )
615
+ }
616
+ )
617
+ ]
618
+ }
619
+ )
620
+ ]);
621
+ }
622
+ }
623
+ ], a = z(null), { tableMeta: c, rowData: C, debouncedFetchData: $ } = we(
624
+ N.readAll
625
+ );
626
+ async function S() {
627
+ await _(
628
+ async () => {
629
+ await N.refreshSegments(), await $({ pageSize: 10, pageIndex: 0 });
630
+ },
631
+ { message: "Refreshing segmentations" }
632
+ );
633
+ }
634
+ async function g(n) {
635
+ await $e.remove(`Are you sure you want to remove ${n.name}?`) && await _(
636
+ async () => {
637
+ await N.delete(n._id), await $({ pageSize: 10, pageIndex: 0 });
638
+ },
639
+ {
640
+ message: `Removing ${n.name}`,
641
+ successMessage: `Removed ${n.name} successfully`
642
+ }
643
+ );
644
+ }
645
+ async function w(n) {
646
+ const o = {
647
+ sortBy: "_id",
648
+ descending: !1,
649
+ rowsPerPage: 1e3,
650
+ page: 1,
651
+ rowsNumber: 0
652
+ }, d = new Ne(), P = (await ve.read({
653
+ limit: 1,
654
+ skip: 0,
655
+ sortBy: o.sortBy,
656
+ descending: o.descending
657
+ })).meta.totalResources ?? 0, A = o.rowsPerPage;
658
+ await _(
659
+ async () => {
660
+ for (let B = 0; B < P; B += A) {
661
+ const V = {
662
+ ...o,
663
+ limit: A,
664
+ skip: o.page - 1,
665
+ sortBy: o.sortBy,
666
+ descending: o.descending
667
+ }, j = await N.paginateSegmentUsers(
668
+ n._id,
669
+ V
670
+ );
671
+ for (const q of j.resources) {
672
+ const H = m(q);
673
+ d.addRecord(H);
674
+ }
675
+ o.page++;
676
+ }
677
+ await be(
678
+ d.buildExcel(),
679
+ `[${n.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
680
+ {
681
+ bookType: "xlsx",
682
+ bookSST: !1,
683
+ type: "array"
684
+ }
685
+ ), o.page = 1;
686
+ },
687
+ {
688
+ message: "Exporting member...",
689
+ successMessage: "Member exported successfully"
690
+ }
691
+ );
692
+ }
693
+ async function M(n) {
694
+ await _(
695
+ async () => {
696
+ var o;
697
+ if (n.type === R.enum.STATIC) {
698
+ const d = new FormData();
699
+ if (d.append("file", n.file), n._id) {
700
+ const { members: P, _id: A, file: B, ...V } = n;
701
+ d.append("segment", JSON.stringify(V)), await N.updateStatic(n._id, d);
702
+ } else {
703
+ const { file: P, ...A } = n;
704
+ d.append("segment", JSON.stringify(A)), await N.createStatic(d);
705
+ }
706
+ n.file && y.open({
707
+ type: "info",
708
+ title: "Import begins soon. Check Queue for updates.",
709
+ action: "View",
710
+ onAction: async () => {
711
+ await f.push({
712
+ name: _e["$connect-QUEUE"],
713
+ query: { type: [fe.enum.SEGMENTATION_IMPORTED] }
714
+ });
715
+ }
716
+ });
717
+ } else if (n._id) {
718
+ const { members: d, _id: P, ...A } = n;
719
+ await N.update(n._id, A);
720
+ } else
721
+ await N.create(n);
722
+ await $({ pageSize: 10, pageIndex: 0 }), (o = a.value) == null || o.hideSheet();
723
+ },
724
+ {
725
+ message: "Saving segment",
726
+ successMessage: "Segment saved"
727
+ }
728
+ );
729
+ }
730
+ function u(n) {
731
+ var o;
732
+ (o = a.value) == null || o.showSheet(n);
733
+ }
734
+ const s = {
735
+ label: x("connect.navigation.queue"),
736
+ value: "queue",
737
+ isPrimary: !1,
738
+ prependIcon: "work_history"
739
+ }, v = ce(() => b.isPremium ? [
740
+ s,
741
+ {
742
+ label: "Refresh segments",
743
+ value: "refresh",
744
+ prependIcon: "refresh"
745
+ },
746
+ {
747
+ label: "Add segment",
748
+ value: "add",
749
+ isPrimary: !0,
750
+ prependIcon: "add"
751
+ }
752
+ ] : []);
753
+ function L(n) {
754
+ switch (n) {
755
+ case "add":
756
+ u();
757
+ break;
758
+ case "refresh":
759
+ S();
760
+ break;
761
+ case "queue":
762
+ f.push({
763
+ name: _e["$connect-QUEUE"],
764
+ query: { type: [fe.enum.SEGMENTATION_IMPORTED] }
765
+ });
766
+ break;
767
+ }
768
+ }
769
+ return Te(async () => {
770
+ const { meta: n } = await ve.read({
771
+ limit: 1,
772
+ skip: 0,
773
+ sortBy: "_id",
774
+ search: void 0,
775
+ descending: !1
776
+ });
777
+ h.value = n.totalResources ?? 0, await $({ pageSize: 10, pageIndex: 0 }), await b.readPremium(), await b.readLocations();
778
+ }), (n, o) => {
779
+ const d = F("FmPill"), P = F("FmPageHead"), A = F("FmIcon"), B = F("FmMenuItem"), V = F("FmMenu"), j = F("FmListItem"), q = F("FmList"), H = F("FmButton"), te = F("FmCard");
780
+ return p(), k(O, null, [
781
+ r(P, {
782
+ title: "Segments",
783
+ actions: t(v),
784
+ "onClick:action": o[0] || (o[0] = (I) => L(I))
785
+ }, {
786
+ title: E(() => [
787
+ l("div", Ct, [
788
+ l("span", kt, D(t(x)("connect.loyalty.segment.title")), 1),
789
+ r(d, { variant: "premium" })
790
+ ])
791
+ ]),
792
+ _: 1
793
+ }, 8, ["actions"]),
794
+ l("div", Mt, [
795
+ t(C).length > 0 || t(c).searchValue || t(c).isLoading ? (p(), k(O, { key: 0 }, [
796
+ r(Fe, {
797
+ loading: t(c).isLoading,
798
+ "row-data": t(C),
799
+ "row-count": t(c).totalRows,
800
+ "column-defs": i,
801
+ "shrink-at": !1,
802
+ "page-count": t(c).pageCount,
803
+ "page-index": t(c).pageIndex,
804
+ "page-size": t(c).pageSize,
805
+ onRowClick: o[1] || (o[1] = (I) => {
806
+ u(I.original);
807
+ }),
808
+ onPageChange: t($)
809
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
810
+ r(q, { class: "w-full hidden xs:block" }, {
811
+ default: E(() => [
812
+ (p(!0), k(O, null, ie(t(C), (I) => (p(), J(j, {
813
+ key: I._id.toString(),
814
+ tag: "label",
815
+ onClick: (Q) => u(I)
816
+ }, {
817
+ default: E(() => [
818
+ l("div", null, [
819
+ l("div", It, D((I.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
820
+ l("div", Tt, D(I.name), 1),
821
+ l("div", Et, D(((I.memberCount ?? 0) * 100 / t(h)).toFixed(2)) + "% of customers ", 1)
822
+ ])
823
+ ]),
824
+ append: E(() => [
825
+ r(V, { "stop-click-propagation": !0 }, {
826
+ "menu-button": E(() => [
827
+ r(A, { name: "more_vert" })
828
+ ]),
829
+ default: E(() => [
830
+ r(B, {
831
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
832
+ label: "Remove",
833
+ "onUpdate:modelValue": (Q) => Q && g(I)
834
+ }, null, 8, ["onUpdate:modelValue"])
835
+ ]),
836
+ _: 2
837
+ }, 1024)
838
+ ]),
839
+ _: 2
840
+ }, 1032, ["onClick"]))), 128))
841
+ ]),
842
+ _: 1
843
+ })
844
+ ], 64)) : (p(), J(te, {
845
+ key: 1,
846
+ variant: "outlined",
847
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
848
+ }, {
849
+ default: E(() => [
850
+ o[3] || (o[3] = l("img", {
851
+ src: Ee,
852
+ class: "aspect-square w-[150px]"
853
+ }, null, -1)),
854
+ o[4] || (o[4] = l("div", { class: "flex flex-col gap-16 text-center" }, [
855
+ l("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
856
+ l("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. ")
857
+ ], -1)),
858
+ r(H, {
859
+ variant: "primary",
860
+ label: "Create segment",
861
+ disabled: !t(b).isPremium,
862
+ icon: "add",
863
+ onClick: o[2] || (o[2] = (I) => u())
864
+ }, null, 8, ["disabled"])
865
+ ]),
866
+ _: 1
867
+ })),
868
+ r(Ft, {
869
+ ref_key: "sheetRef",
870
+ ref: a,
871
+ "onUpdate:modelValue": M
872
+ }, null, 512)
873
+ ])
874
+ ], 64);
875
+ };
876
+ }
877
+ });
878
+ export {
879
+ co as default
880
+ };