"use client" import { useState } from "react" import { usePlugins, useManagePlugin } from "@/hooks/use-plugins" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Badge } from "@/components/ui/badge" import { Switch } from "@/components/ui/switch" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table" import { Spinner } from "@/components/ui/spinner" import { toast } from "sonner" export default function PluginsPage() { const { data: plugins, isLoading } = usePlugins() const manage = useManagePlugin() const [name, setName] = useState("") const [pluginType, setPluginType] = useState("media_processor") const handleCreate = async (e: React.FormEvent) => { e.preventDefault() try { await manage.mutateAsync({ action: "create", name, plugin_type: pluginType, }) setName("") toast.success("Plugin created") } catch { toast.error("Failed to create plugin") } } const handleToggle = async (pluginId: string, enabled: boolean) => { try { await manage.mutateAsync({ action: enabled ? "enable" : "disable", plugin_id: pluginId, }) toast.success(enabled ? "Plugin enabled" : "Plugin disabled") } catch { toast.error("Failed to update plugin") } } return (