PluralKit/src/App.js

53 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-06-26 19:36:46 +02:00
import React, { useState, useCallback} from 'react';
2020-12-09 09:15:55 +01:00
import { Router, Switch, Route, Redirect } from 'react-router-dom';
import * as BS from 'react-bootstrap'
2020-12-09 17:45:11 +01:00
import './App.scss';
2020-12-09 09:15:55 +01:00
import 'bootstrap/dist/css/bootstrap.min.css';
2020-12-14 00:02:38 +01:00
import "react-toggle/style.css"
2020-12-09 09:15:55 +01:00
2021-06-26 19:51:14 +02:00
import Dash from './Pages/Dash.js'
2021-06-26 20:24:35 +02:00
import history from "./History.js"
2020-12-12 19:19:22 +01:00
import Footer from './Components/Footer.js'
2021-06-26 19:51:14 +02:00
import Public from './Pages/Public.js'
2021-06-26 19:36:46 +02:00
import Home from './Pages/Home.js'
2021-06-26 20:12:56 +02:00
import Settings from './Pages/Settings.js'
2021-06-26 20:24:35 +02:00
import Navbar from './Components/Navbar.js'
2020-12-09 09:15:55 +01:00
export default function App() {
2021-06-26 19:36:46 +02:00
const [isLoading, setIsLoading] = useState(false);
const [isSubmit, setIsSubmit] = useState(false);
2020-12-09 09:15:55 +01:00
const [isInvalid, setIsInvalid] = useState(false);
2021-06-26 19:36:46 +02:00
2020-12-13 23:38:10 +01:00
const [, updateState] = useState();
const forceUpdate = useCallback(() => updateState({}), []);
return (
2021-01-06 13:10:40 +01:00
<div className={ `contents ${localStorage.getItem('opendyslexic') ? "opendyslexic" : ""}`}>
2020-12-09 23:56:35 +01:00
<Router history={history} basename="/pk-webs">
2021-06-26 20:24:35 +02:00
<Navbar forceUpdate={forceUpdate} setIsSumbit={setIsSubmit} />
2021-01-06 13:10:40 +01:00
<div className="content">
2020-12-09 09:15:55 +01:00
<BS.Container>
<Switch>
2021-01-06 00:05:34 +01:00
<Route path="/pk-webs/dash">
2020-12-11 16:35:25 +01:00
{ !localStorage.getItem('token') || isInvalid ? <Redirect to="/pk-webs"/> : <Dash />
2020-12-09 09:15:55 +01:00
}
</Route>
2020-12-09 09:32:20 +01:00
<Route exact path="/pk-webs">
2021-06-26 19:36:46 +02:00
<Home isLoading={isLoading} setIsLoading={setIsLoading} isSubmit={isSubmit} setIsSubmit={setIsSubmit} isInvalid={isInvalid} setIsInvalid={setIsInvalid}/>
2020-12-09 09:15:55 +01:00
</Route>
2020-12-14 22:25:35 +01:00
<Route path="/pk-webs/profile">
<Public />
2020-12-13 23:38:10 +01:00
</Route>
2020-12-14 22:25:35 +01:00
<Route path="/pk-webs/settings">
2021-06-26 20:12:56 +02:00
<Settings forceUpdate={forceUpdate}/>
2020-12-13 23:38:10 +01:00
</Route>
2020-12-09 09:15:55 +01:00
</Switch>
</BS.Container>
2021-01-06 13:10:40 +01:00
</div>
2020-12-12 19:19:22 +01:00
<Footer />
2020-12-09 09:15:55 +01:00
</Router>
2020-12-13 23:38:10 +01:00
</div>
);
}