import { connect } from "react-redux";
import { GlobalOutlined, WarningOutlined } from "@ant-design/icons";
import { createStructuredSelector } from "reselect";
import { selectWssStatus } from "../../redux/application/application.selectors";

const mapStateToProps = createStructuredSelector({
  wssStatus: selectWssStatus
});

const mapDispatchToProps = () => ({});

export function WssStatusDisplay({ wssStatus }) {
  console.log("🚀 ~ WssStatusDisplay ~ wssStatus:", wssStatus);

  let icon;
  let color;

  if (wssStatus === "connected") {
    icon = <GlobalOutlined />;
    color = "green";
  } else if (wssStatus === "error") {
    icon = <WarningOutlined />;
    color = "red";
  } else {
    icon = <GlobalOutlined />;
    color = "gray"; // Default for other statuses like "disconnected"
  }

  return <span style={{ color, marginRight: ".5rem" }}>{icon}</span>;
}

export default connect(mapStateToProps, mapDispatchToProps)(WssStatusDisplay);
