@@ -29,6 +29,7 @@ const formattedBadge = (type: string) => {
2929const CategoryView = ( ) => {
3030 const [ categories , setCategories ] = useState < Category [ ] > ( [ ] ) ;
3131 const [ selectedCategoryIndex , setSelectedCategoryIndex ] = useState < number | null > ( null ) ;
32+ const [ currentScripts , setCurrentScripts ] = useState < any [ ] > ( [ ] ) ;
3233 const [ logoIndices , setLogoIndices ] = useState < { [ key : string ] : number } > ( { } ) ;
3334 const router = useRouter ( ) ;
3435
@@ -59,10 +60,12 @@ const CategoryView = () => {
5960
6061 const handleCategoryClick = ( index : number ) => {
6162 setSelectedCategoryIndex ( index ) ;
63+ setCurrentScripts ( categories [ index ] ?. scripts || [ ] ) ; // Update scripts for the selected category
6264 } ;
6365
6466 const handleBackClick = ( ) => {
6567 setSelectedCategoryIndex ( null ) ;
68+ setCurrentScripts ( [ ] ) ; // Clear scripts when going back
6669 } ;
6770
6871 const handleScriptClick = ( scriptSlug : string ) => {
@@ -76,6 +79,7 @@ const CategoryView = () => {
7679 ? ( selectedCategoryIndex - 1 + categories . length ) % categories . length
7780 : ( selectedCategoryIndex + 1 ) % categories . length ;
7881 setSelectedCategoryIndex ( newIndex ) ;
82+ setCurrentScripts ( categories [ newIndex ] ?. scripts || [ ] ) ; // Update scripts for the new category
7983 }
8084 } ;
8185
@@ -151,7 +155,7 @@ const CategoryView = () => {
151155
152156 { /* Scripts Grid */ }
153157 < div className = "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6" >
154- { categories [ selectedCategoryIndex ] . scripts
158+ { currentScripts
155159 . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
156160 . map ( ( script ) => (
157161 < Card
0 commit comments