'use client'; import { Button } from './ui/button'; import { StatusBadge } from './Badge'; import { getContrastColor } from '../../lib/colorUtils'; interface InstalledScript { id: number; script_name: string; script_path: string; container_id: string | null; server_id: number | null; server_name: string | null; server_ip: string | null; server_user: string | null; server_password: string | null; server_color: string | null; installation_date: string; status: 'in_progress' | 'success' | 'failed'; output_log: string | null; } interface ScriptInstallationCardProps { script: InstalledScript; isEditing: boolean; editFormData: { script_name: string; container_id: string }; onInputChange: (field: 'script_name' | 'container_id', value: string) => void; onEdit: () => void; onSave: () => void; onCancel: () => void; onUpdate: () => void; onDelete: () => void; isUpdating: boolean; isDeleting: boolean; } export function ScriptInstallationCard({ script, isEditing, editFormData, onInputChange, onEdit, onSave, onCancel, onUpdate, onDelete, isUpdating, isDeleting }: ScriptInstallationCardProps) { const formatDate = (dateString: string) => { return new Date(dateString).toLocaleString(); }; return (
{/* Header with Script Name and Status */}
{isEditing ? (
onInputChange('script_name', e.target.value)} className="w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary" placeholder="Script name" />
{script.script_path}
) : (
{script.script_name}
{script.script_path}
)}
{script.status.replace('_', ' ').toUpperCase()}
{/* Details Grid */}
{/* Container ID */}
Container ID
{isEditing ? ( onInputChange('container_id', e.target.value)} className="w-full px-2 py-1 text-sm font-mono border border-border rounded bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary" placeholder="Container ID" /> ) : (
{script.container_id ?? '-'}
)}
{/* Server */}
Server
{script.server_name ?? '-'}
{/* Installation Date */}
Installation Date
{formatDate(String(script.installation_date))}
{/* Action Buttons */}
{isEditing ? ( <> ) : ( <> {script.container_id && ( )} )}
); }