Change "Account" to user email when signed out.
This commit is contained in:
parent
f95abb2035
commit
7129071a55
|
@ -98,7 +98,7 @@ const signIn = (email, password) => {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Header items={nav} />
|
<Header items={nav} user={auth} />
|
||||||
<AuthContext.Provider value={auth}>
|
<AuthContext.Provider value={auth}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Home greeting="Hey you're at home!" />} />
|
<Route path="/" element={<Home greeting="Hey you're at home!" />} />
|
||||||
|
|
|
@ -3,24 +3,38 @@ import Navbar from "react-bootstrap/Navbar"
|
||||||
import Nav from "react-bootstrap/Nav"
|
import Nav from "react-bootstrap/Nav"
|
||||||
import NavDropdown from "react-bootstrap/NavDropdown"
|
import NavDropdown from "react-bootstrap/NavDropdown"
|
||||||
|
|
||||||
export function Header ( props ) {
|
export function Header(props) {
|
||||||
// props.items is the value of nav state in App.js
|
// props.items is the value of nav state in App.js
|
||||||
// create a collection of navigation items
|
// create a collection of navigation items
|
||||||
const Links = props.items.map( (item, itemkey) => {
|
const Links = props.items.map((item, itemkey) => {
|
||||||
return (
|
|
||||||
<Nav.Link href={item.link} key={itemkey}> {item.label} </Nav.Link>
|
|
||||||
)
|
|
||||||
} )
|
|
||||||
return (
|
return (
|
||||||
<Navbar>
|
<Nav.Link href={item.link} key={itemkey}> {item.label} </Nav.Link>
|
||||||
<Container>
|
)
|
||||||
<Navbar.Brand>App</Navbar.Brand>
|
})
|
||||||
<Nav>
|
// component for Account
|
||||||
{Links}
|
const Account = (props) => {
|
||||||
<NavDropdown title="Account">
|
if (props.user) {
|
||||||
<NavDropdown.Item>Log out</NavDropdown.Item>
|
return (
|
||||||
</NavDropdown>
|
<NavDropdown title="Account">
|
||||||
</Nav>
|
<NavDropdown.Item href="/signout">Log out</NavDropdown.Item>
|
||||||
</Container>
|
</NavDropdown>
|
||||||
</Navbar>)
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Navbar>
|
||||||
|
<Container>
|
||||||
|
<Navbar.Brand>App</Navbar.Brand>
|
||||||
|
<Nav>
|
||||||
|
{Links}
|
||||||
|
<NavDropdown title={props.user.email}>
|
||||||
|
<NavDropdown.Item href="/signout">Log out</NavDropdown.Item>
|
||||||
|
</NavDropdown>
|
||||||
|
</Nav>
|
||||||
|
</Container>
|
||||||
|
</Navbar>)
|
||||||
}
|
}
|
Loading…
Reference in New Issue