main
UI Deploy (Next-Auth Support) 🎨 / build-and-deploy (push) Has been cancelled

This commit is contained in:
Harun CAN
2026-03-30 15:18:32 +03:00
parent 8bd995ea18
commit 0722faeee9
12 changed files with 12796 additions and 13 deletions
+27 -1
View File
@@ -2,7 +2,7 @@
import { usePathname } from "next/navigation";
import { motion, AnimatePresence } from "framer-motion";
import { Home, FolderOpen, LayoutGrid, Settings, Sparkles, AtSign } from "lucide-react";
import { Home, FolderOpen, LayoutGrid, Settings, Sparkles, AtSign, ShieldCheck } from "lucide-react";
import Link from "next/link";
import { cn } from "@/lib/utils";
import { useCreditBalance, useCurrentUser } from "@/hooks/use-api";
@@ -16,6 +16,8 @@ const navItems = [
{ href: "/dashboard/settings", icon: Settings, label: "Ayarlar" },
];
const adminNavItem = { href: "/dashboard/admin", icon: ShieldCheck, label: "Admin Panel" };
export function MobileNav() {
const pathname = usePathname();
const localePath = pathname.replace(/^\/[a-z]{2}/, "");
@@ -97,6 +99,12 @@ function CreditCard() {
export function DesktopSidebar() {
const pathname = usePathname();
const localePath = pathname.replace(/^\/[a-z]{2}/, "");
const { data } = useCurrentUser();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const user = (data as any)?.data ?? data;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const roles: string[] = (user?.roles ?? []).map((r: any) => r?.role?.name ?? r?.name ?? "");
const isAdmin = roles.includes("admin") || roles.includes("superadmin");
return (
<aside className="hidden md:flex md:w-64 lg:w-72 flex-col h-screen sticky top-0 border-r border-[var(--color-border-faint)] bg-[var(--color-bg-deep)]">
@@ -150,6 +158,24 @@ export function DesktopSidebar() {
{/* Credits Card */}
<CreditCard />
{/* Admin Panel Linki (sadece admin) */}
{isAdmin && (
<div className="px-3 pb-3">
<Link
href={adminNavItem.href}
className={cn(
"relative flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200",
localePath.startsWith("/dashboard/admin")
? "text-rose-300 bg-rose-500/10"
: "text-[var(--color-text-muted)] hover:text-rose-300 hover:bg-rose-500/8"
)}
>
<ShieldCheck size={18} strokeWidth={1.8} />
<span>{adminNavItem.label}</span>
</Link>
</div>
)}
</aside>
);
}