mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-01 16:51:52 +00:00
remove and rename
This commit is contained in:
parent
a59f1cce8f
commit
4e6471e6a6
@ -1,12 +1,8 @@
|
|||||||
// Folder: category-view
|
|
||||||
// File: index.tsx
|
|
||||||
|
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { fetchCategories } from "@/lib/data";
|
|
||||||
import { Category, Script } from "@/lib/types";
|
import { Category, Script } from "@/lib/types";
|
||||||
|
|
||||||
const CategoryView = () => {
|
const CategoryView = () => {
|
||||||
@ -14,9 +10,26 @@ const CategoryView = () => {
|
|||||||
const [selectedCategory, setSelectedCategory] = useState<Category | null>(null);
|
const [selectedCategory, setSelectedCategory] = useState<Category | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCategories()
|
const fetchCategories = async () => {
|
||||||
.then(setCategories)
|
try {
|
||||||
.catch((error) => console.error("Error fetching categories:", error));
|
const response = await fetch("/json/metadata.json"); // JSON-Datei direkt laden
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Failed to fetch categories");
|
||||||
|
}
|
||||||
|
const metadata = await response.json();
|
||||||
|
const categories = metadata.categories.map((category: Category) => {
|
||||||
|
category.scripts = metadata.scripts.filter((script: Script) =>
|
||||||
|
script.categories.includes(category.id)
|
||||||
|
);
|
||||||
|
return category;
|
||||||
|
});
|
||||||
|
setCategories(categories);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching categories:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchCategories();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleCategoryClick = (category: Category) => {
|
const handleCategoryClick = (category: Category) => {
|
Loading…
x
Reference in New Issue
Block a user