import { Server, Database, Cloud, Globe, ExternalLink, Play, Loader } from 'lucide-react'; export default function InstanceCard({ service, vpcs, onAssignVpc, onRemoveVpc, onOpenConsole, isConnecting }) { const titleLower = (service.title || '').toLowerCase(); const isVPS = titleLower.includes('vps') || titleLower.includes('compute'); const isCloud = titleLower.includes('cloud') || titleLower.includes('nextcloud'); const isDB = titleLower.includes('db') || titleLower.includes('base') || titleLower.includes('sql'); const isWeb = !isVPS && !isCloud && !isDB; const hasIP = service.hostingDetails?.ip && service.hostingDetails.ip !== '127.0.0.1' && service.hostingDetails.ip !== ''; let buttonText = "CONSOLE D'ADMINISTRATION"; let ButtonIcon = ExternalLink; let buttonStyle = "bg-cyan-400/10 hover:bg-cyan-400 text-cyan-400 hover:text-gray-900 border-cyan-400"; if (isVPS) { if (hasIP) { buttonText = "GÉRER L'INSTANCE"; ButtonIcon = ExternalLink; } else { buttonText = "INITIALISATION"; ButtonIcon = Play; buttonStyle = "bg-yellow-500/10 text-yellow-500 hover:bg-yellow-500 hover:text-gray-900 border-yellow-500/50"; } } else if (isWeb) { buttonText = "GÉRER L'HÉBERGEMENT"; ButtonIcon = Globe; buttonStyle = "bg-emerald-400/10 hover:bg-emerald-400 text-emerald-400 hover:text-gray-900 border-emerald-400"; } else if (isCloud) { buttonText = "ACCÉDER AU CLOUD"; buttonStyle = "bg-blue-400/10 hover:bg-blue-400 text-blue-400 hover:text-gray-900 border-blue-400"; } else if (isDB) { buttonText = "PHPMYADMIN / CLUSTER"; ButtonIcon = Database; buttonStyle = "bg-purple-400/10 hover:bg-purple-400 text-purple-400 hover:text-gray-900 border-purple-400"; } const getServiceIcon = () => { if (isVPS) return ; if (isCloud) return ; if (isDB) return ; return ; }; const baseTitle = (service.title || '').split(/(?: for | pour )/i)[0].trim(); const shortTitle = baseTitle.split(' ').slice(0, 2).join(' '); const titleMatch = (service.title || '').match(/(?: for | pour )(.+)$/i); const domainFromTitle = titleMatch ? titleMatch[1].trim() : null; let displayDomain = service.hostingDetails?.domain && service.hostingDetails.domain !== '127.0.0.1' ? service.hostingDetails.domain : domainFromTitle || service.domain; if (!displayDomain || displayDomain === '127.0.0.1') displayDomain = null; return (
{getServiceIcon()}
{service.status === 'active' ? ( {isVPS && !hasIP ? 'AWAITING INIT' : 'ONLINE'} ) : ( DEPLOYING )}

{shortTitle}

{displayDomain ? (

{displayDomain}

) : (

En attente de déploiement

)}
Projet VPC:
); }