import { BuildFilled, LoginOutlined } from "@ant-design/icons";
import React from "react";
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 default connect(
  mapStateToProps,
  null
)(function ManageSignInButton({ currentUser }) {
  return currentUser.authorized ? (
    <Link to="/manage">
      <BuildFilled />
      Manage
    </Link>
  ) : (
    <Link to="/signin">
      <LoginOutlined />
      Sign In
    </Link>
  );
});
