diff --git a/app/api/user/validate/route.ts b/app/api/user/validate/route.ts index 801624a..9573f4e 100644 --- a/app/api/user/validate/route.ts +++ b/app/api/user/validate/route.ts @@ -30,7 +30,7 @@ export async function POST(request: NextRequest) { return NextResponse.json({ error: "User not found" }, { status: 404 }); } - return NextResponse.json({ message: "Valid" }, { status: 200 }); + return NextResponse.json({ message: "Valid", username: user.username, name: user.name }, { status: 200 }); } catch (error: any) { return NextResponse.json({ error: "Internal Server Error" }, { status: 500 }); diff --git a/app/dashboard/DashboardPage.tsx b/app/dashboard/DashboardPage.tsx index fce7d71..a741e53 100644 --- a/app/dashboard/DashboardPage.tsx +++ b/app/dashboard/DashboardPage.tsx @@ -1,9 +1,20 @@ +"use client"; +import Sidebar from "@/components/Sidebar"; -export default function DashboardPage() { +interface DashboardPageProps { + username: string; + name: string; +} + +export default function DashboardPage({ username, name }: DashboardPageProps) { return (
-

Dashboard

+ +
+

Dashboard

+
+
); } \ No newline at end of file diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index fbdc5a1..7842aaa 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -11,6 +11,8 @@ import Cookies from "js-cookie"; export default function Dashboard() { const router = useRouter(); const [loading, setLoading] = useState(true); + const [username, setUsername] = useState(""); + const [name, setName] = useState(""); useEffect(() => { const init = async () => { @@ -23,6 +25,8 @@ export default function Dashboard() { Cookies.remove("token"); router.push("/"); } else { + setUsername(response.data.username); + setName(response.data.name); setLoading(false); } }; @@ -32,6 +36,6 @@ export default function Dashboard() { if (loading) { return ; } else { - return ; + return ; } } \ No newline at end of file diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx new file mode 100644 index 0000000..ba458b4 --- /dev/null +++ b/components/Sidebar.tsx @@ -0,0 +1,182 @@ +"use client" + +import type React from "react" + +import { useState } from "react" +import Link from "next/link" +import { + Home, + Globe, + Server, + Layout, + Clock, + PenToolIcon as Tool, + Settings, + LogOut, + ChevronDown, + Menu, +} from "lucide-react" +import packageJson from "@/package.json" +import Image from "next/image" +import Cookies from "js-cookie" +import { useRouter } from "next/navigation" + +interface SidebarProps { + children: React.ReactNode + username: string + fullName: string +} + +export default function Sidebar({ children, username, fullName }: SidebarProps) { + const router = useRouter() + const [isProfileOpen, setIsProfileOpen] = useState(false) + const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false) + + const initials = useState(() => { + const nameToUse = fullName || username + + return nameToUse + .split(" ") + .filter((part) => part.length > 0) + .map((part) => part[0]) + .join("") + .toUpperCase() + .substring(0, 2) + })[0] + + const logout = () => { + Cookies.remove("token") + router.push("/") + } + + return ( +
+ {/* Mobile menu button */} +
+ + CoreControl +
+ + {/* Sidebar */} + + + {/* Main content */} +
{children}
+
+ ) +} diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000..934cd5d Binary files /dev/null and b/public/logo.png differ