import { BuildFilled, LoginOutlined } from "@ant-design/icons";
import { connect } from "react-redux";
import { Link } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { selectCurrentUser } from "../../redux/user/user.selectors";

const mapStateToProps = createStructuredSelector({
  currentUser: selectCurrentUser
});

export function ManageSignInButton({ currentUser }) {
  return currentUser.authorized ? (
    <Link to="/manage/">
      <BuildFilled />
      Manage
    </Link>
  ) : (
    <Link to="/signin">
      <LoginOutlined />
      Sign In
    </Link>
  );
}

export default connect(mapStateToProps, null)(ManageSignInButton);
