'use client';
import { usePathname, useRouter } from 'next/navigation';
import { LuLayoutDashboard } from 'react-icons/lu';
import { RiUser4Line } from 'react-icons/ri';
import { TbHome2, TbLogout2 } from 'react-icons/tb';
export default function Sidebar() {
const router = useRouter();
const pathname = usePathname(); // Get the current route
// Define the routes with relevant icons
const routes = [
{
name: 'Dashboard',
path: '/dashboard',
icon: ,
},
{
name: 'Home',
path: '/home',
icon: ,
},
{
name: 'Profile',
path: '/profile',
icon: ,
},
];
const handleLogout = async () => {
try {
const response = await fetch('/api/auth/logout', {
method: 'GET',
credentials: 'include', // Ensure cookies are sent
});
if (response.ok) {
console.log('Logout successful');
router.push('/login'); // Redirect to login page
} else {
console.error('Failed to log out:', response.status);
}
} catch (error) {
console.error('Error while logging out:', error);
}
};
return (
//

P ink A ura
);
}