diff --git a/app/(page)/admin/create-news/create-news.tsx b/app/(page)/admin/create-news/create-news.tsx index 02f8467..d16e4cb 100644 --- a/app/(page)/admin/create-news/create-news.tsx +++ b/app/(page)/admin/create-news/create-news.tsx @@ -10,6 +10,7 @@ import { // Importe o componente que criámos (ajuste o caminho se necessário) import MultiAspectEditor from '../../../components/MultiAspectEditor'; import dynamic from "next/dynamic"; +import { getFlat, type Category } from "@/lib/categories.api"; // import { keycloak } from '@/app/feature/auth/keycloak-config'; const Editor = dynamic( () => import("@tinymce/tinymce-react").then((mod) => mod.Editor), @@ -68,9 +69,31 @@ export const CreateNewsPage = () => { name?: string; picture?: string; } | null>(null); + + const [categories, setCategories] = useState([]); + const [categoriesLoading, setCategoriesLoading] = useState(true); + const [categoryId, setCategoryId] = useState(""); const fileInputRef = useRef(null); + useEffect(() => { + let cancelled = false; + (async () => { + setCategoriesLoading(true); + try { + const list = await getFlat(); + if (!cancelled) setCategories(list); + } catch { + if (!cancelled) setCategories([]); + } finally { + if (!cancelled) setCategoriesLoading(false); + } + })(); + return () => { + cancelled = true; + }; + }, []); + // 2. Lógica de Upload const handleFileChange = (e: React.ChangeEvent) => { if (e.target.files && e.target.files.length > 0) { @@ -191,10 +214,20 @@ export const CreateNewsPage = () => { - setCategoryId(e.target.value)} + disabled={categoriesLoading} + className="w-full bg-slate-50 border border-slate-100 rounded-lg px-3 py-2 text-sm outline-none disabled:opacity-60" + > + + {categories.map((c) => ( + + ))} diff --git a/app/(page)/admin/create-news/page.tsx b/app/(page)/admin/create-news/page.tsx index 822d512..209f182 100644 --- a/app/(page)/admin/create-news/page.tsx +++ b/app/(page)/admin/create-news/page.tsx @@ -1,22 +1,7 @@ import CreateNewsPage from './create-news'; -import { AdminHeaderPage } from '@/app/components/layout/admin/header'; -import { AdminSideBar } from '@/app/components/layout/admin/sidebar'; - const CreateNews = () => { - return ( -
- - {/* Sidebar Lateral */} - - - {/* Main Content Area */} -
- - -
-
- ); + return ; }; -export default CreateNews; \ No newline at end of file +export default CreateNews; diff --git a/app/(page)/admin/dashboard/page.tsx b/app/(page)/admin/dashboard/page.tsx index 5c11f27..25da434 100644 --- a/app/(page)/admin/dashboard/page.tsx +++ b/app/(page)/admin/dashboard/page.tsx @@ -2,25 +2,16 @@ import React from 'react'; import { Newspaper, TrendingUp, - Eye, Clock, AlertCircle, ChevronRight, Edit3, Trash2, } from 'lucide-react'; -import { AdminHeaderPage } from '@/app/components/layout/admin/header'; -import { AdminSideBar } from '@/app/components/layout/admin/sidebar'; const DashboardMain = () => { return ( -
- - -
- - -
+
{
-
- ); }; diff --git a/app/(page)/admin/layout.tsx b/app/(page)/admin/layout.tsx new file mode 100644 index 0000000..4d3f33d --- /dev/null +++ b/app/(page)/admin/layout.tsx @@ -0,0 +1,15 @@ +import { AdminHeaderPage } from '@/app/components/layout/admin/header'; +import { AdminSideBar } from '@/app/components/layout/admin/sidebar'; + +export default function AdminLayout({ children }: { children: React.ReactNode }) { + return ( +
+ + +
+ +
{children}
+
+
+ ); +} diff --git a/app/(page)/admin/manage-category/page.tsx b/app/(page)/admin/manage-category/page.tsx index 3f8fe0c..b7462cf 100644 --- a/app/(page)/admin/manage-category/page.tsx +++ b/app/(page)/admin/manage-category/page.tsx @@ -1,16 +1,5 @@ -import { AdminHeaderPage } from '@/app/components/layout/admin/header'; -import { AdminSideBar } from '@/app/components/layout/admin/sidebar'; import ManageCategoryClient from './manage-category-client'; export default function ManageCategoryPage() { - return ( -
- - -
- - -
-
- ); + return ; } diff --git a/app/(page)/admin/panel/page.tsx b/app/(page)/admin/panel/page.tsx index 6fe542a..263d795 100644 --- a/app/(page)/admin/panel/page.tsx +++ b/app/(page)/admin/panel/page.tsx @@ -1,18 +1,5 @@ -import { AdminHeaderPage } from '@/app/components/layout/admin/header'; -import { AdminSideBar } from '@/app/components/layout/admin/sidebar'; import PanelEditor from './panel-editor'; export default function PanelPage() { - return ( -
- - -
- -
- -
-
-
- ); + return ; }