adata-ui 2.0.33 → 2.0.34

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,91 @@
1
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
+
3
+ export function useBuyTariffs() {
4
+ const { commonAuth } = useAppConfig()
5
+
6
+ const userApiURL = commonAuth.userApiURL
7
+ const { locale } = useI18n()
8
+ const localePath = useLocalePath()
9
+ const checkNumber = ref(0)
10
+ const messageRate = ref(null)
11
+
12
+
13
+ const isAuthenticated = computed(() => {
14
+ const accessToken = useCookie('accessToken')
15
+ return accessToken.value
16
+ })
17
+
18
+ async function buyTariff(tariffs: any) {
19
+ await fetch(`${removeTrailingSlash(userApiURL)}/user/rate`, {
20
+ method: 'PUT',
21
+ credentials: 'include',
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ 'lang': locale.value,
25
+ Authorization: `Bearer ${isAuthenticated.value}`
26
+ },
27
+ body: JSON.stringify({
28
+ rate_code: tariffs
29
+ })
30
+ })
31
+ location.reload()
32
+ }
33
+
34
+ async function viaKaspiBank(tariffId: any, sum: any) {
35
+ try {
36
+ const info = await fetch(`${removeTrailingSlash(userApiURL)}/user/kaspi-balance/request/`, {
37
+ method: 'POST',
38
+ credentials: 'include',
39
+ headers: {
40
+ 'Content-Type': 'application/json',
41
+ 'lang': locale.value,
42
+ Authorization: `Bearer ${isAuthenticated.value}`
43
+ },
44
+ body: JSON.stringify({
45
+ amount: sum,
46
+ rate_id: tariffId
47
+ })
48
+ })
49
+ const { data } = await info.json().catch(() => ({}))
50
+
51
+ checkNumber.value = data.request_id
52
+ } catch (error) {
53
+ console.error(error)
54
+ } finally {
55
+ window.open(localePath(`https://kaspi.kz/pay/adata?service_id=5964&9507=${checkNumber.value}`), '_blank')
56
+ }
57
+ }
58
+
59
+ async function leaveRequest(name: any, email: any, phone: any, comment: any) {
60
+ try {
61
+ const info = await fetch(`${removeTrailingSlash(userApiURL)}/message/rate`, {
62
+ method: 'POST',
63
+ credentials: 'include',
64
+ headers: {
65
+ 'Content-Type': 'application/json',
66
+ 'lang': locale.value,
67
+ Authorization: `Bearer ${isAuthenticated.value}`
68
+ },
69
+ body: JSON.stringify({
70
+ sender_name: name,
71
+ email: email,
72
+ phone_number: phone,
73
+ message: comment,
74
+ rate_code: 'adata_pro',
75
+ })
76
+ })
77
+ const { data } = await info.json().catch(() => ({}))
78
+ messageRate.value = data
79
+ } catch (error) {
80
+ console.error(error)
81
+ }
82
+ }
83
+
84
+ return {
85
+ buyTariff,
86
+ viaKaspiBank,
87
+ checkNumber,
88
+ leaveRequest,
89
+ messageRate
90
+ }
91
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adata-ui",
3
3
  "type": "module",
4
- "version": "2.0.33",
4
+ "version": "2.0.34",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",