feat: add admin pages for classes, rooms, settings, and users with updated layout and sidebar navigation

This commit is contained in:
Rémi 2025-01-06 02:56:51 +01:00
parent 1ff5126e98
commit 9f2ae08f1a
15 changed files with 103 additions and 27 deletions

View File

@ -0,0 +1,9 @@
import { Metadata } from "next";
export const metadata: Metadata = {
title: "Classes | Toogether",
};
export default async function Page() {
return <p>Classes</p>;
}

View File

@ -2,7 +2,7 @@ import { Sidebar } from "@/app/components/Sidebar";
export default function Layout({ children }: { children: React.ReactNode }) { export default function Layout({ children }: { children: React.ReactNode }) {
return ( return (
<div> <div className="flex">
<Sidebar /> <Sidebar />
<main>{children}</main> <main>{children}</main>
</div> </div>

View File

@ -1,10 +1,9 @@
import { Metadata } from "next"; import { Metadata } from "next";
import { Sidebar } from "../components/Sidebar";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Toogether Admin", title: "Admin | Toogether",
}; };
export default async function AdminPage() { export default async function Page() {
return <Sidebar />; return <p>Admin Home</p>;
} }

View File

@ -0,0 +1,9 @@
import { Metadata } from "next";
export const metadata: Metadata = {
title: "Rooms | Toogether",
};
export default async function Page() {
return <p>Rooms</p>;
}

View File

@ -0,0 +1,9 @@
import { Metadata } from "next";
export const metadata: Metadata = {
title: "Settings | Toogether",
};
export default async function Page() {
return <p>Settings</p>;
}

View File

@ -0,0 +1,9 @@
import { Metadata } from "next";
export const metadata: Metadata = {
title: "Users | Toogether",
};
export default async function Page() {
return <p>Users</p>;
}

View File

@ -1,4 +1,6 @@
"use client"; "use client";
import { useClassStore } from "@/app/stores/classStore";
import { useUserStore } from "@/app/stores/userStore";
import { User } from "@/app/types/next-auth"; import { User } from "@/app/types/next-auth";
import { getInitials } from "@/app/utils/initial"; import { getInitials } from "@/app/utils/initial";
import { import {
@ -18,8 +20,6 @@ import {
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useEffect } from "react"; import { useEffect } from "react";
import { ThemeSwitcher } from "../ThemeSwitcher/ThemeSwitcher"; import { ThemeSwitcher } from "../ThemeSwitcher/ThemeSwitcher";
import { useUserStore } from "@/app/stores/userStore";
import { useClassStore } from "@/app/stores/classStore";
export const HeaderContent = ({ user }: { user?: User }) => { export const HeaderContent = ({ user }: { user?: User }) => {
const router = useRouter(); const router = useRouter();

View File

@ -70,11 +70,9 @@ export const RoomCard = ({ id, name, date, Times, Presentator }: Room) => {
{moment(date).dayOfYear() === moment().dayOfYear() && ( {moment(date).dayOfYear() === moment().dayOfYear() && (
<div className="flex p-2"> <div className="flex p-2">
<Button <Button
isDisabled={ isDisabled={moment(
moment(moment(Times[0].startTime).subtract(5, "minutes")).isAfter( moment(Times[0].startTime).subtract(5, "minutes"),
moment(), ).isAfter(moment())}
)
}
color="primary" color="primary"
radius="full" radius="full"
size="sm" size="sm"

View File

@ -47,11 +47,14 @@ export const RoomList = ({ rooms }: { rooms: Room[] | null }) => {
}; };
}, []); }, []);
if (rooms?.length == 0) return ( if (rooms?.length == 0)
<div className="flex gap-2 rounded-xl bg-default-100 p-4"> return (
<p className="text-default-500 text-center w-full">No rooms found</p> <div className="flex gap-2 rounded-xl bg-default-100 p-4">
</div> <p className="text-default-500 text-center w-full">
) No rooms found
</p>
</div>
);
return ( return (
<ul <ul

View File

@ -1,17 +1,20 @@
"use client"; "use client";
import { FaRegUser } from "react-icons/fa"; import { Divider, Link } from "@nextui-org/react";
import { 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";
import { Link } from "@nextui-org/react";
import { useRouter } from "next/navigation";
export const Sidebar = () => { export const Sidebar = () => {
const router = useRouter(); const router = useRouter();
return ( return (
<aside className="fixed top-0 left-0 w-64 h-screen"> <aside className="h-screen">
<div className="flex flex-col gap-2 h-full px-3 py-4 overflow-y-auto bg-foreground-100"> <div className="flex flex-col w-64 gap-2 h-full px-3 py-4 overflow-y-auto bg-foreground-100">
<ul className="font-medium gap-2"> <ul className="font-medium gap-2">
<li> <li>
<Link <Link
@ -22,8 +25,16 @@ export const Sidebar = () => {
</Link> </Link>
</li> </li>
</ul> </ul>
<section className="flex flex-col gap-2">
<ul> <section className="flex flex-col">
<ul className="flex flex-col gap-2">
<li className="hover:bg-foreground-300 rounded-md cursor-pointer">
<SidebarItem
href="/admin"
title="Dashboard"
icon={<IoMdStats />}
/>
</li>
<li className="hover:bg-foreground-300 rounded-md cursor-pointer"> <li className="hover:bg-foreground-300 rounded-md cursor-pointer">
<SidebarItem <SidebarItem
href="/admin/users" href="/admin/users"
@ -31,8 +42,37 @@ export const Sidebar = () => {
icon={<FaRegUser />} icon={<FaRegUser />}
/> />
</li> </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>
</ul> </ul>
</section> </section>
<Divider className="bg-foreground-300 my-4" />
<section className="flex flex-col">
<ul className="flex flex-col gap-2">
<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 />
</section> </section>

View File

@ -17,7 +17,7 @@ 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" className="w-full px-2 py-1 gap-2 text-xl"
> >
{icon} {icon}
{title} {title}

View File

@ -7,7 +7,7 @@ export const metadata: Metadata = {
"Toogether is a platform that allows you to create and join rooms to study together.", "Toogether is a platform that allows you to create and join rooms to study together.",
}; };
export default async function HomePage() { export default async function Page() {
return ( return (
<div className="flex flex-col gap-8 p-4"> <div className="flex flex-col gap-8 p-4">
<RoomTable /> <RoomTable />

View File

@ -8,7 +8,7 @@ export const metadata: Metadata = {
"Toogether is a platform that allows you to create and join rooms to study together.", "Toogether is a platform that allows you to create and join rooms to study together.",
}; };
export default async function HomePage() { export default async function Page() {
return ( return (
<> <>
<Header /> <Header />