@feedmepos/mf-connect 0.1.0-beta.8 → 0.1.0-beta.80

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 (127) hide show
  1. package/dist/Analytic-C84B4MSt.js +427 -0
  2. package/dist/{App-SRz4257n.js → App-CnbbBVSn.js} +441 -420
  3. package/dist/AuditLogs-KOxiG5Q0.js +1887 -0
  4. package/dist/Bin-BBSQDzD4.js +166 -0
  5. package/dist/{Broadcast-DmkrJGp2.js → Broadcast-DlvPEqW7.js} +56 -54
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CZXSxA9u.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-M1Za3MaN.js} +14 -10
  7. package/dist/Card-BluWm_EY.js +905 -0
  8. package/dist/Collections-DtHJpxRT.js +464 -0
  9. package/dist/{Credit-CcNrq9qk.js → Credit-Be2pcBVn.js} +36 -34
  10. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-DLnvDVgf.js +108 -0
  11. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-BUzUIIUW.js +58 -0
  12. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-sqq_sO_a.js +2182 -0
  13. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BIZDiLns.js → EffectSheet.vue_vue_type_style_index_0_lang-CBsYx54P.js} +49 -49
  14. package/dist/{Experience-DNsQLzDH.js → Experience-CLPyvgs0.js} +32 -30
  15. package/dist/FileSaver.min-NlMItPOc.js +74 -0
  16. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-BrPLkFX8.js +118 -0
  17. package/dist/Game-5kEG7o4J.js +278 -0
  18. package/dist/Index-BSZi21Wo.js +259 -0
  19. package/dist/Marketing-CE1Sq3Pb.js +20071 -0
  20. package/dist/Member-DaBqmOYX.js +287 -0
  21. package/dist/MemberList-jIriR6B0.js +1606 -0
  22. package/dist/MemberTransactions-BGEZwpPO.js +45 -0
  23. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-GCEQCVOt.js → MessageInput.vue_vue_type_script_setup_true_lang-CSlafowP.js} +152 -137
  24. package/dist/Mission-BOByUsYC.js +296 -0
  25. package/dist/Overview-BQQs8TsL.js +1079 -0
  26. package/dist/{Point-Ck8EG_3k.js → Point-BuRBh_HC.js} +55 -53
  27. package/dist/Promotion-Py2WWNt0.js +289 -0
  28. package/dist/Queue-On8_svkl.js +260 -0
  29. package/dist/Record-CSWkHs9Y.js +341 -0
  30. package/dist/Reward-BLVyFkAH.js +442 -0
  31. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-BW8kuoLt.js +150 -0
  32. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-DC8JEmEC.js +1728 -0
  33. package/dist/Segment-BjBskgf9.js +880 -0
  34. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-CrVw6j2M.js +181 -0
  35. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-oaAVUxO4.js +188 -0
  36. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-CKOTgzL-.js +147 -0
  37. package/dist/Setting-CAMlhgGd.js +1932 -0
  38. package/dist/Store-0qvNbHne.js +1842 -0
  39. package/dist/StoreRewards-CjcHvUNa.js +423 -0
  40. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CdZ7QIaf.js +1029 -0
  41. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DrzmjYmU.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-vJaZIDrx.js} +1 -1
  42. package/dist/{Tier-CJ9-d8Zg.js → Tier-D_pHKGSv.js} +350 -334
  43. package/dist/{Title-DZCpvg4q.js → Title-DgdtJ87h.js} +245 -222
  44. package/dist/{Transaction-DpnTxlbf.js → Transaction-CKlLWcjS.js} +2 -2
  45. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-2GOvljvv.js +130 -0
  46. package/dist/Voucher-Cg6zQSAy.js +354 -0
  47. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-rpjQkheM.js +419 -0
  48. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-SukfoJpU.js → ZodTextField.vue_vue_type_script_setup_true_lang-BRdY-P8U.js} +1 -1
  49. package/dist/{app-DzAexOqx.js → app-CScRp4SA.js} +2709 -1265
  50. package/dist/app-jGYefKeR.js +33357 -0
  51. package/dist/app.js +1 -1
  52. package/dist/business-DYhO4gjc.js +79 -0
  53. package/dist/campaign-BgXy1Ngd.js +1810 -0
  54. package/dist/{campaign-winsqufa.js → campaign-CZ5pMrUu.js} +2 -2
  55. package/dist/campaign.enum-CWBDlzqp.js +20 -0
  56. package/dist/campaign.fn-HHZ5mQKe.js +758 -0
  57. package/dist/collectible.enum-MvoLHpuA.js +19 -0
  58. package/dist/{collection.fn-CI5Llblg.js → collection.fn-BHUoLJPj.js} +2 -2
  59. package/dist/dto-DXdR0em1.js +214 -0
  60. package/dist/{effect-CdkrIYgX.js → effect-HLuo1A_f.js} +33 -16
  61. package/dist/email-addresses-DU4ehcHM.js +705 -0
  62. package/dist/{export-DGxfief1.js → export-BDRHAxZr.js} +5 -5
  63. package/dist/{helper-B8RqcTNu.js → helper-JhFOw8n-.js} +1 -1
  64. package/dist/{index-OzicErwL.js → index-BG_GpbnZ.js} +24 -21
  65. package/dist/{index-Cw_aXFH6.js → index-BZWr1bgh.js} +269 -173
  66. package/dist/{loading-DuEFUCwF.js → index-Bs-tzd5F.js} +4609 -4886
  67. package/dist/{index-wzdbEEcZ.js → index-C2nNcNjw.js} +1 -1
  68. package/dist/index-CIF8DeC8.js +54 -0
  69. package/dist/{index-HZC9LLAX.js → index-CqT8uK3R.js} +48 -4
  70. package/dist/index-CsaQJMAR.js +66 -0
  71. package/dist/{index-9w43_U1v.js → index-DVj1MyZp.js} +1506 -1480
  72. package/dist/{index-CZgQVRsm.js → index-GmHsjd7O.js} +1 -1
  73. package/dist/index-QDEKR2Rj.js +115 -0
  74. package/dist/{index-A34xEz20.js → index-cYKPj4fA.js} +2246 -871
  75. package/dist/index-eRBO4PzZ.js +56 -0
  76. package/dist/index-fS6fmvFv.js +29556 -0
  77. package/dist/index-l8E6r07W.js +32 -0
  78. package/dist/index-vh86FiIQ.js +10 -0
  79. package/dist/{index.esm2017-CppSMh_U.js → index.esm2017-B-YrQ0sw.js} +206 -206
  80. package/dist/loading-C09t0mFj.js +71 -0
  81. package/dist/{membership-nsMtWeTC.js → membership-tHAn3VRs.js} +80 -66
  82. package/dist/money-DYVCca49.js +15 -0
  83. package/dist/number-VYuUME2F.js +12 -0
  84. package/dist/objectid-BTO4csVa.js +145 -0
  85. package/dist/plugins-CXgvBDMF.js +208 -0
  86. package/dist/remy-vue-client-Cpppk9h-.js +1693 -0
  87. package/dist/reward-DX9TZrk4.js +36 -0
  88. package/dist/{rule-CPIMqt1h.js → rule-CbCZqulx.js} +185 -178
  89. package/dist/{rule-builder-CSs5XRKP.js → rule-builder-J8K_fjI-.js} +1 -1
  90. package/dist/style.css +1 -1
  91. package/dist/{template-CJZoYavu.js → template-BtYJpEBa.js} +5 -5
  92. package/dist/trigger-D6dpZFSN.js +144 -0
  93. package/dist/user-C0QvWk-o.js +54 -0
  94. package/dist/vue-i18n-cz2_cPSz.js +2365 -0
  95. package/dist/{xlsx-BZlnYinX.js → xlsx-BIPQrY49.js} +1 -1
  96. package/package.json +11 -7
  97. package/dist/Analytic-5QztrYSp.js +0 -622
  98. package/dist/Card-BsjFTVsH.js +0 -825
  99. package/dist/Collections-7wqZHOax.js +0 -453
  100. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-Cuklmxur.js +0 -2813
  101. package/dist/Game-DlzDerT7.js +0 -255
  102. package/dist/Marketing-BqhpaG4o.js +0 -316
  103. package/dist/Member-AFgZcdtz.js +0 -69
  104. package/dist/MemberList-BKgrLz2C.js +0 -1733
  105. package/dist/MemberTransactions-BwT3zE2a.js +0 -38
  106. package/dist/Mission-BTAia7AS.js +0 -261
  107. package/dist/Promotion-0v3kvsK3.js +0 -247
  108. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-BkFm7tXq.js +0 -1753
  109. package/dist/Segment-BenLupqV.js +0 -437
  110. package/dist/Setting-0fpREqpJ.js +0 -1901
  111. package/dist/Store-BDGwe4ar.js +0 -1511
  112. package/dist/StoreRewards-TDZt9H1V.js +0 -401
  113. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-BqpsMcl1.js +0 -890
  114. package/dist/Voucher-DsP_rh8I.js +0 -490
  115. package/dist/app-Cg2pTZJK.js +0 -53428
  116. package/dist/business-Cw_qGw8y.js +0 -78
  117. package/dist/dto-ozu1smC3.js +0 -2770
  118. package/dist/index-BLACZ3-L.js +0 -206
  119. package/dist/index-BaozRfWB.js +0 -762
  120. package/dist/index-CjVmULNd.js +0 -99
  121. package/dist/index-CuvNtC_M.js +0 -61
  122. package/dist/index-DAEmawcj.js +0 -298
  123. package/dist/index-Oxr-mU6h.js +0 -29193
  124. package/dist/money-BGZPFtUc.js +0 -15
  125. package/dist/number-4J0xvXP9.js +0 -12
  126. package/dist/user-Bm4KttFq.js +0 -37
  127. package/dist/vue-i18n-CCyiVzOE.js +0 -2365
@@ -0,0 +1,260 @@
1
+ import { defineComponent as h, h as n, ref as A, watch as B, onBeforeMount as U, resolveComponent as V, openBlock as z, createElementBlock as O, Fragment as q, createVNode as m, unref as o, createElementVNode as g } from "vue";
2
+ import { u as G, _ as L } from "./usePagination-BeF5K3M7.js";
3
+ import { _ as S } from "./FilterChip.vue_vue_type_script_setup_true_lang-BrPLkFX8.js";
4
+ import { c as u, a as Y } from "./plugins-CXgvBDMF.js";
5
+ import { useDialog as j, components as y } from "@feedmepos/ui-library";
6
+ import "./index-BZWr1bgh.js";
7
+ import { J as c, c as d } from "./index-cYKPj4fA.js";
8
+ import "./index-DVj1MyZp.js";
9
+ import "./index-C2nNcNjw.js";
10
+ import "./index-CIF8DeC8.js";
11
+ import "./index-Bs-tzd5F.js";
12
+ import { h as b } from "./moment-BWErdI6_.js";
13
+ import { u as W } from "./vue-i18n-cz2_cPSz.js";
14
+ import { u as H, v as J, w as K } from "./index.esm2017-B-YrQ0sw.js";
15
+ import { useRoute as Q } from "vue-router";
16
+ import { g as $, S as Z, u as X } from "./index-fS6fmvFv.js";
17
+ import { o as ee } from "./objectId-dwaoBfJX.js";
18
+ const te = () => {
19
+ if (!Z.getBusinessId()) throw new Error("Invalid business ID");
20
+ return X("queues");
21
+ }, oe = {
22
+ async readImportMember(p, w) {
23
+ return $(
24
+ await te().get("", {
25
+ params: { ...p, ...w }
26
+ })
27
+ );
28
+ }
29
+ };
30
+ var ae = { firebase: { apiKey: "AIzaSyAj8JdCHtP0Vc5vZobCfgoLzWxPIn0WUG4", authDomain: "feedme-dev-4c3ef.firebaseapp.com", databaseURL: "https://feedme-dev-4c3ef.firebaseio.com", projectId: "feedme-dev-4c3ef", storageBucket: "feedme-dev-4c3ef.appspot.com", messagingSenderId: "458797803788", appId: "1:458797803788:web:37f2af2926a84288f0c129", measurementId: "G-J2QG09D2Q7" }, assetBucketUrl: "feedme-dev-4c3ef.appspot.com", importFilesBucketUrl: "feedme-dev-4c3ef.appspot.com", clientId: "1a362d621873497b277ea55258cc82594ba148d235257f7bd44ea2acc132d8a4" };
31
+ const re = { class: "p-24 flex flex-col gap-y-2" }, ne = { class: "flex items-center justify-between" }, se = { class: "flex gap-8 items-center w-full overflow-x-scroll" }, xe = /* @__PURE__ */ h({
32
+ __name: "Queue",
33
+ setup(p) {
34
+ const v = Q().query.type, { t: x } = W(), E = j(), C = [
35
+ {
36
+ header: "ID",
37
+ accessorKey: "_id",
38
+ meta: {
39
+ maxWidth: "100px"
40
+ },
41
+ cell(t) {
42
+ return n("div", { class: "flex items-center" }, [
43
+ n(y.FmIcon, {
44
+ name: "content_copy",
45
+ outline: !0,
46
+ size: "sm",
47
+ class: "cursor-pointer mr-4",
48
+ onClick: (e) => {
49
+ e.preventDefault(), e.stopPropagation(), Y(t.row.original._id.toString());
50
+ }
51
+ }),
52
+ n(
53
+ "div",
54
+ { class: "pr-2 text-ellipsis overflow-hidden" },
55
+ t.row.original._id.toString()
56
+ )
57
+ ]);
58
+ },
59
+ enableSorting: !1
60
+ },
61
+ {
62
+ header: "Type",
63
+ accessorFn: (t) => u.title(t.type.replace("_", " ")),
64
+ enableSorting: !1
65
+ },
66
+ {
67
+ header: "Status",
68
+ accessorFn: (t) => {
69
+ var e;
70
+ return t.status ? u.title((e = t.status) == null ? void 0 : e.toString()) : "-";
71
+ },
72
+ cell(t) {
73
+ const e = t.row.original.status;
74
+ return n(y.FmChip, {
75
+ label: e ? u.title(e) : "-",
76
+ compact: !0,
77
+ class: D(e)
78
+ });
79
+ },
80
+ enableSorting: !1
81
+ },
82
+ {
83
+ header: "Ref",
84
+ accessorKey: "ref",
85
+ enableSorting: !1
86
+ },
87
+ {
88
+ header: "Created at",
89
+ accessorFn: (t) => b(ee(t._id.toString())).format("D MMM YYYY, hh:mmA"),
90
+ enableSorting: !0
91
+ },
92
+ {
93
+ header: "Context",
94
+ cell(t) {
95
+ var r, a;
96
+ const e = ((a = (r = t.row.original.context) == null ? void 0 : r.context) == null ? void 0 : a.file) || null;
97
+ return e != null && e.downloadUrl && (e != null && e.originalName) ? n(
98
+ "a",
99
+ {
100
+ class: "fm-typo-en-link-md-600",
101
+ href: e.downloadUrl,
102
+ download: e.originalName,
103
+ target: "_blank",
104
+ rel: "noopener"
105
+ },
106
+ e.originalName
107
+ ) : e != null && e.originalName ? n("div", null, e.originalName) : n("div", null, "-");
108
+ },
109
+ enableSorting: !1
110
+ },
111
+ {
112
+ header: "Failed reason",
113
+ cell(t) {
114
+ return n(y.FmButton, {
115
+ icon: "visibility",
116
+ variant: "tertiary",
117
+ disabled: !t.row.original.failedReason,
118
+ onClick: (e) => {
119
+ e.preventDefault(), e.stopPropagation(), M(t.row.original.failedReason);
120
+ }
121
+ });
122
+ },
123
+ enableSorting: !1
124
+ }
125
+ ], D = (t) => {
126
+ switch (t) {
127
+ case c.enum.ACTIVE:
128
+ return "text-fm-color-typo-info bg-fm-color-system-info-100";
129
+ case c.enum.WAITING:
130
+ return "text-fm-color-typo-warning bg-fm-color-system-warning-100";
131
+ case c.enum.COMPLETED:
132
+ return "text-fm-color-typo-success bg-fm-color-system-success-100";
133
+ case c.enum.FAILED:
134
+ return "text-fm-color-typo-error bg-fm-color-system-error-100";
135
+ default:
136
+ return "text-fm-color-typo-primary bg-fm-color-system-primary-100";
137
+ }
138
+ }, F = h({
139
+ name: "FailedReasonDialog",
140
+ props: {
141
+ data: {
142
+ type: String,
143
+ required: !0
144
+ }
145
+ },
146
+ setup(t) {
147
+ return () => n("div", { class: "whitespace-pre-line" }, t.data);
148
+ }
149
+ });
150
+ async function M(t) {
151
+ E.open({
152
+ title: "Failed Reason",
153
+ closeButton: !0,
154
+ dismissAway: !0,
155
+ contentComponent: F,
156
+ contentComponentProps: {
157
+ data: t
158
+ }
159
+ });
160
+ }
161
+ const T = async (t) => {
162
+ const e = H(void 0, ae.importFilesBucketUrl), r = J(e, t);
163
+ return await K(r);
164
+ }, R = c.options.map((t) => ({ label: u.title(t), value: t })), s = A({
165
+ type: v ?? [
166
+ d.enum.MEMBER_IMPORTED,
167
+ d.enum.SEGMENTATION_IMPORTED
168
+ ],
169
+ status: []
170
+ }), { tableMeta: i, rowData: P, onSort: k, debouncedFetchData: f } = G(
171
+ async (t) => {
172
+ const e = {
173
+ ...s.value
174
+ }, r = await oe.readImportMember(t, e);
175
+ return await Promise.all(
176
+ r.resources.map(async (a) => {
177
+ var _, I;
178
+ const l = (I = (_ = a.context) == null ? void 0 : _.context) == null ? void 0 : I.file;
179
+ if (b(a.context.emittedAt).diff(b(), "days") < 7 && l)
180
+ try {
181
+ l.downloadUrl = await T(l == null ? void 0 : l.fbFilePath);
182
+ } catch (N) {
183
+ console.log(N);
184
+ }
185
+ })
186
+ ), {
187
+ resources: r.resources,
188
+ meta: r.meta
189
+ };
190
+ }
191
+ );
192
+ return B(
193
+ s,
194
+ () => {
195
+ f();
196
+ },
197
+ { deep: !0 }
198
+ ), U(async () => {
199
+ await f();
200
+ }), (t, e) => {
201
+ const r = V("FmPageHead");
202
+ return z(), O(q, null, [
203
+ m(r, {
204
+ title: o(x)("connect.queue.title")
205
+ }, null, 8, ["title"]),
206
+ g("div", re, [
207
+ g("div", ne, [
208
+ g("div", se, [
209
+ m(S, {
210
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
211
+ "right-icon": "keyboard_arrow_down",
212
+ modelValue: o(s).type,
213
+ "onUpdate:modelValue": e[0] || (e[0] = (a) => o(s).type = a),
214
+ label: "Type: ",
215
+ "show-item-label": !0,
216
+ items: [
217
+ {
218
+ label: "Member Imported",
219
+ value: o(d).enum.MEMBER_IMPORTED
220
+ },
221
+ {
222
+ label: "Segmentation Imported",
223
+ value: o(d).enum.SEGMENTATION_IMPORTED
224
+ }
225
+ ]
226
+ }, null, 8, ["modelValue", "items"]),
227
+ m(S, {
228
+ class: "cursor-pointer text-fm-color-neutral-gray-400",
229
+ "right-icon": "keyboard_arrow_down",
230
+ modelValue: o(s).status,
231
+ "onUpdate:modelValue": e[1] || (e[1] = (a) => o(s).status = a),
232
+ label: "Status: ",
233
+ "show-item-label": !0,
234
+ items: o(R)
235
+ }, null, 8, ["modelValue", "items"])
236
+ ])
237
+ ]),
238
+ m(L, {
239
+ loading: o(i).isLoading,
240
+ "row-data": o(P),
241
+ "row-count": o(i).totalRows,
242
+ "column-defs": C,
243
+ "page-count": o(i).pageCount,
244
+ "page-index": o(i).pageIndex,
245
+ "page-size": o(i).pageSize,
246
+ "shrink-at": !1,
247
+ onSortChange: o(k),
248
+ onPageChange: e[2] || (e[2] = (a) => o(f)({
249
+ pageSize: a.pageSize,
250
+ pageIndex: a.pageIndex
251
+ }))
252
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"])
253
+ ])
254
+ ], 64);
255
+ };
256
+ }
257
+ });
258
+ export {
259
+ xe as default
260
+ };
@@ -0,0 +1,341 @@
1
+ var q = Object.defineProperty;
2
+ var G = (g, o, m) => o in g ? q(g, o, { enumerable: !0, configurable: !0, writable: !0, value: m }) : g[o] = m;
3
+ var z = (g, o, m) => G(g, typeof o != "symbol" ? o + "" : o, m);
4
+ import { defineComponent as T, ref as B, computed as H, resolveComponent as C, openBlock as I, createBlock as J, unref as n, isRef as Q, withCtx as X, createElementBlock as U, createVNode as w, withModifiers as Z, createCommentVNode as ee, createElementVNode as N, h, onMounted as re, Fragment as te } from "vue";
5
+ import { u as oe, _ as ae } from "./usePagination-BeF5K3M7.js";
6
+ import { g as A } from "./user-C0QvWk-o.js";
7
+ import { components as R } from "@feedmepos/ui-library";
8
+ import "./index-Bs-tzd5F.js";
9
+ import { u as j } from "./vue-i18n-cz2_cPSz.js";
10
+ import { u as L } from "./loading-C09t0mFj.js";
11
+ import { useCoreStore as se } from "@feedmepos/mf-common";
12
+ import { r as v } from "./index-l8E6r07W.js";
13
+ import { c as ie, a as ne } from "./object-qECH92oz.js";
14
+ import { u as ce } from "./membership-tHAn3VRs.js";
15
+ import { a as le, c as de } from "./plugins-CXgvBDMF.js";
16
+ import { u as V, w as me } from "./xlsx-BIPQrY49.js";
17
+ import { e as f } from "./index-vh86FiIQ.js";
18
+ import { h as ue } from "./moment-BWErdI6_.js";
19
+ import { o as pe } from "./objectId-dwaoBfJX.js";
20
+ const fe = {
21
+ key: 0,
22
+ class: "flex justify-end mb-16"
23
+ }, ge = { class: "flex flex-col space-y-16 pr-12" }, he = /* @__PURE__ */ T({
24
+ __name: "UpdateCriteriaProgressSheet",
25
+ emits: ["refresh"],
26
+ setup(g, { expose: o, emit: m }) {
27
+ const y = m;
28
+ j();
29
+ const { minor: k } = L, l = B(!1), d = B({}), F = se(), S = [
30
+ {
31
+ header: "Criteria title",
32
+ accessorFn: (a) => a.name
33
+ },
34
+ {
35
+ header: "Status",
36
+ cell(a) {
37
+ var u;
38
+ const e = a.row.original, r = (u = d.value.criteria_progress) == null ? void 0 : u.find(
39
+ (_) => _.criteria === e._id
40
+ ), i = r ? "Completed" : "Pending", c = r ? "text-fm-color-typo-success bg-fm-color-system-success-100" : "text-fm-color-typo-warning bg-fm-color-system-warning-100";
41
+ return [
42
+ h(R.FmChip, {
43
+ label: i,
44
+ compact: !0,
45
+ class: c
46
+ })
47
+ ];
48
+ }
49
+ },
50
+ {
51
+ id: "actions",
52
+ cell(a) {
53
+ var i;
54
+ const e = a.row.original;
55
+ return [
56
+ !((i = d.value.criteria_progress) == null ? void 0 : i.some(
57
+ (c) => c.criteria === e._id
58
+ )) && e.type == "MANUAL" ? h(R.FmButton, {
59
+ variant: "secondary",
60
+ label: "Mark as completed",
61
+ size: "md",
62
+ onClick: (c) => {
63
+ c.stopPropagation(), x(e._id.toString());
64
+ }
65
+ }) : null
66
+ ];
67
+ }
68
+ }
69
+ ], M = H(() => {
70
+ var e, r, i, c;
71
+ return (((r = (e = d.value) == null ? void 0 : e.criteria_progress) == null ? void 0 : r.filter(
72
+ (u) => {
73
+ var _;
74
+ return (_ = d.value) == null ? void 0 : _.criteria.some(
75
+ (P) => P._id.toString() === u.criteria.toString()
76
+ );
77
+ }
78
+ )) || []).length == ((i = d.value) == null ? void 0 : i.criteria.length) && ((c = d.value) == null ? void 0 : c.status) != "COMPLETED";
79
+ });
80
+ async function x(a) {
81
+ var r;
82
+ const e = ie(ne(d.value));
83
+ e.criteria_progress = [
84
+ {
85
+ criteria: a,
86
+ ref: `ADMIN:${(r = F.user) == null ? void 0 : r.id}:${(/* @__PURE__ */ new Date()).toISOString()}`,
87
+ completedAt: /* @__PURE__ */ new Date()
88
+ }
89
+ ], k(
90
+ async () => {
91
+ await v.updateCriteriaProgress(
92
+ d.value._id,
93
+ e
94
+ ), l.value = !1, y("refresh");
95
+ },
96
+ {
97
+ message: "Updating criteria progress",
98
+ successMessage: "Criteria progress updated successfully"
99
+ }
100
+ );
101
+ }
102
+ function t(a, e) {
103
+ l.value = a, d.value = e;
104
+ }
105
+ function s() {
106
+ l.value = !1;
107
+ }
108
+ return o({
109
+ showSheet: t,
110
+ hideSheet: s,
111
+ data: d
112
+ }), (a, e) => {
113
+ const r = C("FmButton"), i = C("FmTable"), c = C("FmSideSheet");
114
+ return I(), J(c, {
115
+ "max-width": 768,
116
+ modelValue: n(l),
117
+ "onUpdate:modelValue": e[1] || (e[1] = (u) => Q(l) ? l.value = u : null),
118
+ header: "Referee Criteria"
119
+ }, {
120
+ default: X(() => [
121
+ n(M) ? (I(), U("div", fe, [
122
+ w(r, {
123
+ icon: "refresh",
124
+ label: "Refresh",
125
+ onClick: e[0] || (e[0] = Z((u) => x(n(d)._id), ["stop"]))
126
+ })
127
+ ])) : ee("", !0),
128
+ N("div", ge, [
129
+ w(i, {
130
+ "row-data": n(d).criteria,
131
+ "hide-footer": !0,
132
+ "page-size": 100,
133
+ "column-defs": S
134
+ }, null, 8, ["row-data"])
135
+ ])
136
+ ]),
137
+ _: 1
138
+ }, 8, ["modelValue"]);
139
+ };
140
+ }
141
+ });
142
+ class _e {
143
+ constructor() {
144
+ z(this, "data", []);
145
+ }
146
+ addRecord(o) {
147
+ this.data.push(o);
148
+ }
149
+ buildExcel() {
150
+ const o = V.book_new(), m = V.json_to_sheet(this.data);
151
+ return V.book_append_sheet(o, m, "Referrals"), o;
152
+ }
153
+ }
154
+ const we = { class: "flex items-center justify-end" }, $e = /* @__PURE__ */ T({
155
+ __name: "Record",
156
+ setup(g) {
157
+ const { t: o } = j();
158
+ ce();
159
+ const { minor: m } = L, y = B(null), k = [
160
+ {
161
+ header: "ID",
162
+ meta: {
163
+ maxWidth: "100px"
164
+ },
165
+ cell(t) {
166
+ return h("div", { class: "flex items-center" }, [
167
+ h(R.FmIcon, {
168
+ name: "content_copy",
169
+ outline: !0,
170
+ size: "sm",
171
+ class: "cursor-pointer mr-4",
172
+ onClick: (s) => {
173
+ s.preventDefault(), s.stopPropagation(), le(t.row.original._id.toString());
174
+ }
175
+ }),
176
+ h(
177
+ "div",
178
+ { class: "pr-2 text-ellipsis overflow-hidden" },
179
+ t.row.original._id.toString()
180
+ )
181
+ ]);
182
+ },
183
+ enableSorting: !1
184
+ },
185
+ {
186
+ header: o("connect.referral.record.referer_info"),
187
+ enableSorting: !0,
188
+ cell(t) {
189
+ return t.row.original.pf_referer ? A(t.row.original.pf_referer, !0) : "N/A";
190
+ }
191
+ },
192
+ {
193
+ header: o("connect.referral.record.referee_info"),
194
+ enableSorting: !0,
195
+ cell(t) {
196
+ return t.row.original.pf_referee ? A(t.row.original.pf_referee, !0) : "N/A";
197
+ }
198
+ },
199
+ {
200
+ header: o("connect.referral.record.referee_criteria"),
201
+ accessorKey: "criteria",
202
+ id: "criteria",
203
+ cell(t) {
204
+ var r;
205
+ const a = (((r = t.row.original.criteria_progress) == null ? void 0 : r.filter(
206
+ (i) => t.row.original.criteria.some(
207
+ (c) => c._id.toString() === i.criteria.toString()
208
+ )
209
+ )) || []).length, e = t.row.original.criteria.length;
210
+ return e === 0 ? h("div", "No criteria") : h("div", `${a}/${e} completed criteria`);
211
+ }
212
+ },
213
+ {
214
+ header: o("connect.referral.record.status"),
215
+ id: "status",
216
+ cell(t) {
217
+ const s = t.row.original.status;
218
+ return h(R.FmChip, {
219
+ label: de.title(s.replace("_", " ")),
220
+ compact: !0,
221
+ class: s == "COMPLETED" ? "text-fm-color-typo-success bg-fm-color-system-success-100" : "text-fm-color-typo-primary bg-fm-color-system-primary-100"
222
+ });
223
+ }
224
+ }
225
+ ], { tableMeta: l, rowData: d, onSort: F, debouncedFetchData: S, onSearch: M } = oe(v.readRecords);
226
+ async function x() {
227
+ const t = new _e(), s = (await v.readRecords({
228
+ limit: 1,
229
+ skip: 0,
230
+ sortBy: f.sortBy,
231
+ descending: f.descending
232
+ })).meta.totalResources ?? 0, a = f.rowsPerPage;
233
+ await m(
234
+ async () => {
235
+ var e, r, i, c;
236
+ for (let u = 0; u < s; u += a) {
237
+ const _ = {
238
+ ...f,
239
+ limit: a,
240
+ skip: f.page - 1,
241
+ sortBy: f.sortBy,
242
+ descending: f.descending
243
+ }, P = await v.readRecords(_);
244
+ for (const p of P.resources) {
245
+ const E = (p.criteria || []).reduce(
246
+ (b, D) => {
247
+ var $;
248
+ const Y = (($ = p.criteria_progress) == null ? void 0 : $.filter(
249
+ (K) => p.criteria.some(
250
+ (W) => W._id.toString() === K.criteria.toString()
251
+ )
252
+ )) || [];
253
+ return b[D.name] = Y.length > 0 ? "Completed" : "In Progress", b;
254
+ },
255
+ {}
256
+ );
257
+ console.log(E);
258
+ const O = {
259
+ ID: p._id.toString(),
260
+ RefererName: ((e = p.pf_referer) == null ? void 0 : e.name) ?? "",
261
+ RefererPhone: ((r = p.pf_referer) == null ? void 0 : r.phoneNumber) ?? "",
262
+ RefereeName: ((i = p.pf_referee) == null ? void 0 : i.name) ?? "",
263
+ RefereePhone: ((c = p.pf_referee) == null ? void 0 : c.phoneNumber) ?? "",
264
+ ReferredAt: ue(pe(p._id)).format(
265
+ "DD/MM/YYYY"
266
+ ),
267
+ Status: p.status,
268
+ Criteria: Object.entries(E).map(([b, D]) => `${b}: ${D}`).join(", ")
269
+ };
270
+ t.addRecord(O);
271
+ }
272
+ f.page++;
273
+ }
274
+ await me(
275
+ t.buildExcel(),
276
+ `referrals-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
277
+ {
278
+ bookType: "xlsx",
279
+ bookSST: !1,
280
+ type: "array"
281
+ }
282
+ ), f.page = 1;
283
+ },
284
+ {
285
+ message: "Exporting referral records...",
286
+ successMessage: "Referral record exported successfully"
287
+ }
288
+ );
289
+ }
290
+ return re(async () => {
291
+ await S();
292
+ }), (t, s) => {
293
+ const a = C("FmSearch"), e = C("FmButton");
294
+ return I(), U(te, null, [
295
+ N("div", null, [
296
+ N("div", we, [
297
+ w(a, {
298
+ class: "mt-4",
299
+ modelValue: n(l).searchValue,
300
+ "onUpdate:modelValue": [
301
+ s[0] || (s[0] = (r) => n(l).searchValue = r),
302
+ n(M)
303
+ ],
304
+ placeholder: "Search",
305
+ collapsible: ""
306
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
307
+ w(e, {
308
+ icon: "ios_share",
309
+ variant: "tertiary",
310
+ onClick: x
311
+ })
312
+ ]),
313
+ w(ae, {
314
+ loading: n(l).isLoading,
315
+ "row-data": n(d),
316
+ "row-count": n(l).totalRows,
317
+ "column-defs": k,
318
+ "shrink-at": !1,
319
+ "page-count": n(l).pageCount,
320
+ "page-index": n(l).pageIndex,
321
+ "page-size": n(l).pageSize,
322
+ onSortChange: n(F),
323
+ onPageChange: s[1] || (s[1] = (r) => n(S)({ pageSize: r.pageSize, pageIndex: r.pageIndex })),
324
+ onRowClick: s[2] || (s[2] = (r) => {
325
+ var i;
326
+ return (i = n(y)) == null ? void 0 : i.showSheet(!0, r.original);
327
+ })
328
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"])
329
+ ]),
330
+ w(he, {
331
+ ref_key: "updateCriteriaProgressSheetRef",
332
+ ref: y,
333
+ onRefresh: n(S)
334
+ }, null, 8, ["onRefresh"])
335
+ ], 64);
336
+ };
337
+ }
338
+ });
339
+ export {
340
+ $e as default
341
+ };