import React from "react";
import {
  IconCircleCheck,
  IconAlertTriangle,
  IconX,
  IconCircleDashed,
} from "@tabler/icons-react";

export const statusMap = {
  healthy: { label: "Healthy", color: "green", labelCn: "健康" },
  warning: { label: "Warning", color: "orange", labelCn: "警告" },
  error: { label: "Error", color: "red", labelCn: "错误" },
};

export const statusOptions = Object.entries(statusMap).map(([value, { label }]) => ({
  value,
  label,
}));

export const healthStatus = (status) => {
  switch (status) {
    case "activate":
    case "healthy":
    case "online":
      return { color: "green", icon: React.createElement(IconCircleCheck, { size: 16 }) };
    case "warning":
      return { color: "yellow", icon: React.createElement(IconAlertTriangle, { size: 16 }) };
    case "error":
    case "fail":
      return { color: "red", icon: React.createElement(IconX, { size: 16 }) };
    default:
      return { color: "gray", icon: React.createElement(IconCircleDashed, { size: 16 }) };
  }
};
