From 580a87afbdee4d8224ef7fc02036a6cb742aed00 Mon Sep 17 00:00:00 2001 From: gavinlin24 Date: Mon, 9 Mar 2026 19:53:07 -0700 Subject: [PATCH 1/2] Change admin login ui to google --- app/admin/login/page.tsx | 126 ++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 54 deletions(-) diff --git a/app/admin/login/page.tsx b/app/admin/login/page.tsx index 310a3de..89da19d 100644 --- a/app/admin/login/page.tsx +++ b/app/admin/login/page.tsx @@ -1,65 +1,83 @@ "use client"; -import { useState } from "react"; +import { useSession, signIn } from "next-auth/react"; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; export default function AdminLoginPage() { - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); + const { data: session, status } = useSession(); + const router = useRouter(); - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - console.log({ email, password }); - }; + useEffect(() => { + if (session) { + router.push("/admin"); + } + }, [session, router]); + if (status === "loading") { return ( -
-
-
-

Admin Login

-

- Sign in to access the admin dashboard -

-
+
+ Loading... +
+ ); + } -
-
- - setEmail(e.target.value)} - placeholder="admin@example.com" - required - className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" - /> -
+ return ( +
+
+

+ Admin Login +

-
- - setPassword(e.target.value)} - placeholder="••••••••" - required - className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" - /> -
+

+ Sign in to access the dashboard +

- - -
-
- ); + +
+
+ ); } From 3ee19275f40933ce3daeea3ab52fad4e08a61bf6 Mon Sep 17 00:00:00 2001 From: gavinlin24 Date: Mon, 9 Mar 2026 19:53:55 -0700 Subject: [PATCH 2/2] Update admin dashboard ui --- app/admin/page.tsx | 19 +++--- components/admin/ProfileDropdown.tsx | 92 ++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 components/admin/ProfileDropdown.tsx diff --git a/app/admin/page.tsx b/app/admin/page.tsx index 16a284c..05c59b8 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -1,11 +1,12 @@ +import ProfileDropdown from "@/components/admin/ProfileDropdown"; + export default function AdminPage() { - return ( -
-

Admin Dashboard

-

- Base admin layout shell is working & No auth yet. -

+ return ( +
+
+

Admin Dashboard

+
- ); - } - \ No newline at end of file +
+ ); +} diff --git a/components/admin/ProfileDropdown.tsx b/components/admin/ProfileDropdown.tsx new file mode 100644 index 0000000..6e2a659 --- /dev/null +++ b/components/admin/ProfileDropdown.tsx @@ -0,0 +1,92 @@ +"use client"; + +import { useSession, signOut } from "next-auth/react"; +import { useState, useRef, useEffect } from "react"; + +export default function ProfileDropdown() { + const { data: session } = useSession(); + const [open, setOpen] = useState(false); + const ref = useRef(null); + + useEffect(() => { + function handleClickOutside(e: MouseEvent) { + if (ref.current && !ref.current.contains(e.target as Node)) { + setOpen(false); + } + } + document.addEventListener("mousedown", handleClickOutside); + return () => document.removeEventListener("mousedown", handleClickOutside); + }, []); + + return ( +
+ {session?.user?.image && ( + {session.user.name setOpen(!open)} + style={{ + borderRadius: "50%", + objectFit: "cover", + cursor: "pointer", + border: open ? "2px solid #111" : "2px solid transparent", + transition: "border 0.15s", + }} + /> + )} + + {open && ( +
+
+

+ {session?.user?.name} +

+

+ {session?.user?.email} +

+
+ +
+ )} +
+ ); +}