import React from 'react'; import { NavLink } from 'react-router-dom'; import jwt_decode from 'jwt-decode'; import './Navbar.scss'; import { storage } from '../../storage'; let oauthUrl: string; if (!process.env.NODE_ENV) { // dev oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=410818759746650140&redirect_uri=https%3A%2F%2Flocalhost%2Foauth&response_type=code&scope=identify%20guilds`; } else { // prod oauthUrl = `https://discordapp.com/api/oauth2/authorize?client_id=271998875802402816&redirect_uri=https%3A%2F%2Fcashdiscord.com%2Foauth&response_type=code&scope=identify%20guilds%20email`; } 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 = storage.getJWT(); if (token) { const claims: any = jwt_decode(token!); console.log(claims); const email = claims['email']; this.setState({ token, email }); } } private logout = () => { localStorage.clear(); window.location.href = '/'; }; render() { return (
Go Discord Bot
Home Soundboard Youtube Downloader Clips {!this.state.token ? ( Login ) : ( Logout )} {this.state.email &&
{this.state.email}
}
); } }