@feedmepos/mf-payment 1.0.0-beta.8 → 1.0.0-beta.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.
@@ -3,7 +3,7 @@ import { p as z } from "./index-BFYq3eq8.js";
3
3
  import { _ as y, u as S, e as K } from "./index-4meiCsRz.js";
4
4
  import { defineStore as _ } from "pinia";
5
5
  import { useCoreStore as $ } from "@feedmepos/mf-common";
6
- import { c as AA, P as v } from "./payout-account-BsnCr2__.js";
6
+ import { c as AA, P as v } from "./payout-account-CKhGpN_d.js";
7
7
  import { useDialogChild as sA, useDialog as eA } from "@feedmepos/ui-library";
8
8
  import { z as X, a as x } from "./validator-D5jtpt9A.js";
9
9
  import { P as J } from "./PDFViewer-xrBtzrlR.js";
@@ -2,7 +2,7 @@ import { defineComponent as g, resolveComponent as i, openBlock as h, createBloc
2
2
  import { u as S } from "./index-BwFHcZlm.js";
3
3
  import { _ as O } from "./index-4meiCsRz.js";
4
4
  import { _ as K } from "./AdminLayout.vue_vue_type_script_setup_true_lang-BTmMOzwx.js";
5
- import { P as V } from "./payout-account-BsnCr2__.js";
5
+ import { P as V } from "./payout-account-CKhGpN_d.js";
6
6
  import { p as $ } from "./index-BFYq3eq8.js";
7
7
  import "@feedmepos/ui-library";
8
8
  import { _ as D } from "./index.vue_vue_type_script_setup_true_lang-CKOlikHb.js";
@@ -0,0 +1,387 @@
1
+ import { defineComponent as T, openBlock as b, createElementBlock as N, Fragment as Y, createElementVNode as g, createTextVNode as V, toDisplayString as S, toRef as M, ref as F, watch as D, onMounted as G, computed as O, resolveComponent as f, unref as k, createVNode as I, createBlock as _, withCtx as q, createCommentVNode as B, isRef as h, resolveDynamicComponent as L, normalizeProps as j, mergeProps as E } from "vue";
2
+ import { u as R, e as U } from "./index-4meiCsRz.js";
3
+ import { useRouter as A } from "vue-router";
4
+ import { t as C } from "./index-CBa6eapm.js";
5
+ import { _ as z } from "./Layout.vue_vue_type_script_setup_true_lang-DJm5br5a.js";
6
+ import { u as H } from "./index-BwFHcZlm.js";
7
+ import { useSnackbar as Q } from "@feedmepos/ui-library";
8
+ import { u as J } from "./error-K1CakhA9.js";
9
+ import { useCoreStore as $ } from "@feedmepos/mf-common";
10
+ const W = /* @__PURE__ */ T({
11
+ __name: "Information",
12
+ props: {
13
+ terminal: {
14
+ type: Object,
15
+ required: !0
16
+ }
17
+ },
18
+ setup(y) {
19
+ return (d, e) => (b(), N(Y, null, [
20
+ e[0] || (e[0] = g("b", null, "Name", -1)),
21
+ V(": " + S(y.terminal.name), 1),
22
+ e[1] || (e[1] = g("br", null, null, -1)),
23
+ e[2] || (e[2] = g("b", null, "Status", -1)),
24
+ V(": " + S(y.terminal.status), 1),
25
+ e[3] || (e[3] = g("br", null, null, -1)),
26
+ e[4] || (e[4] = g("b", null, "Device ID", -1)),
27
+ V(": " + S(y.terminal.deviceId ?? "-"), 1),
28
+ e[5] || (e[5] = g("br", null, null, -1)),
29
+ e[6] || (e[6] = g("b", null, "Device Type", -1)),
30
+ V(": " + S(y.terminal.deviceType ?? "-"), 1),
31
+ e[7] || (e[7] = g("br", null, null, -1))
32
+ ], 64));
33
+ }
34
+ }), X = {
35
+ key: 0,
36
+ class: "flex items-center justify-center min-h-[80vh]"
37
+ }, Z = { class: "flex mt-6 space-x-6" }, ee = /* @__PURE__ */ T({
38
+ __name: "TerminalGateway",
39
+ props: {
40
+ terminal: {
41
+ type: Object,
42
+ required: !0
43
+ },
44
+ onUpdate: {
45
+ type: Function,
46
+ required: !0
47
+ }
48
+ },
49
+ setup(y) {
50
+ const { isLoading: d, startAsyncCall: e } = R(), c = y, a = M(() => c.terminal), o = F(), v = F(), n = F(-1), p = F({
51
+ terminalId: ""
52
+ }), i = () => {
53
+ p.value.terminalId = "", n.value = -1;
54
+ }, l = () => {
55
+ if (e(async () => {
56
+ o.value = await C.getTerminals(c.terminal.referenceId);
57
+ }), !c.terminal.ecrs)
58
+ return i();
59
+ const t = c.terminal.ecrs.findIndex((m) => m && m.gateway && m.gateway === "FeedMe");
60
+ if (t === -1)
61
+ return i();
62
+ n.value = t;
63
+ const r = c.terminal.ecrs.at(t);
64
+ r.gateway === "FeedMe" && r.config && (p.value = {
65
+ terminalId: r.config.terminalId
66
+ });
67
+ };
68
+ D(a, l), G(l);
69
+ const s = O(() => (o.value ?? []).map((t) => ({
70
+ label: t.name ?? t._id,
71
+ value: t._id
72
+ })));
73
+ async function u(t) {
74
+ var r;
75
+ (r = c.terminal.ecrs) == null || r.splice(t, 1), c.onUpdate(c.terminal);
76
+ }
77
+ return (t, r) => {
78
+ const m = f("FmCircularProgress"), x = f("FmSelect"), w = f("FmButton"), K = f("FmForm");
79
+ return k(d) ? (b(), N("div", X, [
80
+ I(m, { size: "xxl" })
81
+ ])) : (b(), _(K, {
82
+ key: 1,
83
+ ref: v.value,
84
+ class: "flex flex-col gap-16 w-[500px]",
85
+ onValidationSuccess: r[1] || (r[1] = () => {
86
+ n.value > -1 ? a.value.ecrs[n.value] = { gateway: "FeedMe", config: p.value } : (a.value.ecrs || (a.value.ecrs = []), a.value.ecrs.push({ gateway: "FeedMe", config: p.value })), c.onUpdate(a.value);
87
+ })
88
+ }, {
89
+ default: q(() => [
90
+ I(x, {
91
+ modelValue: p.value.terminalId,
92
+ "onUpdate:modelValue": r[0] || (r[0] = (P) => p.value.terminalId = P),
93
+ label: "Terminal ID",
94
+ items: s.value
95
+ }, null, 8, ["modelValue", "items"]),
96
+ g("div", Z, [
97
+ n.value > -1 ? (b(), _(w, {
98
+ key: 0,
99
+ class: "flex-1",
100
+ variant: "secondary",
101
+ label: "Delete",
102
+ onclick: () => u(n.value)
103
+ }, null, 8, ["onclick"])) : B("", !0),
104
+ I(w, {
105
+ type: "submit",
106
+ class: "flex-1",
107
+ variant: "primary",
108
+ label: "Save"
109
+ })
110
+ ])
111
+ ]),
112
+ _: 1
113
+ }, 512));
114
+ };
115
+ }
116
+ }), ae = { class: "flex mt-6 space-x-6" }, te = /* @__PURE__ */ T({
117
+ __name: "FiuuGateway",
118
+ props: {
119
+ terminal: {
120
+ type: Object,
121
+ required: !0
122
+ },
123
+ onUpdate: {
124
+ type: Function,
125
+ required: !0
126
+ }
127
+ },
128
+ setup(y) {
129
+ const d = y, e = $().currentCountry, c = [
130
+ {
131
+ label: "Fiuu Malaysia",
132
+ value: "cc.feedme.payment.rms",
133
+ region: U.F_COUNTRY.enum.MY
134
+ },
135
+ {
136
+ label: "Fiuu Malaysia V2",
137
+ value: "cc.feedme.payment.fiuu_my",
138
+ region: U.F_COUNTRY.enum.MY
139
+ },
140
+ {
141
+ label: "Fiuu Singapore",
142
+ value: "cc.feedme.payment.fiuu_sg",
143
+ region: U.F_COUNTRY.enum.SG
144
+ }
145
+ ], a = M(() => d.terminal), o = F(), v = F(-1), n = F({
146
+ packageId: "",
147
+ uniqueId: ""
148
+ }), p = () => {
149
+ n.value.uniqueId = "", n.value.packageId = "", v.value = -1;
150
+ }, i = () => {
151
+ if (!a.value.gateways)
152
+ return p();
153
+ const s = a.value.gateways.findIndex((t) => t && t.gateway && t.gateway === "Fiuu");
154
+ if (s === -1)
155
+ return p();
156
+ v.value = s;
157
+ const u = a.value.gateways.at(s);
158
+ u.gateway === "Fiuu" && u.config && (n.value = {
159
+ packageId: u.config.packageId,
160
+ uniqueId: u.config.uniqueId
161
+ });
162
+ };
163
+ D(a, i), G(i);
164
+ async function l(s) {
165
+ var u;
166
+ (u = a.value.gateways) == null || u.splice(s, 1), d.onUpdate(a.value);
167
+ }
168
+ return (s, u) => {
169
+ const t = f("FmSelect"), r = f("FmTextField"), m = f("FmButton"), x = f("FmForm");
170
+ return b(), _(x, {
171
+ ref: o.value,
172
+ class: "flex flex-col gap-16 w-[500px]",
173
+ onValidationSuccess: u[2] || (u[2] = () => {
174
+ v.value > -1 ? a.value.gateways[v.value] = { gateway: "Fiuu", config: n.value } : (a.value.gateways || (a.value.gateways = []), a.value.gateways.push({ gateway: "Fiuu", config: n.value })), d.onUpdate(a.value);
175
+ })
176
+ }, {
177
+ default: q(() => [
178
+ I(t, {
179
+ modelValue: n.value.packageId,
180
+ "onUpdate:modelValue": u[0] || (u[0] = (w) => n.value.packageId = w),
181
+ label: "Package ID",
182
+ items: c.filter((w) => w.region === k(e))
183
+ }, null, 8, ["modelValue", "items"]),
184
+ I(r, {
185
+ modelValue: n.value.uniqueId,
186
+ "onUpdate:modelValue": u[1] || (u[1] = (w) => n.value.uniqueId = w),
187
+ label: "Unique ID"
188
+ }, null, 8, ["modelValue"]),
189
+ g("div", ae, [
190
+ v.value > -1 ? (b(), _(m, {
191
+ key: 0,
192
+ class: "flex-1",
193
+ variant: "secondary",
194
+ label: "Delete",
195
+ onclick: () => l(v.value)
196
+ }, null, 8, ["onclick"])) : B("", !0),
197
+ I(m, {
198
+ type: "submit",
199
+ class: "flex-1",
200
+ variant: "primary",
201
+ label: "Save"
202
+ })
203
+ ])
204
+ ]),
205
+ _: 1
206
+ }, 512);
207
+ };
208
+ }
209
+ }), ne = { class: "flex mt-6 space-x-6" }, le = /* @__PURE__ */ T({
210
+ __name: "GhlGateway",
211
+ props: {
212
+ terminal: {
213
+ type: Object,
214
+ required: !0
215
+ },
216
+ onUpdate: {
217
+ type: Function,
218
+ required: !0
219
+ }
220
+ },
221
+ setup(y) {
222
+ const d = y, e = M(() => d.terminal), c = F(), a = F(-1), o = F({
223
+ merchantId: "",
224
+ terminalId: "",
225
+ privateKey: ""
226
+ }), v = () => {
227
+ o.value.merchantId = "", o.value.terminalId = "", o.value.privateKey = "", a.value = -1;
228
+ }, n = () => {
229
+ if (!e.value.ecrs)
230
+ return v();
231
+ const i = e.value.ecrs.findIndex((s) => s && s.gateway && s.gateway === "Ghl");
232
+ if (i === -1)
233
+ return v();
234
+ a.value = i;
235
+ const l = e.value.ecrs.at(i);
236
+ l.gateway === "Ghl" && l.config && (o.value = {
237
+ merchantId: l.config.merchantId,
238
+ terminalId: l.config.terminalId,
239
+ privateKey: l.config.privateKey
240
+ });
241
+ };
242
+ D(e, n), G(n);
243
+ async function p(i) {
244
+ var l;
245
+ (l = e.value.ecrs) == null || l.splice(i, 1), d.onUpdate(e.value);
246
+ }
247
+ return (i, l) => {
248
+ const s = f("FmTextField"), u = f("FmTextarea"), t = f("FmButton"), r = f("FmForm");
249
+ return b(), _(r, {
250
+ ref: c.value,
251
+ class: "flex flex-col gap-16 w-[500px]",
252
+ onValidationSuccess: l[3] || (l[3] = () => {
253
+ a.value > -1 ? e.value.ecrs[a.value] = { gateway: "Ghl", config: o.value } : (e.value.ecrs || (e.value.ecrs = []), e.value.ecrs.push({ gateway: "Ghl", config: o.value })), d.onUpdate(e.value);
254
+ })
255
+ }, {
256
+ default: q(() => [
257
+ I(s, {
258
+ modelValue: o.value.merchantId,
259
+ "onUpdate:modelValue": l[0] || (l[0] = (m) => o.value.merchantId = m),
260
+ label: "Merchant ID"
261
+ }, null, 8, ["modelValue"]),
262
+ I(s, {
263
+ modelValue: o.value.terminalId,
264
+ "onUpdate:modelValue": l[1] || (l[1] = (m) => o.value.terminalId = m),
265
+ label: "Terminal ID"
266
+ }, null, 8, ["modelValue"]),
267
+ I(u, {
268
+ modelValue: o.value.privateKey,
269
+ "onUpdate:modelValue": l[2] || (l[2] = (m) => o.value.privateKey = m),
270
+ label: "Private Key"
271
+ }, null, 8, ["modelValue"]),
272
+ g("div", ne, [
273
+ a.value > -1 ? (b(), _(t, {
274
+ key: 0,
275
+ class: "flex-1",
276
+ variant: "secondary",
277
+ label: "Delete",
278
+ onclick: () => p(a.value)
279
+ }, null, 8, ["onclick"])) : B("", !0),
280
+ I(t, {
281
+ type: "submit",
282
+ class: "flex-1",
283
+ variant: "primary",
284
+ label: "Save"
285
+ })
286
+ ])
287
+ ]),
288
+ _: 1
289
+ }, 512);
290
+ };
291
+ }
292
+ }), pe = /* @__PURE__ */ T({
293
+ __name: "TerminalSetting",
294
+ props: {
295
+ terminalId: {
296
+ type: String,
297
+ required: !0
298
+ }
299
+ },
300
+ setup(y) {
301
+ const d = y, { tab: e } = H({
302
+ tab: "information"
303
+ }), { isLoading: c, startAsyncCall: a } = R(!0), o = A(), v = Q(), n = F();
304
+ async function p(t) {
305
+ a(async () => {
306
+ try {
307
+ await C.updateById(
308
+ d.terminalId,
309
+ {
310
+ name: t.name,
311
+ status: t.status,
312
+ ecrs: t.ecrs ?? [],
313
+ gateways: t.gateways ?? []
314
+ }
315
+ ), n.value = await C.readById(d.terminalId), v.open({
316
+ type: "success",
317
+ message: "Terminal updated successfully"
318
+ });
319
+ } catch (r) {
320
+ v.open({
321
+ type: "error",
322
+ title: "Error occurs when update terminal",
323
+ message: J(r)
324
+ });
325
+ }
326
+ });
327
+ }
328
+ const i = [
329
+ {
330
+ label: "Information",
331
+ value: "information",
332
+ icon: "overview",
333
+ render: W
334
+ },
335
+ {
336
+ label: "Fiuu",
337
+ value: "fiuu",
338
+ icon: "payment",
339
+ render: te
340
+ }
341
+ ], l = $().currentCountry, s = O(() => {
342
+ var t;
343
+ return (t = i.find((r) => r.value === e.value)) == null ? void 0 : t.render;
344
+ });
345
+ async function u() {
346
+ a(async () => {
347
+ n.value = await C.readById(d.terminalId), n.value.deviceType !== "TERMINAL" && (i.push({
348
+ label: "FeedMe Terminal",
349
+ value: "terminal",
350
+ icon: "shopping_cart_checkout",
351
+ render: ee
352
+ }), l.value === U.F_COUNTRY.enum.MY && i.push({
353
+ label: "GHL Terminal (V2)",
354
+ value: "ghl",
355
+ icon: "shopping_cart_checkout",
356
+ render: le
357
+ }));
358
+ });
359
+ }
360
+ return G(u), (t, r) => {
361
+ var x;
362
+ const m = f("FmTabs");
363
+ return b(), _(z, {
364
+ title: `Terminal (${(x = n.value) == null ? void 0 : x._id})`,
365
+ loading: k(c),
366
+ onBack: k(o).back
367
+ }, {
368
+ default: q(() => [
369
+ I(m, {
370
+ "model-value": k(e),
371
+ "onUpdate:modelValue": r[0] || (r[0] = (w) => h(e) ? e.value = w : null),
372
+ class: "mb-6",
373
+ items: i
374
+ }, null, 8, ["model-value"]),
375
+ k(e) ? (b(), _(L(s.value), j(E({ key: 0 }, {
376
+ terminal: n.value,
377
+ onUpdate: p
378
+ })), null, 16)) : B("", !0)
379
+ ]),
380
+ _: 1
381
+ }, 8, ["title", "loading", "onBack"]);
382
+ };
383
+ }
384
+ });
385
+ export {
386
+ pe as default
387
+ };