diff --git a/src/components/DashboardHeader.tsx b/src/components/DashboardHeader.tsx index acdd9e1..f500649 100644 --- a/src/components/DashboardHeader.tsx +++ b/src/components/DashboardHeader.tsx @@ -3,7 +3,7 @@ import { useRouter } from "next/navigation"; import { useEffect } from "react"; import { api } from "~/utils/api"; -export default function DashboardHeader() { +export default function DashboardHeader({ url }: { url: string }) { const { push } = useRouter(); const session = api.admin.session.useQuery(); const logout = api.admin.logout.useMutation(); @@ -15,49 +15,70 @@ export default function DashboardHeader() { }, [logout.isSuccess]) return ( -
-
- -
-

Savage Tracking

-

Hi, {session?.data?.name} ({session?.data?.grade} {session?.data?.class})

+
+
+
+ +
+

Savage Tracking

+

Hi, {session?.data?.name} ({session?.data?.grade} {session?.data?.class})

+
+ +
+
+ + + + + + + { + session?.data?.isAdmin && ( + <> + + + + + + + + + + + ) + }
- -
-
- - - - - - - { - session?.data?.isAdmin && ( - <> - - - - - - - - - - - ) - }
+
) } \ No newline at end of file diff --git a/src/pages/dash.tsx b/src/pages/dash/index.tsx similarity index 94% rename from src/pages/dash.tsx rename to src/pages/dash/index.tsx index fe390f4..2e643c3 100644 --- a/src/pages/dash.tsx +++ b/src/pages/dash/index.tsx @@ -24,7 +24,7 @@ export default function Dash() {
- +
) } \ No newline at end of file diff --git a/src/server/api/routers/admin.ts b/src/server/api/routers/admin.ts index c3eb74e..b64ad76 100644 --- a/src/server/api/routers/admin.ts +++ b/src/server/api/routers/admin.ts @@ -17,16 +17,7 @@ export const adminRouter = createTRPCRouter({ }).then((user) => { const result = compareSync(input.password, user?.password || ""); if (result) { - console.log(user) - console.log(PublicUserType.parse({ - grade: user?.grade, - class: user?.class, - name: user?.name, - username: user?.username, - isAdmin: user?.isAdmin, - })) const session = PublicUserType.parse(user)!; - console.log(session) const token = jwt.sign(session, process.env.JWT_SECRET || "", { expiresIn: "1d" }); ctx.res.setHeader("Set-Cookie", `token=${token}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${60 * 60 * 24};`); return {