diff --git a/src/pages/Home.js b/src/pages/Home.js index fdfe9ef..782c93b 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -12,14 +12,12 @@ import { FormControlLabel, IconButton, Link, - Menu, - MenuItem, Typography } from "@material-ui/core"; import { red } from "@material-ui/core/colors"; -import { AccountCircle, Favorite, Link as LinkIcon, Delete } from "@material-ui/icons"; -import { useHistory } from "react-router-dom"; +import { Favorite, Link as LinkIcon, Delete } from "@material-ui/icons"; import NavBar from "./shared/NavBar"; +import NavBarUser from "./shared/NavBarUser"; import config from "../config"; // TODO: Replace with API accessed feeds @@ -78,23 +76,7 @@ FeedCard.propTypes = { }; function App() { - const history = useHistory(); - const [anchorEl, setAnchorEl] = useState(null); const [categories, setCategories] = useState(feedCategories); - const open = Boolean(anchorEl); - - function handleMenu(event) { - setAnchorEl(event.currentTarget); - } - - function handleClose() { - setAnchorEl(null); - } - - function logout() { - handleClose(); - history.push("/"); - } function toggleCategory(category) { if (categories.includes(category)) @@ -115,36 +97,7 @@ function App() { return (<> -
- - - - - Profile - My account - Logout - -
+
diff --git a/src/pages/shared/NavBarUser.js b/src/pages/shared/NavBarUser.js new file mode 100644 index 0000000..d87dafd --- /dev/null +++ b/src/pages/shared/NavBarUser.js @@ -0,0 +1,63 @@ +import React, { useState } from "react"; +import { useHistory } from "react-router-dom"; +import { AccountCircle } from "@material-ui/icons"; + +import { + IconButton, + Menu, + MenuItem, +} from "@material-ui/core"; + +function NavBarUser() { + const history = useHistory(); + const [anchorEl, setAnchorEl] = useState(null); + const open = Boolean(anchorEl); + + function handleMenu(event) { + setAnchorEl(event.currentTarget); + } + + function handleClose() { + setAnchorEl(null); + } + + function logout() { + handleClose(); + history.push("/"); + } + + return ( +
+ + + + + Profile + My account + Logout + +
+ ); +} + +export default NavBarUser;