File tree Expand file tree Collapse file tree 6 files changed +62
-270
lines changed
Expand file tree Collapse file tree 6 files changed +62
-270
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import { toast } from 'sonner';
2121import { AnalyticsToolbar } from '@/app/(main)/websites/[id]/_components/analytics-toolbar' ;
2222import { Logo } from '@/components/layout/logo' ;
2323import { ThemeToggle } from '@/components/layout/theme-toggle' ;
24- import { UserMenu } from '@/components/layout/user-menu ' ;
24+ import { SignOutButton } from '@/components/layout/sign-out-button ' ;
2525import { NotificationsPopover } from '@/components/notifications/notifications-popover' ;
2626import { Button } from '@/components/ui/button' ;
2727import { ScrollArea } from '@/components/ui/scroll-area' ;
@@ -144,7 +144,7 @@ function Sidebar() {
144144 </ Button >
145145
146146 < NotificationsPopover />
147- < UserMenu />
147+ < SignOutButton />
148148 </ div >
149149 </ div >
150150 </ header >
Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ import {
1818 getDefaultCategory ,
1919 getNavigationWithWebsites ,
2020} from './navigation/navigation-config' ;
21+ import { SignOutButton } from './sign-out-button' ;
2122import { ThemeToggle } from './theme-toggle' ;
22- import { UserMenu } from './user-menu' ;
2323
2424const HelpDialog = dynamic (
2525 ( ) => import ( './help-dialog' ) . then ( ( mod ) => mod . HelpDialog ) ,
@@ -161,16 +161,7 @@ export function CategorySidebar({
161161
162162 { /* Profile */ }
163163 < div className = "flex justify-center" >
164- < Tooltip >
165- < TooltipTrigger asChild >
166- < div className = "flex h-8 w-8 items-center justify-center" >
167- < UserMenu />
168- </ div >
169- </ TooltipTrigger >
170- < TooltipContent side = "right" sideOffset = { 8 } >
171- Profile Menu
172- </ TooltipContent >
173- </ Tooltip >
164+ < SignOutButton />
174165 </ div >
175166 </ div >
176167
Original file line number Diff line number Diff line change 1+ import { authClient } from '@databuddy/auth/client' ;
2+ import { SignOutIcon } from '@phosphor-icons/react' ;
3+ import { useRouter } from 'next/navigation' ;
4+ import { useState } from 'react' ;
5+ import { toast } from 'sonner' ;
6+ import { Button } from '@/components/ui/button' ;
7+ import {
8+ Tooltip ,
9+ TooltipContent ,
10+ TooltipTrigger ,
11+ } from '@/components/ui/tooltip' ;
12+
13+ export function SignOutButton ( ) {
14+ const [ isLoggingOut , setIsLoggingOut ] = useState ( false ) ;
15+ const router = useRouter ( ) ;
16+
17+ const handleLogout = async ( ) => {
18+ setIsLoggingOut ( true ) ;
19+ await authClient . signOut ( {
20+ fetchOptions : {
21+ onSuccess : ( ) => {
22+ toast . success ( 'Logged out successfully' ) ;
23+ router . push ( '/login' ) ;
24+ } ,
25+ onError : ( error ) => {
26+ router . push ( '/login' ) ;
27+ toast . error ( error . error . message || 'Failed to log out' ) ;
28+ } ,
29+ } ,
30+ } ) ;
31+ setIsLoggingOut ( false ) ;
32+ } ;
33+
34+ return (
35+ < Tooltip >
36+ < TooltipTrigger asChild >
37+ < Button
38+ aria-label = { isLoggingOut ? 'Signing out...' : 'Sign out' }
39+ className = "h-8 w-8 not-dark:text-primary hover:bg-destructive/10 hover:text-destructive"
40+ disabled = { isLoggingOut }
41+ onClick = { handleLogout }
42+ size = "icon"
43+ variant = "ghost"
44+ >
45+ < SignOutIcon
46+ className = { isLoggingOut ? 'animate-pulse' : '' }
47+ size = { 16 }
48+ weight = "duotone"
49+ />
50+ </ Button >
51+ </ TooltipTrigger >
52+ < TooltipContent side = "right" >
53+ < p > { isLoggingOut ? 'Signing out...' : 'Sign out' } </ p >
54+ </ TooltipContent >
55+ </ Tooltip >
56+ ) ;
57+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export function ThemeToggle({ className }: ThemeTogglerProps) {
2525 onClick = { switchTheme }
2626 type = "button"
2727 variant = "ghost"
28- >
28+ >
2929 < SunIcon
3030 className = "dark:-rotate-90 h-5 w-5 rotate-0 scale-100 not-dark:text-primary transition-all duration-300 dark:scale-0"
3131 size = { 32 }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments