"use client"; import { useState} from "react"; import { motion } from "framer-motion"; import { Package, Search, Download, ToggleLeft, ToggleRight, RefreshCw } from "lucide-react"; import { BUILTIN_EXTENSIONS } from "@/constants/extensions"; import { toast } from "sonner"; type ExtCategory = "all" | "installed" | "Language" | "Snippets" | "Formatter" | "Linter" | "SCM" | "Tools"; const CATEGORIES: { id: ExtCategory; label: string }[] = [ { id: "all", label: "All" }, { id: "installed", label: "Installed" }, { id: "Language", label: "Language" }, { id: "Snippets", label: "Snippets" }, { id: "Formatter", label: "Formatter" }, { id: "Linter", label: "Linter" }, { id: "SCM", label: "SCM" }, ]; export default function ExtensionPanel() { const [search, setSearch] = useState(""); const [category, setCategory] = useState("all"); const [enabled, setEnabled] = useState>(() => Object.fromEntries(BUILTIN_EXTENSIONS.map((e) => [e.id, e.enabled])) ); const [installed, setInstalled] = useState>(() => Object.fromEntries(BUILTIN_EXTENSIONS.map((e) => [e.id, e.preinstalled])) ); const [installing, setInstalling] = useState(null); const toggle = (id: string) => { setEnabled((prev) => ({ ...prev, [id]: !prev[id] })); toast.success(enabled[id] ? "Extension disabled" : "Extension enabled"); }; const install = async (id: string) => { setInstalling(id); await new Promise((r) => setTimeout(r, 1200)); setInstalled((prev) => ({ ...prev, [id]: true })); setEnabled((prev) => ({ ...prev, [id]: true })); setInstalling(null); toast.success(`Extension installed!`); }; const filtered = BUILTIN_EXTENSIONS.filter((ext) => { const matchSearch = search ? ext.name.toLowerCase().includes(search.toLowerCase()) || ext.description.toLowerCase().includes(search.toLowerCase()) : true; const matchCat = category === "all" ? true : category === "installed" ? installed[ext.id] : ext.category === category; return matchSearch && matchCat; }); return (
{/* Header */}
Extensions
{/* Search */}
setSearch(e.target.value)} />
{/* Category tabs */}
{CATEGORIES.map((cat) => ( ))}
{/* Extension list */}
{filtered.map((ext) => (
{ext.icon}
{ext.name} {installed[ext.id] && ( Installed )}

{ext.description}

{ext.publisher} · v{ext.version} {ext.category}
{/* Actions */}
{installed[ext.id] ? ( ) : ( )}
))} {filtered.length === 0 && (

No extensions found

)}
); }