import React from "react";
import { connect } from "react-redux";
import { Redirect } 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)(LandingPage);

export function LandingPage({ currentUser }) {
  if (currentUser.authorized) return <Redirect to={"/manage"} />;

  return <Redirect to={"/signin"} />;
}
