adata-ui 2.0.45 → 2.0.47

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.
@@ -1,112 +1,112 @@
1
- <script setup lang="ts">
2
- import { removeTrailingSlash } from '#adata-ui/components/utils/removeTrailingSlash'
3
-
4
- const props = defineProps<{
5
- requestId: number
6
- }>()
7
-
8
- const emit = defineEmits<{
9
- (e: 'back', type: 'kaspi'): void
10
- (e: 'updateUserRate'): void
11
- }>()
12
-
13
- const isOpen = defineModel({ default: false })
14
-
15
- const { commonAuth } = useAppConfig()
16
- const { t, locale } = useI18n()
17
- const localePath = useLocalePath()
18
- const accessToken = useCookie('accessToken')
19
-
20
- const userApiURL = commonAuth.userApiURL
21
-
22
- const paymentSuccess = ref(false)
23
- let intervalId: NodeJS.Timeout | null = null
24
-
25
- async function checkPayment() {
26
- try {
27
- const { data } = await $fetch(`${removeTrailingSlash(userApiURL)}/user/kaspi-balance/invoice-status`, {
28
- method: 'GET',
29
- credentials: 'include',
30
- headers: {
31
- Authorization: `Bearer ${accessToken.value}`,
32
- lang: locale.value,
33
- },
34
- params: {
35
- request_id: props.requestId,
36
- initial: 0,
37
- },
38
- })
39
-
40
- if (data.status === 'completed') {
41
- paymentSuccess.value = true
42
- }
43
- }
44
- catch (e) {
45
- console.error(e)
46
- }
47
- }
48
-
49
- function goKaspi() {
50
- window.open(localePath(`https://kaspi.kz/pay/adata?service_id=5964&9507=${props.requestId}`), '_blank')
51
- }
52
-
53
- function onBack() {
54
- emit('back', 'kaspi')
55
- }
56
-
57
- watch(isOpen, async (value) => {
58
- if (!value) {
59
- if (intervalId) {
60
- clearInterval(intervalId)
61
- }
62
- return
63
- }
64
-
65
- intervalId = setInterval(() => {
66
- if (paymentSuccess.value && intervalId) {
67
- clearInterval(intervalId)
68
- emit('updateUserRate')
69
- return
70
- }
71
- checkPayment()
72
- }, 1000)
73
- })
74
- </script>
75
-
76
- <template>
77
- <a-side-panel
78
- v-model="isOpen"
79
- width="484px"
80
- >
81
- <div class="flex flex-col gap-5">
82
- <p class="text-center text-2xl font-bold whitespace-pre-wrap">
83
- {{ t('payment.redirect.title') }}
84
- </p>
85
- <a-button block @click="goKaspi">
86
- {{ t('payment.redirect.goKaspi') }}
87
- </a-button>
88
- <div class="flex flex-col gap-2">
89
- <p class="text-center text-sm">
90
- {{ t('payment.redirect.paymentId') }}
91
- </p>
92
- <p class="text-center text-xl font-semibold">
93
- {{ requestId }}
94
- </p>
95
- </div>
96
- <p class="text-center text-sm">
97
- {{ t('payment.redirect.description') }}
98
- </p>
99
- <a-button
100
- view="outline"
101
- block
102
- @click="onBack"
103
- >
104
- {{ t('payment.redirect.changeMethod') }}
105
- </a-button>
106
- </div>
107
- </a-side-panel>
108
- </template>
109
-
110
- <style scoped>
111
-
112
- </style>
1
+ <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/utils/removeTrailingSlash'
3
+
4
+ const props = defineProps<{
5
+ requestId: number
6
+ }>()
7
+
8
+ const emit = defineEmits<{
9
+ (e: 'back', type: 'kaspi'): void
10
+ (e: 'updateUserRate'): void
11
+ }>()
12
+
13
+ const isOpen = defineModel({ default: false })
14
+
15
+ const { commonAuth } = useAppConfig()
16
+ const { t, locale } = useI18n()
17
+ const localePath = useLocalePath()
18
+ const accessToken = useCookie('accessToken')
19
+
20
+ const userApiURL = commonAuth.userApiURL
21
+
22
+ const paymentSuccess = ref(false)
23
+ let intervalId: NodeJS.Timeout | null = null
24
+
25
+ async function checkPayment() {
26
+ try {
27
+ const { data } = await $fetch(`${removeTrailingSlash(userApiURL)}/user/kaspi-balance/invoice-status`, {
28
+ method: 'GET',
29
+ credentials: 'include',
30
+ headers: {
31
+ Authorization: `Bearer ${accessToken.value}`,
32
+ lang: locale.value,
33
+ },
34
+ params: {
35
+ request_id: props.requestId,
36
+ initial: 0,
37
+ },
38
+ })
39
+
40
+ if (data.status === 'completed') {
41
+ paymentSuccess.value = true
42
+ }
43
+ }
44
+ catch (e) {
45
+ console.error(e)
46
+ }
47
+ }
48
+
49
+ function goKaspi() {
50
+ window.open(localePath(`https://kaspi.kz/pay/adata?service_id=5964&9507=${props.requestId}`), '_blank')
51
+ }
52
+
53
+ function onBack() {
54
+ emit('back', 'kaspi')
55
+ }
56
+
57
+ watch(isOpen, async (value) => {
58
+ if (!value) {
59
+ if (intervalId) {
60
+ clearInterval(intervalId)
61
+ }
62
+ return
63
+ }
64
+
65
+ intervalId = setInterval(() => {
66
+ if (paymentSuccess.value && intervalId) {
67
+ clearInterval(intervalId)
68
+ emit('updateUserRate')
69
+ return
70
+ }
71
+ checkPayment()
72
+ }, 1000)
73
+ })
74
+ </script>
75
+
76
+ <template>
77
+ <a-side-panel
78
+ v-model="isOpen"
79
+ width="484px"
80
+ >
81
+ <div class="flex flex-col gap-5">
82
+ <p class="text-center text-2xl font-bold whitespace-pre-wrap">
83
+ {{ t('payment.redirect.title') }}
84
+ </p>
85
+ <a-button block @click="goKaspi">
86
+ {{ t('payment.redirect.goKaspi') }}
87
+ </a-button>
88
+ <div class="flex flex-col gap-2">
89
+ <p class="text-center text-sm">
90
+ {{ t('payment.redirect.paymentId') }}
91
+ </p>
92
+ <p class="text-center text-xl font-semibold">
93
+ {{ requestId }}
94
+ </p>
95
+ </div>
96
+ <p class="text-center text-sm">
97
+ {{ t('payment.redirect.description') }}
98
+ </p>
99
+ <a-button
100
+ view="outline"
101
+ block
102
+ @click="onBack"
103
+ >
104
+ {{ t('payment.redirect.changeMethod') }}
105
+ </a-button>
106
+ </div>
107
+ </a-side-panel>
108
+ </template>
109
+
110
+ <style scoped>
111
+
112
+ </style>
@@ -1,117 +1,117 @@
1
- <script setup lang="ts">
2
- import { AIconPaymentCard, AIconPaymentKaspi } from '#components'
3
-
4
- type IBank = 'kaspi' | 'other'
5
-
6
- const props = defineProps<{
7
- sum: number
8
- }>()
9
-
10
- const emit = defineEmits<{
11
- (e: 'nextBank', bank: IBank, sum: number): void
12
- (e: 'back', type: 'method'): void
13
- }>()
14
-
15
- const isOpen = defineModel({ default: false })
16
-
17
- const { t } = useI18n()
18
-
19
- const checkbox = ref<IBank>('kaspi')
20
- const cards = [
21
- {
22
- id: 'kaspi',
23
- name: 'payment.method.kaspi',
24
- sum: 10000,
25
- img: AIconPaymentKaspi,
26
- },
27
- {
28
- id: 'other',
29
- name: 'payment.method.other',
30
- sum: 10000,
31
- img: AIconPaymentCard,
32
- },
33
- ]
34
-
35
- function confirm() {
36
- emit('nextBank', checkbox.value, props.sum)
37
- }
38
-
39
- function cancel() {
40
- isOpen.value = false
41
- }
42
-
43
- function onBack() {
44
- emit('back', 'method')
45
- }
46
- </script>
47
-
48
- <template>
49
- <a-side-panel
50
- v-model="isOpen"
51
- width="484px"
52
- >
53
- <template #header>
54
- <div class="flex items-center gap-2">
55
- <button @click="onBack">
56
- <a-icon-chevron-left class="size-6" />
57
- </button>
58
- <p class="text-xl font-semibold">
59
- {{ t('payment.method.title') }}
60
- </p>
61
- </div>
62
- </template>
63
-
64
- <div class="flex flex-col gap-6">
65
- <div class="flex flex-col items-center gap-4">
66
- <a-ill-phone-check class="size-[120px]" />
67
- <p class="text-center text-sm font-semibold">
68
- {{ t('payment.method.description') }}
69
- </p>
70
- </div>
71
-
72
- <div class="font-semibold">
73
- {{ t('payment.method.note') }}
74
- </div>
75
-
76
- <div class="flex flex-col gap-2">
77
- <a-radio-button
78
- v-for="(item) in cards"
79
- :key="item.id"
80
- v-model="checkbox"
81
- :name="`${item.name}`"
82
- side="right"
83
- size="lg"
84
- :value="item.id"
85
- class="flex items-center justify-between gap-2 rounded-md bg-gray-50 p-[10px_16px] dark:bg-[#393D40]"
86
- >
87
- <div class="flex w-full items-center gap-2">
88
- <component :is="item.img" />
89
- <div class="flex w-full items-center justify-between">
90
- {{ t(item.name) }}
91
- <p class="body-600">
92
- {{ Math.round(sum).toLocaleString('RU-ru') }} ₸
93
- </p>
94
- </div>
95
- </div>
96
- </a-radio-button>
97
- </div>
98
-
99
- <div class="flex flex-col gap-2 ">
100
- <a-button block @click="confirm">
101
- {{ t('actions.topUp') }}
102
- </a-button>
103
- <a-button
104
- view="outline"
105
- block
106
- @click="cancel"
107
- >
108
- {{ t('actions.close') }}
109
- </a-button>
110
- </div>
111
- </div>
112
- </a-side-panel>
113
- </template>
114
-
115
- <style scoped>
116
-
117
- </style>
1
+ <script setup lang="ts">
2
+ import { AIconPaymentCard, AIconPaymentKaspi } from '#components'
3
+
4
+ type IBank = 'kaspi' | 'other'
5
+
6
+ const props = defineProps<{
7
+ sum: number
8
+ }>()
9
+
10
+ const emit = defineEmits<{
11
+ (e: 'nextBank', bank: IBank, sum: number): void
12
+ (e: 'back', type: 'method'): void
13
+ }>()
14
+
15
+ const isOpen = defineModel({ default: false })
16
+
17
+ const { t } = useI18n()
18
+
19
+ const checkbox = ref<IBank>('kaspi')
20
+ const cards = [
21
+ {
22
+ id: 'kaspi',
23
+ name: 'payment.method.kaspi',
24
+ sum: 10000,
25
+ img: AIconPaymentKaspi,
26
+ },
27
+ {
28
+ id: 'other',
29
+ name: 'payment.method.other',
30
+ sum: 10000,
31
+ img: AIconPaymentCard,
32
+ },
33
+ ]
34
+
35
+ function confirm() {
36
+ emit('nextBank', checkbox.value, props.sum)
37
+ }
38
+
39
+ function cancel() {
40
+ isOpen.value = false
41
+ }
42
+
43
+ function onBack() {
44
+ emit('back', 'method')
45
+ }
46
+ </script>
47
+
48
+ <template>
49
+ <a-side-panel
50
+ v-model="isOpen"
51
+ width="484px"
52
+ >
53
+ <template #header>
54
+ <div class="flex items-center gap-2">
55
+ <button @click="onBack">
56
+ <a-icon-chevron-left class="size-6" />
57
+ </button>
58
+ <p class="text-xl font-semibold">
59
+ {{ t('payment.method.title') }}
60
+ </p>
61
+ </div>
62
+ </template>
63
+
64
+ <div class="flex flex-col gap-6">
65
+ <div class="flex flex-col items-center gap-4">
66
+ <a-ill-phone-check class="size-[120px]" />
67
+ <p class="text-center text-sm font-semibold">
68
+ {{ t('payment.method.description') }}
69
+ </p>
70
+ </div>
71
+
72
+ <div class="font-semibold">
73
+ {{ t('payment.method.note') }}
74
+ </div>
75
+
76
+ <div class="flex flex-col gap-2">
77
+ <a-radio-button
78
+ v-for="(item) in cards"
79
+ :key="item.id"
80
+ v-model="checkbox"
81
+ :name="`${item.name}`"
82
+ side="right"
83
+ size="lg"
84
+ :value="item.id"
85
+ class="flex items-center justify-between gap-2 rounded-md bg-gray-50 p-[10px_16px] dark:bg-[#393D40]"
86
+ >
87
+ <div class="flex w-full items-center gap-2">
88
+ <component :is="item.img" />
89
+ <div class="flex w-full items-center justify-between">
90
+ {{ t(item.name) }}
91
+ <p class="body-600">
92
+ {{ Math.round(sum).toLocaleString('RU-ru') }} ₸
93
+ </p>
94
+ </div>
95
+ </div>
96
+ </a-radio-button>
97
+ </div>
98
+
99
+ <div class="flex flex-col gap-2 ">
100
+ <a-button block @click="confirm">
101
+ {{ t('actions.topUp') }}
102
+ </a-button>
103
+ <a-button
104
+ view="outline"
105
+ block
106
+ @click="cancel"
107
+ >
108
+ {{ t('actions.close') }}
109
+ </a-button>
110
+ </div>
111
+ </div>
112
+ </a-side-panel>
113
+ </template>
114
+
115
+ <style scoped>
116
+
117
+ </style>