adata-ui 2.0.53 → 2.0.54
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,16 +1,58 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { buildLocalizedUrl } from '#adata-ui/utils/localizedNavigation'
|
|
3
|
+
import {removeTrailingSlash} from "#adata-ui/components/utils/removeTrailingSlash";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
balance?: number
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const { $toast } = useNuxtApp()
|
|
3
10
|
|
|
4
11
|
const { t, locale } = useI18n()
|
|
5
12
|
const { myLayer } = useAppConfig()
|
|
13
|
+
const accessToken = useCookie('accessToken')
|
|
6
14
|
|
|
7
15
|
const { topUpSidePanel } = usePayment()
|
|
16
|
+
const { commonAuth } = useAppConfig()
|
|
8
17
|
|
|
9
18
|
const landingUrl = myLayer.landingUrl
|
|
19
|
+
const userApiURL = commonAuth.userApiURL
|
|
20
|
+
|
|
21
|
+
const isLoading = ref(false)
|
|
22
|
+
|
|
23
|
+
async function updateUserRate() {
|
|
24
|
+
try {
|
|
25
|
+
isLoading.value = true
|
|
26
|
+
await $fetch(`${removeTrailingSlash(userApiURL)}/user/rate`, {
|
|
27
|
+
method: 'PUT',
|
|
28
|
+
credentials: 'include',
|
|
29
|
+
headers: {
|
|
30
|
+
Authorization: `Bearer ${accessToken.value}`,
|
|
31
|
+
lang: locale.value,
|
|
32
|
+
},
|
|
33
|
+
body: {
|
|
34
|
+
rate_code: 'basic_plus',
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
window.location.reload()
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
$toast.error(error.data.message)
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
isLoading.value = false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
10
46
|
|
|
11
47
|
function onBuy() {
|
|
12
|
-
|
|
48
|
+
if (props.balance && props.balance >= 1000) {
|
|
49
|
+
updateUserRate()
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
topUpSidePanel.value = true
|
|
53
|
+
}
|
|
13
54
|
}
|
|
55
|
+
|
|
14
56
|
</script>
|
|
15
57
|
|
|
16
58
|
<template>
|