Last active
October 30, 2019 19:55
-
-
Save GergKllai1/ddc45570d48c37ccc52d5c70604d0e08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { connect } from "react-red"; | |
import { Link } from "react-router-dom"; | |
export const Header = ({ user }) => { | |
return ( | |
<> | |
{user.isSignedIn ? ( | |
<Link to="/logout">Logout</Link> | |
) : ( | |
<Link to="/login">To Login Page</Link> | |
)} | |
{user.isSignedIn && <Link to="/restricted">To Restricted Page</Link>} | |
{user.role === "teacher" && ( | |
<Link to="/only-teacher">To Only Teacher Page</Link> | |
)} | |
{user.role === "student" && ( | |
<Link to="/only-student">To Only Student Page</Link> | |
)} | |
</> | |
); | |
}; | |
const mapStateToProps = state => ({ | |
user: state.userReducer | |
}); | |
export default connect( | |
mapStateToProps, | |
null | |
)(Header); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment