import React, { Component } from "react"; import { BrowserRouter as Router, Route, Link, Switch, Redirect} from "react-router-dom"; import Index from "./Index/Index.js"; import Playlists from "./Playlist/Playlists.js"; import PlaylistView from "./Playlist/PlaylistView.js"; import Settings from "./Settings/Settings.js"; import Admin from "./Admin/Admin.js"; import NotFound from "./Error/NotFound.js"; import showMessage from "./Toast.js" const axios = require('axios'); class PlaylistManager extends Component { constructor(props){ super(props); this.state = { type: null, spotify_linked: null } } 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})`); }); } render(){ return (
{ this.state.type == 'admin' && }
home
playlists
settings
admin
logout
sarsoo.xyz
{ this.state.type == 'admin' && }
); } } export default PlaylistManager;