@feedmepos/mf-connect 0.1.0-beta.9 → 0.1.1-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 (102) hide show
  1. package/dist/Analytic-C2etD-eu.js +620 -0
  2. package/dist/{App-DQUbRsdA.js → App-DlRvkDpN.js} +58 -59
  3. package/dist/Broadcast-DpCGUS6r.js +216 -0
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D-BFllvG.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Cj4IcH5D.js} +20 -20
  5. package/dist/Card-DjGC6jmq.js +823 -0
  6. package/dist/Collections-Q2pYWnJF.js +440 -0
  7. package/dist/Credit-DOIq2VYW.js +214 -0
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-C_ZKNWzb.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-D7ML8ePp.js} +1010 -1026
  9. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CyxWG5I7.js +344 -0
  10. package/dist/Experience-DUst4I0H.js +211 -0
  11. package/dist/Game-CXnQR-wV.js +250 -0
  12. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-ByhTB9Ie.js +144 -0
  13. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-CyGJxUol.js → MainLayout-DpZC6o3R.js} +53 -19
  14. package/dist/Marketing-CZfHsMFC.js +309 -0
  15. package/dist/Member-CX5Ohgeg.js +92 -0
  16. package/dist/MemberList-D8I3SaAs.js +1040 -0
  17. package/dist/MemberOverview-C2n9oJZh.js +58 -0
  18. package/dist/{MemberTransactions-zSxSnUkK.js → MemberTransactions-DfZNbCHD.js} +1 -1
  19. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-BxFVEoBX.js +203 -0
  20. package/dist/Mission-S1pwDbqp.js +248 -0
  21. package/dist/Point-BdLUcGZy.js +220 -0
  22. package/dist/Promotion-DWAeQGkU.js +244 -0
  23. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CTKKhH-r.js → RuleGroup.vue_vue_type_script_setup_true_lang-Dux_NMO5.js} +577 -568
  24. package/dist/Segment-CXSE8Bzf.js +560 -0
  25. package/dist/Setting-CLuXuEId.js +1870 -0
  26. package/dist/Store-Be3cui0S.js +1533 -0
  27. package/dist/StoreRewards-zFy_w8p4.js +429 -0
  28. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-2Jqj_rKv.js → StoreTransactions.vue_vue_type_script_setup_true_lang-DxGJKgbc.js} +10 -10
  29. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BkdSj0cX.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-Dreo45H1.js} +1 -1
  30. package/dist/{Tier-Cpl0FV8L.js → Tier-ChzcISYF.js} +453 -481
  31. package/dist/{Title-CbMDd1Et.js → Title-DQSjhBkT.js} +295 -314
  32. package/dist/Transaction-CeWmWpN_.js +36 -0
  33. package/dist/Voucher-BkLIxiZN.js +485 -0
  34. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js +140 -0
  35. package/dist/app-CLNirPsB.js +2974 -0
  36. package/dist/{app-VxaUCtgl.js → app-DuNsy0aC.js} +1 -1
  37. package/dist/app.js +3 -5
  38. package/dist/{business-DR7jpnLz.js → business-COGiTmLD.js} +1 -1
  39. package/dist/{campaign-MqcTb329.js → campaign-BHZMjQi5.js} +3 -5
  40. package/dist/{collection.fn-CvEoe61K.js → collection.fn-sAxtYO_r.js} +2 -2
  41. package/dist/dto-ndeeV_nc.js +1145 -0
  42. package/dist/{effect-BjjQeiQg.js → effect-BQt0rkdT.js} +9 -9
  43. package/dist/email-addresses-B3PazwKs.js +705 -0
  44. package/dist/{export-B8cvWh5n.js → export-D6r-xNji.js} +3 -3
  45. package/dist/{helper-DfgVNY7B.js → helper-CrjQw_Et.js} +1 -1
  46. package/dist/{index-CWR3qYjb.js → index-Btlj28Vg.js} +1 -1
  47. package/dist/{index-C7zMfUgy.js → index-Buy-yvAZ.js} +319 -304
  48. package/dist/{index-0UYoh1-7.js → index-C3AAy__p.js} +1 -1
  49. package/dist/index-CHAaFSD2.js +11 -0
  50. package/dist/{index-Dap5R3vr.js → index-Cg3RFxc9.js} +91 -102
  51. package/dist/{index-2P9w5u3m.js → index-CqpEhMr6.js} +4 -4
  52. package/dist/{index-BsfWRB8R.js → index-CvHj-wYi.js} +1 -1
  53. package/dist/index-DGLmbBnE.js +28997 -0
  54. package/dist/{index-CJ8Uh2Ja.js → index-DXpd07G3.js} +3 -3
  55. package/dist/{index-B5NufbUt.js → index-Daax_BQa.js} +1 -1
  56. package/dist/{index-C2JNcGc-.js → index-DrLEuIe1.js} +281 -299
  57. package/dist/{index-DBy30v8N.js → index-tSEYvA-2.js} +3 -3
  58. package/dist/{index.esm2017-D1X3PgpO.js → index.esm2017-a5BlZ76G.js} +55 -55
  59. package/dist/{loading-CJ3nOovJ.js → loading-B3XGyQ8W.js} +460 -469
  60. package/dist/{membership-B1cmSRyk.js → membership-GIOJ1ptN.js} +3 -3
  61. package/dist/money-z7VwzhZP.js +15 -0
  62. package/dist/number-DHYb2ua_.js +12 -0
  63. package/dist/{rule-builder-CSmOONdb.js → rule-builder-CcsWd5r9.js} +1 -1
  64. package/dist/{rule-ChWyR-0j.js → rule-iIEblTE4.js} +179 -177
  65. package/dist/style.css +1 -1
  66. package/dist/{template-Cug7aRK0.js → template-DMRMDZOW.js} +63 -63
  67. package/dist/{xlsx-CfgPFFvp.js → usePagination-CNFe0T2B.js} +3176 -2955
  68. package/package.json +5 -8
  69. package/dist/Analytic-CMXUjK_F.js +0 -622
  70. package/dist/Broadcast-DowFtHv6.js +0 -223
  71. package/dist/Card-C7rhL0pV.js +0 -825
  72. package/dist/Collections-B-1wlk3r.js +0 -453
  73. package/dist/Credit-DDjozmoF.js +0 -220
  74. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-pwMuIgs5.js +0 -345
  75. package/dist/Experience-BbE-c1Op.js +0 -221
  76. package/dist/Game-DQdRpaN-.js +0 -255
  77. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js +0 -144
  78. package/dist/MainLayout-B1aJoR95.js +0 -41
  79. package/dist/Marketing-Dgmxzg4h.js +0 -316
  80. package/dist/Member-w23oRVwN.js +0 -69
  81. package/dist/MemberList-BLIdjznQ.js +0 -1735
  82. package/dist/MemberOverview-wL_ailso.js +0 -58
  83. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-Dy_lMdZA.js +0 -432
  84. package/dist/Mission-Cjt0E083.js +0 -261
  85. package/dist/Point-CQJL3Ewu.js +0 -222
  86. package/dist/Promotion-BYViH3bu.js +0 -247
  87. package/dist/Segment-B9Jj1ak0.js +0 -437
  88. package/dist/Setting-DXWbgRxs.js +0 -1901
  89. package/dist/Store-Dswk2e_z.js +0 -1511
  90. package/dist/StoreRewards-CNUhG_Ue.js +0 -401
  91. package/dist/Transaction-BB-kk-84.js +0 -39
  92. package/dist/Voucher-b1_Jlm6X.js +0 -490
  93. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-pG-SrXp9.js +0 -56
  94. package/dist/app-DCHKJoql.js +0 -5639
  95. package/dist/dto-jcK3TGB7.js +0 -2770
  96. package/dist/index-Cv7pLAYq.js +0 -3
  97. package/dist/index-LrSSauN2.js +0 -29193
  98. package/dist/money-BEATdGS6.js +0 -15
  99. package/dist/number-CeAYAKCp.js +0 -12
  100. package/dist/usePagination-BeF5K3M7.js +0 -223
  101. package/dist/vue-i18n-BRhKDHdF.js +0 -2365
  102. package/dist/zod-Bg2FbC-D.js +0 -90
@@ -1,247 +0,0 @@
1
- import { defineComponent as H, ref as S, computed as q, h as z, onMounted as G, resolveComponent as l, openBlock as m, createElementBlock as h, Fragment as w, createVNode as r, unref as a, createElementVNode as s, withCtx as v, renderList as J, createBlock as b, resolveDynamicComponent as Q, toDisplayString as g } from "vue";
2
- import { _ as W } from "./campaign-CpzFl8Vr.js";
3
- import { useDialog as X, components as Y } from "@feedmepos/ui-library";
4
- import { c as O, p as I, u as Z } from "./loading-CJ3nOovJ.js";
5
- import { u as ee } from "./business-DR7jpnLz.js";
6
- import { u as oe } from "./campaign-MqcTb329.js";
7
- import { u as te } from "./vue-i18n-BRhKDHdF.js";
8
- import { g as V } from "./dto-jcK3TGB7.js";
9
- import { e as L } from "./effect-BjjQeiQg.js";
10
- import { _ as ne } from "./ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js";
11
- import { _ as ae } from "./EditCampaignSheet.vue_vue_type_script_setup_true_lang-C_ZKNWzb.js";
12
- import { u as se } from "./template-Cug7aRK0.js";
13
- import { c as u } from "./index-CWR3qYjb.js";
14
- const ie = { class: "px-24 flex flex-col gap-y-16" }, re = { class: "flex items-center justify-between w-full" }, le = { class: "flex gap-8 overflow-x-auto" }, ce = { class: "space-y-8" }, me = { class: "flex w-full gap-4 items-center" }, pe = { class: "space-y-4" }, de = { class: "fm-typo-en-body-lg-600" }, ue = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, fe = { class: "flex flex-col gap-16 text-center" }, ye = { class: "fm-typo-en-title-sm-800" }, ge = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Le = /* @__PURE__ */ H({
15
- __name: "Promotion",
16
- setup(_e) {
17
- const { t } = te(), T = {
18
- label: t("connect.promotion.createCampaign"),
19
- value: "create",
20
- isPrimary: !0,
21
- prependIcon: "add"
22
- }, B = {
23
- label: "Force sync",
24
- value: "sync",
25
- isPrimary: !1,
26
- prependIcon: "refresh"
27
- }, M = se("PROMOTION", X()), x = ee(), f = oe(), { global: R, minor: _ } = Z, i = S({
28
- searchKey: "",
29
- location: null
30
- }), c = q(
31
- () => f.campaigns.promotion.filter(
32
- (e) => !i.value.location || !e.targetLocation || e.targetLocation.includes(i.value.location)
33
- )
34
- ), K = [
35
- {
36
- header: t("connect.promotion.promotionTitle"),
37
- accessorFn: (e) => e.name
38
- },
39
- {
40
- header: t("connect.promotion.status"),
41
- cell(e) {
42
- return V(e.row.original);
43
- }
44
- },
45
- {
46
- header: t("connect.promotion.type"),
47
- accessorFn: (e) => `${O.title(e.effect.options.target)} promotion`
48
- },
49
- {
50
- header: t("connect.promotion.summary"),
51
- accessorFn: (e) => L(e.effect)
52
- },
53
- {
54
- header: t("connect.promotion.actions"),
55
- cell(e) {
56
- return z(Y.FmButton, {
57
- variant: "tertiary",
58
- icon: "delete",
59
- iconColor: "neutral-gray-400",
60
- onClick: (n) => {
61
- n.stopPropagation(), F(e.row.original);
62
- }
63
- });
64
- }
65
- }
66
- ], C = S();
67
- async function F(e) {
68
- await I.remove(t("promotion.confirmRemove", { name: e.name })) && await _(
69
- async () => {
70
- await u.delete(e._id), await f.read("PROMOTION");
71
- },
72
- {
73
- message: t("promotion.removing", { name: e.name }),
74
- successMessage: t("promotion.removedSuccessfully", { name: e.name })
75
- }
76
- );
77
- }
78
- async function y(e) {
79
- e ? await n() : M.open(async (p) => {
80
- await n(p);
81
- });
82
- async function n(p) {
83
- var d;
84
- (d = C.value) == null || d.showSheet(
85
- !0,
86
- "PROMOTION",
87
- e ? await u.readById(e._id) : void 0,
88
- p
89
- );
90
- }
91
- }
92
- async function N(e) {
93
- await _(
94
- async () => {
95
- e.campaign._id ? await u.update(e.campaign._id, e) : await u.create(e), await f.read("PROMOTION");
96
- },
97
- {
98
- message: t(e.campaign._id ? "promotion.updating" : "promotion.creating"),
99
- successMessage: t(
100
- e.campaign._id ? "promotion.updatedSuccessfully" : "promotion.createdSuccessfully"
101
- )
102
- }
103
- );
104
- }
105
- async function A(e) {
106
- switch (e) {
107
- case "create":
108
- y();
109
- break;
110
- case "sync":
111
- await I.confirm(
112
- "Are you sure you want to synchronize all promotions to POS?",
113
- "Force sync"
114
- ) && _(
115
- async () => {
116
- await u.syncAllPromotion();
117
- },
118
- {
119
- message: "Syncing promotions...",
120
- successMessage: "All promotions synced"
121
- }
122
- );
123
- break;
124
- }
125
- }
126
- return G(async () => {
127
- await R(async () => {
128
- await x.readLocations(), await f.read("PROMOTION");
129
- });
130
- }), (e, n) => {
131
- const p = l("FmPageHead"), d = l("FmSearch"), $ = l("FmTable"), D = l("FmChip"), k = l("FmButton"), U = l("FmListItem"), j = l("FmList"), E = l("FmCard");
132
- return m(), h(w, null, [
133
- r(p, {
134
- title: a(t)("connect.promotion.title"),
135
- actions: a(c).length > 0 ? [T, B] : [],
136
- "onClick:action": A
137
- }, null, 8, ["title", "actions"]),
138
- s("div", ie, [
139
- r(d, {
140
- modelValue: i.value.searchKey,
141
- "onUpdate:modelValue": n[0] || (n[0] = (o) => i.value.searchKey = o),
142
- class: "hidden xs:block border-b-2 border-fm-color-neutral-gray-100",
143
- placeholder: a(t)("connect.promotion.search"),
144
- collapsible: ""
145
- }, null, 8, ["modelValue", "placeholder"]),
146
- a(c) && a(c).length > 0 ? (m(), h(w, { key: 0 }, [
147
- s("div", re, [
148
- s("div", le, [
149
- r(ne, {
150
- modelValue: i.value.location,
151
- "onUpdate:modelValue": n[1] || (n[1] = (o) => i.value.location = o),
152
- label: a(t)("connect.promotion.location"),
153
- "show-item-label": !0,
154
- icon: "storefront",
155
- placement: "bottom-start",
156
- items: a(x).locationItems
157
- }, null, 8, ["modelValue", "label", "items"])
158
- ]),
159
- r(d, {
160
- modelValue: i.value.searchKey,
161
- "onUpdate:modelValue": n[2] || (n[2] = (o) => i.value.searchKey = o),
162
- class: "xs:hidden",
163
- placeholder: "search",
164
- collapsible: ""
165
- }, null, 8, ["modelValue"])
166
- ]),
167
- r($, {
168
- class: "xs:hidden",
169
- "row-data": a(c),
170
- "column-defs": K,
171
- "search-value": i.value.searchKey,
172
- "column-filter": [],
173
- onRowClick: n[3] || (n[3] = (o) => y(o.original)),
174
- "hide-footer": a(c).length < 10
175
- }, null, 8, ["row-data", "search-value", "hide-footer"]),
176
- r(j, { class: "hidden xs:flex flex-col mx-[-24px]" }, {
177
- default: v(() => [
178
- (m(!0), h(w, null, J(a(c).filter(
179
- (o) => o.name.toLowerCase().includes(i.value.searchKey.toLowerCase())
180
- ), (o) => (m(), b(U, {
181
- key: o._id.toString(),
182
- onClick: (P) => y(o),
183
- class: "py-12 px-16 flex items-center justify-between border-b border-fm-color-neutral-gray-100"
184
- }, {
185
- default: v(() => [
186
- s("div", ce, [
187
- s("div", me, [
188
- (m(), b(Q(a(V)(o)))),
189
- r(D, {
190
- class: "!text-fm-color-typo-info !bg-fm-color-system-info-100",
191
- compact: !0,
192
- label: `${a(O).title(o.effect.options.target)} promotion`
193
- }, null, 8, ["label"])
194
- ]),
195
- s("div", pe, [
196
- s("div", de, g(o.name), 1),
197
- s("div", ue, g(a(L)(o.effect)), 1)
198
- ])
199
- ]),
200
- r(k, {
201
- icon: "delete",
202
- "icon-color": "neutral-gray-400",
203
- variant: "tertiary",
204
- onClick: (P) => (P.stopPropagation(), F(o))
205
- }, null, 8, ["onClick"])
206
- ]),
207
- _: 2
208
- }, 1032, ["onClick"]))), 128))
209
- ]),
210
- _: 1
211
- })
212
- ], 64)) : (m(), b(E, {
213
- key: 1,
214
- variant: "outlined",
215
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
216
- }, {
217
- default: v(() => [
218
- n[5] || (n[5] = s("img", {
219
- src: W,
220
- class: "aspect-square w-[150px]"
221
- }, null, -1)),
222
- s("div", fe, [
223
- s("div", ye, g(a(t)("connect.promotion.createPromotionCampaign")), 1),
224
- s("div", ge, g(a(t)("connect.promotion.description")), 1)
225
- ]),
226
- r(k, {
227
- variant: "primary",
228
- label: a(t)("connect.promotion.createPromotionCampaign"),
229
- icon: "add",
230
- onClick: n[4] || (n[4] = (o) => y())
231
- }, null, 8, ["label"])
232
- ]),
233
- _: 1
234
- }))
235
- ]),
236
- r(ae, {
237
- ref_key: "sheetRef",
238
- ref: C,
239
- "onSubmit:modelValue": N
240
- }, null, 512)
241
- ], 64);
242
- };
243
- }
244
- });
245
- export {
246
- Le as default
247
- };
@@ -1,437 +0,0 @@
1
- import { defineComponent as A, onMounted as E, openBlock as c, createElementBlock as w, createElementVNode as a, toDisplayString as F, unref as e, createVNode as l, createCommentVNode as T, ref as $, computed as j, resolveComponent as p, createBlock as B, isRef as W, createSlots as K, withCtx as f, Fragment as P, h as R, onBeforeMount as Q, renderList as X } from "vue";
2
- import { _ as ee } from "./campaign-CpzFl8Vr.js";
3
- import { F as N, p as te, u as oe } from "./loading-CJ3nOovJ.js";
4
- import { components as L } from "@feedmepos/ui-library";
5
- import { u as H, _ as O } from "./usePagination-BeF5K3M7.js";
6
- import { u as ne } from "./vue-i18n-BRhKDHdF.js";
7
- import { Z as ae } from "./zod-Bg2FbC-D.js";
8
- import { a as se } from "./index-DBy30v8N.js";
9
- import { u as le } from "./app-wDQR6dpb.js";
10
- import { R as ie } from "./rule-builder-CSmOONdb.js";
11
- import { _ as re } from "./ZodTextField.vue_vue_type_script_setup_true_lang-pG-SrXp9.js";
12
- import { _ as me } from "./RuleGroup.vue_vue_type_script_setup_true_lang-CTKKhH-r.js";
13
- import { h as V } from "./moment-BWErdI6_.js";
14
- import { s as k } from "./membership-B1cmSRyk.js";
15
- import { o as de } from "./objectId-dwaoBfJX.js";
16
- import { u as ce } from "./business-DR7jpnLz.js";
17
- import { m as ue } from "./index-0UYoh1-7.js";
18
- const pe = se.extend({
19
- _id: N.optional(),
20
- business: N.optional()
21
- }), ge = { class: "space-y-16 pr-12" }, fe = { class: "fm-typo-en-title-md-800" }, ye = { class: "flex space-x-8" }, ve = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, _e = { class: "text-fm-color-typo-secondary" }, be = {
22
- key: 0,
23
- class: "w-full flex flex-col gap-16 items-center pt-16"
24
- }, he = /* @__PURE__ */ A({
25
- __name: "ReviewSegment",
26
- props: {
27
- title: {},
28
- segment: {}
29
- },
30
- setup(D) {
31
- const y = D, v = [
32
- {
33
- header: "Name",
34
- accessorFn: (o) => o.name
35
- },
36
- {
37
- header: "Id",
38
- accessorFn: (o) => o._id
39
- },
40
- {
41
- header: "Customer Since",
42
- accessorFn: (o) => V(de(o._id.toString())).format("DD MMM YYYY")
43
- },
44
- {
45
- header: "Phone",
46
- accessorFn: (o) => o.phoneNumber
47
- },
48
- {
49
- header: "Birthday",
50
- accessorFn: (o) => V(o.birthday).format("DD MMM YYYY")
51
- },
52
- {
53
- header: "Last Visit",
54
- accessorFn: (o) => V(o.stats.lastVisit).format("DD MMM YYYY")
55
- }
56
- ], _ = async (o) => y.segment._id ? await k.paginateSegmentUsers(y.segment._id, {
57
- limit: i.value.pageSize,
58
- skip: o.pageIndex ?? 0,
59
- sortBy: "_id",
60
- search: o.searchValue,
61
- descending: !0
62
- }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: i, rowData: d, onSort: h, debouncedFetchData: m, onSearch: r } = H(_);
63
- return E(async () => {
64
- await m();
65
- }), (o, g) => (c(), w("div", ge, [
66
- a("div", fe, F(y.title), 1),
67
- a("div", ye, [
68
- a("div", ve, F(o.segment.members.length), 1),
69
- a("div", _e, [
70
- g[1] || (g[1] = a("div", null, "contacts in your segment", -1)),
71
- a("div", null, "as of " + F(e(V)(o.segment.lastUpdated).format("DD MMM YYYY")), 1)
72
- ])
73
- ]),
74
- l(O, {
75
- loading: e(i).isLoading,
76
- "row-data": e(d),
77
- "row-count": e(i).totalRows,
78
- "column-defs": v,
79
- "page-size": e(i).pageSize,
80
- "page-count": e(i).pageCount,
81
- "page-index": e(i).pageIndex,
82
- onSortChange: e(h),
83
- onPageChange: g[0] || (g[0] = (S) => e(m)({ pageSize: S.pageSize, pageIndex: S.pageIndex }))
84
- }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"]),
85
- e(d).length == 0 ? (c(), w("div", be, g[2] || (g[2] = [
86
- a("div", { class: "fm-typo-en-body-lg-600" }, "No data found", -1),
87
- a("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " No data to show at the current moment. ", -1)
88
- ]))) : T("", !0)
89
- ]));
90
- }
91
- }), Se = { class: "flex items-center gap-x-8" }, xe = {
92
- key: 0,
93
- class: "space-y-16 pr-12"
94
- }, we = { class: "flex items-center gap-8" }, Fe = /* @__PURE__ */ A({
95
- __name: "SegmentSheet",
96
- emits: ["update:model-value"],
97
- setup(D, { expose: y, emit: v }) {
98
- const _ = le(), i = $(!1), d = $(!1), h = {
99
- name: "",
100
- rule: ie.scaffoldGroup(),
101
- members: []
102
- }, m = pe, r = $(h), o = j(() => {
103
- const t = m.safeParse(r.value);
104
- return t.success ? [] : t.error.errors;
105
- });
106
- function g(t) {
107
- i.value = !0, d.value = !1, t ? r.value = { ...t } : r.value = { ...h };
108
- }
109
- function S() {
110
- i.value = !1;
111
- }
112
- async function Y() {
113
- m.safeParse(r.value).success && (d.value = !0);
114
- }
115
- function C() {
116
- d.value = !1;
117
- }
118
- async function z() {
119
- n("update:model-value", r.value);
120
- }
121
- E(async () => {
122
- });
123
- const n = v;
124
- return y({
125
- showSheet: g,
126
- hideSheet: S
127
- }), (t, s) => {
128
- const x = p("FmButton"), M = p("FmSideSheet");
129
- return c(), B(M, {
130
- modelValue: e(i),
131
- "onUpdate:modelValue": s[5] || (s[5] = (b) => W(i) ? i.value = b : null),
132
- header: "Add segment",
133
- "dismiss-away": "",
134
- "close-button": !0,
135
- "max-width": 1100
136
- }, K({
137
- "side-sheet-footer": f(() => [
138
- a("div", we, [
139
- e(d) ? (c(), w(P, { key: 0 }, [
140
- l(x, {
141
- label: "Save Segment",
142
- onClick: z,
143
- loading: e(_).isLoading,
144
- disabled: e(o).length > 0 || e(_).isLoading
145
- }, null, 8, ["loading", "disabled"]),
146
- l(x, {
147
- label: "Cancel",
148
- onClick: s[3] || (s[3] = (b) => C()),
149
- variant: "tertiary"
150
- })
151
- ], 64)) : (c(), w(P, { key: 1 }, [
152
- l(x, {
153
- label: "Review Segment",
154
- disabled: e(o).length > 0 || e(_).isLoading,
155
- onClick: Y
156
- }, null, 8, ["disabled"]),
157
- l(x, {
158
- label: "Cancel",
159
- onClick: s[4] || (s[4] = (b) => S()),
160
- variant: "tertiary"
161
- })
162
- ], 64))
163
- ])
164
- ]),
165
- default: f(() => {
166
- var b;
167
- return [
168
- e(d) ? (c(), B(he, {
169
- key: 1,
170
- title: e(r).name,
171
- segment: e(r)
172
- }, null, 8, ["title", "segment"])) : (c(), w("div", xe, [
173
- l(re, {
174
- modelValue: e(r).name,
175
- "onUpdate:modelValue": s[1] || (s[1] = (I) => e(r).name = I),
176
- label: "Segment title",
177
- schema: e(ae).typeAtPath(e(m), "name")
178
- }, null, 8, ["modelValue", "schema"]),
179
- s[7] || (s[7] = a("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
180
- l(me, {
181
- "trigger-type": "MEMBERSHIP_JOINED",
182
- includeOnly: "user",
183
- "model-value": (b = e(r)) == null ? void 0 : b.rule,
184
- "onUpdate:modelValue": s[2] || (s[2] = (I) => {
185
- e(r).rule = I;
186
- })
187
- }, null, 8, ["model-value"])
188
- ]))
189
- ];
190
- }),
191
- _: 2
192
- }, [
193
- e(d) ? {
194
- name: "side-sheet-header",
195
- fn: f(() => [
196
- a("div", Se, [
197
- l(x, {
198
- icon: "arrow_back",
199
- variant: "tertiary",
200
- onClick: s[0] || (s[0] = (b) => d.value = !1)
201
- }),
202
- s[6] || (s[6] = a("div", null, "Review segment", -1))
203
- ])
204
- ]),
205
- key: "0"
206
- } : void 0
207
- ]), 1032, ["modelValue"]);
208
- };
209
- }
210
- }), Ce = { class: "flex items-center" }, ke = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Me = { class: "px-24 flex flex-col gap-y-16" }, Ie = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Re = { class: "fm-typo-en-body-md-600" }, $e = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Je = /* @__PURE__ */ A({
211
- __name: "Segment",
212
- setup(D) {
213
- const { minor: y } = oe, { t: v } = ne(), _ = ce(), i = $(0), d = [
214
- {
215
- header: v("connect.loyalty.segment.table.name"),
216
- accessorFn: (n) => n.name
217
- },
218
- {
219
- header: v("connect.loyalty.segment.table.total_customers"),
220
- accessorFn: (n) => n.memberCount ?? 0
221
- },
222
- {
223
- header: v("connect.loyalty.segment.table.customer_percentage"),
224
- accessorFn: (n) => ((n.memberCount ?? 0) * 100 / i.value).toFixed(2)
225
- },
226
- {
227
- header: v("connect.loyalty.segment.table.actions"),
228
- meta: {
229
- maxWidth: "100px"
230
- },
231
- cell(n) {
232
- return R("div", { class: "flex items-center justify-end" }, [
233
- R(
234
- L.FmMenu,
235
- {
236
- placement: "bottom-end",
237
- onClick: (t) => {
238
- t.stopPropagation();
239
- }
240
- },
241
- {
242
- "menu-button": () => R(L.FmButton, {
243
- icon: "more_vert",
244
- iconColor: "neutral-gray-400",
245
- variant: "tertiary"
246
- }),
247
- default: () => [
248
- R(
249
- L.FmMenuItem,
250
- {
251
- onClick: async (t) => {
252
- t.stopPropagation(), S(n.row.original);
253
- }
254
- },
255
- {
256
- label: R(
257
- "div",
258
- {
259
- class: "text-fm-color-typo-error fm-typo-en-body-md-400"
260
- },
261
- "Remove"
262
- )
263
- }
264
- )
265
- ]
266
- }
267
- )
268
- ]);
269
- }
270
- }
271
- ], h = $(null), { tableMeta: m, rowData: r, debouncedFetchData: o } = H(
272
- k.readAll
273
- );
274
- async function g() {
275
- await y(
276
- async () => {
277
- await k.refreshSegments(), await o({ pageSize: 10, pageIndex: 0 });
278
- },
279
- { message: "Refreshing segmentations" }
280
- );
281
- }
282
- async function S(n) {
283
- await te.remove(`Are you sure you want to remove ${n.name}?`) && await y(
284
- async () => {
285
- await k.delete(n._id), await o({ pageSize: 10, pageIndex: 0 });
286
- },
287
- {
288
- message: `Removing ${n.name}`,
289
- successMessage: `Removed ${n.name} successfully`
290
- }
291
- );
292
- }
293
- async function Y(n) {
294
- await y(
295
- async () => {
296
- var t;
297
- if (n._id) {
298
- const { members: s, _id: x, ...M } = n;
299
- await k.update(n._id, M);
300
- } else
301
- await k.create(n);
302
- await o({ pageSize: 10, pageIndex: 0 }), (t = h.value) == null || t.hideSheet();
303
- },
304
- {
305
- message: "Saving segment",
306
- successMessage: "Segment saved"
307
- }
308
- );
309
- }
310
- function C(n) {
311
- var t;
312
- (t = h.value) == null || t.showSheet(n);
313
- }
314
- const z = j(() => _.isPremium ? [
315
- {
316
- label: "Refresh segments",
317
- value: "refresh"
318
- },
319
- {
320
- label: "Add segment",
321
- value: "add",
322
- isPrimary: !0,
323
- prependIcon: "add"
324
- }
325
- ] : []);
326
- return Q(async () => {
327
- const { meta: n } = await ue.read({
328
- limit: 1,
329
- skip: 0,
330
- sortBy: "_id",
331
- search: void 0,
332
- descending: !1
333
- });
334
- i.value = n.totalResources ?? 0, await o({ pageSize: 10, pageIndex: 0 }), await _.readPremium();
335
- }), (n, t) => {
336
- const s = p("FmPill"), x = p("FmPageHead"), M = p("FmIcon"), b = p("FmMenuItem"), I = p("FmMenu"), Z = p("FmListItem"), q = p("FmList"), G = p("FmButton"), J = p("FmCard");
337
- return c(), w(P, null, [
338
- l(x, {
339
- title: "Segments",
340
- actions: e(z),
341
- "onClick:action": t[0] || (t[0] = (u) => u === "add" ? C() : g())
342
- }, {
343
- title: f(() => [
344
- a("div", Ce, [
345
- a("span", ke, F(e(v)("connect.loyalty.segment.title")), 1),
346
- l(s, { variant: "premium" })
347
- ])
348
- ]),
349
- _: 1
350
- }, 8, ["actions"]),
351
- a("div", Me, [
352
- e(r).length > 0 || e(m).searchValue || e(m).isLoading ? (c(), w(P, { key: 0 }, [
353
- l(O, {
354
- loading: e(m).isLoading,
355
- "row-data": e(r),
356
- "row-count": e(m).totalRows,
357
- "column-defs": d,
358
- "shrink-at": !1,
359
- "page-count": e(m).pageCount,
360
- "page-index": e(m).pageIndex,
361
- "page-size": e(m).pageSize,
362
- onRowClick: t[1] || (t[1] = (u) => {
363
- C(u.original);
364
- }),
365
- onPageChange: e(o)
366
- }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
367
- l(q, { class: "w-full hidden xs:block" }, {
368
- default: f(() => [
369
- (c(!0), w(P, null, X(e(r), (u) => (c(), B(Z, {
370
- key: u._id.toString(),
371
- tag: "label",
372
- onClick: (U) => C(u)
373
- }, {
374
- default: f(() => [
375
- a("div", null, [
376
- a("div", Ie, F((u.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
377
- a("div", Re, F(u.name), 1),
378
- a("div", $e, F(((u.memberCount ?? 0) * 100 / e(i)).toFixed(2)) + "% of customers ", 1)
379
- ])
380
- ]),
381
- append: f(() => [
382
- l(I, { "stop-click-propagation": !0 }, {
383
- "menu-button": f(() => [
384
- l(M, { name: "more_vert" })
385
- ]),
386
- default: f(() => [
387
- l(b, {
388
- class: "text-fm-color-typo-error fm-typo-en-body-md-400",
389
- label: "Remove",
390
- "onUpdate:modelValue": (U) => U && S(u)
391
- }, null, 8, ["onUpdate:modelValue"])
392
- ]),
393
- _: 2
394
- }, 1024)
395
- ]),
396
- _: 2
397
- }, 1032, ["onClick"]))), 128))
398
- ]),
399
- _: 1
400
- })
401
- ], 64)) : (c(), B(J, {
402
- key: 1,
403
- variant: "outlined",
404
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
405
- }, {
406
- default: f(() => [
407
- t[3] || (t[3] = a("img", {
408
- src: ee,
409
- class: "aspect-square w-[150px]"
410
- }, null, -1)),
411
- t[4] || (t[4] = a("div", { class: "flex flex-col gap-16 text-center" }, [
412
- a("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
413
- a("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. ")
414
- ], -1)),
415
- l(G, {
416
- variant: "primary",
417
- label: "Create segment",
418
- disabled: !e(_).isPremium,
419
- icon: "add",
420
- onClick: t[2] || (t[2] = (u) => C())
421
- }, null, 8, ["disabled"])
422
- ]),
423
- _: 1
424
- })),
425
- l(Fe, {
426
- ref_key: "sheetRef",
427
- ref: h,
428
- "onUpdate:modelValue": Y
429
- }, null, 512)
430
- ])
431
- ], 64);
432
- };
433
- }
434
- });
435
- export {
436
- Je as default
437
- };