@feedmepos/mf-connect 0.0.8 → 0.0.9

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 (77) hide show
  1. package/dist/{Analytic-BxRuK2P2.js → Analytic-CwaN0mge.js} +68 -69
  2. package/dist/{Broadcast-BqGojAWW.js → Broadcast-Cjx5xzUC.js} +27 -28
  3. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-B-VzcVMS.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D4mO5aik.js} +34 -34
  4. package/dist/Card-DbY6YaXk.js +827 -0
  5. package/dist/{Collections-DvdDRozp.js → Collections-DRN2gzwh.js} +158 -168
  6. package/dist/{Credit-BeHm7_2S.js → Credit-DOcrzykJ.js} +11 -12
  7. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-BsbgHsah.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-CUxfXaro.js} +359 -333
  8. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-hwXvdiut.js → EffectSheet.vue_vue_type_style_index_0_lang-EF_rHfwT.js} +5 -5
  9. package/dist/{Experience-CtDY9u4Y.js → Experience-aQj-3H2Y.js} +11 -12
  10. package/dist/{Game-DjaYuqcb.js → Game-Cnje-m_M.js} +22 -23
  11. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-Bq5-Gl9N.js → ImageInput.vue_vue_type_script_setup_true_lang-CG-GBVMP.js} +8 -8
  12. package/dist/{MainLayout-B-iAZM2k.js → MainLayout-Cxl9yLPs.js} +1 -1
  13. package/dist/{Marketing-BJJltAh-.js → Marketing-BYUcbcMU.js} +19 -20
  14. package/dist/{Member-eJ9Pdi5w.js → Member-D7K9fm_Q.js} +2 -2
  15. package/dist/MemberList-DbXkxUzF.js +1717 -0
  16. package/dist/{MemberTransactions-DRET8mSQ.js → MemberTransactions-DED1SYwX.js} +4 -4
  17. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-CLqIp5wR.js +203 -0
  18. package/dist/{Point-DPTOgJbC.js → Point-CQm8whVQ.js} +11 -12
  19. package/dist/{Promotion-wzkRuNqO.js → Promotion-DzVXy_C9.js} +42 -44
  20. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-Z06eB5i5.js → RuleGroup.vue_vue_type_script_setup_true_lang-CeS6KlhP.js} +12 -12
  21. package/dist/Segment-D3o0D3Uv.js +407 -0
  22. package/dist/{Setting-CXuZu0-m.js → Setting-pCzenLoL.js} +17 -18
  23. package/dist/{Store-4Um9keEp.js → Store-DEwEIFYD.js} +18 -19
  24. package/dist/{StoreRewards-B-UFeyQM.js → StoreRewards-D7vnZN4f.js} +86 -87
  25. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-ALzQU3th.js +793 -0
  26. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-I_XFpctY.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-GMIztWCj.js} +1 -1
  27. package/dist/{Tier-C6KVsxGO.js → Tier-BJbX5CPB.js} +401 -377
  28. package/dist/{Title-DuN1ahIM.js → Title-C9xV6rBg.js} +274 -248
  29. package/dist/Transaction-C8OHlhzR.js +36 -0
  30. package/dist/Voucher-eZwm7N1D.js +481 -0
  31. package/dist/{app-CxBTTB31.js → app-DgbDbhL-.js} +34 -34
  32. package/dist/app.js +1 -1
  33. package/dist/{campaign-B0aXkadj.js → campaign-BkvrUTEJ.js} +2 -2
  34. package/dist/{dto-BtdVC-Ab.js → dto-YYVhW73A.js} +52 -53
  35. package/dist/{effect-BUN6rkQM.js → effect-f7DAPYC8.js} +1 -1
  36. package/dist/export-BXbCXTfd.js +97 -0
  37. package/dist/{helper-Cpq3x8K5.js → helper-BhvQ9m6d.js} +1 -1
  38. package/dist/{index-D2Juhkdw.js → index-BhacKx5B.js} +85 -83
  39. package/dist/{index-DDSLx7vu.js → index-BsEqtUmY.js} +2 -2
  40. package/dist/{index-0GYrZr4L.js → index-CdtrQ9tR.js} +5 -5
  41. package/dist/{index-8clzk3uX.js → index-Cfo2A0Se.js} +1 -1
  42. package/dist/index-Cz5RZlYh.js +73 -0
  43. package/dist/{index-BTntbYTS.js → index-DQC_1tRF.js} +1 -1
  44. package/dist/{index-DysVCkrx.js → index-Dd3hrFcQ.js} +3 -3
  45. package/dist/{index-CK9yJMj7.js → index-FWp9M1yS.js} +5 -5
  46. package/dist/{index-C6NgUSl2.js → index-VmFlM704.js} +1 -1
  47. package/dist/{index-BvnZdJBY.js → index-oQLJE4Uw.js} +2 -2
  48. package/dist/libs/packages/core/src/collectible/collectible.dto.d.ts +6 -0
  49. package/dist/{plugins-B_d-WFtN.js → loading-DQaawbHE.js} +8204 -8108
  50. package/dist/{lodash-DsT1nK-T.js → lodash-DzdmTD20.js} +1 -1
  51. package/dist/{membership-DtD45RXh.js → membership-Dq2-b-S_.js} +3 -3
  52. package/dist/{money-CFI1TMCS.js → money-vzwOUBrp.js} +1 -1
  53. package/dist/{number-BBtf4fYz.js → number-CBzs6rfW.js} +1 -1
  54. package/dist/packages/connect/src/components/campaign/CampaignSummary.vue.d.ts +13 -0
  55. package/dist/packages/connect/src/composables/export.d.ts +11 -0
  56. package/dist/packages/connect/src/export/base.export.d.ts +7 -0
  57. package/dist/packages/connect/src/export/card.export.d.ts +5 -6
  58. package/dist/packages/connect/src/export/collection-transaction.export.d.ts +14 -0
  59. package/dist/packages/connect/src/export/index.d.ts +1 -0
  60. package/dist/packages/connect/src/export/store-transaction.export.d.ts +14 -0
  61. package/dist/packages/connect/src/helpers/user.d.ts +6 -0
  62. package/dist/{rule-CB9Qlcx1.js → rule-BR5rrmUV.js} +2 -2
  63. package/dist/{rule-builder-BIKcA4Bg.js → rule-builder-7GBNrPXt.js} +1 -1
  64. package/dist/{template-qlb46PGl.js → template-CETJ6lkf.js} +5 -5
  65. package/dist/{usePagination-CX66ab1Y.js → usePagination-DdZeE4Tt.js} +57 -56
  66. package/dist/user-Bm4KttFq.js +37 -0
  67. package/dist/{xlsx-DMaFso0k.js → xlsx-CDAKxZE_.js} +1 -1
  68. package/package.json +1 -1
  69. package/dist/Card-Dlj5jQp4.js +0 -792
  70. package/dist/MemberList-CrhMqUfJ.js +0 -1664
  71. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-D-ttMwn2.js +0 -166
  72. package/dist/Segment-DnsPrP7Q.js +0 -371
  73. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-BAyotuXd.js +0 -660
  74. package/dist/Transaction-DdfX7Xfe.js +0 -34
  75. package/dist/Voucher-DarXrxZr.js +0 -454
  76. package/dist/index-Dg-PMgXV.js +0 -64
  77. package/dist/loading-Cxp7sI5p.js +0 -100
@@ -1,166 +0,0 @@
1
- import { defineComponent as w, onMounted as S, resolveComponent as o, openBlock as c, createElementBlock as g, createElementVNode as s, createVNode as i, withCtx as y, Fragment as _, renderList as M, createBlock as E, unref as F } from "vue";
2
- import { p as C } from "./plugins-B_d-WFtN.js";
3
- import { r as D } from "./index-0GYrZr4L.js";
4
- const k = {
5
- "user.name": {
6
- name: "User name"
7
- },
8
- "user.birthday": {
9
- name: "Birthday"
10
- },
11
- "user.joinAt": {
12
- name: "Join at"
13
- },
14
- "user.expiringVouchers.days7": {
15
- name: "Expiring vouchers in 7 days"
16
- },
17
- "user.expiringVouchers.days30": {
18
- name: "Expiring vouchers in 30 days"
19
- },
20
- "user.expiringVouchers.days90": {
21
- name: "Expiring vouchers in 90 days"
22
- },
23
- "user.tier": {
24
- name: "User tier"
25
- },
26
- "user.point": {
27
- name: "User experience"
28
- },
29
- "transaction.amount": {
30
- name: "Reward amount"
31
- },
32
- "collectible.name": {
33
- name: "Reward name"
34
- }
35
- }, T = { class: "space-y-0" }, U = { class: "flex items-center gap-8 justify-between" }, j = /* @__PURE__ */ s("div", { class: "fm-typo-en-body-lg-400" }, "Add message", -1), B = { class: "relative" }, L = { class: "absolute bottom-[24px] right-[4px]" }, R = /* @__PURE__ */ w({
36
- __name: "MessageInput",
37
- props: {
38
- modelValue: {
39
- type: Object
40
- },
41
- triggerType: {
42
- type: String,
43
- default: () => "SCHEDULE"
44
- },
45
- helperText: {
46
- type: String
47
- },
48
- helperState: {
49
- type: String
50
- },
51
- variables: {
52
- type: Object,
53
- default: () => [
54
- "user.name",
55
- "user.birthday",
56
- "user.joinAt",
57
- "user.expiringVouchers.days7",
58
- "user.expiringVouchers.days30",
59
- "user.expiringVouchers.days90",
60
- "user.tier",
61
- "user.point",
62
- "transaction.amount",
63
- "collectible.name"
64
- ]
65
- },
66
- placeholder: {
67
- type: String
68
- }
69
- },
70
- emits: ["update:model-value"],
71
- setup(e, { emit: v }) {
72
- const n = e, m = v;
73
- function x() {
74
- var a;
75
- const r = {
76
- user: {
77
- name: "John Doe",
78
- tier: 1,
79
- point: 1283,
80
- birthday: (/* @__PURE__ */ new Date("2000-10-02T16:00:00.000Z")).toLocaleDateString(),
81
- joinAt: (/* @__PURE__ */ new Date("2024-06-14")).toLocaleDateString(),
82
- expiringVouchers: { days7: 3, days30: 5, days90: 5 }
83
- },
84
- transaction: {
85
- amount: 3
86
- },
87
- collectible: {
88
- name: "RM10 Voucher"
89
- }
90
- }, u = D(
91
- ((a = n.modelValue) == null ? void 0 : a.content) ?? "",
92
- r
93
- );
94
- C.confirm(u, "Preview message", "OK");
95
- }
96
- function l(r) {
97
- m("update:model-value", {
98
- channel: "SMS",
99
- content: r,
100
- language: "en",
101
- variables: n.variables
102
- });
103
- }
104
- return S(() => {
105
- m("update:model-value", {
106
- ...n.modelValue,
107
- variables: n.variables
108
- }), n.modelValue || l("");
109
- }), (r, u) => {
110
- var d;
111
- const a = o("FmButton"), b = o("FmTextarea"), f = o("FmMenuItem"), V = o("FmMenu");
112
- return c(), g("div", T, [
113
- s("div", U, [
114
- j,
115
- i(a, {
116
- icon: "visibility",
117
- label: "Preview message",
118
- variant: "plain",
119
- onClick: x
120
- })
121
- ]),
122
- s("div", B, [
123
- i(b, {
124
- "model-value": (d = e.modelValue) == null ? void 0 : d.content,
125
- "onUpdate:modelValue": l,
126
- "max-length": 160,
127
- "show-word-count": !0,
128
- placeholder: e.placeholder,
129
- "helper-state": e.helperState || void 0,
130
- "helper-text": e.helperText
131
- }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text"]),
132
- s("div", L, [
133
- i(V, { placement: "left-end" }, {
134
- "menu-button": y(() => [
135
- i(a, {
136
- icon: "add",
137
- variant: "tertiary",
138
- size: "md"
139
- })
140
- ]),
141
- default: y(() => [
142
- (c(!0), g(_, null, M(e.variables.filter(
143
- (t) => e.triggerType == "SCHEDULE" ? !t.startsWith("transaction.") : !0
144
- ), (t) => {
145
- var p;
146
- return c(), E(f, {
147
- key: t,
148
- label: ((p = F(k)[t]) == null ? void 0 : p.name) || t,
149
- onClick: (A) => {
150
- var h;
151
- return l(((h = e.modelValue) == null ? void 0 : h.content) + `{{${t}}}`);
152
- }
153
- }, null, 8, ["label", "onClick"]);
154
- }), 128))
155
- ]),
156
- _: 1
157
- })
158
- ])
159
- ])
160
- ]);
161
- };
162
- }
163
- });
164
- export {
165
- R as _
166
- };
@@ -1,371 +0,0 @@
1
- import { defineComponent as P, onMounted as N, openBlock as g, createElementBlock as x, createElementVNode as r, toDisplayString as D, unref as e, createVNode as m, createCommentVNode as E, ref as y, computed as U, resolveComponent as R, createBlock as A, isRef as H, createSlots as T, withCtx as Y, Fragment as B, reactive as j, watch as O, onBeforeMount as K, h as C } from "vue";
2
- import { F as L, p as Z } from "./plugins-B_d-WFtN.js";
3
- import { u as G } from "./loading-Cxp7sI5p.js";
4
- import { components as z } from "@feedmepos/ui-library";
5
- import { l as J } from "./lodash-DsT1nK-T.js";
6
- import { _ as q, Z as Q } from "./ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js";
7
- import { a as W } from "./index-DysVCkrx.js";
8
- import { u as X } from "./app-CxBTTB31.js";
9
- import { R as ee } from "./rule-builder-BIKcA4Bg.js";
10
- import { _ as te } from "./RuleGroup.vue_vue_type_script_setup_true_lang-Z06eB5i5.js";
11
- import { h as k } from "./moment-BWErdI6_.js";
12
- import { u as ae, _ as oe } from "./usePagination-CX66ab1Y.js";
13
- import { s as b } from "./membership-DtD45RXh.js";
14
- import { o as se } from "./objectId-dwaoBfJX.js";
15
- import { m as ne } from "./index-Dg-PMgXV.js";
16
- const ie = W.extend({
17
- _id: L.optional(),
18
- business: L.optional()
19
- }), le = { class: "space-y-16 pr-12" }, re = { class: "fm-typo-en-title-md-800" }, ce = { class: "flex space-x-8" }, me = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, de = { class: "text-fm-color-typo-secondary" }, ue = /* @__PURE__ */ r("div", null, "contacts in your segment", -1), pe = {
20
- key: 0,
21
- class: "w-full flex flex-col gap-16 items-center pt-16"
22
- }, ge = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-lg-600" }, "No data found", -1), fe = /* @__PURE__ */ r("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " No data to show at the current moment. ", -1), ve = [
23
- ge,
24
- fe
25
- ], he = /* @__PURE__ */ P({
26
- __name: "ReviewSegment",
27
- props: {
28
- title: {},
29
- segment: {}
30
- },
31
- setup(M) {
32
- const u = M, S = [
33
- {
34
- header: "Name",
35
- accessorFn: (o) => o.name
36
- },
37
- {
38
- header: "Customer Since",
39
- accessorFn: (o) => k(se(o._id.toString())).format("DD MMM YYYY")
40
- },
41
- {
42
- header: "Birthday",
43
- accessorFn: (o) => k(o.birthday).format("DD MMM YYYY")
44
- },
45
- {
46
- header: "Last Visit",
47
- accessorFn: (o) => k(o.stats.lastVisit).format("DD MMM YYYY")
48
- }
49
- ], f = async (o) => u.segment._id ? await b.paginateSegmentUsers(u.segment._id, {
50
- limit: i.value.pageSize,
51
- skip: o.pageIndex ?? 0,
52
- sortBy: "_id",
53
- search: o.searchValue,
54
- descending: !0
55
- }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: i, rowData: c, onSort: w, debouncedFetchData: l, onSearch: s } = ae(f);
56
- return N(async () => {
57
- await l();
58
- }), (o, d) => (g(), x("div", le, [
59
- r("div", re, D(u.title), 1),
60
- r("div", ce, [
61
- r("div", me, D(o.segment.members.length), 1),
62
- r("div", de, [
63
- ue,
64
- r("div", null, "as of " + D(e(k)(o.segment.lastUpdated).format("DD MMM YYYY")), 1)
65
- ])
66
- ]),
67
- m(oe, {
68
- loading: e(i).isLoading,
69
- "row-data": e(c),
70
- "row-count": e(i).totalRows,
71
- "column-defs": S,
72
- "page-size": e(i).pageSize,
73
- "page-count": e(i).pageCount,
74
- "page-index": e(i).pageIndex,
75
- onSortChange: e(w),
76
- onPageChange: d[0] || (d[0] = (v) => e(l)({ pageSize: v.pageSize, pageIndex: v.pageIndex }))
77
- }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"]),
78
- e(c).length == 0 ? (g(), x("div", pe, ve)) : E("", !0)
79
- ]));
80
- }
81
- }), _e = { class: "flex items-center gap-x-8" }, ye = /* @__PURE__ */ r("div", null, "Review segment", -1), Se = {
82
- key: 0,
83
- class: "space-y-16 pr-12"
84
- }, we = /* @__PURE__ */ r("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1), be = { class: "flex items-center gap-8" }, xe = /* @__PURE__ */ P({
85
- __name: "SegmentSheet",
86
- emits: ["update:model-value"],
87
- setup(M, { expose: u, emit: S }) {
88
- const f = X(), i = y(!1), c = y(!1), w = {
89
- name: "",
90
- rule: ee.scaffoldGroup(),
91
- members: []
92
- }, l = ie, s = y(w), o = U(() => {
93
- const a = l.safeParse(s.value);
94
- return a.success ? [] : a.error.errors;
95
- });
96
- function d(a) {
97
- i.value = !0, c.value = !1, a ? s.value = { ...a } : s.value = { ...w };
98
- }
99
- function v() {
100
- i.value = !1;
101
- }
102
- async function V() {
103
- l.safeParse(s.value).success && (c.value = !0);
104
- }
105
- function I() {
106
- c.value = !1;
107
- }
108
- async function F() {
109
- t("update:model-value", s.value);
110
- }
111
- N(async () => {
112
- });
113
- const t = S;
114
- return u({
115
- showSheet: d,
116
- hideSheet: v
117
- }), (a, n) => {
118
- const p = R("FmButton"), h = R("FmSideSheet");
119
- return g(), A(h, {
120
- modelValue: e(i),
121
- "onUpdate:modelValue": n[5] || (n[5] = (_) => H(i) ? i.value = _ : null),
122
- header: "Add segment",
123
- "dismiss-away": "",
124
- "close-button": !0,
125
- "max-width": 1100
126
- }, T({
127
- "side-sheet-footer": Y(() => [
128
- r("div", be, [
129
- e(c) ? (g(), x(B, { key: 0 }, [
130
- m(p, {
131
- label: "Save Segment",
132
- onClick: F,
133
- loading: e(f).isLoading,
134
- disabled: e(o).length > 0 || e(f).isLoading
135
- }, null, 8, ["loading", "disabled"]),
136
- m(p, {
137
- label: "Cancel",
138
- onClick: n[3] || (n[3] = (_) => I()),
139
- variant: "tertiary"
140
- })
141
- ], 64)) : (g(), x(B, { key: 1 }, [
142
- m(p, {
143
- label: "Review Segment",
144
- disabled: e(o).length > 0 || e(f).isLoading,
145
- onClick: V
146
- }, null, 8, ["disabled"]),
147
- m(p, {
148
- label: "Cancel",
149
- onClick: n[4] || (n[4] = (_) => v()),
150
- variant: "tertiary"
151
- })
152
- ], 64))
153
- ])
154
- ]),
155
- default: Y(() => {
156
- var _;
157
- return [
158
- e(c) ? (g(), A(he, {
159
- key: 1,
160
- title: e(s).name,
161
- segment: e(s)
162
- }, null, 8, ["title", "segment"])) : (g(), x("div", Se, [
163
- m(q, {
164
- modelValue: e(s).name,
165
- "onUpdate:modelValue": n[1] || (n[1] = ($) => e(s).name = $),
166
- label: "Segment title",
167
- schema: e(Q).typeAtPath(e(l), "name")
168
- }, null, 8, ["modelValue", "schema"]),
169
- we,
170
- m(te, {
171
- "trigger-type": "MEMBERSHIP_JOINED",
172
- includeOnly: "user",
173
- "model-value": (_ = e(s)) == null ? void 0 : _.rule,
174
- "onUpdate:modelValue": n[2] || (n[2] = ($) => {
175
- e(s).rule = $;
176
- })
177
- }, null, 8, ["model-value"])
178
- ]))
179
- ];
180
- }),
181
- _: 2
182
- }, [
183
- e(c) ? {
184
- name: "side-sheet-header",
185
- fn: Y(() => [
186
- r("div", _e, [
187
- m(p, {
188
- icon: "arrow_back",
189
- variant: "tertiary",
190
- onClick: n[0] || (n[0] = (_) => c.value = !1)
191
- }),
192
- ye
193
- ])
194
- ]),
195
- key: "0"
196
- } : void 0
197
- ]), 1032, ["modelValue"]);
198
- };
199
- }
200
- }), Ce = { class: "px-24 flex flex-col gap-y-32 pb-24" }, Ee = /* @__PURE__ */ P({
201
- __name: "Segment",
202
- setup(M) {
203
- const { minor: u } = G, S = y(0), f = {
204
- label: "Refresh segments",
205
- value: "refresh"
206
- // prependIcon: 'refresh',
207
- }, i = {
208
- label: "Add segment",
209
- value: "add",
210
- isPrimary: !0,
211
- prependIcon: "add"
212
- }, c = [
213
- {
214
- header: "Name",
215
- accessorFn: (t) => t.name
216
- },
217
- {
218
- header: "Total Customers in this Segment",
219
- accessorFn: (t) => t.memberCount ?? 0
220
- },
221
- {
222
- header: "% of customers",
223
- accessorFn: (t) => ((t.memberCount ?? 0) * 100 / S.value).toFixed(2)
224
- },
225
- {
226
- header: "Actions",
227
- cell(t) {
228
- return C("div", { class: "flex items-center justify-end" }, [
229
- C(
230
- z.FmMenu,
231
- {
232
- placement: "bottom-end",
233
- onClick: (a) => {
234
- a.stopPropagation();
235
- }
236
- },
237
- {
238
- "menu-button": () => C(z.FmButton, {
239
- icon: "more_vert",
240
- iconColor: "neutral-gray-400",
241
- variant: "tertiary"
242
- }),
243
- default: () => [
244
- C(
245
- z.FmMenuItem,
246
- {
247
- onClick: async (a) => {
248
- a.stopPropagation(), V(t.row.original);
249
- }
250
- },
251
- {
252
- label: C(
253
- "div",
254
- {
255
- class: "text-fm-color-typo-error fm-typo-en-body-md-400"
256
- },
257
- "Remove"
258
- )
259
- }
260
- )
261
- ]
262
- }
263
- )
264
- ]);
265
- }
266
- }
267
- ], w = j({ searchKey: "", columnFilters: [] }), l = y({
268
- searchValue: "",
269
- pageSize: 10,
270
- pageCount: 0,
271
- pageIndex: 0,
272
- totalRows: 0,
273
- isLoading: !1
274
- }), s = y([]), o = y(null), d = async (t) => {
275
- s.value = [], l.value.isLoading = !0;
276
- const a = await b.readAll({
277
- limit: t.pageSize,
278
- skip: t.pageIndex ?? 0,
279
- sortBy: "_id",
280
- search: l.value.searchValue,
281
- descending: !0
282
- });
283
- s.value = a.resources, l.value.totalRows = a.meta.totalResources ?? 0, l.value.pageCount = a.meta.totalPages ?? 0, l.value.isLoading = !1;
284
- };
285
- async function v() {
286
- await u(
287
- async () => {
288
- await b.refreshSegments(), await d({ pageSize: 10, pageIndex: 0 });
289
- },
290
- { message: "Refreshing segmentations" }
291
- );
292
- }
293
- async function V(t) {
294
- await Z.remove(`Are you sure you want to remove ${t.name}?`) && await u(
295
- async () => {
296
- await b.delete(t._id), await d({ pageSize: 10, pageIndex: 0 });
297
- },
298
- {
299
- message: `Removing ${t.name}`,
300
- successMessage: `Removed ${t.name} successfully`
301
- }
302
- );
303
- }
304
- async function I(t) {
305
- await u(
306
- async () => {
307
- var a;
308
- if (t._id) {
309
- const { members: n, _id: p, ...h } = t;
310
- await b.update(t._id, h);
311
- } else
312
- await b.create(t);
313
- await d({ pageSize: 10, pageIndex: 0 }), (a = o.value) == null || a.hideSheet();
314
- },
315
- {
316
- message: "Saving segment",
317
- successMessage: "Segment saved"
318
- }
319
- );
320
- }
321
- function F(t) {
322
- var a;
323
- (a = o.value) == null || a.showSheet(t);
324
- }
325
- return O(
326
- () => l.value.searchValue,
327
- J.debounce(() => {
328
- d({ pageSize: 10, pageIndex: 0 });
329
- }, 500)
330
- ), K(async () => {
331
- const { meta: t } = await ne.read({
332
- limit: 1,
333
- skip: 0,
334
- sortBy: "_id",
335
- search: l.value.searchValue,
336
- descending: !1
337
- });
338
- S.value = t.totalResources ?? 0, await d({ pageSize: 10, pageIndex: 0 });
339
- }), (t, a) => {
340
- const n = R("FmPageHead"), p = R("FmTable");
341
- return g(), x(B, null, [
342
- m(n, {
343
- title: "Segments",
344
- actions: [f, i],
345
- "onClick:action": a[0] || (a[0] = (h) => h === "add" ? F() : v())
346
- }, null, 8, ["actions"]),
347
- r("div", Ce, [
348
- m(p, {
349
- class: "xs:hidden",
350
- "row-data": e(s),
351
- "column-defs": c,
352
- "search-value": e(w).searchKey,
353
- "column-filter": [],
354
- "hide-footer": !0,
355
- onRowClick: a[1] || (a[1] = (h) => {
356
- F(h.original);
357
- })
358
- }, null, 8, ["row-data", "search-value"]),
359
- m(xe, {
360
- ref_key: "sheetRef",
361
- ref: o,
362
- "onUpdate:modelValue": I
363
- }, null, 512)
364
- ])
365
- ], 64);
366
- };
367
- }
368
- });
369
- export {
370
- Ee as default
371
- };