@feedmepos/mf-connect 0.0.16-beta.1 → 0.0.16-beta.11

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 (95) hide show
  1. package/dist/{Analytic-C-zZmF5N.js → Analytic-Gq7PoNer.js} +368 -365
  2. package/dist/App-Cikl5jnp.js +177 -0
  3. package/dist/Broadcast-DU3JnBwZ.js +223 -0
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-VWLBlxy1.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D0I8IZIR.js} +20 -20
  5. package/dist/Card-hIeQ5XUH.js +825 -0
  6. package/dist/Collections-B1SC1rr7.js +453 -0
  7. package/dist/Credit-BgwI8DR3.js +216 -0
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-Bz6TSmbW.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-D9VR3P2d.js} +1026 -1022
  9. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-AhWnHG02.js → EffectSheet.vue_vue_type_style_index_0_lang-DPgu45MD.js} +29 -29
  10. package/dist/Experience-C2Q-zqV6.js +221 -0
  11. package/dist/Game-DU2pZDGk.js +255 -0
  12. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js +144 -0
  13. package/dist/JsonViewer-v8_C7l5N.js +87 -0
  14. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-DykNOOFD.js → LottieAnimation.vue_vue_type_script_setup_true_lang-CyGJxUol.js} +1 -1
  15. package/dist/{MainLayout-D0AoA1tk.js → MainLayout-B1aJoR95.js} +2 -2
  16. package/dist/Marketing-DWiTQp9I.js +316 -0
  17. package/dist/Member-BEXKBFry.js +69 -0
  18. package/dist/MemberList-DzMdajIf.js +1733 -0
  19. package/dist/MemberOverview-wL_ailso.js +58 -0
  20. package/dist/{MemberTransactions-CTAx5jIV.js → MemberTransactions-Bciankuu.js} +1 -1
  21. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-C-BtHxSc.js → MessageInput.vue_vue_type_script_setup_true_lang-DH25Hfk3.js} +46 -46
  22. package/dist/Mission-KzwRlaA5.js +259 -0
  23. package/dist/Point-CSKvZXHc.js +222 -0
  24. package/dist/Promotion-IiwPhx8p.js +221 -0
  25. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CrpJySSp.js → RuleGroup.vue_vue_type_script_setup_true_lang-4zIO3oCr.js} +545 -544
  26. package/dist/Segment-2Q0PonBb.js +447 -0
  27. package/dist/{Setting-Zrj5P_4m.js → Setting-Df5vVRt4.js} +600 -598
  28. package/dist/Store-C0WXCKs6.js +1503 -0
  29. package/dist/StoreRewards-eSSIO0nk.js +401 -0
  30. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-DS4APaHw.js → StoreTransactions.vue_vue_type_script_setup_true_lang-BjnCRKGX.js} +106 -108
  31. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-ZYjWlDJ1.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-b0xTcoEp.js} +1 -1
  32. package/dist/{Tier-DVWJyQ9S.js → Tier-v-1FkRU-.js} +464 -449
  33. package/dist/{Title-B5kX64vs.js → Title-CQ2JWqBW.js} +315 -299
  34. package/dist/Transaction-0OouN_6s.js +39 -0
  35. package/dist/Voucher-CL0cgogx.js +488 -0
  36. package/dist/_commonjsHelpers-BkfeUUK-.js +28 -0
  37. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  38. package/dist/app-Bd19eW7X.js +5381 -0
  39. package/dist/app-CfS25Z66.js +34797 -0
  40. package/dist/app-wDQR6dpb.js +39 -0
  41. package/dist/app.js +5 -3
  42. package/dist/business-dQh3AEot.js +78 -0
  43. package/dist/{campaign-BZJuknWK.js → campaign-BOl8AgKA.js} +12 -12
  44. package/dist/{collection.fn-DoCkZ6z4.js → collection.fn-B_YsXmrP.js} +2 -2
  45. package/dist/dto-B8NfyVPG.js +1169 -0
  46. package/dist/{effect-B8kmnKvY.js → effect-C2jCStXO.js} +1 -1
  47. package/dist/{export-Dm6LYnWo.js → export-BtZc3Yzh.js} +3 -3
  48. package/dist/{helper-DR4XK3nv.js → helper-8oGsrM56.js} +1 -1
  49. package/dist/{index-DcUrk07Q.js → index-6FkKY3q0.js} +3 -3
  50. package/dist/{index-Bu4_26qI.js → index-C7oeXRUl.js} +1 -1
  51. package/dist/{index-CuL5-ORK.js → index-CZKYIefW.js} +6 -7
  52. package/dist/{index-yxJMhfxj.js → index-C_0IFnwi.js} +5 -5
  53. package/dist/{index-BryrRq8O.js → index-DCixRRvz.js} +36 -30
  54. package/dist/{index-CkiYkbXb.js → index-DFgt4-VW.js} +1 -1
  55. package/dist/{index-CWf0mh3a.js → index-DYDhH9bi.js} +177 -168
  56. package/dist/{index-boor8e80.js → index-Di-kWSmf.js} +3 -3
  57. package/dist/{app-DkI7dYRN.js → index-Dn0jdj0o.js} +9665 -13024
  58. package/dist/index-DwKqFNF6.js +3 -0
  59. package/dist/{index-BobRgQrE.js → index-HoacsZDk.js} +2 -2
  60. package/dist/{index-BxkxVtgm.js → index-UTQHDUdW.js} +1 -1
  61. package/dist/{loading-BzV5acUX.js → loading-D_AN6p24.js} +6807 -6805
  62. package/dist/{lodash-mg4435Qq.js → lodash-B5I3zXaY.js} +1 -1
  63. package/dist/{membership-CqbsLHqx.js → membership-Ccrx9R6r.js} +3 -3
  64. package/dist/{money-DA_gtp3q.js → money-waD-f-Zz.js} +1 -1
  65. package/dist/{number-C388eyOu.js → number-CwTGGsh9.js} +1 -1
  66. package/dist/{rule-Clmr5y4j.js → rule-DJ07h3Gh.js} +2 -2
  67. package/dist/{rule-builder-BgqNbM-P.js → rule-builder-DJ-acvVD.js} +1 -1
  68. package/dist/style.css +1 -1
  69. package/dist/template-clxvNnbF.js +190 -0
  70. package/dist/{usePagination-o5fgsZwU.js → usePagination-BeF5K3M7.js} +86 -86
  71. package/dist/vue-i18n-BxwiXSkp.js +2365 -0
  72. package/dist/{xlsx-BRdh9e2p.js → xlsx-BB366cdN.js} +1945 -1945
  73. package/package.json +9 -5
  74. package/dist/Broadcast-X69Mtv3b.js +0 -216
  75. package/dist/Card-D0X3v1UF.js +0 -822
  76. package/dist/Collections-umR6Ehqf.js +0 -452
  77. package/dist/Credit-C1EWF7R0.js +0 -214
  78. package/dist/Experience-CqL8wyPm.js +0 -211
  79. package/dist/Game--kYe64EV.js +0 -250
  80. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-BjOJ3XSL.js +0 -144
  81. package/dist/Marketing-CTCQ5ZmZ.js +0 -308
  82. package/dist/Member-DCduX7zP.js +0 -91
  83. package/dist/MemberList-B0EkXZJu.js +0 -1729
  84. package/dist/MemberOverview-C2n9oJZh.js +0 -58
  85. package/dist/Mission-CVr9rS_D.js +0 -248
  86. package/dist/Point-BnZ6M74y.js +0 -220
  87. package/dist/Promotion-B0PUve5S.js +0 -218
  88. package/dist/Segment-B-XpkyM5.js +0 -445
  89. package/dist/Store-B2gywCt2.js +0 -1503
  90. package/dist/StoreRewards-D8410Q_-.js +0 -434
  91. package/dist/Transaction-CZBO4v4d.js +0 -36
  92. package/dist/Voucher-se-4JF9B.js +0 -481
  93. package/dist/app-B2ImSO3V.js +0 -53382
  94. package/dist/dto-BWpvRpK2.js +0 -1151
  95. package/dist/template-Dwp7heBA.js +0 -190
@@ -1,218 +0,0 @@
1
- import { defineComponent as A, ref as k, computed as D, onMounted as j, resolveComponent as i, openBlock as c, createElementBlock as g, Fragment as y, createVNode as s, unref as l, createElementVNode as a, withCtx as _, renderList as E, createBlock as h, resolveDynamicComponent as H, toDisplayString as P, h as q } from "vue";
2
- import { _ as z } from "./campaign-CpzFl8Vr.js";
3
- import { useDialog as G, components as J } from "@feedmepos/ui-library";
4
- import { c as S, u as Q, p as W } from "./loading-BzV5acUX.js";
5
- import { a as X } from "./app-DkI7dYRN.js";
6
- import { u as Y } from "./campaign-BZJuknWK.js";
7
- import { g as O } from "./dto-BWpvRpK2.js";
8
- import { e as L } from "./effect-B8kmnKvY.js";
9
- import { _ as Z } from "./ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js";
10
- import { _ as ee } from "./EditCampaignSheet.vue_vue_type_script_setup_true_lang-Bz6TSmbW.js";
11
- import { u as oe } from "./template-Dwp7heBA.js";
12
- import { c as f } from "./index-BxkxVtgm.js";
13
- const te = { class: "px-24 flex flex-col gap-y-16" }, ae = { class: "flex items-center justify-between w-full" }, ne = { class: "flex gap-8 overflow-x-auto" }, se = { class: "space-y-8" }, le = { class: "flex w-full gap-4 items-center" }, ie = { class: "space-y-4" }, re = { class: "fm-typo-en-body-lg-600" }, ce = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, me = /* @__PURE__ */ a("img", {
14
- src: z,
15
- class: "aspect-square w-[150px]"
16
- }, null, -1), de = /* @__PURE__ */ a("div", { class: "flex flex-col gap-16 text-center" }, [
17
- /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Create promotion campaign"),
18
- /* @__PURE__ */ a("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Special offers or deals made available for a limited time to encourage user engagement and purchases. Promotions are generally available to all eligible users without the need for a specific code and are applied by merchant during the promotional period. ")
19
- ], -1), ke = /* @__PURE__ */ A({
20
- __name: "Promotion",
21
- setup(pe) {
22
- const V = {
23
- label: "Create campaign",
24
- value: "create",
25
- isPrimary: !0,
26
- prependIcon: "add"
27
- }, $ = oe("PROMOTION", G()), v = X(), p = Y(), { global: T, minor: w } = Q, n = k({
28
- searchKey: "",
29
- location: null
30
- }), r = D(
31
- () => p.campaigns.promotion.filter(
32
- (e) => !n.value.location || !e.targetLocation || e.targetLocation.includes(n.value.location)
33
- )
34
- ), I = [
35
- {
36
- header: "Promotion title",
37
- accessorFn: (e) => e.name
38
- },
39
- {
40
- header: "Status",
41
- cell(e) {
42
- return O(e.row.original);
43
- }
44
- },
45
- {
46
- header: "Type",
47
- accessorFn: (e) => `${S.title(e.effect.options.target)} promotion`
48
- },
49
- {
50
- header: "Summary",
51
- accessorFn: (e) => L(e.effect)
52
- },
53
- {
54
- header: "Actions",
55
- cell(e) {
56
- return q(J.FmButton, {
57
- variant: "tertiary",
58
- icon: "delete",
59
- iconColor: "neutral-gray-400",
60
- onClick: (t) => {
61
- t.stopPropagation(), x(e.row.original);
62
- }
63
- });
64
- }
65
- }
66
- ], b = k();
67
- async function x(e) {
68
- await W.remove(`Are you sure you want to remove ${e.name}?`) && await w(
69
- async () => {
70
- await f.delete(e._id), await p.read("PROMOTION");
71
- },
72
- {
73
- message: `Removing ${e.name}`,
74
- successMessage: `Removed ${e.name} successfully`
75
- }
76
- );
77
- }
78
- async function u(e) {
79
- e ? await t() : $.open(async (m) => {
80
- await t(m);
81
- });
82
- async function t(m) {
83
- var d;
84
- (d = b.value) == null || d.showSheet(
85
- !0,
86
- "PROMOTION",
87
- e ? await f.readById(e._id) : void 0,
88
- m
89
- );
90
- }
91
- }
92
- async function R(e) {
93
- await w(
94
- async () => {
95
- e.campaign._id ? await f.update(e.campaign._id, e) : await f.create(e), await p.read("PROMOTION");
96
- },
97
- {
98
- message: `${e.campaign._id ? "Updating" : "Creating"} promotion`,
99
- successMessage: `Promotion ${e.campaign._id ? "updated" : "created"} successfully`
100
- }
101
- );
102
- }
103
- return j(async () => {
104
- await T(async () => {
105
- await v.readLocations(), await p.read("PROMOTION");
106
- });
107
- }), (e, t) => {
108
- const m = i("FmPageHead"), d = i("FmSearch"), B = i("FmTable"), M = i("FmChip"), C = i("FmButton"), K = i("FmListItem"), N = i("FmList"), U = i("FmCard");
109
- return c(), g(y, null, [
110
- s(m, {
111
- title: "Promotion",
112
- actions: l(r).length > 0 ? [V] : [],
113
- "onClick:action": t[0] || (t[0] = (o) => u())
114
- }, null, 8, ["actions"]),
115
- a("div", te, [
116
- s(d, {
117
- modelValue: n.value.searchKey,
118
- "onUpdate:modelValue": t[1] || (t[1] = (o) => n.value.searchKey = o),
119
- class: "hidden xs:block border-b-2 border-fm-color-neutral-gray-100",
120
- placeholder: "search",
121
- collapsible: ""
122
- }, null, 8, ["modelValue"]),
123
- l(r) && l(r).length > 0 ? (c(), g(y, { key: 0 }, [
124
- a("div", ae, [
125
- a("div", ne, [
126
- s(Z, {
127
- modelValue: n.value.location,
128
- "onUpdate:modelValue": t[2] || (t[2] = (o) => n.value.location = o),
129
- label: "Location: ",
130
- "show-item-label": !0,
131
- icon: "storefront",
132
- placement: "bottom-start",
133
- items: l(v).locationItems
134
- }, null, 8, ["modelValue", "items"])
135
- ]),
136
- s(d, {
137
- modelValue: n.value.searchKey,
138
- "onUpdate:modelValue": t[3] || (t[3] = (o) => n.value.searchKey = o),
139
- class: "xs:hidden",
140
- placeholder: "search",
141
- collapsible: ""
142
- }, null, 8, ["modelValue"])
143
- ]),
144
- s(B, {
145
- class: "xs:hidden",
146
- "row-data": l(r),
147
- "column-defs": I,
148
- "search-value": n.value.searchKey,
149
- "column-filter": [],
150
- onRowClick: t[4] || (t[4] = (o) => u(o.original)),
151
- "hide-footer": l(r).length < 10
152
- }, null, 8, ["row-data", "search-value", "hide-footer"]),
153
- s(N, { class: "hidden xs:flex flex-col mx-[-24px]" }, {
154
- default: _(() => [
155
- (c(!0), g(y, null, E(l(r).filter(
156
- (o) => o.name.toLowerCase().includes(n.value.searchKey.toLowerCase())
157
- ), (o) => (c(), h(K, {
158
- key: o._id.toString(),
159
- onClick: (F) => u(o),
160
- class: "py-12 px-16 flex items-center justify-between border-b border-fm-color-neutral-gray-100"
161
- }, {
162
- default: _(() => [
163
- a("div", se, [
164
- a("div", le, [
165
- (c(), h(H(l(O)(o)))),
166
- s(M, {
167
- class: "!text-fm-color-typo-info !bg-fm-color-system-info-100",
168
- compact: !0,
169
- label: `${l(S).title(o.effect.options.target)} promotion`
170
- }, null, 8, ["label"])
171
- ]),
172
- a("div", ie, [
173
- a("div", re, P(o.name), 1),
174
- a("div", ce, P(l(L)(o.effect)), 1)
175
- ])
176
- ]),
177
- s(C, {
178
- icon: "delete",
179
- "icon-color": "neutral-gray-400",
180
- variant: "tertiary",
181
- onClick: (F) => (F.stopPropagation(), x(o))
182
- }, null, 8, ["onClick"])
183
- ]),
184
- _: 2
185
- }, 1032, ["onClick"]))), 128))
186
- ]),
187
- _: 1
188
- })
189
- ], 64)) : (c(), h(U, {
190
- key: 1,
191
- variant: "outlined",
192
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
193
- }, {
194
- default: _(() => [
195
- me,
196
- de,
197
- s(C, {
198
- variant: "primary",
199
- label: "Create promotion campaign",
200
- icon: "add",
201
- onClick: t[5] || (t[5] = (o) => u())
202
- })
203
- ]),
204
- _: 1
205
- }))
206
- ]),
207
- s(ee, {
208
- ref_key: "sheetRef",
209
- ref: b,
210
- "onSubmit:modelValue": R
211
- }, null, 512)
212
- ], 64);
213
- };
214
- }
215
- });
216
- export {
217
- ke as default
218
- };
@@ -1,445 +0,0 @@
1
- import { defineComponent as A, onMounted as E, openBlock as p, createElementBlock as b, createElementVNode as a, toDisplayString as M, unref as e, createVNode as n, createCommentVNode as q, ref as w, computed as j, resolveComponent as u, createBlock as B, isRef as G, createSlots as J, withCtx as g, Fragment as V, reactive as W, watch as Q, onBeforeMount as X, renderList as ee, h as I } from "vue";
2
- import { _ as te } from "./campaign-CpzFl8Vr.js";
3
- import { F as N, p as oe, u as ae } from "./loading-BzV5acUX.js";
4
- import { components as L } from "@feedmepos/ui-library";
5
- import { l as se } from "./lodash-mg4435Qq.js";
6
- import { Z as ne } from "./zod-W_PvIofQ.js";
7
- import { a as le } from "./index-boor8e80.js";
8
- import { u as ie, a as re } from "./app-DkI7dYRN.js";
9
- import { R as me } from "./rule-builder-BgqNbM-P.js";
10
- import { _ as ce } from "./ZodTextField.vue_vue_type_script_setup_true_lang-CWt4tVdk.js";
11
- import { _ as de } from "./RuleGroup.vue_vue_type_script_setup_true_lang-CrpJySSp.js";
12
- import { h as P } from "./moment-BWErdI6_.js";
13
- import { u as ue, _ as pe } from "./usePagination-o5fgsZwU.js";
14
- import { s as k } from "./membership-CqbsLHqx.js";
15
- import { o as fe } from "./objectId-dwaoBfJX.js";
16
- import { m as ge } from "./index-DcUrk07Q.js";
17
- const _e = le.extend({
18
- _id: N.optional(),
19
- business: N.optional()
20
- }), ve = { class: "space-y-16 pr-12" }, ye = { class: "fm-typo-en-title-md-800" }, he = { class: "flex space-x-8" }, Se = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, be = { class: "text-fm-color-typo-secondary" }, xe = /* @__PURE__ */ a("div", null, "contacts in your segment", -1), we = {
21
- key: 0,
22
- class: "w-full flex flex-col gap-16 items-center pt-16"
23
- }, Fe = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-lg-600" }, "No data found", -1), Ce = /* @__PURE__ */ a("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " No data to show at the current moment. ", -1), ke = [
24
- Fe,
25
- Ce
26
- ], Me = /* @__PURE__ */ A({
27
- __name: "ReviewSegment",
28
- props: {
29
- title: {},
30
- segment: {}
31
- },
32
- setup(D) {
33
- const _ = D, x = [
34
- {
35
- header: "Name",
36
- accessorFn: (s) => s.name
37
- },
38
- {
39
- header: "Customer Since",
40
- accessorFn: (s) => P(fe(s._id.toString())).format("DD MMM YYYY")
41
- },
42
- {
43
- header: "Birthday",
44
- accessorFn: (s) => P(s.birthday).format("DD MMM YYYY")
45
- },
46
- {
47
- header: "Last Visit",
48
- accessorFn: (s) => P(s.stats.lastVisit).format("DD MMM YYYY")
49
- }
50
- ], v = async (s) => _.segment._id ? await k.paginateSegmentUsers(_.segment._id, {
51
- limit: r.value.pageSize,
52
- skip: s.pageIndex ?? 0,
53
- sortBy: "_id",
54
- search: s.searchValue,
55
- descending: !0
56
- }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: r, rowData: c, onSort: m, debouncedFetchData: d, onSearch: l } = ue(v);
57
- return E(async () => {
58
- await d();
59
- }), (s, F) => (p(), b("div", ve, [
60
- a("div", ye, M(_.title), 1),
61
- a("div", he, [
62
- a("div", Se, M(s.segment.members.length), 1),
63
- a("div", be, [
64
- xe,
65
- a("div", null, "as of " + M(e(P)(s.segment.lastUpdated).format("DD MMM YYYY")), 1)
66
- ])
67
- ]),
68
- n(pe, {
69
- loading: e(r).isLoading,
70
- "row-data": e(c),
71
- "row-count": e(r).totalRows,
72
- "column-defs": x,
73
- "page-size": e(r).pageSize,
74
- "page-count": e(r).pageCount,
75
- "page-index": e(r).pageIndex,
76
- onSortChange: e(m),
77
- onPageChange: F[0] || (F[0] = (h) => e(d)({ pageSize: h.pageSize, pageIndex: h.pageIndex }))
78
- }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"]),
79
- e(c).length == 0 ? (p(), b("div", we, ke)) : q("", !0)
80
- ]));
81
- }
82
- }), $e = { class: "flex items-center gap-x-8" }, Re = /* @__PURE__ */ a("div", null, "Review segment", -1), Ie = {
83
- key: 0,
84
- class: "space-y-16 pr-12"
85
- }, Ve = /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1), Pe = { class: "flex items-center gap-8" }, Be = /* @__PURE__ */ A({
86
- __name: "SegmentSheet",
87
- emits: ["update:model-value"],
88
- setup(D, { expose: _, emit: x }) {
89
- const v = ie(), r = w(!1), c = w(!1), m = {
90
- name: "",
91
- rule: me.scaffoldGroup(),
92
- members: []
93
- }, d = _e, l = w(m), s = j(() => {
94
- const t = d.safeParse(l.value);
95
- return t.success ? [] : t.error.errors;
96
- });
97
- function F(t) {
98
- r.value = !0, c.value = !1, t ? l.value = { ...t } : l.value = { ...m };
99
- }
100
- function h() {
101
- r.value = !1;
102
- }
103
- async function Y() {
104
- d.safeParse(l.value).success && (c.value = !0);
105
- }
106
- function C() {
107
- c.value = !1;
108
- }
109
- async function z() {
110
- o("update:model-value", l.value);
111
- }
112
- E(async () => {
113
- });
114
- const o = x;
115
- return _({
116
- showSheet: F,
117
- hideSheet: h
118
- }), (t, i) => {
119
- const S = u("FmButton"), $ = u("FmSideSheet");
120
- return p(), B($, {
121
- modelValue: e(r),
122
- "onUpdate:modelValue": i[5] || (i[5] = (y) => G(r) ? r.value = y : null),
123
- header: "Add segment",
124
- "dismiss-away": "",
125
- "close-button": !0,
126
- "max-width": 1100
127
- }, J({
128
- "side-sheet-footer": g(() => [
129
- a("div", Pe, [
130
- e(c) ? (p(), b(V, { key: 0 }, [
131
- n(S, {
132
- label: "Save Segment",
133
- onClick: z,
134
- loading: e(v).isLoading,
135
- disabled: e(s).length > 0 || e(v).isLoading
136
- }, null, 8, ["loading", "disabled"]),
137
- n(S, {
138
- label: "Cancel",
139
- onClick: i[3] || (i[3] = (y) => C()),
140
- variant: "tertiary"
141
- })
142
- ], 64)) : (p(), b(V, { key: 1 }, [
143
- n(S, {
144
- label: "Review Segment",
145
- disabled: e(s).length > 0 || e(v).isLoading,
146
- onClick: Y
147
- }, null, 8, ["disabled"]),
148
- n(S, {
149
- label: "Cancel",
150
- onClick: i[4] || (i[4] = (y) => h()),
151
- variant: "tertiary"
152
- })
153
- ], 64))
154
- ])
155
- ]),
156
- default: g(() => {
157
- var y;
158
- return [
159
- e(c) ? (p(), B(Me, {
160
- key: 1,
161
- title: e(l).name,
162
- segment: e(l)
163
- }, null, 8, ["title", "segment"])) : (p(), b("div", Ie, [
164
- n(ce, {
165
- modelValue: e(l).name,
166
- "onUpdate:modelValue": i[1] || (i[1] = (R) => e(l).name = R),
167
- label: "Segment title",
168
- schema: e(ne).typeAtPath(e(d), "name")
169
- }, null, 8, ["modelValue", "schema"]),
170
- Ve,
171
- n(de, {
172
- "trigger-type": "MEMBERSHIP_JOINED",
173
- includeOnly: "user",
174
- "model-value": (y = e(l)) == null ? void 0 : y.rule,
175
- "onUpdate:modelValue": i[2] || (i[2] = (R) => {
176
- e(l).rule = R;
177
- })
178
- }, null, 8, ["model-value"])
179
- ]))
180
- ];
181
- }),
182
- _: 2
183
- }, [
184
- e(c) ? {
185
- name: "side-sheet-header",
186
- fn: g(() => [
187
- a("div", $e, [
188
- n(S, {
189
- icon: "arrow_back",
190
- variant: "tertiary",
191
- onClick: i[0] || (i[0] = (y) => c.value = !1)
192
- }),
193
- Re
194
- ])
195
- ]),
196
- key: "0"
197
- } : void 0
198
- ]), 1032, ["modelValue"]);
199
- };
200
- }
201
- }), De = { class: "flex items-center" }, Ye = /* @__PURE__ */ a("span", { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, " Segments ", -1), ze = { class: "px-24 flex flex-col gap-y-16" }, Le = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Ae = { class: "fm-typo-en-body-md-600" }, Ue = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Ne = /* @__PURE__ */ a("img", {
202
- src: te,
203
- class: "aspect-square w-[150px]"
204
- }, null, -1), Ee = /* @__PURE__ */ a("div", { class: "flex flex-col gap-16 text-center" }, [
205
- /* @__PURE__ */ a("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
206
- /* @__PURE__ */ 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. ")
207
- ], -1), st = /* @__PURE__ */ A({
208
- __name: "Segment",
209
- setup(D) {
210
- const { minor: _ } = ae, x = re(), v = w(0), r = [
211
- {
212
- header: "Name",
213
- accessorFn: (o) => o.name
214
- },
215
- {
216
- header: "Total Customers in this Segment",
217
- accessorFn: (o) => o.memberCount ?? 0
218
- },
219
- {
220
- header: "% of customers",
221
- accessorFn: (o) => ((o.memberCount ?? 0) * 100 / v.value).toFixed(2)
222
- },
223
- {
224
- header: "Actions",
225
- meta: {
226
- maxWidth: "100px"
227
- },
228
- cell(o) {
229
- return I("div", { class: "flex items-center justify-end" }, [
230
- I(
231
- L.FmMenu,
232
- {
233
- placement: "bottom-end",
234
- onClick: (t) => {
235
- t.stopPropagation();
236
- }
237
- },
238
- {
239
- "menu-button": () => I(L.FmButton, {
240
- icon: "more_vert",
241
- iconColor: "neutral-gray-400",
242
- variant: "tertiary"
243
- }),
244
- default: () => [
245
- I(
246
- L.FmMenuItem,
247
- {
248
- onClick: async (t) => {
249
- t.stopPropagation(), h(o.row.original);
250
- }
251
- },
252
- {
253
- label: I(
254
- "div",
255
- {
256
- class: "text-fm-color-typo-error fm-typo-en-body-md-400"
257
- },
258
- "Remove"
259
- )
260
- }
261
- )
262
- ]
263
- }
264
- )
265
- ]);
266
- }
267
- }
268
- ], c = W({ searchKey: "", columnFilters: [] }), m = w({
269
- searchValue: "",
270
- pageSize: 10,
271
- pageCount: 0,
272
- pageIndex: 0,
273
- totalRows: 0,
274
- isLoading: !1
275
- }), d = w([]), l = w(null), s = async (o) => {
276
- d.value = [], m.value.isLoading = !0;
277
- const t = await k.readAll({
278
- limit: o.pageSize,
279
- skip: o.pageIndex ?? 0,
280
- sortBy: "_id",
281
- search: m.value.searchValue,
282
- descending: !0
283
- });
284
- d.value = t.resources, m.value.totalRows = t.meta.totalResources ?? 0, m.value.pageCount = t.meta.totalPages ?? 0, m.value.isLoading = !1;
285
- };
286
- async function F() {
287
- await _(
288
- async () => {
289
- await k.refreshSegments(), await s({ pageSize: 10, pageIndex: 0 });
290
- },
291
- { message: "Refreshing segmentations" }
292
- );
293
- }
294
- async function h(o) {
295
- await oe.remove(`Are you sure you want to remove ${o.name}?`) && await _(
296
- async () => {
297
- await k.delete(o._id), await s({ pageSize: 10, pageIndex: 0 });
298
- },
299
- {
300
- message: `Removing ${o.name}`,
301
- successMessage: `Removed ${o.name} successfully`
302
- }
303
- );
304
- }
305
- async function Y(o) {
306
- await _(
307
- async () => {
308
- var t;
309
- if (o._id) {
310
- const { members: i, _id: S, ...$ } = o;
311
- await k.update(o._id, $);
312
- } else
313
- await k.create(o);
314
- await s({ pageSize: 10, pageIndex: 0 }), (t = l.value) == null || t.hideSheet();
315
- },
316
- {
317
- message: "Saving segment",
318
- successMessage: "Segment saved"
319
- }
320
- );
321
- }
322
- function C(o) {
323
- var t;
324
- (t = l.value) == null || t.showSheet(o);
325
- }
326
- const z = j(() => x.isPremium ? [
327
- {
328
- label: "Refresh segments",
329
- value: "refresh"
330
- },
331
- {
332
- label: "Add segment",
333
- value: "add",
334
- isPrimary: !0,
335
- prependIcon: "add"
336
- }
337
- ] : []);
338
- return Q(
339
- () => m.value.searchValue,
340
- se.debounce(() => {
341
- s({ pageSize: 10, pageIndex: 0 });
342
- }, 500)
343
- ), X(async () => {
344
- const { meta: o } = await ge.read({
345
- limit: 1,
346
- skip: 0,
347
- sortBy: "_id",
348
- search: m.value.searchValue,
349
- descending: !1
350
- });
351
- v.value = o.totalResources ?? 0, await s({ pageSize: 10, pageIndex: 0 }), await x.readPremium();
352
- }), (o, t) => {
353
- const i = u("FmPill"), S = u("FmPageHead"), $ = u("FmTable"), y = u("FmIcon"), R = u("FmMenuItem"), H = u("FmMenu"), T = u("FmListItem"), O = u("FmList"), K = u("FmButton"), Z = u("FmCard");
354
- return p(), b(V, null, [
355
- n(S, {
356
- title: "Segments",
357
- actions: e(z),
358
- "onClick:action": t[0] || (t[0] = (f) => f === "add" ? C() : F())
359
- }, {
360
- title: g(() => [
361
- a("div", De, [
362
- Ye,
363
- n(i, { variant: "premium" })
364
- ])
365
- ]),
366
- _: 1
367
- }, 8, ["actions"]),
368
- a("div", ze, [
369
- e(d).length > 0 || e(m).searchValue ? (p(), b(V, { key: 0 }, [
370
- n($, {
371
- class: "xs:hidden",
372
- "row-data": e(d),
373
- "column-defs": r,
374
- "search-value": e(c).searchKey,
375
- "column-filter": [],
376
- "hide-footer": !0,
377
- onRowClick: t[1] || (t[1] = (f) => {
378
- C(f.original);
379
- })
380
- }, null, 8, ["row-data", "search-value"]),
381
- n(O, { class: "w-full hidden xs:block" }, {
382
- default: g(() => [
383
- (p(!0), b(V, null, ee(e(d), (f) => (p(), B(T, {
384
- key: f._id.toString(),
385
- tag: "label",
386
- onClick: (U) => C(f)
387
- }, {
388
- default: g(() => [
389
- a("div", null, [
390
- a("div", Le, M((f.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
391
- a("div", Ae, M(f.name), 1),
392
- a("div", Ue, M(((f.memberCount ?? 0) * 100 / e(v)).toFixed(2)) + "% of customers ", 1)
393
- ])
394
- ]),
395
- append: g(() => [
396
- n(H, { "stop-click-propagation": !0 }, {
397
- "menu-button": g(() => [
398
- n(y, { name: "more_vert" })
399
- ]),
400
- default: g(() => [
401
- n(R, {
402
- class: "text-fm-color-typo-error fm-typo-en-body-md-400",
403
- label: "Remove",
404
- "onUpdate:modelValue": (U) => U && h(f)
405
- }, null, 8, ["onUpdate:modelValue"])
406
- ]),
407
- _: 2
408
- }, 1024)
409
- ]),
410
- _: 2
411
- }, 1032, ["onClick"]))), 128))
412
- ]),
413
- _: 1
414
- })
415
- ], 64)) : (p(), B(Z, {
416
- key: 1,
417
- variant: "outlined",
418
- class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
419
- }, {
420
- default: g(() => [
421
- Ne,
422
- Ee,
423
- n(K, {
424
- variant: "primary",
425
- label: "Create segment",
426
- disabled: !e(x).isPremium,
427
- icon: "add",
428
- onClick: t[2] || (t[2] = (f) => C())
429
- }, null, 8, ["disabled"])
430
- ]),
431
- _: 1
432
- })),
433
- n(Be, {
434
- ref_key: "sheetRef",
435
- ref: l,
436
- "onUpdate:modelValue": Y
437
- }, null, 512)
438
- ])
439
- ], 64);
440
- };
441
- }
442
- });
443
- export {
444
- st as default
445
- };