import { useTranslation } from "react-i18next"; import useSWR from "swr"; export default function Status({ service }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`); if (error) {
{t("docker.error")}
} if (data) { let statusLabel = ""; if (data.status?.includes("running")) { if (data.health === "starting") { return (
{t("docker.starting")}
); } if (data.health === "unhealthy") { return (
{t("docker.unhealthy")}
); } if (!data.health) { statusLabel = data.status.replace("running", t("docker.running")) } else { statusLabel = data.health === "healthy" ? t("docker.healthy") : data.health } return (
{statusLabel}
); } if (data.status === "not found" || data.status === "exited" || data.status?.startsWith("partial")) { if (data.status === "not found") statusLabel = t("docker.not_found") else if (data.status === "exited") statusLabel = t("docker.exited") else statusLabel = data.status.replace("partial", t("docker.partial")) return (
{statusLabel}
); } } return (
{t("docker.unknown")}
); }