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

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