@@ -4,6 +4,10 @@ import { useQueryClient } from '@tanstack/vue-query';
44import { ref } from ' vue' ;
55import { useI18n } from ' #imports' ;
66import { useTheme } from ' ~/composables/useTheme' ;
7+ import Avatar from ' ~/components/ui/Avatar.vue' ;
8+
9+ const dmUnseenCount = inject <Ref <number >>(' dmUnseenCount' , ref (0 ));
10+ const notificationUnseenCount = inject <Ref <number >>(' unseenNotificationsCount' , ref (0 ));
711
812const { locale, setLocale } = useI18n ();
913const { mode, toggleTheme } = useTheme ();
@@ -13,7 +17,7 @@ const queryClient = useQueryClient();
1317
1418const handleLogout = async () => {
1519 await loginService .logout ();
16- queryClient .removeQueries ({ queryKey: [ ' layout-data ' ] } );
20+ await queryClient .clear ( );
1721};
1822
1923const lang = ref (locale .value );
@@ -41,10 +45,20 @@ const switchLanguage = () => {
4145 :tab =" { label: ' explore' , icon: ' search' , route: ' /explore' } "
4246 ></SideBarLeftTab >
4347 <SideBarLeftTab
44- :tab =" { label: ' notifications' , icon: ' notifications' , route: ' /notifications' } "
48+ :tab =" {
49+ label: ' notifications' ,
50+ icon: ' notifications' ,
51+ route: ' /notifications' ,
52+ badgeCount: notificationUnseenCount ,
53+ } "
4554 ></SideBarLeftTab >
4655 <SideBarLeftTab
47- :tab =" { label: ' messages' , icon: ' chat' , route: ' /messages' } "
56+ :tab =" {
57+ label: ' messages' ,
58+ icon: ' chat' ,
59+ route: ' /messages' ,
60+ badgeCount: dmUnseenCount ,
61+ } "
4862 ></SideBarLeftTab >
4963 <SideBarLeftTab
5064 :tab =" {
@@ -54,7 +68,7 @@ const switchLanguage = () => {
5468 } "
5569 ></SideBarLeftTab >
5670 <SideBarLeftTab
57- :tab =" { label: ' settings' , icon: ' settings' , route: ' /settings/account ' } "
71+ :tab =" { label: ' settings' , icon: ' settings' , route: ' /settings' } "
5872 data-cy="sidebar-settings-btn"
5973 ></SideBarLeftTab >
6074 <UiButton variant="ghost-default" size="icon-xl" @click =" switchLanguage " >
@@ -68,14 +82,63 @@ const switchLanguage = () => {
6882 size="24"
6983 />
7084 </UiButton >
71- <UiButton
72- variant="ghost-default"
73- size="icon-xl"
74- data-cy="logout-button"
75- @click =" handleLogout "
76- >
77- <Icon name="ic:outline-logout " size="24" />
78- </UiButton >
85+ </div >
86+ <div class =" flex w-full flex-grow p-2 pb-4" >
87+ <UiAlertDialog >
88+ <UiDropdownMenu >
89+ <UiDropdownMenuTrigger as-child>
90+ <UiButton
91+ variant="ghost-default"
92+ size="2xl"
93+ class="mx-auto mt-auto xl:w-full "
94+ data-cy="logout-btn-trigger"
95+ >
96+ <div class =" flex w-full items-center gap-3" >
97+ <Avatar
98+ :img =" userStore .user ?.avatarUrl || ' ' "
99+ :alt =" userStore .user ?.displayName || ' User Avatar' "
100+ size="sm"
101+ />
102+ <div class =" hidden text-start xl:block" >
103+ <p >{{ userStore.user?.displayName || 'User' }}</p >
104+ <p class =" text-muted-foreground text-sm" >
105+ {{ '@' + (userStore.user?.username || 'username') }}
106+ </p >
107+ </div >
108+ <div class =" ms-auto hidden xl:flex" >
109+ <Icon name="lucide:more-horizontal " class="pe-2" />
110+ </div >
111+ </div >
112+ </UiButton >
113+ </UiDropdownMenuTrigger >
114+ <UiDropdownMenuContent align="center" class="bg-background">
115+ <UiAlertDialogTrigger >
116+ <UiDropdownMenuItem data-cy="logout-button">
117+ {{ $t('ui.logout.label', { username: userStore.user?.username || 'username' }) }}
118+ </UiDropdownMenuItem >
119+ </UiAlertDialogTrigger >
120+ </UiDropdownMenuContent >
121+ </UiDropdownMenu >
122+
123+ <UiAlertDialogContent >
124+ <UiAlertDialogHeader >
125+ <UiAlertDialogTitle >
126+ {{ $t('ui.logout.title') }}
127+ </UiAlertDialogTitle >
128+ <UiAlertDialogDescription >
129+ {{ $t('ui.logout.description') }}
130+ </UiAlertDialogDescription >
131+ </UiAlertDialogHeader >
132+ <UiAlertDialogFooter >
133+ <UiAlertDialogAction data-cy="confirm-logout-button" @click =" handleLogout " >
134+ {{ $t('ui.logout.confirm') }}
135+ </UiAlertDialogAction >
136+ <UiAlertDialogCancel >
137+ {{ $t('ui.cancel') }}
138+ </UiAlertDialogCancel >
139+ </UiAlertDialogFooter >
140+ </UiAlertDialogContent >
141+ </UiAlertDialog >
79142 </div >
80143 </div >
81144</template >
0 commit comments