// SPDX-FileCopyrightText: © 2017 EteSync Authors // SPDX-License-Identifier: AGPL-3.0-only import * as React from "react"; import { List, ListItem, ListSubheader, ListDivider } from "../widgets/List"; import ActionCode from "@material-ui/icons/Code"; import ActionHome from "@material-ui/icons/Home"; import ActionSettings from "@material-ui/icons/Settings"; import ActionJournals from "@material-ui/icons/LibraryBooks"; import ActionBugReport from "@material-ui/icons/BugReport"; import ActionQuestionAnswer from "@material-ui/icons/QuestionAnswer"; import LogoutIcon from "@material-ui/icons/PowerSettingsNew"; import IconImport from "@material-ui/icons/ImportExport"; import logo from "../images/logo.svg"; import { routeResolver } from "../App"; import { store } from "../store"; import { logout } from "../store/actions"; import * as C from "../constants"; import { useTheme } from "@material-ui/core"; import { useCredentials } from "../login"; import { useHistory } from "react-router"; interface PropsType { onCloseDrawerRequest: () => void; } export default function SideMenu(props: PropsType) { const theme = useTheme(); const etesync = useCredentials(); const username = etesync?.credentials.email ?? C.appName; const history = useHistory(); function logoutDo() { store.dispatch(logout(etesync! as any)); props.onCloseDrawerRequest(); } let loggedInItems; if (etesync) { loggedInItems = ( } onClick={() => { props.onCloseDrawerRequest(); history.push(routeResolver.getRoute("journals")); }} /> } onClick={() => { props.onCloseDrawerRequest(); history.push(routeResolver.getRoute("journals.import")); }} /> } onClick={() => { props.onCloseDrawerRequest(); history.push(routeResolver.getRoute("settings")); }} /> } onClick={logoutDo} /> ); } return (
App logo
{username}
} onClick={() => { props.onCloseDrawerRequest(); history.push(routeResolver.getRoute("home")); }} /> {loggedInItems} External Links } href={C.homePage} /> } href={C.faq} /> } href={C.sourceCode} /> } href={C.reportIssue} />
); }