2026-05-26 15:48:01 +05:30
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
|
import { useAuth } from '@/context/AuthContext';
|
|
|
|
|
import { Button } from '@/components/ui/button';
|
|
|
|
|
import { Switch } from '@/components/ui/switch';
|
|
|
|
|
import { log } from 'console';
|
2026-03-16 17:55:33 +05:30
|
|
|
|
|
|
|
|
export default function Header() {
|
2026-05-26 15:48:01 +05:30
|
|
|
const { user, logout } = useAuth();
|
2026-03-16 17:55:33 +05:30
|
|
|
const [darkMode, setDarkMode] = useState<boolean>(false);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-05-26 15:48:01 +05:30
|
|
|
if (darkMode) document.documentElement.classList.add('dark');
|
|
|
|
|
else document.documentElement.classList.remove('dark');
|
2026-03-16 17:55:33 +05:30
|
|
|
}, [darkMode]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<header className="border-b bg-card">
|
|
|
|
|
<div className="flex items-center justify-between px-6 h-16">
|
|
|
|
|
<div>
|
|
|
|
|
<p className="text-sm text-muted-foreground">Welcome back</p>
|
|
|
|
|
<p className="font-semibold">{user?.username}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-4">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="text-sm">Dark</span>
|
|
|
|
|
<Switch checked={darkMode} onCheckedChange={setDarkMode} />
|
|
|
|
|
</div>
|
|
|
|
|
<Button variant="destructive" onClick={logout}>
|
|
|
|
|
Logout
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|