feat:admin
This commit is contained in:
@@ -1,4 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
|
||||
export default function Footer() {
|
||||
const [isAdmin, setIsAdmin] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
authClient.getSession().then((session) => {
|
||||
const user = session.data?.user as { role?: string } | undefined;
|
||||
setIsAdmin(user?.role === "admin");
|
||||
setIsLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<footer className="snap-section relative z-40 flex h-[250px] flex-col items-center justify-center bg-[#d09035]">
|
||||
<div className="text-center">
|
||||
@@ -21,6 +38,14 @@ export default function Footer() {
|
||||
<a href="/contact" className="transition-colors hover:text-white">
|
||||
Contact
|
||||
</a>
|
||||
{!isLoading && isAdmin && (
|
||||
<>
|
||||
<span className="text-white/40">|</span>
|
||||
<Link to="/admin" className="transition-colors hover:text-white">
|
||||
Admin
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-6 font-['Intro',sans-serif] text-white/50 text-xs">
|
||||
|
||||
Reference in New Issue
Block a user