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