import React from 'react'; import { NavLink } from 'react-router-dom'; import jwt_decode from 'jwt-decode'; import { StorageService } from '../../services'; import './Navbar.scss'; const baseUrl = window.location.origin + '/oauth'; const oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=410818759746650140&redirect_uri=${baseUrl}&response_type=code&scope=identify%20guilds`; interface Props {} interface State { token: string | null; email?: string; } export class Navbar extends React.Component { constructor(props: Props) { super(props); this.state = { token: null, }; } componentDidMount() { const token = StorageService.getJWT(); if (token) { const claims: any = jwt_decode(token!); const email = claims['email']; this.setState({ token, email }); } } private logout = () => { StorageService.clear(); window.location.href = '/'; }; render() { return (
Sound Bot
Home Soundboard Youtube Downloader Clips Stats {!this.state.token ? ( Login ) : ( Logout )} {this.state.email &&
{this.state.email}
}
); } }