1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 17:51:49 +00:00

Update page.tsx

This commit is contained in:
CanbiZ 2025-01-27 17:48:22 +01:00 committed by GitHub
parent c3a21069d2
commit 661654987d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,6 +29,7 @@ const formattedBadge = (type: string) => {
const CategoryView = () => { const CategoryView = () => {
const [categories, setCategories] = useState<Category[]>([]); const [categories, setCategories] = useState<Category[]>([]);
const [selectedCategoryIndex, setSelectedCategoryIndex] = useState<number | null>(null); const [selectedCategoryIndex, setSelectedCategoryIndex] = useState<number | null>(null);
const [currentScripts, setCurrentScripts] = useState<any[]>([]);
const [logoIndices, setLogoIndices] = useState<{ [key: string]: number }>({}); const [logoIndices, setLogoIndices] = useState<{ [key: string]: number }>({});
const router = useRouter(); const router = useRouter();
@ -59,10 +60,12 @@ const CategoryView = () => {
const handleCategoryClick = (index: number) => { const handleCategoryClick = (index: number) => {
setSelectedCategoryIndex(index); setSelectedCategoryIndex(index);
setCurrentScripts(categories[index]?.scripts || []); // Update scripts for the selected category
}; };
const handleBackClick = () => { const handleBackClick = () => {
setSelectedCategoryIndex(null); setSelectedCategoryIndex(null);
setCurrentScripts([]); // Clear scripts when going back
}; };
const handleScriptClick = (scriptSlug: string) => { const handleScriptClick = (scriptSlug: string) => {
@ -76,6 +79,7 @@ const CategoryView = () => {
? (selectedCategoryIndex - 1 + categories.length) % categories.length ? (selectedCategoryIndex - 1 + categories.length) % categories.length
: (selectedCategoryIndex + 1) % categories.length; : (selectedCategoryIndex + 1) % categories.length;
setSelectedCategoryIndex(newIndex); setSelectedCategoryIndex(newIndex);
setCurrentScripts(categories[newIndex]?.scripts || []); // Update scripts for the new category
} }
}; };
@ -151,7 +155,7 @@ const CategoryView = () => {
{/* Scripts Grid */} {/* Scripts Grid */}
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6"> <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6">
{categories[selectedCategoryIndex].scripts {currentScripts
.sort((a, b) => a.name.localeCompare(b.name)) .sort((a, b) => a.name.localeCompare(b.name))
.map((script) => ( .map((script) => (
<Card <Card