@feedmepos/mf-payment 1.0.0-beta.2 → 1.0.0-beta.4

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.
@@ -0,0 +1,483 @@
1
+ import { defineComponent as h, openBlock as y, createElementBlock as N, unref as i, createCommentVNode as V, createElementVNode as I, resolveComponent as _, createBlock as R, normalizeClass as q, withCtx as b, toDisplayString as S, createVNode as c, Fragment as $, renderList as K, ref as L, watch as C, isRef as x, h as T } from "vue";
2
+ import { c as g } from "./index-CWaKb7bG.js";
3
+ import { h as w } from "./moment-h96o7c8I.js";
4
+ import { u as P } from "./index-7KNaibcq.js";
5
+ import { _ as B } from "./index.vue_vue_type_script_setup_true_lang-JdAFa8vy.js";
6
+ import { _ as G } from "./AdminLayout.vue_vue_type_script_setup_true_lang-BTmMOzwx.js";
7
+ import { useSnackbar as U, useDialog as Q } from "@feedmepos/ui-library";
8
+ import { g as W } from "./assets-NrCec-W0.js";
9
+ import { E as j, t as F } from "./index-DbJpbpSs.js";
10
+ import { d as z } from "./dinero-CIVmXLL-.js";
11
+ import { _ as H } from "./AsyncButton.vue_vue_type_script_setup_true_lang-DcjzvYwT.js";
12
+ import { _ as J } from "./AutoCopyCell.vue_vue_type_script_setup_true_lang-GXPXBEf5.js";
13
+ import { useRouter as X } from "vue-router";
14
+ import { w as Z } from "./Modal-DB8M9o1T.js";
15
+ import { u as D } from "./error-K1CakhA9.js";
16
+ import { _ as ee } from "./SelectAll.vue_vue_type_script_setup_true_lang-DA4rs3tk.js";
17
+ const te = { class: "flex" }, ae = ["src"], ne = ["src"], re = /* @__PURE__ */ h({
18
+ __name: "Gateway",
19
+ props: {
20
+ row: {},
21
+ data: {}
22
+ },
23
+ setup(p) {
24
+ return (a, m) => (y(), N("div", te, [
25
+ a.row.original.ecrGateway ? (y(), N("img", {
26
+ key: 0,
27
+ class: "bg-fm-color-overlay-background rounded-md m-auto border-transparent w-[32px] h-[32px]",
28
+ src: i(j)
29
+ }, null, 8, ae)) : V("", !0),
30
+ I("img", {
31
+ class: "rounded-md m-auto border-transparent w-[32px] h-[32px]",
32
+ src: i(W)(a.row.original.gateway)
33
+ }, null, 8, ne)
34
+ ]));
35
+ }
36
+ }), oe = /* @__PURE__ */ h({
37
+ __name: "Status",
38
+ props: {
39
+ row: {},
40
+ data: {}
41
+ },
42
+ setup(p) {
43
+ const a = p;
44
+ function m() {
45
+ return a.data === g.F_TERMINAL_TRANSACTION_ACTION.Enum.process ? "!w-[16px] !h-[16px] bg-yellow-400" : a.data === g.F_TERMINAL_TRANSACTION_ACTION.Enum.failed ? "!w-[16px] !h-[16px] bg-red-400" : a.data === g.F_TERMINAL_TRANSACTION_ACTION.Enum.refunded ? "!w-[16px] !h-[16px] bg-blue-400" : "!w-[16px] !h-[16px] bg-green-400";
46
+ }
47
+ return (r, l) => {
48
+ const s = _("FmBadge");
49
+ return y(), R(s, {
50
+ inline: "",
51
+ class: q(m())
52
+ }, {
53
+ default: b(() => [
54
+ I("div", null, S(r.data.toUpperCase()), 1)
55
+ ]),
56
+ _: 1
57
+ }, 8, ["class"]);
58
+ };
59
+ }
60
+ }), se = /* @__PURE__ */ h({
61
+ __name: "RouteCell",
62
+ props: {
63
+ data: {},
64
+ route: {}
65
+ },
66
+ setup(p) {
67
+ const a = p, m = X();
68
+ function r() {
69
+ m.push(a.route);
70
+ }
71
+ return (l, s) => (y(), N("div", {
72
+ class: "fm-typo-en-link-md-600",
73
+ onClick: s[0] || (s[0] = (f) => {
74
+ f.stopPropagation(), r();
75
+ })
76
+ }, S(l.data), 1));
77
+ }
78
+ }), le = /* @__PURE__ */ h({
79
+ __name: "Actions",
80
+ props: {
81
+ onAction: { type: Function }
82
+ },
83
+ setup(p) {
84
+ const a = [
85
+ {
86
+ label: "Query",
87
+ sublabel: "Perform transaction status inquriy",
88
+ icon: "question_answer",
89
+ action: "query"
90
+ },
91
+ {
92
+ label: "Refund",
93
+ sublabel: "Perform transaction refund request",
94
+ icon: "request_page",
95
+ action: "refund"
96
+ }
97
+ ];
98
+ return (m, r) => {
99
+ const l = _("FmIcon"), s = _("FmMenuItem"), f = _("FmMenu");
100
+ return y(), N("div", {
101
+ onClick: r[0] || (r[0] = (u) => {
102
+ u.stopPropagation();
103
+ })
104
+ }, [
105
+ c(f, null, {
106
+ "menu-button": b(() => [
107
+ c(l, { name: "settings" })
108
+ ]),
109
+ default: b(() => [
110
+ (y(), N($, null, K(a, (u) => c(s, {
111
+ selectable: !0,
112
+ key: u.label,
113
+ sublabel: u.sublabel,
114
+ label: u.label,
115
+ icon: u.icon,
116
+ onclick: () => m.onAction(u.action)
117
+ }, null, 8, ["sublabel", "label", "icon", "onclick"])), 64))
118
+ ]),
119
+ _: 1
120
+ })
121
+ ]);
122
+ };
123
+ }
124
+ });
125
+ function ie(p) {
126
+ let a;
127
+ try {
128
+ a = parseInt(p.substr(0, 8), 16) * 1e3;
129
+ } catch {
130
+ return null;
131
+ }
132
+ return new Date(a);
133
+ }
134
+ const ce = /* @__PURE__ */ h({
135
+ __name: "Timestamp",
136
+ props: {
137
+ createdAt: {},
138
+ transactionAt: {},
139
+ refundedAt: {}
140
+ },
141
+ setup(p) {
142
+ return (a, m) => {
143
+ const r = _("FmListItem"), l = _("FmList");
144
+ return y(), R(l, { class: "w-[180px]" }, {
145
+ default: b(() => [
146
+ c(r, {
147
+ label: "Created At",
148
+ sublabel: a.createdAt
149
+ }, null, 8, ["sublabel"]),
150
+ c(r, {
151
+ label: "Transaction At",
152
+ sublabel: a.transactionAt
153
+ }, null, 8, ["sublabel"]),
154
+ c(r, {
155
+ label: "Refunded At",
156
+ sublabel: a.refundedAt
157
+ }, null, 8, ["sublabel"])
158
+ ]),
159
+ _: 1
160
+ });
161
+ };
162
+ }
163
+ }), ue = { class: "flex justify-between mb-6 items-start" }, me = { class: "flex space-x-4 items-start" }, de = { class: "flex space-x-4" }, Ce = /* @__PURE__ */ h({
164
+ __name: "TerminalTransaction",
165
+ setup(p) {
166
+ const a = U(), m = Q(), r = L(), { dateRange: l, status: s, searchKey: f } = P({
167
+ searchKey: "",
168
+ status: [g.F_TERMINAL_TRANSACTION_ACTION.Enum.success],
169
+ dateRange: {
170
+ startDate: w().startOf("day").format("YYYY-MM-DD"),
171
+ endDate: w().endOf("day").format("YYYY-MM-DD")
172
+ }
173
+ });
174
+ C([l, s], () => {
175
+ var e;
176
+ return (e = r.value) == null ? void 0 : e.reset();
177
+ });
178
+ let u;
179
+ C(f, async () => {
180
+ u && clearTimeout(u), u = setTimeout(
181
+ () => {
182
+ var e;
183
+ return (e = r.value) == null ? void 0 : e.reset();
184
+ },
185
+ 700
186
+ );
187
+ });
188
+ async function M(e) {
189
+ var o, d, A;
190
+ const t = (d = (o = r.value) == null ? void 0 : o.pageData()) == null ? void 0 : d.at(e);
191
+ if (!t) {
192
+ a.open({
193
+ type: "error",
194
+ title: "Something went wrong",
195
+ message: "Fail to find transactions from the displayed transactions."
196
+ });
197
+ return;
198
+ }
199
+ if (!t.refId) {
200
+ a.open({
201
+ type: "error",
202
+ title: "Something went wrong",
203
+ message: "Transaction isn't a valid transaction to perform query"
204
+ });
205
+ return;
206
+ }
207
+ try {
208
+ const n = await F.queryTransaction(t._id);
209
+ (A = r.value) == null || A.replaceData(e, n), a.open({
210
+ type: "success",
211
+ title: "Transaction queried and updated successfully."
212
+ });
213
+ } catch (n) {
214
+ a.open({
215
+ type: "error",
216
+ title: "Fail to query transaction.",
217
+ message: D(n)
218
+ });
219
+ }
220
+ }
221
+ async function k(e) {
222
+ var o, d;
223
+ const t = (d = (o = r.value) == null ? void 0 : o.pageData()) == null ? void 0 : d.at(e);
224
+ if (!t) {
225
+ a.open({
226
+ type: "error",
227
+ title: "Something went wrong",
228
+ message: "Fail to find transactions from the displayed transactions."
229
+ });
230
+ return;
231
+ }
232
+ if (!t.refId) {
233
+ a.open({
234
+ type: "error",
235
+ title: "Something went wrong",
236
+ message: "Transaction isn't a valid transaction to perform refund"
237
+ });
238
+ return;
239
+ }
240
+ Z(
241
+ m,
242
+ "Refund Transaction",
243
+ "Are you sure to refund transaction? This action cannot be revert!",
244
+ async () => {
245
+ var A;
246
+ try {
247
+ const n = await F.refundTransaction({
248
+ transactionId: t._id,
249
+ reason: "portal transaction refund",
250
+ amount: t.details.amount
251
+ });
252
+ (A = r.value) == null || A.replaceData(e, n), a.open({
253
+ type: "success",
254
+ title: "Transaction queried and updated successfully."
255
+ });
256
+ } catch (n) {
257
+ a.open({
258
+ type: "error",
259
+ title: "Fail to query transaction.",
260
+ message: D(n)
261
+ });
262
+ }
263
+ }
264
+ );
265
+ }
266
+ const v = [
267
+ {
268
+ label: "Success",
269
+ value: g.F_TERMINAL_TRANSACTION_ACTION.Enum.success
270
+ },
271
+ {
272
+ label: "Refunded",
273
+ value: g.F_TERMINAL_TRANSACTION_ACTION.Enum.refunded
274
+ },
275
+ {
276
+ label: "Process",
277
+ value: g.F_TERMINAL_TRANSACTION_ACTION.Enum.process
278
+ },
279
+ {
280
+ label: "Failed",
281
+ value: g.F_TERMINAL_TRANSACTION_ACTION.Enum.failed
282
+ }
283
+ ], E = function(e) {
284
+ const t = e;
285
+ let o = "-";
286
+ t.details && t.details.amount && (console.log(t._id), o = z(t.details.amount).toFormat("$0.00"));
287
+ const d = ie(e._id);
288
+ return {
289
+ id: e._id,
290
+ orderId: e.orderId,
291
+ refId: e.refId,
292
+ owner: e.owner,
293
+ terminalId: e.terminalId,
294
+ action: e.action,
295
+ gateway: e.gateway,
296
+ ecrGateway: e.ecrGateway,
297
+ amount: o,
298
+ createdAt: d ? w(d).format("YYYY-MM-DD hh:mm:ss") : "N/A",
299
+ transactionAt: e.transactionAt ? w(e.transactionAt).format("YYYY-MM-DD hh:mm:ss") : "N/A",
300
+ refundedAt: e.refundedAt ? w(e.refundedAt).format("YYYY-MM-DD hh:mm:ss") : "N/A"
301
+ };
302
+ }, Y = [
303
+ {
304
+ accessorKey: "id",
305
+ header: () => "Transaction ID",
306
+ meta: {
307
+ textAlign: "left"
308
+ },
309
+ cell: ({ cell: e }) => T(J, { data: e.getValue() })
310
+ },
311
+ {
312
+ accessorKey: "orderId",
313
+ header: () => "Pay ID",
314
+ meta: {
315
+ textAlign: "left"
316
+ }
317
+ },
318
+ {
319
+ accessorKey: "refId",
320
+ header: () => "Reference ID",
321
+ meta: {
322
+ textAlign: "left"
323
+ }
324
+ },
325
+ {
326
+ accessorKey: "gateway",
327
+ header: () => "Gateway",
328
+ meta: {
329
+ textAlign: "center",
330
+ maxWidth: "128px"
331
+ },
332
+ cell: ({ cell: e, row: t }) => T(re, { row: t, data: e.getValue() })
333
+ },
334
+ {
335
+ accessorKey: "action",
336
+ header: () => "Status",
337
+ meta: {
338
+ textAlign: "right",
339
+ maxWidth: "132px"
340
+ },
341
+ cell: ({ cell: e, row: t }) => T(oe, { row: t, data: e.getValue() })
342
+ },
343
+ {
344
+ accessorKey: "amount",
345
+ header: () => "Sales Amount",
346
+ meta: {
347
+ textAlign: "center"
348
+ }
349
+ },
350
+ {
351
+ accessorKey: "terminalId",
352
+ header: () => "Terminal ID",
353
+ meta: {
354
+ textAlign: "left"
355
+ },
356
+ cell: ({ cell: e, row: t }) => {
357
+ const o = e.getValue();
358
+ return T(se, {
359
+ data: o,
360
+ route: {
361
+ name: "mf-payment-admin.terminal-setting",
362
+ params: { terminalId: o }
363
+ }
364
+ });
365
+ }
366
+ },
367
+ {
368
+ accessorKey: "owner",
369
+ header: () => "Reference",
370
+ meta: {
371
+ textAlign: "left"
372
+ }
373
+ },
374
+ {
375
+ accessorKey: "timestamp",
376
+ header: () => "Timestamp",
377
+ meta: {
378
+ textAlign: "left"
379
+ },
380
+ cell: ({ row: e }) => T(ce, {
381
+ createdAt: e.original.createdAt,
382
+ transactionAt: e.original.transactionAt,
383
+ refundedAt: e.original.refundedAt
384
+ })
385
+ },
386
+ {
387
+ header: () => "Actions",
388
+ accessorKey: "actions",
389
+ cell: ({ row: e }) => {
390
+ if (e.original.gateway === "ScanPay")
391
+ return T(le, {
392
+ onAction: (t) => {
393
+ const o = e.index;
394
+ switch (t) {
395
+ case "query":
396
+ return M(o);
397
+ case "refund":
398
+ return k(o);
399
+ }
400
+ }
401
+ });
402
+ }
403
+ }
404
+ ];
405
+ return (e, t) => {
406
+ const o = _("FmSearch"), d = _("FmSelect"), A = _("FmSimpleDateRangePicker");
407
+ return y(), R(G, {
408
+ title: "Offline Transactions",
409
+ loading: !1
410
+ }, {
411
+ default: b(() => [
412
+ I("div", ue, [
413
+ I("div", me, [
414
+ c(o, {
415
+ "model-value": i(f),
416
+ "onUpdate:modelValue": t[0] || (t[0] = (n) => x(f) ? f.value = n : null),
417
+ class: "mr-8",
418
+ label: "Search",
419
+ placeholder: "Search Transactions ..."
420
+ }, null, 8, ["model-value"]),
421
+ c(d, {
422
+ modelValue: i(s),
423
+ "onUpdate:modelValue": t[2] || (t[2] = (n) => x(s) ? s.value = n : null),
424
+ class: "mr-6 w-[300px]",
425
+ label: "Status",
426
+ "label-mark": "required",
427
+ multiselect: "",
428
+ items: v
429
+ }, {
430
+ "prepend-menu": b(() => [
431
+ c(ee, {
432
+ modelValue: i(s),
433
+ "onUpdate:modelValue": t[1] || (t[1] = (n) => x(s) ? s.value = n : null),
434
+ items: v
435
+ }, null, 8, ["modelValue"])
436
+ ]),
437
+ _: 1
438
+ }, 8, ["modelValue"]),
439
+ c(A, {
440
+ modelValue: i(l),
441
+ "onUpdate:modelValue": t[3] || (t[3] = (n) => x(l) ? l.value = n : null),
442
+ "show-predefined-range": ""
443
+ }, null, 8, ["modelValue"])
444
+ ]),
445
+ I("div", de, [
446
+ c(H, {
447
+ button: {
448
+ appendIcon: "file_download",
449
+ variant: "primary",
450
+ label: "Export"
451
+ },
452
+ handler: async () => {
453
+ var n;
454
+ return i(F).downloadTransactions(await ((n = r.value) == null ? void 0 : n.allData()) ?? []);
455
+ }
456
+ }, null, 8, ["handler"])
457
+ ])
458
+ ]),
459
+ c(B, {
460
+ ref_key: "controller",
461
+ ref: r,
462
+ "column-defs": Y,
463
+ "rows-defs": E,
464
+ onRowClick: t[4] || (t[4] = () => {
465
+ }),
466
+ paginate: (n, O) => i(F).readTransactions({
467
+ status: i(s),
468
+ searchKey: i(f),
469
+ limit: n,
470
+ cursor: O,
471
+ start: i(l).startDate,
472
+ end: i(l).endDate
473
+ })
474
+ }, null, 8, ["paginate"])
475
+ ]),
476
+ _: 1
477
+ });
478
+ };
479
+ }
480
+ });
481
+ export {
482
+ Ce as default
483
+ };