@feedmepos/mf-payment 0.0.0-beta.36 → 0.0.0-beta.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ import { p as z } from "./index-ApzEWD1P.js";
3
3
  import { _ as I, u as S, c as h } from "./index-Cnxt2xmc.js";
4
4
  import { defineStore as _ } from "pinia";
5
5
  import { useCoreStore as $ } from "@feedmepos/mf-common";
6
- import { c as AA, P as j } from "./payout-account-B8jXnkVN.js";
6
+ import { c as AA, P as j } from "./payout-account-DKm-YncB.js";
7
7
  import { useDialogChild as sA, useDialog as eA } from "@feedmepos/ui-library";
8
8
  import { z as f, a as q } from "./validator-D5jtpt9A.js";
9
9
  import { P as K } from "./PDFViewer-CjH_C1uT.js";
@@ -2,7 +2,7 @@ import { defineComponent as b, resolveComponent as m, openBlock as g, createBloc
2
2
  import { u as S } from "./index-BgnU5ezY.js";
3
3
  import { _ as O } from "./index-Cnxt2xmc.js";
4
4
  import { _ as K } from "./AdminLayout.vue_vue_type_script_setup_true_lang-1DSAdvX7.js";
5
- import { P as V } from "./payout-account-B8jXnkVN.js";
5
+ import { P as V } from "./payout-account-DKm-YncB.js";
6
6
  import { p as D } from "./index-ApzEWD1P.js";
7
7
  import "@feedmepos/ui-library";
8
8
  import { _ as T } from "./index.vue_vue_type_script_setup_true_lang-B8eGz19R.js";
@@ -0,0 +1,372 @@
1
+ import { defineComponent as x, openBlock as f, createElementBlock as B, createTextVNode as L, createElementVNode as h, toDisplayString as U, resolveComponent as p, createVNode as v, normalizeClass as O, withCtx as V, createBlock as g, createCommentVNode as I, ref as k, computed as z, unref as c, watch as D, isRef as K, h as E } from "vue";
2
+ import "./index-Cnxt2xmc.js";
3
+ import { h as Y } from "./moment-h96o7c8I.js";
4
+ import { u as j } from "./index-BgnU5ezY.js";
5
+ import { _ as q } from "./index.vue_vue_type_script_setup_true_lang-B8eGz19R.js";
6
+ import { _ as Q } from "./AdminLayout.vue_vue_type_script_setup_true_lang-1DSAdvX7.js";
7
+ import { useSnackbar as $, useDialogChild as G, useDialog as H } from "@feedmepos/ui-library";
8
+ import { t as A } from "./index-CBFVJirn.js";
9
+ import { c as J } from "./clipboard-4jh1WteU.js";
10
+ import { u as N } from "./error-K1CakhA9.js";
11
+ import { z as P, a as R } from "./validator-D5jtpt9A.js";
12
+ import { useCoreStore as W } from "@feedmepos/mf-common";
13
+ import { w as X } from "./Modal-DB8M9o1T.js";
14
+ import { useRouter as Z } from "vue-router";
15
+ const ee = { class: "t-caption" }, te = { class: "t-h1 my-6 text-center" }, ne = /* @__PURE__ */ x({
16
+ __name: "TerminalBindCodeDialog",
17
+ props: {
18
+ code: {
19
+ type: String,
20
+ required: !0
21
+ }
22
+ },
23
+ setup(y) {
24
+ return (n, o) => (f(), B("div", ee, [
25
+ o[0] || (o[0] = L(" Enter the binding code below on your device to link it with this terminal and apply the configuration. ")),
26
+ h("div", te, U(y.code), 1)
27
+ ]));
28
+ }
29
+ }), oe = /* @__PURE__ */ x({
30
+ __name: "ID",
31
+ props: {
32
+ row: {},
33
+ data: {}
34
+ },
35
+ setup(y) {
36
+ const n = y, o = $();
37
+ function r() {
38
+ return n.row.original.status === "Active" ? "!w-[16px] !h-[16px] bg-green-400" : "!w-[16px] !h-[16px] bg-red-400";
39
+ }
40
+ function l() {
41
+ try {
42
+ J(n.data), o.open({ title: "Text copied to clipboard." }, 1e3);
43
+ } catch {
44
+ o.open({ title: "Clipboard API incompatible." }, 1e3);
45
+ }
46
+ n.data;
47
+ }
48
+ return (s, a) => {
49
+ const d = p("FmBadge");
50
+ return f(), B("div", {
51
+ onClick: a[0] || (a[0] = (_) => {
52
+ _.stopPropagation(), l();
53
+ })
54
+ }, [
55
+ v(d, {
56
+ inline: "",
57
+ class: O(r())
58
+ }, {
59
+ default: V(() => [
60
+ h("div", null, U(s.data), 1)
61
+ ]),
62
+ _: 1
63
+ }, 8, ["class"])
64
+ ]);
65
+ };
66
+ }
67
+ }), ae = { class: "flex" }, re = /* @__PURE__ */ x({
68
+ __name: "Actions",
69
+ props: {
70
+ data: {}
71
+ },
72
+ emits: ["link", "unlink", "edit"],
73
+ setup(y, { emit: n }) {
74
+ const o = n;
75
+ return (r, l) => {
76
+ const s = p("FmButton");
77
+ return f(), B("div", ae, [
78
+ r.data.deviceType === "TERMINAL" && !r.data.deviceId ? (f(), g(s, {
79
+ key: 0,
80
+ variant: "plain",
81
+ "prepend-icon": "link",
82
+ onClick: l[0] || (l[0] = (a) => {
83
+ a.stopPropagation(), o("link");
84
+ })
85
+ })) : I("", !0),
86
+ r.data.deviceType === "TERMINAL" && r.data.deviceId ? (f(), g(s, {
87
+ key: 1,
88
+ variant: "plain",
89
+ "prepend-icon": "link_off",
90
+ onClick: l[1] || (l[1] = (a) => {
91
+ a.stopPropagation(), o("unlink");
92
+ })
93
+ })) : I("", !0),
94
+ v(s, {
95
+ variant: "plain",
96
+ "prepend-icon": "edit",
97
+ onClick: l[2] || (l[2] = (a) => {
98
+ a.stopPropagation(), o("edit");
99
+ })
100
+ })
101
+ ]);
102
+ };
103
+ }
104
+ }), le = /* @__PURE__ */ x({
105
+ __name: "TerminalDialog",
106
+ props: {
107
+ terminal: {
108
+ type: Object
109
+ }
110
+ },
111
+ setup(y) {
112
+ var w, T, F;
113
+ const n = y, o = W(), r = G(), l = k(), s = k((w = n.terminal) == null ? void 0 : w.name), a = k((T = n.terminal) == null ? void 0 : T.referenceId), d = k(((F = n.terminal) == null ? void 0 : F.status) === "Active"), _ = z(() => o.restaurants.value.map((b) => ({
114
+ label: b.profile.name,
115
+ value: b._id
116
+ })));
117
+ return (b, u) => {
118
+ const e = p("FmSelect"), t = p("FmTextField"), m = p("FmSwitch"), C = p("FmButton"), S = p("FmForm");
119
+ return f(), g(S, {
120
+ ref: l.value,
121
+ class: "flex flex-col gap-16 mb-6",
122
+ onValidationSuccess: u[3] || (u[3] = () => {
123
+ c(r).emitData({ name: s.value, referenceId: a.value, status: d.value ? "Active" : "Inactive" }), c(r).emitAction("primary");
124
+ })
125
+ }, {
126
+ default: V(() => [
127
+ n.terminal ? I("", !0) : (f(), g(e, {
128
+ key: 0,
129
+ modelValue: a.value,
130
+ "onUpdate:modelValue": u[0] || (u[0] = (i) => a.value = i),
131
+ label: "Restaurant",
132
+ items: _.value,
133
+ rules: c(P)(c(R).string())
134
+ }, null, 8, ["modelValue", "items", "rules"])),
135
+ v(t, {
136
+ modelValue: s.value,
137
+ "onUpdate:modelValue": u[1] || (u[1] = (i) => s.value = i),
138
+ label: "Terminal Name",
139
+ rules: c(P)(c(R).string())
140
+ }, null, 8, ["modelValue", "rules"]),
141
+ n.terminal ? (f(), g(m, {
142
+ key: 1,
143
+ modelValue: d.value,
144
+ "onUpdate:modelValue": u[2] || (u[2] = (i) => d.value = i),
145
+ label: "Status"
146
+ }, null, 8, ["modelValue"])) : I("", !0),
147
+ v(C, {
148
+ type: "submit",
149
+ label: "Create"
150
+ })
151
+ ]),
152
+ _: 1
153
+ }, 512);
154
+ };
155
+ }
156
+ }), ie = { class: "flex justify-between mb-6 items-center" }, se = { class: "flex space-x-4" }, ce = { class: "flex space-x-4" }, xe = /* @__PURE__ */ x({
157
+ __name: "Terminal",
158
+ setup(y) {
159
+ const n = k(), { searchKey: o, deviceType: r } = j({
160
+ searchKey: "",
161
+ deviceType: void 0
162
+ });
163
+ D(r, () => {
164
+ var e;
165
+ return (e = n.value) == null ? void 0 : e.reset();
166
+ });
167
+ let l;
168
+ D(o, async () => {
169
+ l && clearTimeout(l), l = setTimeout(
170
+ () => {
171
+ var e;
172
+ return (e = n.value) == null ? void 0 : e.reset();
173
+ },
174
+ 700
175
+ );
176
+ });
177
+ const s = Z(), a = H(), d = $();
178
+ async function _(e) {
179
+ X(
180
+ a,
181
+ "Terminal Unbind",
182
+ "Are you sure to unbind terminal from device? This action cannot be revert and device will be logged out!",
183
+ async () => {
184
+ var t;
185
+ try {
186
+ await A.unbind(e), (t = n.value) == null || t.reset(), d.open({
187
+ type: "success",
188
+ message: "Terminal unbind successfully"
189
+ });
190
+ } catch (m) {
191
+ d.open({
192
+ type: "error",
193
+ title: "Error occurs when unbind terminal",
194
+ message: N(m)
195
+ });
196
+ }
197
+ }
198
+ );
199
+ }
200
+ async function w(e) {
201
+ const t = await A.getBindCode(e);
202
+ a.open({
203
+ title: "Terminal Bind Code",
204
+ closeButton: !0,
205
+ overlay: !0,
206
+ contentComponent: ne,
207
+ contentComponentProps: { code: t }
208
+ });
209
+ }
210
+ async function T(e) {
211
+ a.open({
212
+ title: e ? "Update Terminal" : "Create New Terminal",
213
+ closeButton: !0,
214
+ overlay: !0,
215
+ contentComponent: le,
216
+ contentComponentProps: { terminal: e }
217
+ }).onPrimary(async (t) => {
218
+ var m;
219
+ a.close();
220
+ try {
221
+ await A.create(t), (m = n.value) == null || m.reset(), d.open({
222
+ type: "success",
223
+ message: e ? "Terminal udpated successfully" : "Terminal created successfully."
224
+ });
225
+ } catch (C) {
226
+ d.open({
227
+ type: "error",
228
+ title: "Error occurs when create terminal",
229
+ message: N(C)
230
+ });
231
+ }
232
+ });
233
+ }
234
+ const F = function(e) {
235
+ return {
236
+ id: e._id,
237
+ status: e.status,
238
+ referenceId: e.referenceId,
239
+ name: e.name,
240
+ deviceId: e.deviceId,
241
+ deviceType: e.deviceType,
242
+ updatedAt: Y(e.updatedAt).format("YYYY-MM-DD hh:mm:ss")
243
+ };
244
+ }, b = [
245
+ {
246
+ accessorKey: "id",
247
+ header: () => "Terminal ID",
248
+ meta: {
249
+ textAlign: "right"
250
+ },
251
+ cell: ({ cell: e, row: t }) => E(oe, { row: t, data: e.getValue() })
252
+ },
253
+ {
254
+ accessorKey: "deviceType",
255
+ header: () => "Device Type",
256
+ meta: {
257
+ textAlign: "left"
258
+ }
259
+ },
260
+ {
261
+ accessorKey: "name",
262
+ header: () => "Name",
263
+ meta: {
264
+ textAlign: "left"
265
+ }
266
+ },
267
+ {
268
+ accessorKey: "referenceId",
269
+ header: () => "Reference",
270
+ meta: {
271
+ textAlign: "left"
272
+ }
273
+ },
274
+ {
275
+ accessorKey: "deviceId",
276
+ header: () => "Bound Device Id",
277
+ meta: {
278
+ textAlign: "left"
279
+ }
280
+ },
281
+ {
282
+ accessorKey: "updatedAt",
283
+ header: () => "Last Updated",
284
+ meta: {
285
+ textAlign: "left"
286
+ }
287
+ },
288
+ {
289
+ accessorKey: "id",
290
+ header: () => "Actions",
291
+ meta: {
292
+ textAlign: "center"
293
+ },
294
+ cell: ({ row: e }) => {
295
+ var m;
296
+ const t = (m = n.value) == null ? void 0 : m.pageData().at(e.index);
297
+ return E(re, {
298
+ data: t,
299
+ onLink: () => w(t._id),
300
+ onUnlink: () => _(t._id),
301
+ onEdit: () => T(t)
302
+ });
303
+ }
304
+ }
305
+ ], u = [
306
+ {
307
+ label: "POS",
308
+ value: "POS"
309
+ },
310
+ {
311
+ label: "KIOSK",
312
+ value: "KIOSK"
313
+ },
314
+ {
315
+ label: "TERMINAL",
316
+ value: "TERMINAL"
317
+ }
318
+ ];
319
+ return (e, t) => {
320
+ const m = p("FmSearch"), C = p("FmSelect"), S = p("FmButton");
321
+ return f(), g(Q, {
322
+ title: "Terminals",
323
+ loading: !1
324
+ }, {
325
+ default: V(() => [
326
+ h("div", ie, [
327
+ h("div", se, [
328
+ v(m, {
329
+ "model-value": c(o),
330
+ "onUpdate:modelValue": t[0] || (t[0] = (i) => K(o) ? o.value = i : null),
331
+ class: "mr-8",
332
+ label: "Search",
333
+ placeholder: "Search Terminals ..."
334
+ }, null, 8, ["model-value"]),
335
+ v(C, {
336
+ modelValue: c(r),
337
+ "onUpdate:modelValue": t[1] || (t[1] = (i) => K(r) ? r.value = i : null),
338
+ class: "ml-6 w-[180px]",
339
+ label: "Device",
340
+ items: u
341
+ }, null, 8, ["modelValue"])
342
+ ]),
343
+ h("div", ce, [
344
+ v(S, {
345
+ label: "Create",
346
+ icon: "add",
347
+ onClick: t[2] || (t[2] = () => T())
348
+ })
349
+ ])
350
+ ]),
351
+ v(q, {
352
+ ref_key: "controller",
353
+ ref: n,
354
+ "column-defs": b,
355
+ "rows-defs": F,
356
+ paginate: (i, M) => c(A).read({ searchKey: c(o), deviceType: c(r), limit: i, cursor: M }),
357
+ onRowClick: t[3] || (t[3] = (i) => c(s).push({
358
+ name: "mf-payment-admin.terminal-setting",
359
+ params: {
360
+ terminalId: i._id
361
+ }
362
+ }))
363
+ }, null, 8, ["paginate"])
364
+ ]),
365
+ _: 1
366
+ });
367
+ };
368
+ }
369
+ });
370
+ export {
371
+ xe as default
372
+ };