@feedmepos/mf-connect 0.1.31-prod → 0.1.32-prod

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-CSyE-O7F.js → Analytic-DRJEtVnN.js} +11 -11
  2. package/dist/{App-CI6T_Ggm.js → App-C1IuGBAJ.js} +6 -6
  3. package/dist/{Bin-D129K0UY.js → Bin-CM9cU-iH.js} +8 -8
  4. package/dist/{Broadcast-1YnrjwTp.js → Broadcast-1Fy8Nob5.js} +9 -9
  5. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CUBa7vmH.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DiAEDcl5.js} +6 -6
  6. package/dist/{Card-DnKxZI51.js → Card-CnuSjjCj.js} +97 -96
  7. package/dist/{Collections-H1k_V_JM.js → Collections-DAj_A1iu.js} +21 -20
  8. package/dist/{Credit-vgVhr8NN.js → Credit-DLH2GYYz.js} +9 -9
  9. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-DdqBz-Sf.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-C4Sy1K8q.js} +29 -28
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-yeZq9E-H.js → EffectSheet.vue_vue_type_style_index_0_lang-D4--kNds.js} +6 -6
  11. package/dist/{Experience-DF0WMhAg.js → Experience-Dgyi4U-L.js} +9 -9
  12. package/dist/FileSaver.min-NlMItPOc.js +74 -0
  13. package/dist/{Game-9aC2CMq1.js → Game-VKYjF7hq.js} +10 -10
  14. package/dist/{Index-raxs8-hT.js → Index-B0BkKPLD.js} +10 -10
  15. package/dist/{Marketing-BhCFLx2Z.js → Marketing-Bzl7m10d.js} +6 -6
  16. package/dist/Member-CDmDoJFr.js +287 -0
  17. package/dist/{MemberList-DLJxPc32.js → MemberList-C4l_Q9y1.js} +38 -37
  18. package/dist/{MemberTransactions-cNPt5lU8.js → MemberTransactions-SUlFwOov.js} +1 -1
  19. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-CLfpoWwi.js → MessageInput.vue_vue_type_script_setup_true_lang-Buj3xx1j.js} +17 -16
  20. package/dist/{Mission-DTqWDFkL.js → Mission-BriLVrc4.js} +88 -93
  21. package/dist/{Overview-Di1RiMiZ.js → Overview-AklJfO0G.js} +64 -63
  22. package/dist/{Point-C7vAdfqf.js → Point-B7VnNPaG.js} +9 -9
  23. package/dist/{Promotion-DwAl2ueC.js → Promotion-hlKzzWJD.js} +10 -10
  24. package/dist/{Queue-Ckh5U2q9.js → Queue-gOxy9cBG.js} +72 -63
  25. package/dist/{Record-CS22Hick.js → Record-BwWXqFv6.js} +17 -16
  26. package/dist/{Reward-ceTGl-6M.js → Reward-JKh-M0oD.js} +15 -15
  27. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-N5HNvabk.js → RewardGroup.vue_vue_type_script_setup_true_lang-DFogiHWh.js} +11 -11
  28. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-Bln0CsrL.js → RuleGroup.vue_vue_type_script_setup_true_lang-CTOfCYsE.js} +15 -14
  29. package/dist/Segment-BlMx0eoR.js +880 -0
  30. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-CdBSrSG-.js → SelectItems.vue_vue_type_script_setup_true_lang-DCsFcqQ5.js} +2 -2
  31. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-3WYVAiVq.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-G01kJeLd.js} +11 -11
  32. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-D5kPXWZM.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-gUoBLfVo.js} +3 -3
  33. package/dist/{Setting-B080_HzI.js → Setting-CoKP6Z-F.js} +43 -42
  34. package/dist/{Store-DTeptzE3.js → Store-CxUagz23.js} +28 -27
  35. package/dist/{StoreRewards-CNrENhoO.js → StoreRewards-CLSQgaNo.js} +13 -13
  36. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-D39kPD0g.js → StoreTransactions.vue_vue_type_script_setup_true_lang-V4rH3vAQ.js} +26 -25
  37. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-YeLylLcx.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DJ7incG7.js} +1 -1
  38. package/dist/{Tier-DCtk62vI.js → Tier-DwTL1xNM.js} +22 -21
  39. package/dist/{Title-WLmc_Sgb.js → Title-DhBL_eYK.js} +19 -19
  40. package/dist/{Transaction-DrZ66hh2.js → Transaction-CRskHsNr.js} +2 -2
  41. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-B934hePK.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-DoE7rDgi.js} +6 -6
  42. package/dist/{Voucher-BWxGUu1r.js → Voucher-CxDqASF5.js} +12 -12
  43. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-Cwm5rKfF.js → VoucherEditor.vue_vue_type_script_setup_true_lang-wkihtNI3.js} +10 -10
  44. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-DgNwerl-.js → ZodTextField.vue_vue_type_script_setup_true_lang-BeLTXjOv.js} +1 -1
  45. package/dist/{app-CD95Y8ID.js → app-CTFwjMxq.js} +1 -1
  46. package/dist/{app-DXDpfEp1.js → app-QgT2HXjv.js} +34 -30
  47. package/dist/app.js +1 -1
  48. package/dist/{business-BMmMPKlg.js → business-DhCzKu3V.js} +1 -1
  49. package/dist/{campaign-CXiUdGVH.js → campaign-CFggCOe6.js} +9 -9
  50. package/dist/{campaign-DsHXtfeO.js → campaign-DAgovrbX.js} +2 -2
  51. package/dist/{campaign.enum-BmZUaKGr.js → campaign.enum-pZr63pXN.js} +1 -1
  52. package/dist/{campaign.fn-0yxgF1-s.js → campaign.fn-CM_t1wNu.js} +70 -70
  53. package/dist/{collectible.enum-CkHgwpV8.js → collectible.enum-fbWiJ-v2.js} +1 -1
  54. package/dist/{collection.fn-BEL2ePbu.js → collection.fn-BrbSJ0dj.js} +2 -2
  55. package/dist/{dto-C9i038zS.js → dto-BcLrcoo_.js} +12 -12
  56. package/dist/{effect-hnRcV89q.js → effect-WVUo2VX0.js} +1 -1
  57. package/dist/{email-addresses-B3aOGn9Q.js → email-addresses-B8YBttOp.js} +1 -1
  58. package/dist/{export-DhXPjZn4.js → export-FilTnKIf.js} +3 -3
  59. package/dist/{helper-B91UqTPy.js → helper-A-JE89j8.js} +1 -1
  60. package/dist/{index-CaQznIQx.js → index-BPCfLPV5.js} +1 -1
  61. package/dist/{index-DdkPyb-X.js → index-BSavh-ab.js} +3 -3
  62. package/dist/{index-BpiC24Lh.js → index-C1vwtNMj.js} +6 -6
  63. package/dist/{index-DRolGtez.js → index-CK_9lnGD.js} +3 -3
  64. package/dist/{index-DUESWqjo.js → index-CX4Q-ODj.js} +1 -1
  65. package/dist/{index-MTD1KXCx.js → index-CyqffI0r.js} +1 -1
  66. package/dist/{index-DwUvEDm8.js → index-CzH8ux-h.js} +2 -2
  67. package/dist/{index-CkB8qWx9.js → index-CzbdA0d3.js} +1 -1
  68. package/dist/{plugins-CA83RlbH.js → index-DFS6jDHm.js} +3784 -3989
  69. package/dist/{index-Dk0fL4Um.js → index-DI956UFg.js} +1 -1
  70. package/dist/{index-h-U0YoGx.js → index-DvM-OpLR.js} +469 -456
  71. package/dist/{index-mWR-Io8r.js → index-FsTLGrIL.js} +1 -1
  72. package/dist/{index-Bv_q5cPS.js → index-OehNKdCW.js} +1 -1
  73. package/dist/{index.esm2017-DvR1i10j.js → index.esm2017-CScWJGpE.js} +1 -1
  74. package/dist/{loading-CYFHRqwc.js → loading-CXZ39_xw.js} +1 -1
  75. package/dist/{membership-t5YCs8vf.js → membership-Bg_pBT1C.js} +54 -48
  76. package/dist/{money-u692Iuhj.js → money-D4vhiGvs.js} +1 -1
  77. package/dist/{number-BFoRQ3UV.js → number-p3U-wKsr.js} +1 -1
  78. package/dist/{objectid-ySkduRSJ.js → objectid-C_k8DXMk.js} +4 -4
  79. package/dist/plugins-BzCgGFW_.js +208 -0
  80. package/dist/{reward-BxAjgaY0.js → reward-DL7dVgek.js} +1 -1
  81. package/dist/{rule-builder-D3z1ZTIu.js → rule-builder-DZEGo8FL.js} +1 -1
  82. package/dist/{rule-B2-KiDax.js → rule-iUlMzG59.js} +3 -3
  83. package/dist/{template-Ep0uKJmD.js → template-FZF9V1B2.js} +4 -4
  84. package/dist/{trigger-i6Qv7Nko.js → trigger-woPb5C0Z.js} +4 -4
  85. package/dist/{user-bkYeGrIH.js → user-CoOoRDFP.js} +1 -1
  86. package/dist/{vue-i18n-2yeRgkZ7.js → vue-i18n-5r8XYctA.js} +251 -251
  87. package/dist/{xlsx-DIyBpsUe.js → xlsx-Cx714TFU.js} +1 -1
  88. package/package.json +1 -1
  89. package/dist/Member-ej-Yvlr1.js +0 -348
  90. package/dist/Segment-CT4UwYMZ.js +0 -578
@@ -0,0 +1,880 @@
1
+ import { defineComponent as ee, ref as z, resolveComponent as w, openBlock as p, createElementBlock as k, createVNode as i, unref as t, createCommentVNode as le, createElementVNode as s, withCtx as E, Fragment as O, renderList as ie, createBlock as J, toDisplayString as D, normalizeClass as re, onMounted as xe, 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-BzCgGFW_.js";
4
+ import { u as Ae } from "./loading-CXZ39_xw.js";
5
+ import { FmButtonVariant as ae, useSnackbar as Re, components as X } from "@feedmepos/ui-library";
6
+ import { u as Se, _ as we } from "./usePagination-JoYaROkV.js";
7
+ import { u as Fe } from "./vue-i18n-5r8XYctA.js";
8
+ import { i as De, j as R, c as fe } from "./index-DvM-OpLR.js";
9
+ import "./index-CzH8ux-h.js";
10
+ import "./index-C1vwtNMj.js";
11
+ import "./index-CzbdA0d3.js";
12
+ import "./index-CK_9lnGD.js";
13
+ import { u as ne, w as be } from "./xlsx-Cx714TFU.js";
14
+ import { e as Pe, M as Ne } from "./email-addresses-B8YBttOp.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-DFS6jDHm.js";
18
+ import { R as ge } from "./rule-builder-DZEGo8FL.js";
19
+ import { _ as Le } from "./ZodTextField.vue_vue_type_script_setup_true_lang-BeLTXjOv.js";
20
+ import { _ as Ue } from "./RuleGroup.vue_vue_type_script_setup_true_lang-CTOfCYsE.js";
21
+ import { u as ze, v as Oe, w as je } from "./index.esm2017-CScWJGpE.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-Bg_pBT1C.js";
25
+ import { o as Ge } from "./objectId-dwaoBfJX.js";
26
+ import { u as Ce } from "./business-DhCzKu3V.js";
27
+ import { f as Je } from "./number-p3U-wKsr.js";
28
+ import { t as Qe } from "./money-D4vhiGvs.js";
29
+ import "./index-CyqffI0r.js";
30
+ import { useRouter as We } from "vue-router";
31
+ import { m as ve } from "./index-FsTLGrIL.js";
32
+ import { R as _e } from "./app-QgT2HXjv.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 = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Upload File", -1), et = {
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
+ }, tt = { class: "flex justify-end" }, ot = {
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
+ }, at = { 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: v }) {
59
+ const _ = e, b = v, { t: m } = Fe(), y = z(null), f = z(null), F = ["Id"], l = [
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 n() {
72
+ if (_.importFile)
73
+ try {
74
+ const h = ze(), x = Oe(h, _.importFile), S = await je(x);
75
+ window.open(S, "_blank");
76
+ } catch (h) {
77
+ console.log(h);
78
+ }
79
+ }
80
+ async function c(h) {
81
+ switch (h) {
82
+ case "csv":
83
+ const x = new Blob([F.join(",")], {
84
+ type: "text/csv;charset=utf-8;"
85
+ });
86
+ qe.saveAs(x, "ImportSegmentTemplate.csv");
87
+ break;
88
+ case "xlsx":
89
+ const S = ne.aoa_to_sheet([F]), M = ne.book_new();
90
+ ne.book_append_sheet(M, S, "Sheet1"), be(M, "ImportSegmentTemplate.xlsx");
91
+ break;
92
+ }
93
+ }
94
+ function C(h) {
95
+ y.value = h, b("update:file", y.value);
96
+ }
97
+ function $(h) {
98
+ var S, M;
99
+ const x = ((M = (S = h.target) == null ? void 0 : S.files) == null ? void 0 : M[0]) ?? null;
100
+ C(x);
101
+ }
102
+ return (h, x) => {
103
+ const S = w("FmButton"), M = w("FmMenuItem"), u = w("FmMenu"), r = w("FmDropField");
104
+ return p(), k("div", Ke, [
105
+ Xe,
106
+ h.importFile ? (p(), k("div", et, [
107
+ i(S, {
108
+ label: t(m)("View uploaded file"),
109
+ variant: t(ae).Plain,
110
+ icon: "file_present",
111
+ onClick: n
112
+ }, null, 8, ["label", "variant"])
113
+ ])) : le("", !0),
114
+ s("div", null, [
115
+ s("div", tt, [
116
+ i(u, { class: "" }, {
117
+ "menu-button": E(() => [
118
+ i(S, {
119
+ variant: "tertiary",
120
+ icon: "download",
121
+ label: "Download Template"
122
+ })
123
+ ]),
124
+ default: E(() => [
125
+ (p(), k(O, null, ie(l, (g) => i(M, {
126
+ key: g.value,
127
+ icon: g.icon,
128
+ label: g.label,
129
+ onClick: (L) => c(g.value),
130
+ selectable: ""
131
+ }, null, 8, ["icon", "label", "onClick"])), 64))
132
+ ]),
133
+ _: 1
134
+ })
135
+ ]),
136
+ y.value ? (p(), k("div", ot, [
137
+ i(S, {
138
+ variant: t(ae).Tertiary,
139
+ "prepend-icon": "attach_file"
140
+ }, null, 8, ["variant"]),
141
+ s("p", at, D(y.value.name), 1),
142
+ s("label", {
143
+ ref_key: "fileLabelRef",
144
+ ref: f,
145
+ htmlFor: "file"
146
+ }, [
147
+ i(S, {
148
+ variant: t(ae).Plain,
149
+ label: t(m)("Replace File"),
150
+ onClick: x[1] || (x[1] = () => {
151
+ var g;
152
+ return (g = f.value) == null ? void 0 : g.click();
153
+ })
154
+ }, null, 8, ["variant", "label"]),
155
+ s("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(r, {
165
+ key: 0,
166
+ onFileUpload: x[0] || (x[0] = (g) => C(g)),
167
+ accept: ".csv, .xlsx",
168
+ "max-file-size": 2e7
169
+ }))
170
+ ])
171
+ ]);
172
+ };
173
+ }
174
+ }), st = { class: "space-y-16 pr-12" }, lt = { class: "fm-typo-en-title-md-800" }, it = { class: "flex space-x-8" }, rt = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, ct = { class: "text-fm-color-typo-secondary" }, dt = /* @__PURE__ */ s("div", null, "contacts in your segment", -1), ut = /* @__PURE__ */ ee({
175
+ __name: "ReviewSegment",
176
+ props: {
177
+ title: {},
178
+ segment: {}
179
+ },
180
+ setup(e) {
181
+ const v = e, _ = [
182
+ {
183
+ header: "Name",
184
+ accessorFn: (n) => n.name
185
+ },
186
+ {
187
+ header: "Id",
188
+ accessorFn: (n) => n._id
189
+ },
190
+ {
191
+ header: "Customer Since",
192
+ accessorFn: (n) => G(Ge(n._id.toString())).format("DD MMM YYYY")
193
+ },
194
+ {
195
+ header: "Phone",
196
+ accessorFn: (n) => n.phoneNumber
197
+ },
198
+ {
199
+ header: "Birthday",
200
+ accessorFn: (n) => G(n.birthday).format("DD MMM YYYY")
201
+ },
202
+ {
203
+ header: "Last Visit",
204
+ accessorFn: (n) => G(n.stats.lastVisit).format("DD MMM YYYY")
205
+ }
206
+ ];
207
+ async function b(n) {
208
+ return v.segment._id ? (console.log(n), await N.paginateSegmentUsers(
209
+ v.segment._id,
210
+ n
211
+ )) : {
212
+ resources: [],
213
+ meta: {
214
+ totalResources: 0,
215
+ totalPages: 0,
216
+ skip: n.skip,
217
+ limit: n.limit,
218
+ sortBy: n.sortBy
219
+ }
220
+ };
221
+ }
222
+ const { tableMeta: m, rowData: y, onSort: f, debouncedFetchData: F, onSearch: l } = Se(b);
223
+ return xe(async () => {
224
+ await F();
225
+ }), (n, c) => (p(), k("div", st, [
226
+ s("div", lt, D(v.title), 1),
227
+ s("div", it, [
228
+ s("div", rt, D(n.segment.members.length), 1),
229
+ s("div", ct, [
230
+ dt,
231
+ s("div", null, "as of " + D(t(G)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
232
+ ])
233
+ ]),
234
+ i(we, {
235
+ loading: t(m).isLoading,
236
+ "row-data": t(y),
237
+ "row-count": t(m).totalRows,
238
+ "column-defs": _,
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(F)({ pageSize: C.pageSize, pageIndex: C.pageIndex }))
244
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
245
+ ]));
246
+ }
247
+ }), pt = { class: "space-y-24" }, mt = { class: "grid grid-cols-2 gap-16" }, ft = { class: "fm-typo-en-title-sm-800" }, yt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, gt = /* @__PURE__ */ ee({
248
+ __name: "SegmentTypeOption",
249
+ props: {
250
+ modelValue: {},
251
+ errorText: {}
252
+ },
253
+ emits: ["update:model-value"],
254
+ setup(e, { emit: v }) {
255
+ const _ = e, b = v, 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 !== _.modelValue && b("update:model-value", f);
269
+ }
270
+ return (f, F) => {
271
+ const l = w("FmCard"), n = w("FmHelperText");
272
+ return p(), k("div", pt, [
273
+ s("div", mt, [
274
+ (p(), k(O, null, ie(m, (c) => i(l, {
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
+ s("div", ft, D(c.label), 1),
286
+ s("div", yt, D(c.sublabel), 1)
287
+ ]),
288
+ _: 2
289
+ }, 1032, ["class", "onClick"])), 64))
290
+ ]),
291
+ f.errorText ? (p(), J(n, {
292
+ key: 0,
293
+ class: "!mt-4",
294
+ text: f.errorText,
295
+ state: "error"
296
+ }, null, 8, ["text"])) : le("", !0)
297
+ ]);
298
+ };
299
+ }
300
+ }), vt = { class: "flex items-center gap-x-8" }, _t = /* @__PURE__ */ s("div", null, "Review segment", -1), ht = {
301
+ key: 0,
302
+ class: "space-y-16 pr-12"
303
+ }, xt = { class: "flex flex-col space-y-16" }, St = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Type", -1), wt = {
304
+ key: 0,
305
+ class: "flex flex-col space-y-16"
306
+ }, Ft = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1), bt = {
307
+ key: 1,
308
+ class: "flex flex-col space-y-16"
309
+ }, Ct = {
310
+ key: 2,
311
+ class: "flex flex-col space-y-16"
312
+ }, kt = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Status", -1), Mt = { class: "flex items-center gap-8" }, It = /* @__PURE__ */ ee({
313
+ __name: "SegmentSheet",
314
+ emits: ["update:model-value"],
315
+ setup(e, { expose: v, emit: _ }) {
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
+ }, F = Ze, l = z(f), n = ce(() => {
323
+ const u = F.safeParse(l.value);
324
+ return u.success ? [] : u.error.errors;
325
+ });
326
+ function c(u) {
327
+ m.value = !0, y.value = !1, u ? l.value = {
328
+ ...u,
329
+ isActive: u.isActive !== !1,
330
+ type: u.type ?? (u.importFile ? R.enum.STATIC : R.enum.DYNAMIC)
331
+ } : l.value = { ...f };
332
+ }
333
+ function C() {
334
+ m.value = !1;
335
+ }
336
+ async function $() {
337
+ F.safeParse(l.value).success && (y.value = !0);
338
+ }
339
+ function h() {
340
+ y.value = !1;
341
+ }
342
+ async function x() {
343
+ l.value.type === R.enum.STATIC ? (l.value.rule = ge.scaffoldGroup(), l.value.isActive = !0) : l.value.file = void 0, M("update:model-value", l.value);
344
+ }
345
+ async function S(u) {
346
+ l.value.type = u;
347
+ }
348
+ xe(async () => {
349
+ });
350
+ const M = _;
351
+ return v({
352
+ showSheet: c,
353
+ hideSheet: C
354
+ }), (u, r) => {
355
+ const g = w("FmButton"), L = w("FmSwitch"), o = w("FmSideSheet");
356
+ return p(), J(o, {
357
+ modelValue: t(m),
358
+ "onUpdate:modelValue": r[8] || (r[8] = (a) => Me(m) ? m.value = a : null),
359
+ header: "Add segment",
360
+ "dismiss-away": "",
361
+ "close-button": !0,
362
+ "max-width": 1100
363
+ }, Ie({
364
+ "side-sheet-footer": E(() => [
365
+ s("div", Mt, [
366
+ t(y) || t(l).type === t(R).enum.STATIC ? (p(), k(O, { key: 0 }, [
367
+ i(g, {
368
+ label: "Save Segment",
369
+ onClick: x,
370
+ loading: t(b).isLoading,
371
+ disabled: t(n).length > 0 || t(b).isLoading
372
+ }, null, 8, ["loading", "disabled"]),
373
+ i(g, {
374
+ label: "Cancel",
375
+ onClick: r[6] || (r[6] = (a) => h()),
376
+ variant: "tertiary"
377
+ })
378
+ ], 64)) : (p(), k(O, { key: 1 }, [
379
+ i(g, {
380
+ label: "Review Segment",
381
+ disabled: t(n).length > 0 || t(b).isLoading,
382
+ onClick: $
383
+ }, null, 8, ["disabled"]),
384
+ i(g, {
385
+ label: "Cancel",
386
+ onClick: r[7] || (r[7] = (a) => C()),
387
+ variant: "tertiary"
388
+ })
389
+ ], 64))
390
+ ])
391
+ ]),
392
+ default: E(() => {
393
+ var a;
394
+ return [
395
+ t(y) ? (p(), J(ut, {
396
+ key: 1,
397
+ title: t(l).name,
398
+ segment: t(l)
399
+ }, null, 8, ["title", "segment"])) : (p(), k("div", ht, [
400
+ i(Le, {
401
+ modelValue: t(l).name,
402
+ "onUpdate:modelValue": r[1] || (r[1] = (d) => t(l).name = d),
403
+ label: "Segment title",
404
+ schema: t(Be).typeAtPath(t(F), "name")
405
+ }, null, 8, ["modelValue", "schema"]),
406
+ s("div", xt, [
407
+ St,
408
+ i(gt, {
409
+ "model-value": t(l).type,
410
+ "onUpdate:modelValue": r[2] || (r[2] = (d) => {
411
+ S(d);
412
+ })
413
+ }, null, 8, ["model-value"])
414
+ ]),
415
+ t(l).type === t(R).enum.DYNAMIC ? (p(), k("div", wt, [
416
+ Ft,
417
+ i(Ue, {
418
+ "trigger-type": "MEMBERSHIP_JOINED",
419
+ includeOnly: "user",
420
+ "model-value": (a = t(l)) == null ? void 0 : a.rule,
421
+ "onUpdate:modelValue": r[3] || (r[3] = (d) => {
422
+ t(l).rule = d;
423
+ })
424
+ }, null, 8, ["model-value"])
425
+ ])) : (p(), k("div", bt, [
426
+ i(nt, {
427
+ importFile: t(l).importFile,
428
+ "onUpdate:file": r[4] || (r[4] = (d) => {
429
+ t(l).file = d;
430
+ })
431
+ }, null, 8, ["importFile"])
432
+ ])),
433
+ t(l).type === t(R).enum.DYNAMIC ? (p(), k("div", Ct, [
434
+ kt,
435
+ i(L, {
436
+ "model-value": t(l).isActive ?? !0,
437
+ "onUpdate:modelValue": r[5] || (r[5] = (d) => t(l).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
+ s("div", vt, [
452
+ i(g, {
453
+ icon: "arrow_back",
454
+ variant: "tertiary",
455
+ onClick: r[0] || (r[0] = (a) => y.value = !1)
456
+ }),
457
+ _t
458
+ ])
459
+ ]),
460
+ key: "0"
461
+ } : void 0
462
+ ]), 1032, ["modelValue"]);
463
+ };
464
+ }
465
+ }), he = He(), Tt = Ce();
466
+ function se(e) {
467
+ const v = G(e);
468
+ return v.isValid() ? v.format("DD/MM/YYYY") : "";
469
+ }
470
+ const Et = {
471
+ mapMemberExportRow: (e) => {
472
+ var n, c, C, $, h, x, S, M, u, r, g, L, o, a, d, P, A, B, V, j, q, H, te, I, Q, de, ue, pe;
473
+ const v = ce(() => Tt.locations.map((T) => ({
474
+ label: T.name,
475
+ value: T._id
476
+ }))), _ = (n = Pe.parseOneAddress(
477
+ e == null ? void 0 : e.email
478
+ )) != null && n.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 = he.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 = (he.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 = ((x = (h = ($ = e.collection) == null ? void 0 : $.CREDIT) == null ? void 0 : h.at(0)) == null ? void 0 : x.balance) || 0, f = ((r = (u = (M = (S = e.collection) == null ? void 0 : S.CREDIT) == null ? void 0 : M.at(0)) == null ? void 0 : u.expiryBalance) == null ? void 0 : r.reduce(
497
+ (T, U) => T + U.amount,
498
+ 0
499
+ )) || 0, F = Je(y, 2);
500
+ return {
501
+ ID: e._id.toString(),
502
+ Name: ((g = e.name) == null ? void 0 : g.trim()) || "",
503
+ Phone: ((L = e == null ? void 0 : e.phoneNumber) == null ? void 0 : L.trim()) || "",
504
+ Email: _ || "",
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(F) - Number(f)).toFixed(2)),
509
+ FreeCredit: Number(f.toFixed(2)),
510
+ TotalCredit: Number(F),
511
+ Exp: e != null && e.collection ? ((d = (a = (o = e.collection) == null ? void 0 : o.POINT) == null ? void 0 : a.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 = v.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
+ }, $t = { class: "flex items-center" }, At = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Rt = { class: "px-24 flex flex-col gap-y-16" }, Dt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Pt = { class: "fm-typo-en-body-md-600" }, Nt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Bt = /* @__PURE__ */ s("img", {
534
+ src: Ee,
535
+ class: "aspect-square w-[150px]"
536
+ }, null, -1), Vt = /* @__PURE__ */ s("div", { class: "flex flex-col gap-16 text-center" }, [
537
+ /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
538
+ /* @__PURE__ */ 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. ")
539
+ ], -1), _o = /* @__PURE__ */ ee({
540
+ __name: "Segment",
541
+ setup(e) {
542
+ const { minor: v } = Ae, { t: _ } = Fe(), b = Ce(), { mapMemberExportRow: m } = Et, y = Re(), f = We(), F = z(0), l = [
543
+ {
544
+ header: _("connect.loyalty.segment.table.name"),
545
+ accessorFn: (o) => o.name
546
+ },
547
+ {
548
+ header: _("connect.loyalty.segment.table.status"),
549
+ enableSorting: !1,
550
+ cell(o) {
551
+ const a = o.row.original.isActive === !1 ? "Inactive" : "Active";
552
+ return Y(X.FmChip, {
553
+ class: o.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",
554
+ label: a,
555
+ compact: !0
556
+ });
557
+ }
558
+ },
559
+ {
560
+ header: _("connect.loyalty.segment.table.total_customers"),
561
+ accessorFn: (o) => o.memberCount ?? 0
562
+ },
563
+ {
564
+ header: _("connect.loyalty.segment.table.customer_percentage"),
565
+ accessorFn: (o) => ((o.memberCount ?? 0) * 100 / F.value).toFixed(2)
566
+ },
567
+ {
568
+ header: _("connect.loyalty.segment.table.actions"),
569
+ meta: {
570
+ maxWidth: "100px"
571
+ },
572
+ cell(o) {
573
+ return Y("div", { class: "flex items-center justify-end" }, [
574
+ Y(
575
+ X.FmMenu,
576
+ {
577
+ placement: "bottom-end",
578
+ onClick: (a) => {
579
+ a.stopPropagation();
580
+ }
581
+ },
582
+ {
583
+ "menu-button": () => Y(X.FmButton, {
584
+ icon: "more_vert",
585
+ iconColor: "neutral-gray-400",
586
+ variant: "tertiary"
587
+ }),
588
+ default: () => [
589
+ Y(
590
+ X.FmMenuItem,
591
+ {
592
+ onClick: async (a) => {
593
+ a.stopPropagation(), S(o.row.original);
594
+ }
595
+ },
596
+ {
597
+ label: Y(
598
+ "div",
599
+ {
600
+ class: "fm-typo-en-body-md-400"
601
+ },
602
+ "Export"
603
+ )
604
+ }
605
+ ),
606
+ Y(
607
+ X.FmMenuItem,
608
+ {
609
+ onClick: async (a) => {
610
+ a.stopPropagation(), x(o.row.original);
611
+ }
612
+ },
613
+ {
614
+ label: Y(
615
+ "div",
616
+ {
617
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
618
+ },
619
+ "Remove"
620
+ )
621
+ }
622
+ )
623
+ ]
624
+ }
625
+ )
626
+ ]);
627
+ }
628
+ }
629
+ ], n = z(null), { tableMeta: c, rowData: C, debouncedFetchData: $ } = Se(
630
+ N.readAll
631
+ );
632
+ async function h() {
633
+ await v(
634
+ async () => {
635
+ await N.refreshSegments(), await $({ pageSize: 10, pageIndex: 0 });
636
+ },
637
+ { message: "Refreshing segmentations" }
638
+ );
639
+ }
640
+ async function x(o) {
641
+ await $e.remove(`Are you sure you want to remove ${o.name}?`) && await v(
642
+ async () => {
643
+ await N.delete(o._id), await $({ pageSize: 10, pageIndex: 0 });
644
+ },
645
+ {
646
+ message: `Removing ${o.name}`,
647
+ successMessage: `Removed ${o.name} successfully`
648
+ }
649
+ );
650
+ }
651
+ async function S(o) {
652
+ const a = {
653
+ sortBy: "_id",
654
+ descending: !1,
655
+ rowsPerPage: 1e3,
656
+ page: 1,
657
+ rowsNumber: 0
658
+ }, d = new Ne(), P = (await ve.read({
659
+ limit: 1,
660
+ skip: 0,
661
+ sortBy: a.sortBy,
662
+ descending: a.descending
663
+ })).meta.totalResources ?? 0, A = a.rowsPerPage;
664
+ await v(
665
+ async () => {
666
+ for (let B = 0; B < P; B += A) {
667
+ const V = {
668
+ ...a,
669
+ limit: A,
670
+ skip: a.page - 1,
671
+ sortBy: a.sortBy,
672
+ descending: a.descending
673
+ }, j = await N.paginateSegmentUsers(
674
+ o._id,
675
+ V
676
+ );
677
+ for (const q of j.resources) {
678
+ const H = m(q);
679
+ d.addRecord(H);
680
+ }
681
+ a.page++;
682
+ }
683
+ await be(
684
+ d.buildExcel(),
685
+ `[${o.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
686
+ {
687
+ bookType: "xlsx",
688
+ bookSST: !1,
689
+ type: "array"
690
+ }
691
+ ), a.page = 1;
692
+ },
693
+ {
694
+ message: "Exporting member...",
695
+ successMessage: "Member exported successfully"
696
+ }
697
+ );
698
+ }
699
+ async function M(o) {
700
+ await v(
701
+ async () => {
702
+ var a;
703
+ if (o.type === R.enum.STATIC) {
704
+ const d = new FormData();
705
+ if (d.append("file", o.file), o._id) {
706
+ const { members: P, _id: A, file: B, ...V } = o;
707
+ d.append("segment", JSON.stringify(V)), await N.updateStatic(o._id, d);
708
+ } else {
709
+ const { file: P, ...A } = o;
710
+ d.append("segment", JSON.stringify(A)), await N.createStatic(d);
711
+ }
712
+ o.file && y.open({
713
+ type: "info",
714
+ title: "Import begins soon. Check Queue for updates.",
715
+ action: "View",
716
+ onAction: async () => {
717
+ await f.push({
718
+ name: _e["$connect-QUEUE"],
719
+ query: { type: [fe.enum.SEGMENTATION_IMPORTED] }
720
+ });
721
+ }
722
+ });
723
+ } else if (o._id) {
724
+ const { members: d, _id: P, ...A } = o;
725
+ await N.update(o._id, A);
726
+ } else
727
+ await N.create(o);
728
+ await $({ pageSize: 10, pageIndex: 0 }), (a = n.value) == null || a.hideSheet();
729
+ },
730
+ {
731
+ message: "Saving segment",
732
+ successMessage: "Segment saved"
733
+ }
734
+ );
735
+ }
736
+ function u(o) {
737
+ var a;
738
+ (a = n.value) == null || a.showSheet(o);
739
+ }
740
+ const r = {
741
+ label: _("connect.navigation.queue"),
742
+ value: "queue",
743
+ isPrimary: !1,
744
+ prependIcon: "work_history"
745
+ }, g = ce(() => b.isPremium ? [
746
+ r,
747
+ {
748
+ label: "Refresh segments",
749
+ value: "refresh",
750
+ prependIcon: "refresh"
751
+ },
752
+ {
753
+ label: "Add segment",
754
+ value: "add",
755
+ isPrimary: !0,
756
+ prependIcon: "add"
757
+ }
758
+ ] : []);
759
+ function L(o) {
760
+ switch (o) {
761
+ case "add":
762
+ u();
763
+ break;
764
+ case "refresh":
765
+ h();
766
+ break;
767
+ case "queue":
768
+ f.push({
769
+ name: _e["$connect-QUEUE"],
770
+ query: { type: [fe.enum.SEGMENTATION_IMPORTED] }
771
+ });
772
+ break;
773
+ }
774
+ }
775
+ return Te(async () => {
776
+ const { meta: o } = await ve.read({
777
+ limit: 1,
778
+ skip: 0,
779
+ sortBy: "_id",
780
+ search: void 0,
781
+ descending: !1
782
+ });
783
+ F.value = o.totalResources ?? 0, await $({ pageSize: 10, pageIndex: 0 }), await b.readPremium(), await b.readLocations();
784
+ }), (o, a) => {
785
+ const d = w("FmPill"), P = w("FmPageHead"), A = w("FmIcon"), B = w("FmMenuItem"), V = w("FmMenu"), j = w("FmListItem"), q = w("FmList"), H = w("FmButton"), te = w("FmCard");
786
+ return p(), k(O, null, [
787
+ i(P, {
788
+ title: "Segments",
789
+ actions: t(g),
790
+ "onClick:action": a[0] || (a[0] = (I) => L(I))
791
+ }, {
792
+ title: E(() => [
793
+ s("div", $t, [
794
+ s("span", At, D(t(_)("connect.loyalty.segment.title")), 1),
795
+ i(d, { variant: "premium" })
796
+ ])
797
+ ]),
798
+ _: 1
799
+ }, 8, ["actions"]),
800
+ s("div", Rt, [
801
+ t(C).length > 0 || t(c).searchValue || t(c).isLoading ? (p(), k(O, { key: 0 }, [
802
+ i(we, {
803
+ loading: t(c).isLoading,
804
+ "row-data": t(C),
805
+ "row-count": t(c).totalRows,
806
+ "column-defs": l,
807
+ "shrink-at": !1,
808
+ "page-count": t(c).pageCount,
809
+ "page-index": t(c).pageIndex,
810
+ "page-size": t(c).pageSize,
811
+ onRowClick: a[1] || (a[1] = (I) => {
812
+ u(I.original);
813
+ }),
814
+ onPageChange: t($)
815
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
816
+ i(q, { class: "w-full hidden xs:block" }, {
817
+ default: E(() => [
818
+ (p(!0), k(O, null, ie(t(C), (I) => (p(), J(j, {
819
+ key: I._id.toString(),
820
+ tag: "label",
821
+ onClick: (Q) => u(I)
822
+ }, {
823
+ default: E(() => [
824
+ s("div", null, [
825
+ s("div", Dt, D((I.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
826
+ s("div", Pt, D(I.name), 1),
827
+ s("div", Nt, D(((I.memberCount ?? 0) * 100 / t(F)).toFixed(2)) + "% of customers ", 1)
828
+ ])
829
+ ]),
830
+ append: E(() => [
831
+ i(V, { "stop-click-propagation": !0 }, {
832
+ "menu-button": E(() => [
833
+ i(A, { name: "more_vert" })
834
+ ]),
835
+ default: E(() => [
836
+ i(B, {
837
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
838
+ label: "Remove",
839
+ "onUpdate:modelValue": (Q) => Q && x(I)
840
+ }, null, 8, ["onUpdate:modelValue"])
841
+ ]),
842
+ _: 2
843
+ }, 1024)
844
+ ]),
845
+ _: 2
846
+ }, 1032, ["onClick"]))), 128))
847
+ ]),
848
+ _: 1
849
+ })
850
+ ], 64)) : (p(), J(te, {
851
+ key: 1,
852
+ variant: "outlined",
853
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
854
+ }, {
855
+ default: E(() => [
856
+ Bt,
857
+ Vt,
858
+ i(H, {
859
+ variant: "primary",
860
+ label: "Create segment",
861
+ disabled: !t(b).isPremium,
862
+ icon: "add",
863
+ onClick: a[2] || (a[2] = (I) => u())
864
+ }, null, 8, ["disabled"])
865
+ ]),
866
+ _: 1
867
+ })),
868
+ i(It, {
869
+ ref_key: "sheetRef",
870
+ ref: n,
871
+ "onUpdate:modelValue": M
872
+ }, null, 512)
873
+ ])
874
+ ], 64);
875
+ };
876
+ }
877
+ });
878
+ export {
879
+ _o as default
880
+ };