adata-ui 2.0.46 → 2.0.48

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.
@@ -15,10 +15,18 @@ const props = defineProps<Props>()
15
15
 
16
16
  const appConfig = useAppConfig()
17
17
  const loginUrl = appConfig.myLayer.loginUrl
18
+ const authMode = appConfig.myLayer.authMode
18
19
  const device = useAdaptive()
19
20
  const { t, locale } = useI18n()
20
21
 
22
+ const { loginModal } = useIdModals()
23
+
21
24
  function goAuth() {
25
+ if (authMode === 'local') {
26
+ loginModal.value = true
27
+ return
28
+ }
29
+
22
30
  if (window) {
23
31
  if (props.to) {
24
32
  navigateToLocalizedPage(props.to)
@@ -12,6 +12,7 @@ type Props = {
12
12
  label: string
13
13
  required?: boolean
14
14
  options: T[]
15
+ hideOverflow?: boolean
15
16
  keyToShow?: string
16
17
  getOnlyKey?: boolean
17
18
  keyToSelect?: string
@@ -41,6 +42,7 @@ type Emits = {
41
42
 
42
43
  const props = withDefaults(defineProps<Props>(), {
43
44
  required: false,
45
+ hideOverflow: false,
44
46
  getOnlyKey: false,
45
47
  keyToShow: 'name',
46
48
  keyToSelect: 'id',
@@ -79,7 +81,7 @@ const { x, y, strategy, update } = useFloating(reference, floating, {
79
81
  const el = elements.floating as HTMLElement
80
82
  el.style.width = `${rects.reference.width}px`
81
83
  el.style.maxHeight = `${Math.max(140, Math.min(availableHeight, 320))}px`
82
- el.style.overflowY = 'auto'
84
+ el.style.overflowY = props.hideOverflow ? 'hidden' : 'auto'
83
85
  },
84
86
  }),
85
87
  ],
@@ -0,0 +1,104 @@
1
+ <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/utils/removeTrailingSlash'
3
+
4
+ const props = defineProps<{
5
+ balance: number
6
+ }>()
7
+
8
+ const { $toast } = useNuxtApp()
9
+ const { t, locale } = useI18n()
10
+ const { commonAuth } = useAppConfig()
11
+ const accessToken = useCookie('accessToken')
12
+
13
+ const { topUpSidePanel } = usePayment()
14
+
15
+ const userApiURL = commonAuth.userApiURL
16
+
17
+ const isLoading = ref(false)
18
+
19
+ async function updateUserRate() {
20
+ try {
21
+ isLoading.value = true
22
+ await $fetch(`${removeTrailingSlash(userApiURL)}/user/rate`, {
23
+ method: 'PUT',
24
+ credentials: 'include',
25
+ headers: {
26
+ Authorization: `Bearer ${accessToken.value}`,
27
+ lang: locale.value,
28
+ },
29
+ body: {
30
+ rate_code: 'basic_plus',
31
+ },
32
+ })
33
+ window.location.reload()
34
+ }
35
+ catch (error) {
36
+ $toast.error(error.data.message)
37
+ }
38
+ finally {
39
+ isLoading.value = false
40
+ }
41
+ }
42
+
43
+ function onUpdate() {
44
+ if (props.balance >= 1000) {
45
+ updateUserRate()
46
+ }
47
+ else {
48
+ topUpSidePanel.value = true
49
+ }
50
+ }
51
+ </script>
52
+
53
+ <template>
54
+ <div class="gradient flex justify-between rounded-lg p-4 ring-1 ring-inset ring-blue-700/80 dark:bg-gray-800">
55
+ <div>
56
+ <p class="mb-2 font-semibold">
57
+ {{ t('modals.id.banners.basicPlusLimit.title') }}
58
+ </p>
59
+ <i18n-t
60
+ keypath="modals.id.banners.basicPlusLimit.subtitle"
61
+ tag="p"
62
+ class="text-sm text-gray-600 dark:text-gray-200"
63
+ >
64
+ <template #topUp>
65
+ <button
66
+ class="font-semibold text-blue-700 dark:text-blue-500"
67
+ @click="topUpSidePanel = true"
68
+ >
69
+ {{ t('modals.id.banners.basicPlusLimit.topUp') }}
70
+ </button>
71
+ </template>
72
+ </i18n-t>
73
+ </div>
74
+
75
+ <a-button
76
+ size="md"
77
+ class="self-end"
78
+ @click="onUpdate"
79
+ :loading="isLoading"
80
+ >
81
+ {{ t('actions.update') }}
82
+ </a-button>
83
+ </div>
84
+ </template>
85
+
86
+ <style scoped>
87
+ .gradient {
88
+ background: linear-gradient(
89
+ 239.71deg,
90
+ #B3D5F9 -7.48%,
91
+ #E6F1FD 39.62%,
92
+ #CCE2FB 85.82%
93
+ );
94
+ }
95
+
96
+ .dark .gradient {
97
+ background: linear-gradient(
98
+ 239.71deg,
99
+ #17303F -7.48%,
100
+ #161617 39.62%,
101
+ #17303F 85.82%
102
+ );
103
+ }
104
+ </style>
@@ -1,69 +1,66 @@
1
- <script setup lang="ts">
2
- import { buildLocalizedUrl } from '#adata-ui/utils/localizedNavigation'
3
- import PaymentProcess from '#adata-ui/components/features/payment/process/PaymentProcess.vue'
4
-
5
- const { t, locale } = useI18n()
6
- const { myLayer } = useAppConfig()
7
-
8
- const { topUpSidePanel } = usePayment()
9
-
10
- const landingUrl = myLayer.landingUrl
11
-
12
- function onBuy() {
13
- topUpSidePanel.value = true
14
- }
15
- </script>
16
-
17
- <template>
18
- <div class="gradient flex justify-between rounded-lg p-4 ring-1 ring-inset ring-blue-700/80 dark:bg-gray-800">
19
- <div>
20
- <p class="mb-2 font-semibold">
21
- {{ t('payment.banner.title') }}
22
- </p>
23
- <i18n-t
24
- keypath="payment.banner.subtitle"
25
- tag="p"
26
- class="text-sm text-gray-600 dark:text-gray-200"
27
- >
28
- <template #tariffs>
29
- <nuxt-link
30
- class="font-semibold text-blue-700 dark:text-blue-500"
31
- :to="buildLocalizedUrl(locale, landingUrl, '/tariffs')"
32
- >
33
- {{ t('payment.banner.tariffs') }}
34
- </nuxt-link>
35
- </template>
36
- </i18n-t>
37
- </div>
38
-
39
- <a-button
40
- size="md"
41
- class="self-end"
42
- @click="onBuy"
43
- >
44
- {{ t('actions.buy') }}
45
- </a-button>
46
- </div>
47
-
48
- <payment-process />
49
- </template>
50
-
51
- <style scoped>
52
- .gradient {
53
- background: linear-gradient(
54
- 239.71deg,
55
- #B3D5F9 -7.48%,
56
- #E6F1FD 39.62%,
57
- #CCE2FB 85.82%
58
- );
59
- }
60
-
61
- .dark .gradient {
62
- background: linear-gradient(
63
- 239.71deg,
64
- #17303F -7.48%,
65
- #161617 39.62%,
66
- #17303F 85.82%
67
- );
68
- }
69
- </style>
1
+ <script setup lang="ts">
2
+ import { buildLocalizedUrl } from '#adata-ui/utils/localizedNavigation'
3
+
4
+ const { t, locale } = useI18n()
5
+ const { myLayer } = useAppConfig()
6
+
7
+ const { topUpSidePanel } = usePayment()
8
+
9
+ const landingUrl = myLayer.landingUrl
10
+
11
+ function onBuy() {
12
+ topUpSidePanel.value = true
13
+ }
14
+ </script>
15
+
16
+ <template>
17
+ <div class="gradient flex justify-between rounded-lg p-4 ring-1 ring-inset ring-blue-700/80 dark:bg-gray-800">
18
+ <div>
19
+ <p class="mb-2 font-semibold">
20
+ {{ t('payment.banner.title') }}
21
+ </p>
22
+ <i18n-t
23
+ keypath="payment.banner.subtitle"
24
+ tag="p"
25
+ class="text-sm text-gray-600 dark:text-gray-200"
26
+ >
27
+ <template #tariffs>
28
+ <nuxt-link
29
+ class="font-semibold text-blue-700 dark:text-blue-500"
30
+ :to="buildLocalizedUrl(locale, landingUrl, '/tariffs')"
31
+ >
32
+ {{ t('payment.banner.tariffs') }}
33
+ </nuxt-link>
34
+ </template>
35
+ </i18n-t>
36
+ </div>
37
+
38
+ <a-button
39
+ size="md"
40
+ class="self-end"
41
+ @click="onBuy"
42
+ >
43
+ {{ t('actions.buy') }}
44
+ </a-button>
45
+ </div>
46
+ </template>
47
+
48
+ <style scoped>
49
+ .gradient {
50
+ background: linear-gradient(
51
+ 239.71deg,
52
+ #B3D5F9 -7.48%,
53
+ #E6F1FD 39.62%,
54
+ #CCE2FB 85.82%
55
+ );
56
+ }
57
+
58
+ .dark .gradient {
59
+ background: linear-gradient(
60
+ 239.71deg,
61
+ #17303F -7.48%,
62
+ #161617 39.62%,
63
+ #17303F 85.82%
64
+ );
65
+ }
66
+ </style>
@@ -1,158 +1,158 @@
1
- <script setup lang="ts">
2
- import { toCanvas } from 'qrcode'
3
- import { removeTrailingSlash } from '#adata-ui/components/utils/removeTrailingSlash'
4
-
5
- const props = defineProps<{
6
- requestUrl: string
7
- requestId: number
8
- }>()
9
-
10
- const emit = defineEmits<{
11
- (e: 'back', type: 'kaspi'): void
12
- (e: 'updateUserRate'): void
13
- }>()
14
-
15
- const isOpen = defineModel({ default: false })
16
-
17
- const { t, locale } = useI18n()
18
- const { commonAuth } = useAppConfig()
19
- const accessToken = useCookie('accessToken')
20
- const colorMode = useColorMode()
21
-
22
- const userApiURL = commonAuth.userApiURL
23
-
24
- const paymentSuccess = ref(false)
25
- let intervalId: NodeJS.Timeout | null = null
26
-
27
- function onBack() {
28
- emit('back', 'kaspi')
29
- }
30
-
31
- async function checkPayment() {
32
- try {
33
- const { data } = await $fetch(`${removeTrailingSlash(userApiURL)}/user/kaspi-balance/invoice-status`, {
34
- method: 'GET',
35
- credentials: 'include',
36
- headers: {
37
- Authorization: `Bearer ${accessToken.value}`,
38
- lang: locale.value,
39
- },
40
- params: {
41
- request_id: props.requestId,
42
- initial: 0,
43
- },
44
- })
45
-
46
- if (data.status === 'completed') {
47
- paymentSuccess.value = true
48
- }
49
- }
50
- catch (e) {
51
- console.error(e)
52
- }
53
- }
54
-
55
- watch(isOpen, async (value) => {
56
- if (!value) {
57
- if (intervalId) {
58
- clearInterval(intervalId)
59
- }
60
- return
61
- }
62
-
63
- await nextTick()
64
-
65
- const canvas = document.getElementById('kaspiQr') as HTMLCanvasElement | null
66
- if (!canvas) return
67
-
68
- toCanvas(
69
- canvas,
70
- props.requestUrl,
71
- {
72
- errorCorrectionLevel: 'H',
73
- width: 300,
74
- margin: 0,
75
- color: {
76
- dark: colorMode.value === 'dark' ? '#FFFFFF' : '#000000', // квадраты
77
- light: colorMode.value === 'dark' ? '#000000' : '#FFFFFF' // фон
78
- }
79
- },
80
- (error) => {
81
-
82
- if (error) {
83
- console.error(error)
84
- return
85
- }
86
-
87
- const ctx = canvas.getContext('2d')
88
- if (!ctx) return
89
-
90
- const logo = new Image()
91
- logo.src = '/kaspi/logo.svg'
92
- logo.onload = () => {
93
- const size = canvas.width * 0.2
94
- const x = (canvas.width - size) / 2
95
- const y = (canvas.height - size) / 2
96
-
97
- ctx.fillStyle = colorMode.value === 'dark' ? '#000000' : '#fff'
98
- ctx.fillRect(x - 6, y - 6, size + 12, size + 12)
99
-
100
- ctx.drawImage(logo, x, y, size, size)
101
- }
102
- })
103
-
104
- intervalId = setInterval(() => {
105
- if (paymentSuccess.value && intervalId) {
106
- clearInterval(intervalId)
107
- emit('updateUserRate')
108
- return
109
- }
110
- checkPayment()
111
- }, 1000)
112
- })
113
-
114
- </script>
115
-
116
- <template>
117
- <a-side-panel v-model="isOpen" width="484px">
118
- <template #header>
119
- <div class="flex items-center gap-2">
120
- <button @click="onBack">
121
- <a-icon-chevron-left class="size-6" />
122
- </button>
123
- <p class="text-xl font-semibold">
124
- {{ t('payment.kaspi.title') }}
125
- </p>
126
- </div>
127
- </template>
128
-
129
- <div class="flex flex-col gap-6">
130
- <div class="flex flex-col items-center text-center text-black dark:text-white">
131
- <p class="mb-4 font-semibold text-sm">
132
- {{ t('payment.kaspi.description') }}
133
- </p>
134
-
135
- <div class="flex gap-3 items-center">
136
- <a-icon-kaspi-qr class="size-16" />
137
- <span class="font-bold text-[44px]">
138
- {{ t('payment.kaspi.qr') }}
139
- </span>
140
- </div>
141
-
142
- <p class="mt-5 font-bold text-2xl">{{ t('payment.kaspi.scan') }}</p>
143
-
144
- <canvas class="mt-5" id="kaspiQr"></canvas>
145
-
146
- <p class="mt-10 text-lg">{{ t('payment.kaspi.adata') }}</p>
147
- </div>
148
-
149
- <a-button @click="onBack" view="outline">
150
- {{ t('payment.kaspi.changeMethod') }}
151
- </a-button>
152
- </div>
153
- </a-side-panel>
154
- </template>
155
-
156
- <style scoped>
157
-
158
- </style>
1
+ <script setup lang="ts">
2
+ import { toCanvas } from 'qrcode'
3
+ import { removeTrailingSlash } from '#adata-ui/components/utils/removeTrailingSlash'
4
+
5
+ const props = defineProps<{
6
+ requestUrl: string
7
+ requestId: number
8
+ }>()
9
+
10
+ const emit = defineEmits<{
11
+ (e: 'back', type: 'kaspi'): void
12
+ (e: 'updateUserRate'): void
13
+ }>()
14
+
15
+ const isOpen = defineModel({ default: false })
16
+
17
+ const { t, locale } = useI18n()
18
+ const { commonAuth } = useAppConfig()
19
+ const accessToken = useCookie('accessToken')
20
+ const colorMode = useColorMode()
21
+
22
+ const userApiURL = commonAuth.userApiURL
23
+
24
+ const paymentSuccess = ref(false)
25
+ let intervalId: NodeJS.Timeout | null = null
26
+
27
+ function onBack() {
28
+ emit('back', 'kaspi')
29
+ }
30
+
31
+ async function checkPayment() {
32
+ try {
33
+ const { data } = await $fetch(`${removeTrailingSlash(userApiURL)}/user/kaspi-balance/invoice-status`, {
34
+ method: 'GET',
35
+ credentials: 'include',
36
+ headers: {
37
+ Authorization: `Bearer ${accessToken.value}`,
38
+ lang: locale.value,
39
+ },
40
+ params: {
41
+ request_id: props.requestId,
42
+ initial: 0,
43
+ },
44
+ })
45
+
46
+ if (data.status === 'completed') {
47
+ paymentSuccess.value = true
48
+ }
49
+ }
50
+ catch (e) {
51
+ console.error(e)
52
+ }
53
+ }
54
+
55
+ watch(isOpen, async (value) => {
56
+ if (!value) {
57
+ if (intervalId) {
58
+ clearInterval(intervalId)
59
+ }
60
+ return
61
+ }
62
+
63
+ await nextTick()
64
+
65
+ const canvas = document.getElementById('kaspiQr') as HTMLCanvasElement | null
66
+ if (!canvas) return
67
+
68
+ toCanvas(
69
+ canvas,
70
+ props.requestUrl,
71
+ {
72
+ errorCorrectionLevel: 'H',
73
+ width: 300,
74
+ margin: 0,
75
+ color: {
76
+ dark: colorMode.value === 'dark' ? '#FFFFFF' : '#000000', // квадраты
77
+ light: colorMode.value === 'dark' ? '#000000' : '#FFFFFF' // фон
78
+ }
79
+ },
80
+ (error) => {
81
+
82
+ if (error) {
83
+ console.error(error)
84
+ return
85
+ }
86
+
87
+ const ctx = canvas.getContext('2d')
88
+ if (!ctx) return
89
+
90
+ const logo = new Image()
91
+ logo.src = '/kaspi/logo.svg'
92
+ logo.onload = () => {
93
+ const size = canvas.width * 0.2
94
+ const x = (canvas.width - size) / 2
95
+ const y = (canvas.height - size) / 2
96
+
97
+ ctx.fillStyle = colorMode.value === 'dark' ? '#000000' : '#fff'
98
+ ctx.fillRect(x - 6, y - 6, size + 12, size + 12)
99
+
100
+ ctx.drawImage(logo, x, y, size, size)
101
+ }
102
+ })
103
+
104
+ intervalId = setInterval(() => {
105
+ if (paymentSuccess.value && intervalId) {
106
+ clearInterval(intervalId)
107
+ emit('updateUserRate')
108
+ return
109
+ }
110
+ checkPayment()
111
+ }, 1000)
112
+ })
113
+
114
+ </script>
115
+
116
+ <template>
117
+ <a-side-panel v-model="isOpen" width="484px">
118
+ <template #header>
119
+ <div class="flex items-center gap-2">
120
+ <button @click="onBack">
121
+ <a-icon-chevron-left class="size-6" />
122
+ </button>
123
+ <p class="text-xl font-semibold">
124
+ {{ t('payment.kaspi.title') }}
125
+ </p>
126
+ </div>
127
+ </template>
128
+
129
+ <div class="flex flex-col gap-6">
130
+ <div class="flex flex-col items-center text-center text-black dark:text-white">
131
+ <p class="mb-4 font-semibold text-sm">
132
+ {{ t('payment.kaspi.description') }}
133
+ </p>
134
+
135
+ <div class="flex gap-3 items-center">
136
+ <a-icon-kaspi-qr class="size-16" />
137
+ <span class="font-bold text-[44px]">
138
+ {{ t('payment.kaspi.qr') }}
139
+ </span>
140
+ </div>
141
+
142
+ <p class="mt-5 font-bold text-2xl">{{ t('payment.kaspi.scan') }}</p>
143
+
144
+ <canvas class="mt-5" id="kaspiQr"></canvas>
145
+
146
+ <p class="mt-10 text-lg">{{ t('payment.kaspi.adata') }}</p>
147
+ </div>
148
+
149
+ <a-button @click="onBack" view="outline">
150
+ {{ t('payment.kaspi.changeMethod') }}
151
+ </a-button>
152
+ </div>
153
+ </a-side-panel>
154
+ </template>
155
+
156
+ <style scoped>
157
+
158
+ </style>