-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminNavbar.tsx
More file actions
43 lines (39 loc) · 1.14 KB
/
Copy pathAdminNavbar.tsx
File metadata and controls
43 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use client";
import { useClerk } from "@clerk/nextjs";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
export default function AdminNavbar() {
const { user, signOut } = useClerk();
const router = useRouter();
const allowedEmail = "msfunbook@gmail.com";
useEffect(() => {
if (user && user?.primaryEmailAddress?.emailAddress !== allowedEmail) {
router.push("/");
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user]);
return (
<div className="px-3">
<div className="m-auto flex h-10 max-w-5xl items-center justify-between gap-2">
<Link href="/admin" className="font-semibold underline">
Admin Dashboard
</Link>
<div className="space-x-2">
<span className="font-semibold">
{user?.primaryEmailAddress?.emailAddress}
</span>
<button
onClick={async () => {
await signOut();
router.push("/");
}}
className="underline"
>
Log out
</button>
</div>
</div>
</div>
);
}