diff --git a/frontend/src/app/category-view/page.tsx b/frontend/src/app/category-view/page.tsx index 6050f4ae..aec49a34 100644 --- a/frontend/src/app/category-view/page.tsx +++ b/frontend/src/app/category-view/page.tsx @@ -52,6 +52,10 @@ const CategoryView = () => { : text; }; + const getRandomLogos = (scripts: any[], count: number) => { + return scripts.sort(() => Math.random() - 0.5).slice(0, count); + }; + return (
{categories.length === 0 && ( @@ -62,7 +66,7 @@ const CategoryView = () => { -

{selectedCategory.name}

+

{selectedCategory.name}

{selectedCategory.scripts .sort((a, b) => a.name.localeCompare(b.name)) @@ -94,7 +98,7 @@ const CategoryView = () => { ) : (
-

Categories

+

Categories

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

@@ -107,19 +111,19 @@ const CategoryView = () => { className="cursor-pointer hover:shadow-lg flex flex-col items-center justify-center" > -
- {category.scripts && category.scripts.slice(0, 4).map((script, index) => ( +
+ {category.scripts && getRandomLogos(category.scripts, 5).map((script, index) => ( {script.name ))}

{category.name}

-

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

+ {category.description || "No description available."}

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