import React, {useContext, useEffect, useState} from 'react'; import {Link} from "react-router-dom"; import {AuthContext} from "../App"; const pathsCenter = [ {name: "All Data", to: "/all", extra: ""}, {name: "Upload Data", to: "/upload", extra: ""}, {name: "My Data", to: "/mydata", extra: ""}, ] const pathsGuest = [ {name: "Log In", to: "/login", extra: ""}, {name: "Sign Up", to: "/register", extra: "rounded-full border border-white px-4 pb-1 pt-1 inline-block"}, ] const pathsLoggedIn = [ {name: "Account", to: "/account", extra: ""}, {name: "Logout", to: "/logout", extra: ""}, ] const pathsAdmin = [ {name: "Admin", to: "/admin", extra: ""}, {name: "Account", to: "/account", extra: ""}, {name: "Logout", to: "/logout", extra: ""}, ] function Navbar({color = "text-white", hover = "hover:border-white"}) { const [showDropdown, setDropdown] = useState(false) const [userPaths, setUserPaths] = useState(pathsGuest) const {authState} = useContext(AuthContext) useEffect(() => { console.log(authState) if (authState.loggedIn) { if (authState.admin) setUserPaths(() => pathsAdmin) else setUserPaths(() => pathsLoggedIn) } else setUserPaths(() => pathsGuest) }, [authState]) return

RainTrack

; } function LinksContainer(props) { return
{props.paths.map(path =>
{path.name}
)}
} export default Navbar;