import React, {useState} from 'react';
import {BrowserView, MobileView} from "react-device-detect";
import {Link} from 'react-router-dom';
import List from '@material-ui/core/List';
import Avatar from '@material-ui/core/Avatar';
import Menu from '@material-ui/core/Menu';
import ListItem from '@material-ui/core/ListItem';
import MenuItem from '@material-ui/core/MenuItem';
import Select from '@material-ui/core/Select';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import HomeIcon from '@material-ui/icons/Home';
import PolymerIcon from '@material-ui/icons/Polymer';
import AppsIcon from '@material-ui/icons/Apps';
import DescriptionIcon from '@material-ui/icons/Description';
import Grid from '@material-ui/core/Grid';
import { useTheme } from '@material-ui/core/styles';
const hoverColor = "#f85a3e"
const hoverOutColor = "#e8eaf6"
const Header = props => {
const { globalUrl, isLoggedIn, removeCookie, homePage, isLoaded, userdata, cookies } = props;
const theme = useTheme();
const [HomeHoverColor, setHomeHoverColor] = useState(hoverOutColor);
const [SoarHoverColor, setSoarHoverColor] = useState(hoverOutColor);
const [LoginHoverColor, setLoginHoverColor] = useState(hoverOutColor);
const [DocsHoverColor, setDocsHoverColor] = useState(hoverOutColor);
const [HelpHoverColor, setHelpHoverColor] = useState(hoverOutColor);
const [anchorEl, setAnchorEl] = React.useState(null);
const hrefStyle = {
color: hoverOutColor,
textDecoration: "none",
}
// DEBUG HERE
const handleClickLogout = () => {
console.log("COOKIES: ", cookies, "Remover: ", removeCookie)
// Don't really care about the logout
fetch(globalUrl+"/api/v1/logout", {
credentials: "include",
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
})
.then(() => {
// Log out anyway
//cookies.remove("session_token")
//window.location.pathname = "/"
console.log("Should've logged out")
removeCookie("session_token", {path: "/"})
removeCookie("session_token", {path: "/workflows"})
window.location.reload()
})
.catch(error => {
console.log("Error in logout: ", error)
removeCookie("session_token", {path: "/"})
window.location.reload()
//removeCookie("session_token", {path: "/"})
})
}
// Rofl this is weird
const handleDocsHover = () => {
setDocsHoverColor(hoverColor)
}
const handleDocsHoverOut = () => {
setDocsHoverColor(hoverOutColor)
}
const handleHomeHover = () => {
setHomeHoverColor(hoverColor)
}
const handleHelpHover = () => {
setHelpHoverColor(hoverColor)
}
const handleHelpHoverOut = () => {
setHelpHoverColor(hoverOutColor)
}
const handleSoarHover = () => {
setSoarHoverColor(hoverColor)
}
const handleSoarHoverOut = () => {
setSoarHoverColor(hoverOutColor)
}
const handleHomeHoverOut = () => {
setHomeHoverColor(hoverOutColor)
}
const handleLoginHover = () => {
setLoginHoverColor(hoverColor)
}
const handleLoginHoverOut = () => {
setLoginHoverColor(hoverOutColor)
}
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
// Should be based on some path
const avatarMenu =