import { useScripts, useDeleteScript } from '@/api/hooks' import { Plus, Trash2, FileCode, RefreshCw } from 'lucide-react' import type { Script } from '@/api/types' export default function Scripts() { const { data: scripts, isLoading, refetch } = useScripts() const deleteScript = useDeleteScript() const handleDelete = async (id: number) => { if (confirm('Delete this script?')) { await deleteScript.mutateAsync(id) } } if (isLoading) { return
Loading...
} return (
{/* Header */}

Scripts

{/* Grid */}
{scripts?.map(script => ( handleDelete(script.id)} /> ))} {(!scripts || scripts.length === 0) && (
No scripts found
)}
) } function ScriptCard({ script, onDelete }: { script: Script; onDelete: () => void }) { const formatDate = (date: string) => { return new Date(date).toLocaleDateString() } const getLanguageColor = (lang: string) => { const colors: Record = { python: '#3776ab', javascript: '#f7df1e', typescript: '#3178c6', go: '#00add8', bash: '#4eaa25', shell: '#4eaa25', } return colors[lang?.toLowerCase()] || '#6b7280' } return (
{script.name}
{script.filename}
{script.language || 'Unknown'}
Updated: {formatDate(script.updated_at)}
) }