feat: add sidebar footer with sign out
This commit is contained in:
parent
c4e9f2aeaa
commit
b4d6f976dd
40
app/components/admin/sidebar/sidebar-footer.tsx
Normal file
40
app/components/admin/sidebar/sidebar-footer.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
import { useNavigate } from 'react-router';
|
||||
import { LogOut, Settings } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import { Button } from '~/components/ui/button';
|
||||
import { Text } from '~/components/ui/text';
|
||||
import { SidebarLink } from '~/components/admin/sidebar/sidebar-link';
|
||||
import { ROUTES } from '~/data/routes';
|
||||
import { useAdminData } from '~/hooks/admin/use-admin-data';
|
||||
import { signOut } from '~/services/auth';
|
||||
|
||||
export function SidebarFooter({ settingsActive, onNavigate }: { settingsActive: boolean; onNavigate?: () => void }) {
|
||||
const { email } = useAdminData();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-2'>
|
||||
<SidebarLink size='nav' to={ROUTES.settings} label='Settings' active={settingsActive} leading={<Settings size={14} />} onNavigate={onNavigate} />
|
||||
<div className='flex flex-col items-start gap-2 border-t border-border-divider px-1.5 pt-3'>
|
||||
{email && (
|
||||
<Text variant='caption' tone='secondary' truncate className='max-w-full'>
|
||||
{email}
|
||||
</Text>
|
||||
)}
|
||||
<Button
|
||||
variant='link'
|
||||
size='sm'
|
||||
className='h-auto gap-2 text-text-subtle hover:text-text-primary'
|
||||
onClick={() => {
|
||||
signOut();
|
||||
toast.success('Signed out');
|
||||
navigate(ROUTES.login, { replace: true });
|
||||
}}
|
||||
>
|
||||
<LogOut size={13} />
|
||||
Sign out
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user