From 5dc1a7d219387c16f16a8b53619b0a1d30e57fb2 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 27 Jan 2025 13:31:47 +0100 Subject: [PATCH] Update page.tsx --- frontend/src/app/category-view/page.tsx | 46 +++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/category-view/page.tsx b/frontend/src/app/category-view/page.tsx index aec49a34..08474eb1 100644 --- a/frontend/src/app/category-view/page.tsx +++ b/frontend/src/app/category-view/page.tsx @@ -52,8 +52,9 @@ const CategoryView = () => { : text; }; - const getRandomLogos = (scripts: any[], count: number) => { - return scripts.sort(() => Math.random() - 0.5).slice(0, count); + const getRandomScripts = (scripts: any[]) => { + if (!scripts || scripts.length <= 5) return scripts; + return scripts.sort(() => 0.5 - Math.random()).slice(0, 5); }; return ( @@ -66,12 +67,16 @@ const CategoryView = () => { -
Created at: {script.date_created || "No date available"}
++ Created at: {script.date_created || "No date available"} +
{truncateDescription(script.description || "No description available.")}
{categories.reduce((acc, cat) => acc + (cat.scripts?.length || 0), 0)} Total scripts
{category.description || "No description available."}