From ce1a38eb50358a94b4f34302848e6e951f319689 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 27 Jan 2025 13:53:00 +0100 Subject: [PATCH] Update page.tsx --- frontend/src/app/category-view/page.tsx | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/category-view/page.tsx b/frontend/src/app/category-view/page.tsx index 2d2e198b..cad896ff 100644 --- a/frontend/src/app/category-view/page.tsx +++ b/frontend/src/app/category-view/page.tsx @@ -58,17 +58,17 @@ const CategoryView = () => { }; return ( -
+
{categories.length === 0 && (

No categories available. Please check the API endpoint.

)} {selectedCategory ? (
- -

{selectedCategory.name}

-
+

{selectedCategory.name}

+
{selectedCategory.scripts .sort((a, b) => a.name.localeCompare(b.name)) .map((script) => ( @@ -108,29 +108,34 @@ const CategoryView = () => {
) : (
-
-

Categories

+
+

Categories

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

-
+
{categories.map((category) => ( handleCategoryClick(category)} - className="cursor-pointer hover:shadow-lg flex flex-col items-center justify-center" + className="cursor-pointer hover:shadow-lg flex flex-col items-center justify-center py-6" > -

{category.name}

-
+

{category.name}

+
{category.scripts && getRandomScripts(category.scripts).map((script, index) => ( {script.name { + e.stopPropagation(); // Prevent card click + handleScriptClick(script.slug); + }} + className="h-8 w-8 object-contain cursor-pointer hover:scale-110 transition-transform" /> ))}