"use client"; import { Container } from "@/types"; import { motion } from "framer-motion"; import { ExternalLink, Power, Circle } from "lucide-react"; interface ContainerGroupProps { title: string; containers: Container[]; icon: string; } export default function ContainerGroup({ title, containers, icon, }: ContainerGroupProps) { const getStatusColor = (state: string) => { switch (state.toLowerCase()) { case "running": return "text-green-500"; case "paused": return "text-yellow-500"; case "exited": return "text-red-500"; default: return "text-gray-500"; } }; const getTraefikUrl = (labels: Record) => { const host = labels["traefik.http.routers.https.rule"]; if (host) { const match = host.match(/Host\(`([^`]+)`\)/); if (match) return `https://${match[1]}`; } return null; }; return (

{icon} {title} {containers.length}{" "} {containers.length === 1 ? "container" : "containers"}

{containers.map((container, idx) => { const url = getTraefikUrl(container.labels); return (

{container.name}

{container.image}

Status {container.status}
{container.ports.length > 0 && (
Ports {container.ports .filter((p) => p.publicPort) .map((p) => p.publicPort) .join(", ") || "Internal"}
)} {url && ( Open )}
); })}
); }