1
1
<script setup lang="ts">
2
- import { onMounted } from ' vue'
3
- import { Menu , MenuButton , MenuItem , MenuItems } from ' @headlessui/vue'
4
- import useAuth , { getClient } from ' ../../auth-utils/useAuth'
5
- import useAuthRedirect from ' @/auth-utils/useAuthRedirect'
2
+ import { onMounted } from " vue" ;
3
+ import { Menu , MenuButton , MenuItem , MenuItems } from " @headlessui/vue" ;
4
+ import useAuth , { getClient } from " ../../auth-utils/useAuth" ;
5
+ import useAuthRedirect from " @/auth-utils/useAuthRedirect" ;
6
6
7
- const { user, logout, isLoggedIn, getCurrentUser, responseFromServer, checkIfLoggedIn, avatarUrl } = useAuth (getClient ())
7
+ const { user, logout, isLoggedIn, checkIfLoggedIn, avatarUrl } = useAuth (
8
+ getClient ()
9
+ );
8
10
9
- const { setUrl } = useAuthRedirect ()
11
+ const { setUrl } = useAuthRedirect ();
10
12
11
13
onMounted (() => {
12
- checkIfLoggedIn ()
13
- })
14
+ checkIfLoggedIn ();
15
+ });
14
16
</script >
15
17
16
18
<template >
17
19
<div class =" dark:text-zinc-200 dark:ring-white/10 pl-4" >
18
20
<BaseButton
19
- v-if =" !isLoggedIn" href =" /login" color =" primary" class =" font-medium hidden md:block"
21
+ v-if =" !isLoggedIn"
22
+ href =" /login"
23
+ color =" primary"
24
+ class =" font-medium hidden md:block"
20
25
@click =" setUrl()"
21
26
>
22
27
Log In
23
28
</BaseButton >
24
29
<BaseButton
25
- v-if =" !isLoggedIn" href =" /login" color =" primary" class =" font-medium block md:hidden" size =" sm"
30
+ v-if =" !isLoggedIn"
31
+ href =" /login"
32
+ color =" primary"
33
+ class =" font-medium block md:hidden"
34
+ size =" sm"
26
35
@click =" setUrl()"
27
36
>
28
37
Log In
@@ -31,19 +40,24 @@ onMounted(() => {
31
40
<Menu as =" div" class =" relative inline-block text-left" >
32
41
<div >
33
42
<MenuButton
34
- class =" inline-flex items-center w-full justify-center gap-x-1.5 rounded-full text-sm font-semibold text-verse-900 dark:text-verse-100 shadow-sm ring-gray-300 hover:bg-gray-50"
43
+ class =" inline-flex items-center w-full justify-center gap-x-1.5 rounded-full text-sm font-semibold text-verse-900 dark:text-verse-100 shadow-sm ring-gray-300 hover:bg-gray-50"
35
44
>
36
45
<div v-if =" avatarUrl" >
37
- <img class =" w-10 aspect-square rounded-full" :src =" avatarUrl" >
46
+ <img
47
+ class =" w-10 aspect-square rounded-full"
48
+ :src =" avatarUrl"
49
+ alt =" User Avatar"
50
+ />
38
51
</div >
39
- <!-- <ChevronDownIcon class="-mr-1 h-5 w-5 text-gray-400" aria-hidden="true" /> -->
40
52
</MenuButton >
41
53
</div >
42
54
43
55
<transition
44
56
enter-active-class =" transition ease-out duration-100"
45
- enter-from-class =" transform opacity-0 scale-95" enter-to-class =" transform opacity-100 scale-100"
46
- leave-active-class =" transition ease-in duration-75" leave-from-class =" transform opacity-100 scale-100"
57
+ enter-from-class =" transform opacity-0 scale-95"
58
+ enter-to-class =" transform opacity-100 scale-100"
59
+ leave-active-class =" transition ease-in duration-75"
60
+ leave-from-class =" transform opacity-100 scale-100"
47
61
leave-to-class =" transform opacity-0 scale-95"
48
62
>
49
63
<MenuItems
@@ -53,15 +67,24 @@ onMounted(() => {
53
67
<MenuItem v-slot =" { active }" >
54
68
<NuxtLink
55
69
href =" /user/me"
56
- class =" block px-4 py-2 text-sm" :class =" [active ? 'bg-gray-400/10 text-verse-900 dark:text-verse-100' : 'text-verse-900 dark:text-verse-100']"
70
+ class =" block px-4 py-2 text-sm"
71
+ :class =" [
72
+ active
73
+ ? 'bg-gray-400/10 text-verse-900 dark:text-verse-100'
74
+ : 'text-verse-900 dark:text-verse-100',
75
+ ]"
57
76
>
58
- My
59
- Profile
77
+ My Profile
60
78
</NuxtLink >
61
79
</MenuItem >
62
80
<MenuItem v-slot =" { active }" >
63
81
<NuxtLink
64
- class =" block px-4 py-2 text-sm cursor-pointer" :class =" [active ? 'bg-gray-400/10 text-verse-900 dark:text-verse-100' : 'text-verse-900 dark:text-verse-100']"
82
+ class =" block px-4 py-2 text-sm cursor-pointer"
83
+ :class =" [
84
+ active
85
+ ? 'bg-gray-400/10 text-verse-900 dark:text-verse-100'
86
+ : 'text-verse-900 dark:text-verse-100',
87
+ ]"
65
88
@click =" logout()"
66
89
>
67
90
Logout
@@ -71,7 +94,10 @@ onMounted(() => {
71
94
<div class =" text-verse-900 dark:text-verse-100 p-4 text-sm" >
72
95
<div class =" flex flex-col items-center justify-center gap-2" >
73
96
<div v-if =" avatarUrl" >
74
- <img class =" w-16 aspect-square rounded-full" :src =" avatarUrl" >
97
+ <img
98
+ class =" w-16 aspect-square rounded-full"
99
+ :src =" avatarUrl"
100
+ />
75
101
</div >
76
102
77
103
{{ user?.full_name }}
0 commit comments