Skip to content

Commit 795ab8c

Browse files
committed
Admin page added
1 parent 54dc104 commit 795ab8c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

app/admin/page.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import * as React from "react"
2+
3+
import { headers } from "next/headers"
4+
import { redirect } from "next/navigation"
5+
6+
import { auth } from "@/lib/auth"
7+
8+
const AdminPage: React.FC = async () => {
9+
const session = await auth.api.getSession({
10+
headers: await headers(),
11+
})
12+
13+
if (!session?.user) return redirect("/auth/")
14+
15+
return (
16+
<main>
17+
<section className="p-6 md:p-15 h-dvh">
18+
<div className="grid place-content-center h-full bg-zinc-100 relative">
19+
<div className="flex flex-col gap-4">
20+
<p>
21+
Welcome{" "}
22+
<span className="underline underline-offset-2">
23+
{session.user.name}
24+
</span>
25+
!
26+
</p>
27+
<form
28+
action={async () => {
29+
"use server"
30+
await auth.api.signOut({
31+
headers: await headers(),
32+
})
33+
redirect("/auth/")
34+
}}
35+
>
36+
<button
37+
className="border-dashed w-full border border-zinc-300 transition-colors focus:border-zinc-800 hover:border-zinc-800 bg-zinc-50 px-3 py-2 text-sm cursor-pointer text-center"
38+
type="submit"
39+
>
40+
Sign Out
41+
</button>
42+
</form>
43+
</div>
44+
</div>
45+
</section>
46+
</main>
47+
)
48+
}
49+
50+
export default AdminPage

0 commit comments

Comments
 (0)