Compare commits

...

4 Commits

8 changed files with 96 additions and 75 deletions

View File

@ -5,5 +5,5 @@ export const metadata: Metadata = {
}; };
export default async function Page() { export default async function Page() {
return <p>Classes</p>; return <p>Hello world!</p>;
} }

View File

@ -1,10 +1,41 @@
"use client";
import { Sidebar } from "@/app/components/Sidebar"; import { Sidebar } from "@/app/components/Sidebar";
import { Divider } from "@nextui-org/react";
import { usePathname } from "next/navigation";
import { FaDoorClosed, FaRegUser } from "react-icons/fa";
import { FiSettings } from "react-icons/fi";
import { IoMdStats } from "react-icons/io";
import { MdInbox } from "react-icons/md";
export default function Layout({ children }: { children: React.ReactNode }) { export default function Layout({ children }: { children: React.ReactNode }) {
const pathName = usePathname();
const sidebarItems = [
[
{ href: "/admin", title: "Dashboard", icon: <IoMdStats /> },
{ href: "/admin/users", title: "Users", icon: <FaRegUser /> },
{ href: "/admin/classes", title: "Classes", icon: <MdInbox /> },
{ href: "/admin/rooms", title: "Rooms", icon: <FaDoorClosed /> },
],
[{ href: "/admin/settings", title: "Settings", icon: <FiSettings /> }],
];
return ( return (
<div className="flex"> <div className="flex">
<Sidebar /> <Sidebar items={sidebarItems} />
<main>{children}</main> <main className="p-7 w-full">
<h1 className="text-2xl font-semibold">
{
sidebarItems
.flat()
.find((item) => item.href === pathName)?.title
}
</h1>
<Divider className="mt-2 mb-5 bg-foreground-300" />
{children}
</main>
</div> </div>
); );
} }

View File

@ -5,5 +5,7 @@ export const metadata: Metadata = {
}; };
export default async function Page() { export default async function Page() {
return <p>Admin Home</p>; return (
<p>Hello world!</p>
);
} }

View File

@ -5,5 +5,7 @@ export const metadata: Metadata = {
}; };
export default async function Page() { export default async function Page() {
return <p>Rooms</p>; return (
<p>Hello world!</p>
);
} }

View File

@ -5,5 +5,7 @@ export const metadata: Metadata = {
}; };
export default async function Page() { export default async function Page() {
return <p>Settings</p>; return (
<p>Hello world!</p>
);
} }

View File

@ -6,9 +6,5 @@ export const metadata: Metadata = {
}; };
export default async function Page() { export default async function Page() {
return ( return <UserList />;
<div className="p-4">
<UserList />
</div>
);
} }

View File

@ -1,77 +1,65 @@
"use client"; "use client";
import { Divider, Link } from "@nextui-org/react"; import { Divider, Link } from "@nextui-org/react";
import { useRouter } from "next/navigation"; import { usePathname, useRouter } from "next/navigation";
import { FaDoorClosed, FaRegUser } from "react-icons/fa";
import { FiSettings } from "react-icons/fi";
import { IoMdStats } from "react-icons/io";
import { MdInbox } from "react-icons/md";
import { ThemeSwitcher } from "../ThemeSwitcher/ThemeSwitcher"; import { ThemeSwitcher } from "../ThemeSwitcher/ThemeSwitcher";
import { SidebarItem } from "./item"; import { SidebarItem } from "./item";
export const Sidebar = () => { export const Sidebar = ({
items,
}: {
items: {
href: string;
title: string;
icon: React.ReactNode;
}[][];
}) => {
const router = useRouter(); const router = useRouter();
const pathName = usePathname();
return ( return (
<aside className="h-screen"> <aside className="h-screen">
<div className="flex flex-col w-64 gap-2 h-full px-3 py-4 overflow-y-auto bg-foreground-100"> <div className="flex flex-col w-72 gap-5 h-full px-3 py-4 overflow-y-auto bg-foreground-100">
<ul className="font-medium gap-2"> <div className="flex flex-col gap-2 p-2">
<li>
<Link <Link
className="flex justify-center p-2 text-gray-900 dark:text-white rounded-lg cursor-pointer" className="flex text-2xl font-semibold text-gray-900 dark:text-white rounded-lg cursor-pointer"
onPress={() => router.push("/")} onPress={() => router.push("/")}
> >
Toogether Toogether
</Link> </Link>
</li> <p className="text-sm text-foreground-400 dark:text-gray-400">
</ul> Manage classes, rooms, and users
</p>
</div>
{items.map((group, index) => (
<div key={index}>
<section className="flex flex-col"> <section className="flex flex-col">
<ul className="flex flex-col gap-2"> <ul className="flex flex-col gap-2">
<li className="hover:bg-foreground-300 rounded-md cursor-pointer"> {group.map((item, index) => (
<li
key={index}
className={`${
pathName === item.href
? "bg-foreground-300"
: "hover:bg-foreground-200"
} rounded-md cursor-pointer`}
>
<SidebarItem <SidebarItem
href="/admin" href={item.href}
title="Dashboard" title={item.title}
icon={<IoMdStats />} icon={item.icon}
/>
</li>
<li className="hover:bg-foreground-300 rounded-md cursor-pointer">
<SidebarItem
href="/admin/users"
title="Users"
icon={<FaRegUser />}
/>
</li>
<li className="hover:bg-foreground-300 rounded-md cursor-pointer">
<SidebarItem
href="/admin/classes"
title="Classes"
icon={<MdInbox />}
/>
</li>
<li className="hover:bg-foreground-300 rounded-md cursor-pointer">
<SidebarItem
href="/admin/rooms"
title="Rooms"
icon={<FaDoorClosed />}
/> />
</li> </li>
))}
</ul> </ul>
</section> </section>
<Divider className="bg-foreground-300 my-4" /> {index < items.length - 1 && (
<Divider className="bg-foreground-300 mt-4" />
<section className="flex flex-col"> )}
<ul className="flex flex-col gap-2"> </div>
<li className="hover:bg-foreground-300 rounded-md cursor-pointer"> ))}
<SidebarItem
href="/admin/settings"
title="Settings"
icon={<FiSettings />}
/>
</li>
</ul>
</section>
<section className="mt-auto flex justify-between"> <section className="mt-auto flex justify-between">
<ThemeSwitcher /> <ThemeSwitcher />

View File

@ -17,9 +17,9 @@ export const SidebarItem = ({
<Link <Link
onPress={() => router.push(href)} onPress={() => router.push(href)}
color="foreground" color="foreground"
className="w-full px-2 py-1 gap-2 text-xl" className="w-full p-2 gap-3 text-md"
> >
{icon} <span className="text-xl">{icon}</span>
{title} {title}
</Link> </Link>
); );