import {
  STATUS_DANGEROUS,
  STATUS_NORMAL,
  STATUS_SOS,
  STATUS_WARNING,
} from '@/constants';
import { Badge, GlobalToken } from 'antd';
import IconFont from '../IconFont';

export const getBadgeStatus = (status: number) => {
  switch (status) {
    case STATUS_NORMAL:
      return <Badge size="default" status="success" />;
    case STATUS_WARNING:
      return <Badge size="default" status="warning" />;
    case STATUS_DANGEROUS:
      return <Badge size="default" status="error" />;
    case STATUS_SOS:
      return <Badge size="default" status="error" />;
    default:
      return <Badge size="default" status="default" />;
  }
};

export const getBadgeConnection = (online: boolean) => {
  switch (online) {
    case true:
      return <Badge status="processing" />;
    default:
      return <IconFont type="icon-cloud-disconnect" />;
  }
};

export const getTitleColorByDeviceStateLevel = (
  level: number,
  token: GlobalToken,
) => {
  switch (level) {
    case STATUS_NORMAL:
      return token.colorSuccess;
    case STATUS_WARNING:
      return token.colorWarning;
    case STATUS_DANGEROUS:
      return token.colorError;
    case STATUS_SOS:
      return token.colorError;
    default:
      return token.colorText;
  }
};
