diff --git a/app/(page)/admin/create-news/create-news.tsx b/app/(page)/admin/create-news/create-news.tsx index 5e10e29..02f8467 100644 --- a/app/(page)/admin/create-news/create-news.tsx +++ b/app/(page)/admin/create-news/create-news.tsx @@ -158,12 +158,12 @@ export const CreateNewsPage = () => { {/* TinyMCE Editor */}
- setContent(newContent)} - /> + /> */}
diff --git a/app/components/layout/admin/admin-sidebar-nav.tsx b/app/components/layout/admin/admin-sidebar-nav.tsx new file mode 100644 index 0000000..ef2edc5 --- /dev/null +++ b/app/components/layout/admin/admin-sidebar-nav.tsx @@ -0,0 +1,90 @@ +"use client"; + +import type { ReactNode } from "react"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { + BarChart3, + FolderPlus, + HelpCircle, + LayoutDashboard, + Newspaper, + Settings, + Users, +} from "lucide-react"; + +type NavLinkItem = { + kind: "link"; + href: string; + label: string; + icon: ReactNode; +}; + +type NavDisabledItem = { + kind: "disabled"; + label: string; + icon: ReactNode; +}; + +const navItems: (NavLinkItem | NavDisabledItem)[] = [ + { kind: "link", href: "/admin/dashboard", label: "Painel", icon: }, + { kind: "disabled", label: "Meus Artigos", icon: }, + { kind: "disabled", label: "Equipa", icon: }, + { kind: "disabled", label: "Análises", icon: }, + { kind: "link", href: "/admin/create-news", label: "Adicionar Notícia", icon: }, + { + kind: "link", + href: "/admin/manage-category", + label: "Adicionar categoria", + icon: , + }, + { kind: "disabled", label: "Definições", icon: }, + { kind: "disabled", label: "Ajuda", icon: }, +]; + +function pathIsActive(pathname: string, href: string) { + if (pathname === href) return true; + if (href === "/admin/dashboard") return false; + return pathname.startsWith(`${href}/`); +} + +export function AdminSidebarNav() { + const pathname = usePathname(); + + return ( + + ); +} diff --git a/app/components/layout/admin/sidebar.tsx b/app/components/layout/admin/sidebar.tsx index 5582793..4a7fbd0 100644 --- a/app/components/layout/admin/sidebar.tsx +++ b/app/components/layout/admin/sidebar.tsx @@ -1,62 +1,48 @@ import { getUserProfile } from "@/src/lib/auth/get-user-profile"; -import { BarChart3, HelpCircle, LayoutDashboard, Newspaper, Settings, Users } from "lucide-react"; import { redirect } from "next/navigation"; -import Image from 'next/image'; +import Image from "next/image"; +import Link from "next/link"; +import { AdminSidebarNav } from "./admin-sidebar-nav"; export const AdminSideBar = async () => { - const user = await getUserProfile(); + const user = await getUserProfile(); - if (!user) { - redirect("/login"); - } + if (!user) { + redirect("/login"); + } return ( + ); }; - - - -// Componentes Auxiliares para Limpeza de Código -const NavItem = ({ icon, label, active = false }: { icon: any, label: string, active?: boolean }) => ( -
- {icon} - {label} -
- ); - - const ActivityItem = ({ user, action }: { user: string, action: string }) => ( +function ActivityItem({ user, action }: { user: string; action: string }) { + return (

@@ -64,4 +50,4 @@ const NavItem = ({ icon, label, active = false }: { icon: any, label: string, ac

); - \ No newline at end of file +}