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) => (