adata-ui 2.0.30 → 2.0.32

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.
@@ -68,12 +68,12 @@ onUnmounted(() => clearTimer())
68
68
  <component
69
69
  :is="item.icon"
70
70
  class="shrink-0 size-6 transition-colors duration-300 ease-in-out"
71
- :class="selected === idx ? 'text-white dark:text-gray-900' : 'text-gray-600 dark:text-gray-200'"
71
+ :class="selected === idx ? 'text-white dark:text-gray-900' : 'text-gray-600 dark:text-[#9DA3AC]'"
72
72
  />
73
73
  </div>
74
74
  <p
75
75
  class="font-semibold text-base lg:text-xl transition-colors duration-300 ease-in-out"
76
- :class="selected === idx ? 'dark:text-[#E3E5E8]' : 'text-gray-600 dark:text-gray-200'"
76
+ :class="selected === idx ? 'dark:text-[#E3E5E8]' : 'text-gray-600 dark:text-[#9DA3AC]'"
77
77
  >
78
78
  {{ item.title }}
79
79
  </p>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import IdOtpInput from '#adata-ui/components/modals/id/IdOtpInput.vue'
3
4
  import { useAuthStore } from '#adata-ui/stores/auth.store'
4
5
 
@@ -21,7 +22,7 @@ const showError = ref(false)
21
22
  const isLoading = ref(false)
22
23
 
23
24
  async function loginUser() {
24
- const login = await fetch(`${authApiURL}/login`, {
25
+ const login = await fetch(`${removeTrailingSlash(authApiURL)}/login`, {
25
26
  method: 'POST',
26
27
  credentials: 'include',
27
28
  headers: {
@@ -35,7 +36,7 @@ async function loginUser() {
35
36
  })
36
37
  await login.json().catch(() => ({}))
37
38
 
38
- const response = await fetch(`${authApiURL}/access/cookie`, {
39
+ const response = await fetch(`${removeTrailingSlash(authApiURL)}/access/cookie`, {
39
40
  method: 'GET',
40
41
  credentials: 'include',
41
42
  headers: {
@@ -60,7 +61,7 @@ async function onConfirm() {
60
61
  try {
61
62
  isLoading.value = true
62
63
 
63
- await $fetch(`${authApiURL}/email/verify-otp`, {
64
+ await $fetch(`${removeTrailingSlash(authApiURL)}/email/verify-otp`, {
64
65
  method: 'GET',
65
66
  credentials: 'include',
66
67
  headers: {
@@ -97,7 +98,7 @@ function onClose() {
97
98
 
98
99
  async function onResend() {
99
100
  try {
100
- await $fetch(`${authApiURL}/email/resend-otp`, {
101
+ await $fetch(`${removeTrailingSlash(authApiURL)}/email/resend-otp`, {
101
102
  method: 'GET',
102
103
  credentials: 'include',
103
104
  headers: {
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import { useAuthStore } from '#adata-ui/stores/auth.store'
3
4
  import { navigateToLocalizedPage } from '#adata-ui/utils/localizedNavigation'
4
5
  import * as z from 'zod'
@@ -61,7 +62,7 @@ async function submit() {
61
62
  submitted.value = true
62
63
  if (!validation.value) {
63
64
  loading.value = true
64
- const login = await fetch(`${authApiURL}/login`, {
65
+ const login = await fetch(`${removeTrailingSlash(authApiURL)}/login`, {
65
66
  method: 'POST',
66
67
  credentials: 'include',
67
68
  headers: {
@@ -86,7 +87,7 @@ async function submit() {
86
87
  if (login.status === 206) {
87
88
  confirmAccountOtpModal.value = true
88
89
 
89
- $fetch(`${authApiURL}/email/resend-otp`, {
90
+ $fetch(`${removeTrailingSlash(authApiURL)}/email/resend-otp`, {
90
91
  method: 'GET',
91
92
  credentials: 'include',
92
93
  headers: {
@@ -108,7 +109,7 @@ async function submit() {
108
109
  twoFactorModal.value = true
109
110
  }
110
111
  else if (data.email_is_verified) {
111
- const response = await fetch(`${authApiURL}/access/cookie`, {
112
+ const response = await fetch(`${removeTrailingSlash(authApiURL)}/access/cookie`, {
112
113
  method: 'GET',
113
114
  credentials: 'include',
114
115
  headers: {
@@ -128,14 +129,14 @@ async function submit() {
128
129
  secure: true,
129
130
  }).value = access_token
130
131
  }
131
- $toast.success(t('login.successfully'))
132
+ $toast.success(t('reuse.successfully'))
132
133
  loginModal.value = false
133
134
  window.location.reload()
134
135
  }
135
136
  else {
136
137
  confirmAccountOtpModal.value = true
137
138
 
138
- $fetch(`${authApiURL}/email/resend-otp`, {
139
+ $fetch(`${removeTrailingSlash(authApiURL)}/email/resend-otp`, {
139
140
  method: 'GET',
140
141
  credentials: 'include',
141
142
  headers: {
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import IdConfirmAccountOtpModal from '#adata-ui/components/modals/id/IdConfirmAccountOtpModal.vue'
3
4
  import IdConfirmSuccessfulModal from '#adata-ui/components/modals/id/IdConfirmSuccessfulModal.vue'
4
5
  import IdLoginModal from '#adata-ui/components/modals/id/IdLoginModal.vue'
@@ -20,6 +21,36 @@ const {
20
21
  confirmSuccessfulModal,
21
22
  twoFactorModal,
22
23
  } = useIdModals()
24
+
25
+ const { locale } = useI18n()
26
+ const { commonAuth } = useAppConfig()
27
+ const authApiURL = commonAuth.authApiURL
28
+
29
+ onMounted(async () => {
30
+ const accessToken = useCookie('accessToken')
31
+
32
+ const response = await fetch(`${removeTrailingSlash(authApiURL)}/access/cookie`, {
33
+ method: 'GET',
34
+ credentials: 'include',
35
+ headers: {
36
+ lang: locale.value,
37
+ },
38
+ })
39
+ const { data: cookiesData } = await response.json()
40
+ if (cookiesData?.access_token && !accessToken.value) {
41
+ const { access_token, expire_in } = cookiesData
42
+ const hostname = location.hostname.split('.').reverse()
43
+
44
+ useCookie('accessToken', {
45
+ maxAge: expire_in,
46
+ domain: `.${hostname[1]}.${hostname[0]}`,
47
+ path: '/',
48
+ secure: true,
49
+ }).value = access_token
50
+
51
+ window.location.reload()
52
+ }
53
+ })
23
54
  </script>
24
55
 
25
56
  <template>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import { useAuthStore } from '#adata-ui/stores/auth.store'
3
4
  import * as z from 'zod'
4
5
 
@@ -55,7 +56,7 @@ async function onSubmit() {
55
56
  if (validation.value) return
56
57
  loading.value = true
57
58
 
58
- const response = await $fetch(`${authApiURL}/password/reset-otp`, {
59
+ const response = await $fetch(`${removeTrailingSlash(authApiURL)}/password/reset-otp`, {
59
60
  method: 'POST',
60
61
  credentials: 'include',
61
62
  headers: {
@@ -125,8 +125,11 @@ function moveFocus(index: number, to: string) {
125
125
  v-model="otp[index]"
126
126
  type="text"
127
127
  maxlength="1"
128
- class="size-10 rounded bg-deepblue-900/5 text-center text-lg caret-transparent focus:border focus:border-blue-500 focus:outline-none dark:bg-[#E3E5E80D]"
129
- :class="{ 'border border-[#E74135] bg-[#E741351A] dark:border-[#F47E75] dark:bg-[#F47E751A]': showError }"
128
+ class="size-10 rounded bg-deepblue-900/5 text-center text-lg caret-transparent focus:outline-none dark:bg-[#E3E5E80D]"
129
+ :class="{
130
+ 'border border-[#E74135] bg-[#E741351A] dark:border-[#F47E75] dark:bg-[#F47E751A]': showError,
131
+ 'focus:border focus:border-blue-700 dark:focus:border-blue-500': !showError,
132
+ }"
130
133
  @input="onInput($event, index)"
131
134
  @keydown.backspace="onBackspace(index, $event)"
132
135
  @keydown.enter.prevent
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import { useAuthStore } from '#adata-ui/stores/auth.store'
3
4
  import * as z from 'zod'
4
5
 
@@ -35,7 +36,7 @@ async function onSubmit() {
35
36
  if (validation.value) return
36
37
  loading.value = true
37
38
 
38
- await $fetch(`${authApiURL}/password/email-otp`, {
39
+ await $fetch(`${removeTrailingSlash(authApiURL)}/password/email-otp`, {
39
40
  method: 'POST',
40
41
  credentials: 'include',
41
42
  headers: {
@@ -1,7 +1,8 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import { PAGES } from '#adata-ui/shared/constans/pages'
3
- import { useAuthStore } from '#adata-ui/stores/auth.store'
4
4
 
5
+ import { useAuthStore } from '#adata-ui/stores/auth.store'
5
6
  import { computed, reactive, ref } from 'vue'
6
7
  import * as z from 'zod'
7
8
 
@@ -74,7 +75,7 @@ async function onSubmit() {
74
75
 
75
76
  try {
76
77
  loading.value = true
77
- const { success, message } = await $fetch(`${authApiURL}/register`, {
78
+ const { success, message } = await $fetch(`${removeTrailingSlash(authApiURL)}/v2/register`, {
78
79
  method: 'POST',
79
80
  credentials: 'include',
80
81
  headers: {
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import IdOtpInput from '#adata-ui/components/modals/id/IdOtpInput.vue'
3
4
  import { useAuthStore } from '#adata-ui/stores/auth.store'
4
5
 
@@ -24,7 +25,7 @@ async function onConfirm() {
24
25
  try {
25
26
  isLoading.value = true
26
27
 
27
- const response = await $fetch(`${authApiURL}/password/validate-otp`, {
28
+ const response = await $fetch(`${removeTrailingSlash(authApiURL)}/password/validate-otp`, {
28
29
  method: 'POST',
29
30
  credentials: 'include',
30
31
  headers: {
@@ -62,7 +63,7 @@ function onClose() {
62
63
 
63
64
  async function onResend() {
64
65
  try {
65
- await $fetch(`${authApiURL}/password/email-otp`, {
66
+ await $fetch(`${removeTrailingSlash(authApiURL)}/password/email-otp`, {
66
67
  method: 'POST',
67
68
  credentials: 'include',
68
69
  headers: {
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/modals/id/helpers/removeTrailingSlash'
2
3
  import IdOtpInput from '#adata-ui/components/modals/id/IdOtpInput.vue'
3
4
  import { useAuthStore } from '#adata-ui/stores/auth.store'
4
5
 
@@ -22,7 +23,7 @@ const isLoading = ref(false)
22
23
 
23
24
  async function onConfirm() {
24
25
  isLoading.value = true
25
- const login = await fetch(`${authApiURL}/login`, {
26
+ const login = await fetch(`${removeTrailingSlash(authApiURL)}/login`, {
26
27
  method: 'POST',
27
28
  credentials: 'include',
28
29
  headers: {
@@ -44,7 +45,7 @@ async function onConfirm() {
44
45
  }
45
46
  }
46
47
  else {
47
- const response = await fetch(`${authApiURL}/access/cookie`, {
48
+ const response = await fetch(`${removeTrailingSlash(authApiURL)}/access/cookie`, {
48
49
  method: 'GET',
49
50
  credentials: 'include',
50
51
  headers: {
@@ -0,0 +1,7 @@
1
+ export function removeTrailingSlash(str: string): string {
2
+ if (str.endsWith('/')) {
3
+ return str.slice(0, -1)
4
+ }
5
+
6
+ return str
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adata-ui",
3
3
  "type": "module",
4
- "version": "2.0.30",
4
+ "version": "2.0.32",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",