From 250e77cff741fdb7b5b35373ac0958b04a0a759f Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 23 Jan 2025 11:40:58 +0100 Subject: [PATCH] formatting --- frontend/src/app/category-view/page.tsx | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/category-view/page.tsx b/frontend/src/app/category-view/page.tsx index c1ad9aa8..336fa6c5 100644 --- a/frontend/src/app/category-view/page.tsx +++ b/frontend/src/app/category-view/page.tsx @@ -15,7 +15,7 @@ const CategoryView = () => { const fetchCategories = async () => { try { const basePath = process.env.NODE_ENV === "production" ? "/ProxmoxVE" : ""; - const response = await fetch(`${basePath}/api/categories`); // Prüfe den Endpunkt + const response = await fetch(`${basePath}/api/categories`); if (!response.ok) { throw new Error("Failed to fetch categories"); } @@ -39,19 +39,18 @@ const CategoryView = () => { }; return ( -
- {categories.length === 0 ? ( -

- No categories available. Please check the API endpoint. -

- ) : selectedCategory ? ( +
+ {categories.length === 0 && ( +

No categories available. Please check the API endpoint.

+ )} + {selectedCategory ? (

{selectedCategory.name}

- {(selectedCategory.scripts || []) + {selectedCategory.scripts .sort((a, b) => a.name.localeCompare(b.name)) .map((script) => ( @@ -67,7 +66,12 @@ const CategoryView = () => {
) : (
-

Categories

+
+

Categories

+

+ {categories.reduce((acc, cat) => acc + (cat.scripts?.length || 0), 0)} Total scripts +

+
{categories.map((category) => ( { >
- {(category.scripts || []).slice(0, 4).map((script, index) => ( + {category.scripts && category.scripts.slice(0, 4).map((script, index) => ( {

{category.name}

- {(category as any).description || "No description available."} + {category.description || "No description available."}

@@ -100,4 +104,4 @@ const CategoryView = () => { ); }; -export default CategoryView; +export default CategoryView; \ No newline at end of file