From 661654987da9ff553b4e780cdb0bb69cde19f955 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 27 Jan 2025 17:48:22 +0100 Subject: [PATCH] Update page.tsx --- frontend/src/app/category-view/page.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/category-view/page.tsx b/frontend/src/app/category-view/page.tsx index c8fc443f..5ad3251e 100644 --- a/frontend/src/app/category-view/page.tsx +++ b/frontend/src/app/category-view/page.tsx @@ -29,6 +29,7 @@ const formattedBadge = (type: string) => { const CategoryView = () => { const [categories, setCategories] = useState([]); const [selectedCategoryIndex, setSelectedCategoryIndex] = useState(null); + const [currentScripts, setCurrentScripts] = useState([]); const [logoIndices, setLogoIndices] = useState<{ [key: string]: number }>({}); const router = useRouter(); @@ -59,10 +60,12 @@ const CategoryView = () => { const handleCategoryClick = (index: number) => { setSelectedCategoryIndex(index); + setCurrentScripts(categories[index]?.scripts || []); // Update scripts for the selected category }; const handleBackClick = () => { setSelectedCategoryIndex(null); + setCurrentScripts([]); // Clear scripts when going back }; const handleScriptClick = (scriptSlug: string) => { @@ -76,6 +79,7 @@ const CategoryView = () => { ? (selectedCategoryIndex - 1 + categories.length) % categories.length : (selectedCategoryIndex + 1) % categories.length; setSelectedCategoryIndex(newIndex); + setCurrentScripts(categories[newIndex]?.scripts || []); // Update scripts for the new category } }; @@ -151,7 +155,7 @@ const CategoryView = () => { {/* Scripts Grid */}
- {categories[selectedCategoryIndex].scripts + {currentScripts .sort((a, b) => a.name.localeCompare(b.name)) .map((script) => (