import React, { Component } from "react"; import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; import NotFound from "./Error/NotFound.js"; import showMessage from "./Toast.js" import GlobalTheme from './Theme.js'; import { Typography } from '@material-ui/core'; import { ThemeProvider } from '@material-ui/core/styles'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; import IconButton from '@material-ui/core/IconButton'; import MenuIcon from '@material-ui/icons/Menu'; import Drawer from '@material-ui/core/Drawer'; import List from '@material-ui/core/List'; import Divider from '@material-ui/core/Divider'; import ChevronLeftIcon from '@material-ui/icons/ChevronLeft'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; import HomeIcon from '@material-ui/icons/Home'; import { Build, PieChart, QueueMusic, ExitToApp, AccountCircle, KeyboardBackspace } from '@material-ui/icons' const axios = require('axios'); const LazyIndex = React.lazy(() => import("./Index/Index")) const LazyMaths = React.lazy(() => import("./Maths/MathsRouter")) const LazyPlaylists = React.lazy(() => import("./Playlist/AllPlaylistsRouter")) const LazyPlaylistView = React.lazy(() => import("./Playlist/View/PlaylistRouter")) const LazySettings = React.lazy(() => import("./Settings/SettingsRouter")) const LazyAdmin = React.lazy(() => import("./Admin/AdminRouter")) class MusicTools extends Component { constructor(props){ super(props); this.state = { type: null, spotify_linked: null, drawerOpen: false } this.setOpen = this.setOpen.bind(this); } componentDidMount() { this.getUserInfo(); } componentWillUnmount() { this.userInfoCancelToken.cancel(); } getUserInfo(){ this.userInfoCancelToken = axios.CancelToken.source(); var self = this; axios.get('/api/user', { cancelToken: this.userInfoCancelToken.token }) .then((response) => { self.setState({ type: response.data.type, spotify_linked: response.data.spotify_linked }) }) .catch((error) => { showMessage(`error getting user info (${error.response.status})`); }); } setOpen(bool){ this.setState({ drawerOpen: bool }) } render(){ return ( this.setOpen(true)}> Music Tools this.setOpen(false)} >
this.setOpen(false)}>
this.setOpen(false)} onKeyDown={(e) => this.setOpen(false)} > { this.state.type == 'admin' && }
}> { this.state.type == 'admin' && }
); } } function LoadingMessage(props) { return Loading...; } export default MusicTools;