2019-06-10 00:29:10 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import { hot } from 'react-hot-loader/root';
|
2019-06-29 05:17:29 +00:00
|
|
|
import { BrowserRouter, BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
2019-06-22 23:45:51 +00:00
|
|
|
import { StoreProvider } from 'easy-peasy';
|
|
|
|
import { store } from '@/state';
|
2019-06-26 04:28:56 +00:00
|
|
|
import DashboardRouter from '@/routers/DashboardRouter';
|
2019-06-29 05:17:29 +00:00
|
|
|
import ServerRouter from '@/routers/ServerRouter';
|
|
|
|
import AuthenticationRouter from '@/routers/AuthenticationRouter';
|
2019-06-10 00:29:10 +00:00
|
|
|
|
2019-06-23 00:07:28 +00:00
|
|
|
interface WindowWithUser extends Window {
|
|
|
|
PterodactylUser?: {
|
|
|
|
uuid: string;
|
|
|
|
username: string;
|
|
|
|
email: string;
|
|
|
|
root_admin: boolean;
|
|
|
|
use_totp: boolean;
|
|
|
|
language: string;
|
|
|
|
updated_at: string;
|
|
|
|
created_at: string;
|
|
|
|
};
|
|
|
|
}
|
2019-06-22 23:45:51 +00:00
|
|
|
|
2019-06-23 00:07:28 +00:00
|
|
|
const App = () => {
|
|
|
|
const data = (window as WindowWithUser).PterodactylUser;
|
2019-06-23 00:07:54 +00:00
|
|
|
if (data && !store.getState().user.data) {
|
2019-06-23 00:07:28 +00:00
|
|
|
store.getActions().user.setUserData({
|
|
|
|
uuid: data.uuid,
|
|
|
|
username: data.username,
|
|
|
|
email: data.email,
|
|
|
|
language: data.language,
|
|
|
|
rootAdmin: data.root_admin,
|
|
|
|
useTotp: data.use_totp,
|
|
|
|
createdAt: new Date(data.created_at),
|
|
|
|
updatedAt: new Date(data.updated_at),
|
|
|
|
});
|
2019-06-12 06:12:03 +00:00
|
|
|
}
|
|
|
|
|
2019-06-23 00:07:28 +00:00
|
|
|
return (
|
|
|
|
<StoreProvider store={store}>
|
|
|
|
<Router basename={'/'}>
|
2019-06-25 05:17:58 +00:00
|
|
|
<div className={'mx-auto w-auto'}>
|
2019-06-29 05:17:29 +00:00
|
|
|
<BrowserRouter basename={'/'}>
|
|
|
|
<Switch>
|
2019-06-29 05:49:08 +00:00
|
|
|
<Route path="/server/:id" component={ServerRouter}/>
|
2019-06-29 05:17:29 +00:00
|
|
|
<Route path="/auth" component={AuthenticationRouter}/>
|
2019-06-29 05:49:08 +00:00
|
|
|
<Route path="/" component={DashboardRouter}/>
|
2019-06-29 05:17:29 +00:00
|
|
|
</Switch>
|
|
|
|
</BrowserRouter>
|
2019-06-23 01:10:57 +00:00
|
|
|
</div>
|
2019-06-23 00:07:28 +00:00
|
|
|
</Router>
|
|
|
|
</StoreProvider>
|
|
|
|
);
|
|
|
|
};
|
2019-06-10 00:29:10 +00:00
|
|
|
|
|
|
|
export default hot(App);
|