mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-11 10:19:16 +00:00
Update index.tsx
This commit is contained in:
parent
70ef075ccd
commit
9f29a66bb7
@ -1,13 +1,23 @@
|
|||||||
import React, { useState } from 'react';
|
"use client";
|
||||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
|
||||||
import { Button } from '@/components/ui/button';
|
import React, { useEffect, useState } from "react";
|
||||||
import { routes } from '@/routes'; // Assuming your route.ts file is at this location
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||||
import { Grid } from '@mui/material'; // Using Material-UI's Grid
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Grid } from "@mui/material";
|
||||||
|
import { fetchCategories } from "@/lib/data";
|
||||||
|
import { Category } from "@/lib/types";
|
||||||
|
|
||||||
const CategoryView = () => {
|
const CategoryView = () => {
|
||||||
const [selectedCategory, setSelectedCategory] = useState(null);
|
const [categories, setCategories] = useState<Category[]>([]);
|
||||||
|
const [selectedCategory, setSelectedCategory] = useState<Category | null>(null);
|
||||||
|
|
||||||
const handleCategoryClick = (category) => {
|
useEffect(() => {
|
||||||
|
fetchCategories()
|
||||||
|
.then(setCategories)
|
||||||
|
.catch((error) => console.error("Error fetching categories:", error));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleCategoryClick = (category: Category) => {
|
||||||
setSelectedCategory(category);
|
setSelectedCategory(category);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -15,14 +25,6 @@ const CategoryView = () => {
|
|||||||
setSelectedCategory(null);
|
setSelectedCategory(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const categories = routes.map((route) => ({
|
|
||||||
name: route.category,
|
|
||||||
scripts: route.scripts.map((script) => ({
|
|
||||||
name: script.name,
|
|
||||||
date: script.date || 'N/A', // Assuming scripts have a `date` field
|
|
||||||
})),
|
|
||||||
}));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
{selectedCategory ? (
|
{selectedCategory ? (
|
||||||
@ -39,7 +41,7 @@ const CategoryView = () => {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<h3 className="text-lg font-medium">{script.name}</h3>
|
<h3 className="text-lg font-medium">{script.name}</h3>
|
||||||
<p className="text-sm text-gray-600">{script.date}</p>
|
<p className="text-sm text-gray-600">{script.date || "N/A"}</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
Reference in New Issue
Block a user