1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-11 01:22:48 +00:00

UI Overhaul

This commit is contained in:
2018-08-19 18:17:40 -05:00
parent 5fedcd4b40
commit e593472c84
58 changed files with 633 additions and 685 deletions

View File

@@ -0,0 +1,43 @@
import jwt_decode from 'jwt-decode';
import { action, observable } from 'mobx';
import { IClaims } from '../model';
import { axios, StorageService } from '../services';
import { Util } from '../util';
export class AppStore {
@observable
public navbarOpen: boolean = false;
@observable
public jwt?: string;
@observable
public claims?: IClaims;
constructor() {
const jwt = StorageService.getJWT();
this.setJWT(jwt as string);
this.initNavbar();
}
private initNavbar() {
if (!Util.isMobileScreen()) {
this.navbarOpen = true;
}
}
private setJWT(jwt?: string) {
if (!jwt) {
return;
}
axios.defaults.headers['Authorization'] = `Bearer ${jwt}`;
this.jwt = jwt;
const claims = jwt_decode(jwt);
if (claims) {
this.claims = claims as IClaims;
}
}
@action
public toggleNavbar = () => {
this.navbarOpen = !this.navbarOpen;
};
}

View File

@@ -0,0 +1,2 @@
export * from './app.store';
export * from './root.store';

View File

@@ -0,0 +1,7 @@
import { AppStore } from './app.store';
export class RootStore {
public appStore = new AppStore();
}
export const rootStoreInstance = new RootStore();