@feedmepos/mf-connect 0.1.91-prod → 0.1.93-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 (101) hide show
  1. package/dist/{Analytic-NC-USqGi.js → Analytic-CF3P53vZ.js} +11 -11
  2. package/dist/{App-7D_MZN0d.js → App-Dbibh5dj.js} +11 -11
  3. package/dist/{Bin-60inU7_9.js → Bin-B2fl-fdo.js} +8 -8
  4. package/dist/{Broadcast-BFMikTv0.js → Broadcast-Bdd60JEW.js} +8 -8
  5. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DrHHwGED.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BkXOSFhp.js} +6 -7
  6. package/dist/{Card-vafU4dyU.js → Card-BsfpC3iw.js} +20 -21
  7. package/dist/{Collections-BNSNZg7H.js → Collections-b35P-S0E.js} +8 -8
  8. package/dist/{Credit-Cy6YPGph.js → Credit-D52WVEI2.js} +8 -8
  9. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-7IXALR4_.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-CCUOC17_.js} +32 -33
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-7Tanljx6.js → EffectSheet.vue_vue_type_style_index_0_lang-Bt7uoapk.js} +6 -6
  11. package/dist/{Experience-BVneXtjz.js → Experience-_zsgF0a8.js} +8 -8
  12. package/dist/{FileSaver.min-DRZVt2c-.js → FileSaver.min-B7bT7uZB.js} +1 -1
  13. package/dist/{Game-leXiqv6v.js → Game-RJSHKHn3.js} +9 -9
  14. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-bvPXAI2I.js → ImageInput.vue_vue_type_script_setup_true_lang-SEhYAL8G.js} +1 -1
  15. package/dist/{Index-BU3ubcCK.js → Index-D3ezuXa9.js} +10 -10
  16. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-DmnST0XL.js → LottieAnimation.vue_vue_type_script_setup_true_lang-BrE_KuQ8.js} +1 -1
  17. package/dist/{MainLayout-DfMxhjyZ.js → MainLayout-CVV2DhUe.js} +1 -1
  18. package/dist/Marketing-DEuThlZJ.js +235 -0
  19. package/dist/MarketingMaterialEdit-CUTvpMNA.js +1032 -0
  20. package/dist/{Member-C1UGjz3K.js → Member-VETbkHa9.js} +13 -14
  21. package/dist/{MemberList-B51qk9PN.js → MemberList-Zf4a_QPT.js} +33 -33
  22. package/dist/{MemberTransactions-XeeZVSj7.js → MemberTransactions-CKkhiXHs.js} +1 -1
  23. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-BZFh4LbN.js → MessageInput.vue_vue_type_script_setup_true_lang-CWFhJcf_.js} +9 -9
  24. package/dist/{Mission-_2ubnxed.js → Mission-ebr00gRa.js} +30 -30
  25. package/dist/{Overview-Wtw2Gxca.js → Overview-DAVsiqOi.js} +30 -30
  26. package/dist/{Point-BWNPBISs.js → Point-MVRhs_TV.js} +8 -8
  27. package/dist/{Promotion-Cq1rta1U.js → Promotion-gY4_IDdN.js} +20 -19
  28. package/dist/{Queue-BislCglv.js → Queue-DYG5qt5V.js} +23 -23
  29. package/dist/{Record-DllYWBQs.js → Record-DJQbIHO-.js} +14 -13
  30. package/dist/{Reward-DNnMSiIt.js → Reward-Cl9Q83Ic.js} +16 -16
  31. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-CYgKBX4A.js → RewardGroup.vue_vue_type_script_setup_true_lang-B9oA4sF8.js} +13 -14
  32. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CBLDHomx.js → RuleGroup.vue_vue_type_script_setup_true_lang-4xWx1fZP.js} +16 -17
  33. package/dist/Segment-DmgI9KPo.js +1015 -0
  34. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-DaF39TyG.js → SelectItems.vue_vue_type_script_setup_true_lang-DySwa7Ny.js} +2 -2
  35. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-vxFwpQoN.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-DD-KfnJK.js} +30 -31
  36. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-BBddcORt.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-D8hgPIT2.js} +4 -4
  37. package/dist/{Setting-Gt-j2X-h.js → Setting-Czy9M6ce.js} +14 -14
  38. package/dist/{SettingAdvertisements-CETtBWdy.js → SettingAdvertisements-BMnfsHLy.js} +29 -29
  39. package/dist/{Store-DxBaC_7y.js → Store-C-ys_2QK.js} +23 -24
  40. package/dist/{StoreRewards-CbmzaAnf.js → StoreRewards-DK7IUkUO.js} +15 -15
  41. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-CB6y-TEk.js → StoreTransactions.vue_vue_type_script_setup_true_lang-kaIV3mqE.js} +29 -29
  42. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-Ckdg2H3D.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DnRJPsED.js} +2 -2
  43. package/dist/{Tier-BRBr_4Vs.js → Tier-B7bsxmsf.js} +22 -22
  44. package/dist/{Title-N1Aoum66.js → Title-D4KW30Ks.js} +22 -23
  45. package/dist/{Transaction-DzrBiUhw.js → Transaction-CKyWN0zZ.js} +2 -2
  46. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-xtnyUh_C.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-tqshXO3D.js} +6 -6
  47. package/dist/{Voucher-95IbNNON.js → Voucher-DLw9lMUt.js} +12 -12
  48. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-BOf9umaT.js → VoucherEditor.vue_vue_type_script_setup_true_lang-D5QC7oDC.js} +12 -12
  49. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-vCA6xspO.js → ZodTextField.vue_vue_type_script_setup_true_lang-DpfeD9sJ.js} +2 -2
  50. package/dist/{app-CSXjCxhe.js → app-AQ3uPcGw.js} +9630 -9256
  51. package/dist/app.js +1 -1
  52. package/dist/{business-B1gGiOi3.js → business-C-SeKOpM.js} +1 -1
  53. package/dist/{campaign-CJ-3fIa_.js → campaign-Dk0dzJrv.js} +21 -20
  54. package/dist/{campaign-CTPJV80W.js → campaign-Jnfn3VT0.js} +1 -1
  55. package/dist/{campaign.enum-C6mTkAc0.js → campaign.enum-jrT7BDfx.js} +1 -1
  56. package/dist/{campaign.fn-Dnq8oOA7.js → campaign.fn-v9Ckc2hW.js} +62 -62
  57. package/dist/{collectible.enum-Bm9ym61N.js → collectible.enum-DFWdMC2z.js} +1 -1
  58. package/dist/{collection.fn-eGKUovTx.js → collection.fn-BDtuxdF8.js} +2 -2
  59. package/dist/{dto-BmlZ970m.js → dto-zWYoDEwd.js} +16 -16
  60. package/dist/{effect-Fi165HuU.js → effect-DOecbCOM.js} +1 -1
  61. package/dist/{email-addresses-CkqIxXsD.js → email-addresses-DSr_tXqu.js} +2 -2
  62. package/dist/{export-BINxBZ3o.js → export-CZkFZ1ql.js} +3 -3
  63. package/dist/{helper-BJpoVem-.js → helper-Qh6msr0l.js} +1 -1
  64. package/dist/{index-elY0gYnL.js → index--gM0b_9n.js} +1 -1
  65. package/dist/{index-BazRPGxz.js → index-9VFfiC3i.js} +1 -1
  66. package/dist/{index-CMnMUrQv.js → index-B1rzQD1z.js} +3 -3
  67. package/dist/{index-Cg170bHf.js → index-BlK42Hsj.js} +19 -21
  68. package/dist/{index-BBTSDrdg.js → index-BnY_w7sd.js} +3 -3
  69. package/dist/{index-agtRTQ1_.js → index-BoC2dMV5.js} +334 -333
  70. package/dist/{index-Ceebw9zT.js → index-CRiRSGK0.js} +1 -1
  71. package/dist/{index-ShgzGUii.js → index-D0n4WOl2.js} +3 -3
  72. package/dist/{index-D2lJ7rbj.js → index-DFw3Bb9V.js} +91 -68
  73. package/dist/{index-D_D_KuCj.js → index-DObqZ6KJ.js} +1 -1
  74. package/dist/{index-msYk4Nww.js → index-YUpYN8aL.js} +1 -1
  75. package/dist/{index-C-7bzCQ9.js → index-tv01Kl2W.js} +1342 -1148
  76. package/dist/{index.esm2017-CFwZeNKo.js → index.esm2017-B-Gv-i1i.js} +1 -1
  77. package/dist/{loading-CWsuOmex.js → loading-CCrn-MJR.js} +4 -3
  78. package/dist/{lodash-Cm9Z1YF2.js → lodash-CtOTzbaj.js} +1 -1
  79. package/dist/{membership-DMInG-QR.js → membership-EQqU26uC.js} +38 -18
  80. package/dist/{money-COObXSez.js → money-BKkxOcfp.js} +1 -1
  81. package/dist/{number-ZsyBuNFr.js → number-CB4PaVTY.js} +1 -1
  82. package/dist/{objectid-Tx-E_slw.js → objectid-DZkH2UHF.js} +5 -5
  83. package/dist/{plugins-CvqTFq6l.js → plugins-DY6km6IL.js} +297 -326
  84. package/dist/{reward-BDSUzN0_.js → reward-CtjrIJKv.js} +1 -1
  85. package/dist/{rule-BzWFD4lu.js → rule-CZ3RGeiy.js} +3 -3
  86. package/dist/{rule-builder-y5PUkSk9.js → rule-builder-UZUhhSdz.js} +1 -1
  87. package/dist/string-Gcy5IM_H.js +32 -0
  88. package/dist/style.css +1 -1
  89. package/dist/{template-CO3A7_3t.js → template-D5j-p60O.js} +7 -7
  90. package/dist/{timezone-ClbAM0Sw.js → timezone-D6XtPLkX.js} +2 -2
  91. package/dist/{trigger-DGoPndhx.js → trigger-D899b9LT.js} +14 -14
  92. package/dist/useMarketingMaterialActions-CacZ3qjm.js +107 -0
  93. package/dist/{usePagination-COHUplyH.js → usePagination-bOOb_012.js} +1 -1
  94. package/dist/{user-CnDTKRSl.js → user-CH5kl3DX.js} +19 -19
  95. package/dist/{vue-i18n-X1TYXdQD.js → vue-i18n-zOam3pfw.js} +282 -282
  96. package/dist/{xlsx-W_9bPRI8.js → xlsx-DF35RkrA.js} +166 -166
  97. package/dist/{zod-D9xVg76J.js → zod-CmBShukP.js} +1 -1
  98. package/package.json +3 -2
  99. package/dist/Marketing-DVZfv6KL.js +0 -319
  100. package/dist/Segment-BawFn2kF.js +0 -882
  101. package/dist/index-CfEzixyr.js +0 -38
@@ -0,0 +1,1015 @@
1
+ import { defineComponent as le, ref as W, resolveComponent as x, openBlock as r, createElementBlock as k, createElementVNode as s, createVNode as d, unref as e, createCommentVNode as K, withCtx as $, Fragment as Z, renderList as me, createBlock as V, toDisplayString as D, normalizeClass as ce, computed as O, onMounted as we, isRef as Te, createSlots as Ee, h as B, onBeforeMount as De } from "vue";
2
+ import { _ as $e } from "./campaign-CpzFl8Vr.js";
3
+ import { n as Ae, p as Pe } from "./plugins-DY6km6IL.js";
4
+ import { u as Re } from "./loading-CCrn-MJR.js";
5
+ import { FmButtonVariant as re, useSnackbar as Ne, components as ae } from "@feedmepos/ui-library";
6
+ import { u as Fe, _ as Ce } from "./usePagination-bOOb_012.js";
7
+ import { u as pe } from "./vue-i18n-zOam3pfw.js";
8
+ import { i as Be, j as U, D as Ue, k as Ve, c as ye } from "./index-tv01Kl2W.js";
9
+ import "./index-BlK42Hsj.js";
10
+ import { F as ge, z as Le } from "./index-D0n4WOl2.js";
11
+ import "./index-DFw3Bb9V.js";
12
+ import "./index-BnY_w7sd.js";
13
+ import { u as de, w as ke } from "./xlsx-DF35RkrA.js";
14
+ import { e as Ye, M as ze } from "./email-addresses-DSr_tXqu.js";
15
+ import { Z as Oe } from "./zod-CmBShukP.js";
16
+ import { u as je } from "./app-wDQR6dpb.js";
17
+ import { R as ve } from "./rule-builder-UZUhhSdz.js";
18
+ import { _ as qe } from "./ZodTextField.vue_vue_type_script_setup_true_lang-DpfeD9sJ.js";
19
+ import { _ as Ge } from "./RuleGroup.vue_vue_type_script_setup_true_lang-4xWx1fZP.js";
20
+ import { u as He, v as Ke, w as Je } from "./index.esm2017-B-Gv-i1i.js";
21
+ import { F as Qe } from "./FileSaver.min-B7bT7uZB.js";
22
+ import { h as se } from "./moment-D7p2TMB-.js";
23
+ import { s as z, u as We } from "./membership-EQqU26uC.js";
24
+ import { o as Ze } from "./objectId-dwaoBfJX.js";
25
+ import { J as Xe } from "./JsonViewer-v8_C7l5N.js";
26
+ import { u as Ie } from "./business-C-SeKOpM.js";
27
+ import { f as et } from "./number-CB4PaVTY.js";
28
+ import { t as tt } from "./money-BKkxOcfp.js";
29
+ import "./index-9VFfiC3i.js";
30
+ import { useRouter as ot } from "vue-router";
31
+ import { m as _e } from "./index-CRiRSGK0.js";
32
+ import { R as Se } from "./app-AQ3uPcGw.js";
33
+ const nt = Be.extend({
34
+ _id: ge.optional(),
35
+ business: ge.optional(),
36
+ file: Le.any().nullish()
37
+ });
38
+ var at = { firebase: { apiKey: "AIzaSyA_isPR1-9bX7UmRiJIhsIRNNwdn6DdmW4", authDomain: "feedme-253402.firebaseapp.com", databaseURL: "https://feedme-253402.firebaseio.com", projectId: "feedme-253402", storageBucket: "image.feedme.cc", messagingSenderId: "128512026847", appId: "1:128512026847:web:7c5c8ab7e8b90502dc616a", measurementId: "G-LTKS7N2HQS" }, assetBucketUrl: "static.feedme.cc", importFilesBucketUrl: "feedme-253402.appspot.com", clientId: "d5f8840d63dbb758b6c4ee2a5e8b013d15dd25e242c457481326062b83962476" };
39
+ const st = { class: "flex flex-col space-y-16" }, lt = {
40
+ key: 0,
41
+ class: /* @__PURE__ */ ce([
42
+ "p-16 pl-24 space-x-8",
43
+ "bg-fm-color-primary-oats rounded-lg",
44
+ "flex items-center",
45
+ "justify-between"
46
+ ])
47
+ }, it = { class: "flex justify-end" }, ct = {
48
+ key: 1,
49
+ class: /* @__PURE__ */ ce([
50
+ "flex items-center",
51
+ "border border-fm-color-neutral-gray-300",
52
+ "p-16 space-x-16 rounded-md"
53
+ ])
54
+ }, rt = { class: "fm-typo-en-body-lg-400 flex-1 truncate" }, dt = /* @__PURE__ */ le({
55
+ __name: "ImportSegment",
56
+ props: {
57
+ importFile: {}
58
+ },
59
+ emits: ["update:file"],
60
+ setup(t, { emit: f }) {
61
+ const c = t, M = f, { t: b } = pe(), _ = W(null), u = W(null), T = ["Id"], E = [
62
+ {
63
+ label: "CSV",
64
+ icon: "csv",
65
+ value: "csv"
66
+ },
67
+ {
68
+ label: "Excel",
69
+ icon: "description",
70
+ value: "xlsx"
71
+ }
72
+ ];
73
+ async function a() {
74
+ if (c.importFile)
75
+ try {
76
+ const y = He(void 0, at.importFilesBucketUrl), p = Ke(y, c.importFile), g = await Je(p);
77
+ window.open(g, "_blank");
78
+ } catch (y) {
79
+ console.log(y), Ae.error("Failed to download uploaded file");
80
+ }
81
+ }
82
+ async function m(y) {
83
+ switch (y) {
84
+ case "csv":
85
+ const p = new Blob([T.join(",")], {
86
+ type: "text/csv;charset=utf-8;"
87
+ });
88
+ Qe.saveAs(p, "ImportSegmentTemplate.csv");
89
+ break;
90
+ case "xlsx":
91
+ const g = de.aoa_to_sheet([T]), S = de.book_new();
92
+ de.book_append_sheet(S, g, "Sheet1"), ke(S, "ImportSegmentTemplate.xlsx");
93
+ break;
94
+ }
95
+ }
96
+ function i(y) {
97
+ _.value = y, M("update:file", _.value);
98
+ }
99
+ function A(y) {
100
+ var g, S;
101
+ const p = ((S = (g = y.target) == null ? void 0 : g.files) == null ? void 0 : S[0]) ?? null;
102
+ i(p);
103
+ }
104
+ return (y, p) => {
105
+ const g = x("FmButton"), S = x("FmMenuItem"), j = x("FmMenu"), q = x("FmDropField");
106
+ return r(), k("div", st, [
107
+ p[2] || (p[2] = s("div", { class: "fm-typo-en-title-sm-800" }, "Upload File", -1)),
108
+ t.importFile ? (r(), k("div", lt, [
109
+ d(g, {
110
+ label: e(b)("View uploaded file"),
111
+ variant: e(re).Plain,
112
+ icon: "file_present",
113
+ onClick: a
114
+ }, null, 8, ["label", "variant"])
115
+ ])) : K("", !0),
116
+ s("div", null, [
117
+ s("div", it, [
118
+ d(j, { class: "" }, {
119
+ "menu-button": $(() => [
120
+ d(g, {
121
+ variant: "tertiary",
122
+ icon: "download",
123
+ label: "Download Template"
124
+ })
125
+ ]),
126
+ default: $(() => [
127
+ (r(), k(Z, null, me(E, (I) => d(S, {
128
+ key: I.value,
129
+ icon: I.icon,
130
+ label: I.label,
131
+ onClick: (G) => m(I.value),
132
+ selectable: ""
133
+ }, null, 8, ["icon", "label", "onClick"])), 64))
134
+ ]),
135
+ _: 1
136
+ })
137
+ ]),
138
+ _.value ? (r(), k("div", ct, [
139
+ d(g, {
140
+ variant: e(re).Tertiary,
141
+ "prepend-icon": "attach_file"
142
+ }, null, 8, ["variant"]),
143
+ s("p", rt, D(_.value.name), 1),
144
+ s("label", {
145
+ ref_key: "fileLabelRef",
146
+ ref: u,
147
+ htmlFor: "file"
148
+ }, [
149
+ d(g, {
150
+ variant: e(re).Plain,
151
+ label: e(b)("Replace File"),
152
+ onClick: p[1] || (p[1] = () => {
153
+ var I;
154
+ return (I = u.value) == null ? void 0 : I.click();
155
+ })
156
+ }, null, 8, ["variant", "label"]),
157
+ s("input", {
158
+ id: "file",
159
+ accept: ".csv",
160
+ class: "hidden",
161
+ type: "file",
162
+ multiple: "",
163
+ onChange: A
164
+ }, null, 32)
165
+ ], 512)
166
+ ])) : (r(), V(q, {
167
+ key: 0,
168
+ onFileUpload: p[0] || (p[0] = (I) => i(I)),
169
+ accept: ".csv, .xlsx",
170
+ "max-file-size": 2e7
171
+ }))
172
+ ])
173
+ ]);
174
+ };
175
+ }
176
+ }), ut = { class: "space-y-16 pr-12" }, mt = { class: "fm-typo-en-title-md-800" }, pt = { class: "flex space-x-8" }, ft = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, yt = { class: "text-fm-color-typo-secondary" }, xe = /* @__PURE__ */ le({
177
+ __name: "ReviewSegment",
178
+ props: {
179
+ title: {},
180
+ segment: {}
181
+ },
182
+ setup(t) {
183
+ const f = t, c = O(
184
+ () => f.segment.memberCount ?? f.segment.members.length
185
+ ), M = O(
186
+ () => f.segment.lastUpdated ? se(f.segment.lastUpdated).format("DD MMM YYYY") : "Not refreshed yet"
187
+ ), b = [
188
+ {
189
+ header: "Name",
190
+ accessorFn: (i) => i.name
191
+ },
192
+ {
193
+ header: "Id",
194
+ accessorFn: (i) => i._id
195
+ },
196
+ {
197
+ header: "Customer Since",
198
+ accessorFn: (i) => se(Ze(i._id.toString())).format("DD MMM YYYY")
199
+ },
200
+ {
201
+ header: "Phone",
202
+ accessorFn: (i) => i.phoneNumber
203
+ },
204
+ {
205
+ header: "Birthday",
206
+ accessorFn: (i) => se(i.birthday).format("DD MMM YYYY")
207
+ },
208
+ {
209
+ header: "Last Visit",
210
+ accessorFn: (i) => se(i.stats.lastVisit).format("DD MMM YYYY")
211
+ }
212
+ ];
213
+ async function _(i) {
214
+ return f.segment._id ? (console.log(i), await z.paginateSegmentUsers(
215
+ f.segment._id,
216
+ i
217
+ )) : {
218
+ resources: [],
219
+ meta: {
220
+ totalResources: 0,
221
+ totalPages: 0,
222
+ skip: i.skip,
223
+ limit: i.limit,
224
+ sortBy: i.sortBy
225
+ }
226
+ };
227
+ }
228
+ const { tableMeta: u, rowData: T, onSort: E, debouncedFetchData: a, onSearch: m } = Fe(_);
229
+ return we(async () => {
230
+ await a();
231
+ }), (i, A) => (r(), k("div", ut, [
232
+ s("div", mt, D(f.title), 1),
233
+ s("div", pt, [
234
+ s("div", ft, D(e(c)), 1),
235
+ s("div", yt, [
236
+ A[1] || (A[1] = s("div", null, "contacts in your segment", -1)),
237
+ s("div", null, "as of " + D(e(M)), 1)
238
+ ])
239
+ ]),
240
+ d(Ce, {
241
+ loading: e(u).isLoading,
242
+ "row-data": e(T),
243
+ "row-count": e(u).totalRows,
244
+ "column-defs": b,
245
+ "page-size": e(u).pageSize,
246
+ "page-count": e(u).pageCount,
247
+ "page-index": e(u).pageIndex,
248
+ onSortChange: e(E),
249
+ onPageChange: A[0] || (A[0] = (y) => e(a)({ pageSize: y.pageSize, pageIndex: y.pageIndex }))
250
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
251
+ ]));
252
+ }
253
+ }), gt = { class: "space-y-24" }, vt = { class: "grid grid-cols-2 gap-16" }, _t = { class: "fm-typo-en-title-sm-800" }, St = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, xt = /* @__PURE__ */ le({
254
+ __name: "SegmentTypeOption",
255
+ props: {
256
+ modelValue: {},
257
+ errorText: {}
258
+ },
259
+ emits: ["update:model-value"],
260
+ setup(t, { emit: f }) {
261
+ const c = t, M = f, b = [
262
+ {
263
+ label: "Dynamic",
264
+ sublabel: "Segment statistics are based on rules configured and will be recalculated automatically when rule changes.",
265
+ value: U.enum.DYNAMIC
266
+ },
267
+ {
268
+ label: "Static",
269
+ sublabel: "Segment statistics are based on imported data and will not be recalculated.",
270
+ value: U.enum.STATIC
271
+ }
272
+ ];
273
+ function _(u) {
274
+ u !== c.modelValue && M("update:model-value", u);
275
+ }
276
+ return (u, T) => {
277
+ const E = x("FmCard"), a = x("FmHelperText");
278
+ return r(), k("div", gt, [
279
+ s("div", vt, [
280
+ (r(), k(Z, null, me(b, (m) => d(E, {
281
+ variant: "outlined",
282
+ class: ce(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-2", {
283
+ "col-span-2": b.length == 1,
284
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": t.modelValue === m.value,
285
+ "hover:bg-fm-color-opacity-sm": t.modelValue !== m.value
286
+ }]),
287
+ onClick: (i) => _(m.value),
288
+ key: m.value
289
+ }, {
290
+ default: $(() => [
291
+ s("div", _t, D(m.label), 1),
292
+ s("div", St, D(m.sublabel), 1)
293
+ ]),
294
+ _: 2
295
+ }, 1032, ["class", "onClick"])), 64))
296
+ ]),
297
+ t.errorText ? (r(), V(a, {
298
+ key: 0,
299
+ class: "!mt-4",
300
+ text: t.errorText,
301
+ state: "error"
302
+ }, null, 8, ["text"])) : K("", !0)
303
+ ]);
304
+ };
305
+ }
306
+ }), ht = { class: "flex items-center gap-x-8" }, bt = {
307
+ key: 0,
308
+ class: "space-y-16 pr-12"
309
+ }, wt = {
310
+ key: 0,
311
+ class: "flex flex-col gap-12"
312
+ }, Ft = { class: "flex flex-wrap items-center gap-8" }, Ct = { class: "fm-typo-en-title-sm-800" }, kt = { class: "flex flex-col gap-4" }, It = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" }, Mt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tt = {
313
+ key: 2,
314
+ class: "flex flex-col space-y-16"
315
+ }, Et = {
316
+ key: 3,
317
+ class: "flex flex-col space-y-16"
318
+ }, Dt = {
319
+ key: 4,
320
+ class: "flex flex-col space-y-16"
321
+ }, $t = {
322
+ key: 5,
323
+ class: "flex flex-col space-y-16"
324
+ }, At = { class: "flex items-center gap-8" }, Pt = /* @__PURE__ */ le({
325
+ __name: "SegmentSheet",
326
+ emits: ["update:model-value"],
327
+ setup(t, { expose: f, emit: c }) {
328
+ const M = je(), { t: b } = pe(), _ = W(!1), u = W(!1), T = {
329
+ name: "",
330
+ isActive: !0,
331
+ type: U.enum.DYNAMIC,
332
+ rule: ve.scaffoldGroup(),
333
+ members: []
334
+ }, E = nt, a = W(T), m = O(() => !!a.value.defaultKey), i = O(
335
+ () => a.value.defaultKey ? `connect.loyalty.segment.default_segments.${a.value.defaultKey.toLowerCase()}` : void 0
336
+ ), A = O(
337
+ () => i.value ? b(`${i.value}.name`) : a.value.name
338
+ ), y = O(() => {
339
+ const v = a.value.defaultKey;
340
+ return v ? b(Ue[v]) : a.value.description ?? "";
341
+ }), p = O(() => {
342
+ const v = E.safeParse(a.value);
343
+ return v.success ? [] : v.error.errors;
344
+ });
345
+ function g(v) {
346
+ _.value = !0, u.value = !1, v ? a.value = {
347
+ ...v,
348
+ isActive: v.isActive !== !1,
349
+ type: v.type ?? (v.importFile ? U.enum.STATIC : U.enum.DYNAMIC)
350
+ } : a.value = { ...T };
351
+ }
352
+ function S() {
353
+ _.value = !1;
354
+ }
355
+ async function j() {
356
+ E.safeParse(a.value).success && (u.value = !0);
357
+ }
358
+ function q(v) {
359
+ v === U.enum.STATIC ? S() : u.value = !1;
360
+ }
361
+ async function I() {
362
+ a.value.type === U.enum.STATIC ? (a.value.rule = ve.scaffoldGroup(), a.value.isActive = !0) : a.value.file = void 0, J("update:model-value", a.value);
363
+ }
364
+ async function G(v) {
365
+ a.value.type = v;
366
+ }
367
+ we(async () => {
368
+ });
369
+ const J = c;
370
+ return f({
371
+ showSheet: g,
372
+ hideSheet: S
373
+ }), (v, l) => {
374
+ const P = x("FmButton"), X = x("FmChip"), ee = x("FmCard"), te = x("FmSwitch"), o = x("FmSideSheet");
375
+ return r(), V(o, {
376
+ modelValue: e(_),
377
+ "onUpdate:modelValue": l[9] || (l[9] = (n) => Te(_) ? _.value = n : null),
378
+ header: e(m) ? e(b)("connect.loyalty.segment.default_segments.default_segment") : e(a)._id ? "Edit segment" : "Add segment",
379
+ "dismiss-away": "",
380
+ "close-button": !0,
381
+ "max-width": 1100
382
+ }, Ee({
383
+ "side-sheet-footer": $(() => [
384
+ s("div", At, [
385
+ e(m) ? (r(), V(P, {
386
+ key: 0,
387
+ label: e(b)("connect.loyalty.segment.default_segments.close"),
388
+ onClick: l[6] || (l[6] = (n) => S()),
389
+ variant: "tertiary"
390
+ }, null, 8, ["label"])) : e(u) || e(a).type === e(U).enum.STATIC ? (r(), k(Z, { key: 1 }, [
391
+ d(P, {
392
+ label: "Save Segment",
393
+ onClick: I,
394
+ loading: e(M).isLoading,
395
+ disabled: e(p).length > 0 || e(M).isLoading
396
+ }, null, 8, ["loading", "disabled"]),
397
+ d(P, {
398
+ label: "Cancel",
399
+ onClick: l[7] || (l[7] = (n) => q(e(a).type)),
400
+ variant: "tertiary"
401
+ })
402
+ ], 64)) : (r(), k(Z, { key: 2 }, [
403
+ d(P, {
404
+ label: "Review Segment",
405
+ disabled: e(p).length > 0 || e(M).isLoading,
406
+ onClick: j
407
+ }, null, 8, ["disabled"]),
408
+ d(P, {
409
+ label: "Cancel",
410
+ onClick: l[8] || (l[8] = (n) => S()),
411
+ variant: "tertiary"
412
+ })
413
+ ], 64))
414
+ ])
415
+ ]),
416
+ default: $(() => {
417
+ var n, F;
418
+ return [
419
+ d(Xe, { json: e(a) }, null, 8, ["json"]),
420
+ e(u) ? (r(), V(xe, {
421
+ key: 1,
422
+ title: e(a).name,
423
+ segment: e(a)
424
+ }, null, 8, ["title", "segment"])) : (r(), k("div", bt, [
425
+ e(m) ? (r(), k("div", wt, [
426
+ s("div", Ft, [
427
+ s("div", Ct, D(e(A)), 1),
428
+ d(X, {
429
+ label: e(b)("connect.loyalty.segment.default_segments.system"),
430
+ compact: "",
431
+ class: "text-fm-color-typo-info bg-fm-color-system-info-100"
432
+ }, null, 8, ["label"])
433
+ ]),
434
+ d(ee, {
435
+ variant: "outlined",
436
+ class: "p-16"
437
+ }, {
438
+ default: $(() => [
439
+ s("div", kt, [
440
+ s("div", It, D(e(b)("connect.loyalty.segment.default_segments.description")), 1),
441
+ s("div", Mt, D(e(y)), 1)
442
+ ])
443
+ ]),
444
+ _: 1
445
+ })
446
+ ])) : (r(), V(qe, {
447
+ key: 1,
448
+ modelValue: e(a).name,
449
+ "onUpdate:modelValue": l[1] || (l[1] = (w) => e(a).name = w),
450
+ label: "Segment title",
451
+ schema: e(Oe).typeAtPath(e(E), "name")
452
+ }, null, 8, ["modelValue", "schema"])),
453
+ e(m) ? K("", !0) : (r(), k("div", Tt, [
454
+ l[11] || (l[11] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Type", -1)),
455
+ d(xt, {
456
+ "model-value": e(a).type,
457
+ "onUpdate:modelValue": l[2] || (l[2] = (w) => {
458
+ G(w);
459
+ })
460
+ }, null, 8, ["model-value"])
461
+ ])),
462
+ e(a).type === e(U).enum.DYNAMIC && !e(m) ? (r(), k("div", Et, [
463
+ l[12] || (l[12] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
464
+ d(Ge, {
465
+ "trigger-type": "MEMBERSHIP_JOINED",
466
+ includeOnly: "user",
467
+ "model-value": (n = e(a)) == null ? void 0 : n.rule,
468
+ "onUpdate:modelValue": l[3] || (l[3] = (w) => {
469
+ e(a).rule = w;
470
+ })
471
+ }, null, 8, ["model-value"])
472
+ ])) : e(m) ? K("", !0) : (r(), k("div", Dt, [
473
+ d(dt, {
474
+ importFile: e(a).importFile,
475
+ "onUpdate:file": l[4] || (l[4] = (w) => {
476
+ e(a).file = w;
477
+ })
478
+ }, null, 8, ["importFile"])
479
+ ])),
480
+ e(a).type === e(U).enum.DYNAMIC && !e(m) ? (r(), k("div", $t, [
481
+ l[13] || (l[13] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Status", -1)),
482
+ d(te, {
483
+ "model-value": e(a).isActive ?? !0,
484
+ "onUpdate:modelValue": l[5] || (l[5] = (w) => e(a).isActive = w),
485
+ label: "Active",
486
+ sublabel: "When enabled, this will recalculate the segment statistics daily.",
487
+ "label-placement": "right"
488
+ }, null, 8, ["model-value"])
489
+ ])) : K("", !0),
490
+ e(m) ? (r(), V(xe, {
491
+ key: (F = e(a)._id) == null ? void 0 : F.toString(),
492
+ title: e(b)("connect.loyalty.segment.default_segments.members"),
493
+ segment: e(a)
494
+ }, null, 8, ["title", "segment"])) : K("", !0)
495
+ ]))
496
+ ];
497
+ }),
498
+ _: 2
499
+ }, [
500
+ e(u) && !e(m) ? {
501
+ name: "side-sheet-header",
502
+ fn: $(() => [
503
+ s("div", ht, [
504
+ d(P, {
505
+ icon: "arrow_back",
506
+ variant: "tertiary",
507
+ onClick: l[0] || (l[0] = (n) => u.value = !1)
508
+ }),
509
+ l[10] || (l[10] = s("div", null, "Review segment", -1))
510
+ ])
511
+ ]),
512
+ key: "0"
513
+ } : void 0
514
+ ]), 1032, ["modelValue", "header"]);
515
+ };
516
+ }
517
+ }), he = We(), Rt = Ie();
518
+ function ue(t) {
519
+ const f = se(t);
520
+ return f.isValid() ? f.format("DD/MM/YYYY") : "";
521
+ }
522
+ const Nt = {
523
+ mapMemberExportRow: (t) => {
524
+ var a, m, i, A, y, p, g, S, j, q, I, G, J, v, l, P, X, ee, te, o, n, F, w, R, H, L, oe, ne;
525
+ const f = O(() => Rt.locations.map((C) => ({
526
+ label: C.name,
527
+ value: C._id
528
+ }))), c = (a = Ye.parseOneAddress(
529
+ t == null ? void 0 : t.email
530
+ )) != null && a.domain.includes("feedmepos.com") ? void 0 : t.email, M = (i = ((m = t == null ? void 0 : t.collection) == null ? void 0 : m.TITLE) || []) == null ? void 0 : i.reduce(
531
+ (C, N) => {
532
+ var h, Y;
533
+ const Q = (Y = (h = he.sortedTitles) == null ? void 0 : h.find(
534
+ (ie) => ie._id === N.collectible
535
+ )) == null ? void 0 : Y.name;
536
+ return !Q || N.balance <= 0 || C.push(Q), C;
537
+ },
538
+ []
539
+ ), b = (he.sortedTitles || []).reduce(
540
+ (C, N) => {
541
+ var h, Y, ie, fe;
542
+ const Q = (fe = (ie = (Y = (((h = t == null ? void 0 : t.collection) == null ? void 0 : h.TITLE) || []).find(
543
+ (Me) => Me.collectible === N._id
544
+ )) == null ? void 0 : Y.expiryBalance) == null ? void 0 : ie[0]) == null ? void 0 : fe.expiredAt;
545
+ return C[N.name] = Q ? se(Q).format("DD/MM/YYYY") : "", C;
546
+ },
547
+ {}
548
+ ), _ = ((p = (y = (A = t.collection) == null ? void 0 : A.CREDIT) == null ? void 0 : y.at(0)) == null ? void 0 : p.balance) || 0, u = ((q = (j = (S = (g = t.collection) == null ? void 0 : g.CREDIT) == null ? void 0 : S.at(0)) == null ? void 0 : j.expiryBalance) == null ? void 0 : q.reduce(
549
+ (C, N) => C + N.amount,
550
+ 0
551
+ )) || 0, T = et(_, 2);
552
+ return {
553
+ ID: t._id.toString(),
554
+ Name: ((I = t.name) == null ? void 0 : I.trim()) || "",
555
+ Phone: ((G = t == null ? void 0 : t.phoneNumber) == null ? void 0 : G.trim()) || "",
556
+ Email: c || "",
557
+ Gender: t.gender || "",
558
+ CardNo: t.cardNo || "",
559
+ Birthday: t != null && t.birthday ? ue(t == null ? void 0 : t.birthday) : "",
560
+ Credit: parseFloat((Number(T) - Number(u)).toFixed(2)),
561
+ FreeCredit: Number(u.toFixed(2)),
562
+ TotalCredit: Number(T),
563
+ Exp: t != null && t.collection ? ((l = (v = (J = t.collection) == null ? void 0 : J.POINT) == null ? void 0 : v.at(0)) == null ? void 0 : l.balance) ?? 0 : 0,
564
+ Point: t != null && t.collection ? ((ee = (X = (P = t.collection) == null ? void 0 : P.COIN) == null ? void 0 : X.at(0)) == null ? void 0 : ee.balance) ?? 0 : 0,
565
+ Level: t != null && t.collection ? ((n = (o = (te = t.collection) == null ? void 0 : te.TIER) == null ? void 0 : o.at(0)) == null ? void 0 : n.balance) ?? 0 : 0,
566
+ Tier: t != null && t.collection ? ((R = (w = (F = t.collection) == null ? void 0 : F.TIER) == null ? void 0 : w.at(0)) == null ? void 0 : R.balance) ?? 0 : 0,
567
+ Titles: M.join(","),
568
+ ...b,
569
+ TotalTransaction: t.stats.visitCount,
570
+ AvgSpent: tt(Number(t.stats.avgBillSize || 0)).toFormat(
571
+ !1
572
+ ),
573
+ TotalSpent: t.stats.avgBillSize * t.stats.visitCount,
574
+ LastVisit: ue(t.stats.lastVisit),
575
+ Feedback: ((H = t.stats) == null ? void 0 : H.feedbackCount) || 0,
576
+ LastSeasonTierEarned: ((L = t.stats) == null ? void 0 : L.lastSeasonTierEarned) || 0,
577
+ LastSeasonPointEarned: ((oe = t.stats) == null ? void 0 : oe.lastSeasonPointEarned) || 0,
578
+ JoinedAt: ue(t.joinAt || void 0),
579
+ JoinedAtLocation: t.location && ((ne = f.value.find((C) => C.value == t.location)) == null ? void 0 : ne.label) || "-",
580
+ VisitFrequency: `${Number(
581
+ Math.ceil(t.stats.avgVisitFrequency).toFixed(0)
582
+ )}`
583
+ };
584
+ }
585
+ }, Bt = { class: "flex items-center" }, Ut = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Vt = { class: "px-24 flex flex-col gap-y-16" }, Lt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Yt = { class: "flex flex-wrap items-center gap-8" }, zt = { class: "fm-typo-en-body-md-600" }, Ot = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, jt = { class: "flex flex-col gap-16 text-center" }, qt = { class: "fm-typo-en-title-sm-800" }, Gt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, be = "text-fm-color-typo-info bg-fm-color-system-info-100", ko = /* @__PURE__ */ le({
586
+ __name: "Segment",
587
+ setup(t) {
588
+ const { minor: f } = Re, { t: c } = pe(), M = Ie(), { mapMemberExportRow: b } = Nt, _ = Ne(), u = ot(), T = W(0);
589
+ function E(o) {
590
+ return !!o.defaultKey;
591
+ }
592
+ function a(o) {
593
+ return o ? `connect.loyalty.segment.default_segments.${o.toLowerCase()}` : void 0;
594
+ }
595
+ function m(o) {
596
+ const n = a(o.defaultKey);
597
+ return n ? c(`${n}.name`) : o.name;
598
+ }
599
+ function i(o) {
600
+ return T.value <= 0 ? "0.00" : ((o ?? 0) * 100 / T.value).toFixed(2);
601
+ }
602
+ const A = [
603
+ {
604
+ header: c("connect.loyalty.segment.table.name"),
605
+ accessorFn: (o) => o.name,
606
+ cell(o) {
607
+ return B("div", { class: "flex flex-wrap items-center gap-8" }, [
608
+ B("span", m(o.row.original)),
609
+ ...E(o.row.original) ? [
610
+ B(ae.FmChip, {
611
+ class: be,
612
+ label: c("connect.loyalty.segment.default_segments.system"),
613
+ compact: !0
614
+ })
615
+ ] : []
616
+ ]);
617
+ }
618
+ },
619
+ {
620
+ header: c("connect.loyalty.segment.table.status"),
621
+ enableSorting: !1,
622
+ cell(o) {
623
+ const n = o.row.original.isActive === !1 ? "Inactive" : "Active";
624
+ return B(ae.FmChip, {
625
+ 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",
626
+ label: n,
627
+ compact: !0
628
+ });
629
+ }
630
+ },
631
+ {
632
+ header: c("connect.loyalty.segment.table.total_customers"),
633
+ accessorFn: (o) => o.memberCount ?? 0
634
+ },
635
+ {
636
+ header: c("connect.loyalty.segment.table.customer_percentage"),
637
+ accessorFn: (o) => i(o.memberCount)
638
+ },
639
+ {
640
+ header: c("connect.loyalty.segment.table.actions"),
641
+ meta: {
642
+ maxWidth: "100px"
643
+ },
644
+ cell(o) {
645
+ return B("div", { class: "flex items-center justify-end" }, [
646
+ B(
647
+ ae.FmMenu,
648
+ {
649
+ placement: "bottom-end",
650
+ onClick: (n) => {
651
+ n.stopPropagation();
652
+ }
653
+ },
654
+ {
655
+ "menu-button": () => B(ae.FmButton, {
656
+ icon: "more_vert",
657
+ iconColor: "neutral-gray-400",
658
+ variant: "tertiary"
659
+ }),
660
+ default: () => [
661
+ B(
662
+ ae.FmMenuItem,
663
+ {
664
+ onClick: async (n) => {
665
+ n.stopPropagation(), J(o.row.original);
666
+ }
667
+ },
668
+ {
669
+ label: B(
670
+ "div",
671
+ {
672
+ class: "fm-typo-en-body-md-400"
673
+ },
674
+ "Export"
675
+ )
676
+ }
677
+ ),
678
+ ...E(o.row.original) ? [] : [
679
+ B(
680
+ ae.FmMenuItem,
681
+ {
682
+ onClick: async (n) => {
683
+ n.stopPropagation(), G(o.row.original);
684
+ }
685
+ },
686
+ {
687
+ label: B(
688
+ "div",
689
+ {
690
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
691
+ },
692
+ "Remove"
693
+ )
694
+ }
695
+ )
696
+ ]
697
+ ]
698
+ }
699
+ )
700
+ ]);
701
+ }
702
+ }
703
+ ], y = W(null), { tableMeta: p, rowData: g, debouncedFetchData: S } = Fe(
704
+ z.readAll
705
+ ), j = O(() => g.value.length === 0 ? !1 : Ve.some(
706
+ (o) => !g.value.some((n) => n.defaultKey === o)
707
+ ));
708
+ async function q() {
709
+ var o;
710
+ try {
711
+ await z.refreshSegments(), _.open({ type: "info", title: "Segment refresh queued" });
712
+ } catch (n) {
713
+ if (((n == null ? void 0 : n.status) ?? ((o = n == null ? void 0 : n.response) == null ? void 0 : o.status)) === 409) {
714
+ _.open({
715
+ type: "info",
716
+ title: "Segment refresh already in progress"
717
+ });
718
+ return;
719
+ }
720
+ _.open({
721
+ type: "error",
722
+ title: (n == null ? void 0 : n.message) ?? "Failed to queue segment refresh"
723
+ });
724
+ }
725
+ }
726
+ async function I() {
727
+ await f(
728
+ async () => {
729
+ await z.startDefaultSegments(), await S({ pageSize: 10, pageIndex: 0 });
730
+ },
731
+ {
732
+ message: c(
733
+ "connect.loyalty.segment.default_segments.get_started.loading"
734
+ ),
735
+ successMessage: c(
736
+ "connect.loyalty.segment.default_segments.get_started.success"
737
+ )
738
+ }
739
+ );
740
+ }
741
+ async function G(o) {
742
+ await Pe.remove(`Are you sure you want to remove ${o.name}?`) && await f(
743
+ async () => {
744
+ await z.delete(o._id), await S({ pageSize: 10, pageIndex: 0 });
745
+ },
746
+ {
747
+ message: `Removing ${o.name}`,
748
+ successMessage: `Removed ${o.name} successfully`
749
+ }
750
+ );
751
+ }
752
+ async function J(o) {
753
+ const n = {
754
+ sortBy: "_id",
755
+ descending: !1,
756
+ rowsPerPage: 1e3,
757
+ page: 1,
758
+ rowsNumber: 0
759
+ }, F = new ze(), w = m(o), R = (await _e.read({
760
+ limit: 1,
761
+ skip: 0,
762
+ sortBy: n.sortBy,
763
+ descending: n.descending
764
+ })).meta.totalResources ?? 0, H = n.rowsPerPage;
765
+ await f(
766
+ async () => {
767
+ for (let L = 0; L < R; L += H) {
768
+ const oe = {
769
+ ...n,
770
+ limit: H,
771
+ skip: n.page - 1,
772
+ sortBy: n.sortBy,
773
+ descending: n.descending
774
+ }, ne = await z.paginateSegmentUsers(
775
+ o._id,
776
+ oe
777
+ );
778
+ for (const C of ne.resources) {
779
+ const N = b(C);
780
+ F.addRecord(N);
781
+ }
782
+ n.page++;
783
+ }
784
+ await ke(
785
+ F.buildExcel(),
786
+ `[${w}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
787
+ {
788
+ bookType: "xlsx",
789
+ bookSST: !1,
790
+ type: "array"
791
+ }
792
+ ), n.page = 1;
793
+ },
794
+ {
795
+ message: "Exporting member...",
796
+ successMessage: "Member exported successfully"
797
+ }
798
+ );
799
+ }
800
+ async function v(o) {
801
+ await f(
802
+ async () => {
803
+ var n;
804
+ if (o.type === U.enum.STATIC) {
805
+ const F = new FormData();
806
+ if (F.append("file", o.file), o._id) {
807
+ const { members: w, _id: R, file: H, ...L } = o;
808
+ F.append("segment", JSON.stringify(L)), await z.updateStatic(o._id, F);
809
+ } else {
810
+ const { file: w, ...R } = o;
811
+ F.append("segment", JSON.stringify(R)), await z.createStatic(F);
812
+ }
813
+ o.file && _.open({
814
+ type: "info",
815
+ title: "Import begins soon. Check Queue for updates.",
816
+ action: "View",
817
+ onAction: async () => {
818
+ await u.push({
819
+ name: Se["$connect-QUEUE"],
820
+ query: { type: [ye.enum.SEGMENTATION_IMPORTED] }
821
+ });
822
+ }
823
+ });
824
+ } else if (o._id) {
825
+ const { members: F, _id: w, ...R } = o;
826
+ await z.update(o._id, R);
827
+ } else
828
+ await z.create(o);
829
+ await S({ pageSize: 10, pageIndex: 0 }), (n = y.value) == null || n.hideSheet();
830
+ },
831
+ {
832
+ message: "Saving segment",
833
+ successMessage: "Segment saved"
834
+ }
835
+ );
836
+ }
837
+ function l(o) {
838
+ var n;
839
+ (n = y.value) == null || n.showSheet(o);
840
+ }
841
+ const P = {
842
+ label: c("connect.navigation.queue"),
843
+ value: "queue",
844
+ isPrimary: !1,
845
+ prependIcon: "work_history"
846
+ }, X = {
847
+ label: c("connect.loyalty.segment.default_segments.get_started.action"),
848
+ value: "start-default-segments",
849
+ isPrimary: !1,
850
+ prependIcon: "auto_awesome"
851
+ }, ee = O(() => {
852
+ if (!M.isPremium)
853
+ return [];
854
+ const o = [P];
855
+ return j.value && o.push(X), o.push(
856
+ {
857
+ label: c("connect.loyalty.segment.actions.refresh"),
858
+ value: "refresh",
859
+ prependIcon: "refresh"
860
+ },
861
+ {
862
+ label: c("connect.loyalty.segment.actions.add"),
863
+ value: "add",
864
+ isPrimary: !0,
865
+ prependIcon: "add"
866
+ }
867
+ ), o;
868
+ });
869
+ function te(o) {
870
+ switch (o) {
871
+ case "add":
872
+ l();
873
+ break;
874
+ case "refresh":
875
+ q();
876
+ break;
877
+ case "queue":
878
+ u.push({
879
+ name: Se["$connect-QUEUE"],
880
+ query: { type: [ye.enum.SEGMENTATION_IMPORTED] }
881
+ });
882
+ break;
883
+ case "start-default-segments":
884
+ I();
885
+ break;
886
+ }
887
+ }
888
+ return De(async () => {
889
+ const { meta: o } = await _e.read({
890
+ limit: 1,
891
+ skip: 0,
892
+ sortBy: "_id",
893
+ search: void 0,
894
+ descending: !1
895
+ });
896
+ T.value = o.totalResources ?? 0, await S({ pageSize: 10, pageIndex: 0 }), await M.readPremium(), await M.readLocations();
897
+ }), (o, n) => {
898
+ const F = x("FmPill"), w = x("FmPageHead"), R = x("FmChip"), H = x("FmIcon"), L = x("FmMenuItem"), oe = x("FmMenu"), ne = x("FmListItem"), C = x("FmList"), N = x("FmButton"), Q = x("FmCard");
899
+ return r(), k(Z, null, [
900
+ d(w, {
901
+ title: "Segments",
902
+ actions: e(ee),
903
+ "onClick:action": n[0] || (n[0] = (h) => te(h))
904
+ }, {
905
+ title: $(() => [
906
+ s("div", Bt, [
907
+ s("span", Ut, D(e(c)("connect.loyalty.segment.title")), 1),
908
+ d(F, { variant: "premium" })
909
+ ])
910
+ ]),
911
+ _: 1
912
+ }, 8, ["actions"]),
913
+ s("div", Vt, [
914
+ e(g).length > 0 || e(p).searchValue || e(p).isLoading ? (r(), k(Z, { key: 0 }, [
915
+ d(Ce, {
916
+ loading: e(p).isLoading,
917
+ "row-data": e(g),
918
+ "row-count": e(p).totalRows,
919
+ "column-defs": A,
920
+ "shrink-at": !1,
921
+ "page-count": e(p).pageCount,
922
+ "page-index": e(p).pageIndex,
923
+ "page-size": e(p).pageSize,
924
+ onRowClick: n[1] || (n[1] = (h) => {
925
+ l(h.original);
926
+ }),
927
+ onPageChange: e(S)
928
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
929
+ d(C, { class: "w-full hidden xs:!block" }, {
930
+ default: $(() => [
931
+ (r(!0), k(Z, null, me(e(g), (h) => (r(), V(ne, {
932
+ key: h._id.toString(),
933
+ tag: "label",
934
+ onClick: (Y) => l(h)
935
+ }, {
936
+ default: $(() => [
937
+ s("div", null, [
938
+ s("div", Lt, D((h.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
939
+ s("div", Yt, [
940
+ s("span", zt, D(m(h)), 1),
941
+ E(h) ? (r(), V(R, {
942
+ key: 0,
943
+ class: ce(be),
944
+ label: e(c)("connect.loyalty.segment.default_segments.system"),
945
+ compact: ""
946
+ }, null, 8, ["label"])) : K("", !0)
947
+ ]),
948
+ s("div", Ot, D(i(h.memberCount)) + "% of customers ", 1)
949
+ ])
950
+ ]),
951
+ append: $(() => [
952
+ d(oe, { "stop-click-propagation": !0 }, {
953
+ "menu-button": $(() => [
954
+ d(H, { name: "more_vert" })
955
+ ]),
956
+ default: $(() => [
957
+ d(L, {
958
+ class: "fm-typo-en-body-md-400",
959
+ label: "Export",
960
+ "onUpdate:modelValue": (Y) => Y && J(h)
961
+ }, null, 8, ["onUpdate:modelValue"]),
962
+ E(h) ? K("", !0) : (r(), V(L, {
963
+ key: 0,
964
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
965
+ label: "Remove",
966
+ "onUpdate:modelValue": (Y) => Y && G(h)
967
+ }, null, 8, ["onUpdate:modelValue"]))
968
+ ]),
969
+ _: 2
970
+ }, 1024)
971
+ ]),
972
+ _: 2
973
+ }, 1032, ["onClick"]))), 128))
974
+ ]),
975
+ _: 1
976
+ })
977
+ ], 64)) : (r(), V(Q, {
978
+ key: 1,
979
+ variant: "outlined",
980
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
981
+ }, {
982
+ default: $(() => [
983
+ n[3] || (n[3] = s("img", {
984
+ src: $e,
985
+ class: "aspect-square w-[150px]"
986
+ }, null, -1)),
987
+ s("div", jt, [
988
+ s("div", qt, D(e(c)("connect.loyalty.segment.default_segments.get_started.title")), 1),
989
+ s("div", Gt, D(e(c)(
990
+ "connect.loyalty.segment.default_segments.get_started.description"
991
+ )), 1)
992
+ ]),
993
+ d(N, {
994
+ variant: "primary",
995
+ label: e(c)("connect.loyalty.segment.default_segments.get_started.action"),
996
+ disabled: !e(M).isPremium,
997
+ icon: "auto_awesome",
998
+ onClick: n[2] || (n[2] = (h) => I())
999
+ }, null, 8, ["label", "disabled"])
1000
+ ]),
1001
+ _: 1
1002
+ })),
1003
+ d(Pt, {
1004
+ ref_key: "sheetRef",
1005
+ ref: y,
1006
+ "onUpdate:modelValue": v
1007
+ }, null, 512)
1008
+ ])
1009
+ ], 64);
1010
+ };
1011
+ }
1012
+ });
1013
+ export {
1014
+ ko as default
1015
+ };