From 1c12d378d66b92b1674acd17640f2bac752da289 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 25 Mar 2025 14:13:06 -0400 Subject: Converted public dashboard to admin dashboard; Made API have a consistent output message --- web/src/app/api/auth/[...nextauth]/route.js | 2 - web/src/app/components/Guilds.jsx | 25 ----------- web/src/app/components/Navbar.jsx | 25 +++++++++++ web/src/app/components/sign-in.jsx | 14 ------- web/src/app/components/sign-out.jsx | 11 +---- web/src/app/dashboard/page.js | 65 ++++++++++++++++------------- web/src/app/page.js | 42 ++++++++++++------- 7 files changed, 89 insertions(+), 95 deletions(-) delete mode 100644 web/src/app/api/auth/[...nextauth]/route.js delete mode 100644 web/src/app/components/Guilds.jsx create mode 100644 web/src/app/components/Navbar.jsx delete mode 100644 web/src/app/components/sign-in.jsx (limited to 'web/src/app') diff --git a/web/src/app/api/auth/[...nextauth]/route.js b/web/src/app/api/auth/[...nextauth]/route.js deleted file mode 100644 index 5951f83..0000000 --- a/web/src/app/api/auth/[...nextauth]/route.js +++ /dev/null @@ -1,2 +0,0 @@ -import { handlers } from "@/lib/auth" -export const { GET, POST } = handlers diff --git a/web/src/app/components/Guilds.jsx b/web/src/app/components/Guilds.jsx deleted file mode 100644 index 38626e4..0000000 --- a/web/src/app/components/Guilds.jsx +++ /dev/null @@ -1,25 +0,0 @@ - -export default async function Guilds({session}) { - - const response = await fetch("https://discord.com/api/users/@me/guilds", { - headers: { - Authorization: `Bearer ${session.accessToken}`, - }, - }); - const guilds = await response.json(); - - const ADMINISTRATOR = 0x0000000000000008; - const MANAGE_GUILD = 0x00000020; - - const filteredGuilds = guilds.filter((guild) => { - // Convert permissions string to a BigInt for bitwise operations - const permissions = BigInt(guild.permissions); - // Check if user is owner, has ADMINISTRATOR or MANAGE_GUILD permissions - return guild.owner || - (permissions & BigInt(ADMINISTRATOR)) === BigInt(ADMINISTRATOR) || - (permissions & BigInt(MANAGE_GUILD)) === BigInt(MANAGE_GUILD); }); - - return filteredGuilds.map((guild) => ( -
{guild.name}
- )) -} diff --git a/web/src/app/components/Navbar.jsx b/web/src/app/components/Navbar.jsx new file mode 100644 index 0000000..242175c --- /dev/null +++ b/web/src/app/components/Navbar.jsx @@ -0,0 +1,25 @@ +import SignOut from "@/app/components/sign-out"; + +export default function Navbar() { + return ( + + ) +} diff --git a/web/src/app/components/sign-in.jsx b/web/src/app/components/sign-in.jsx deleted file mode 100644 index 3d7142f..0000000 --- a/web/src/app/components/sign-in.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import { signIn } from "@/lib/auth" - -export default function SignIn() { - return ( -
{ - "use server" - await signIn("discord") - }} - > - -
- ) -} diff --git a/web/src/app/components/sign-out.jsx b/web/src/app/components/sign-out.jsx index 69162a4..dd6693d 100644 --- a/web/src/app/components/sign-out.jsx +++ b/web/src/app/components/sign-out.jsx @@ -1,14 +1,5 @@ -import { signOut } from "@/lib/auth" - export default function SignOut() { return ( -
{ - "use server" - await signOut("discord") - }} - > - -
+ ) } diff --git a/web/src/app/dashboard/page.js b/web/src/app/dashboard/page.js index bab3bd8..a252958 100644 --- a/web/src/app/dashboard/page.js +++ b/web/src/app/dashboard/page.js @@ -1,39 +1,44 @@ -import { redirect } from "next/navigation"; -import { auth } from "@/lib/auth"; -import SignOut from "@/app/components/sign-out"; -import Guilds from "@/app/components/Guilds"; - -export default async function Home() { - const session = await auth(); - if (!session) redirect("/"); +import Navbar from "@/app/components/Navbar"; +export default function Dashboard() { return ( <> - -
-
-
Settings
- -
-
-

Logging

-

Channel 1

-

Channel 2

-

Quote of the Day

-

LLM Chatbot

- ) + ); } diff --git a/web/src/app/page.js b/web/src/app/page.js index 76e5d27..99556e8 100644 --- a/web/src/app/page.js +++ b/web/src/app/page.js @@ -1,19 +1,33 @@ -import { redirect } from "next/navigation"; -import { auth } from "@/lib/auth"; +export default function Home() { -export default async function Home() { - const session = await auth(); - if (session) redirect("/dashboard"); - return ( - <> -
-
- - - - + return ( +
+

AleeBot

+ + + + +
- ); } -- cgit v1.2.3