"use client"; import { AppSidebar } from "@/components/app-sidebar" import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb" import { Separator } from "@/components/ui/separator" import { SidebarInset, SidebarProvider, SidebarTrigger, } from "@/components/ui/sidebar" import { Button } from "@/components/ui/button" import { Plus, Link, Home, Trash2 } from "lucide-react" // Importiere Icons import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card" import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, } from "@/components/ui/pagination" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { useState, useEffect } from "react"; import axios from 'axios'; export default function Dashboard() { const [name, setName] = useState(""); const [description, setDescription] = useState(""); const [icon, setIcon] = useState(""); const [publicURL, setPublicURL] = useState(""); const [localURL, setLocalURL] = useState(""); const [currentPage, setCurrentPage] = useState(1); const [maxPage, setMaxPage] = useState(1); const [applications, setApplications] = useState([]); const add = async () => { try { const response = await axios.post('/api/applications/add', { name, description, icon, publicURL, localURL }); // Nach erfolgreichem Hinzufügen kannst du auch die Liste neu laden: getApplications(); } catch (error: any) { console.log(error.response.data); } } const getApplications = async () => { try { const response = await axios.post('/api/applications/get', { page: currentPage }); setApplications(response.data.applications); setMaxPage(response.data.maxPage); } catch (error: any) { console.log(error.response); } } useEffect(() => { getApplications(); }, [currentPage]); const handlePrevious = () => { setCurrentPage(prev => Math.max(1, prev - 1)); } const handleNext = () => { setCurrentPage(prev => Math.min(maxPage, prev + 1)); } const deleteApplication = async (id: number) => { try { await axios.post('/api/applications/delete', { id }); getApplications(); } catch (error: any) { console.log(error.response.data); } } return (
/ Customization Applications
Your Applications Add an application
setName(e.target.value)}/>