Feat/hide unused features
This commit is contained in:
parent
8d5d0a666e
commit
41b86d4a6d
28 changed files with 3357 additions and 20314 deletions
54
src/App.tsx
54
src/App.tsx
|
|
@ -1,36 +1,16 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import React from 'react';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import { Router, RouteComponentProps } from '@reach/router';
|
||||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { Toaster } from 'react-hot-toast';
|
||||
|
||||
import { isValid } from 'src/services/api';
|
||||
import { useAuth } from 'src/services/auth';
|
||||
import { Apps, Dashboard, Users, Login, AppSingle } from './modules';
|
||||
import { Dashboard, Users, Login } from './modules';
|
||||
import { Layout } from './components';
|
||||
import { LoginCallback } from './modules/login/LoginCallback';
|
||||
|
||||
type AppProps = RouteComponentProps;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function App(_: AppProps) {
|
||||
const { auth } = useAuth();
|
||||
// const isLoginPage = useMatch('/login');
|
||||
|
||||
const [initialized, setInitialized] = useState(false);
|
||||
const [initializedToken, setInitializedToken] = useState<string | null>(null);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!isValid(auth) && !isLoginPage) {
|
||||
// navigate('/login');
|
||||
// }
|
||||
// }, [auth, isLoginPage]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isValid(auth) && (!initialized || initializedToken !== auth.token)) {
|
||||
setInitialized(true);
|
||||
setInitializedToken(auth.token);
|
||||
}
|
||||
}, [auth, initialized, initializedToken]);
|
||||
function App() {
|
||||
const { authToken } = useAuth();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -46,24 +26,22 @@ function App(_: AppProps) {
|
|||
</Helmet>
|
||||
|
||||
<div className="app bg-gray-50 min-h-screen flex flex-col">
|
||||
{!isValid(auth) ? (
|
||||
<Router>
|
||||
<Login default path="/login" />
|
||||
<LoginCallback path="/login-callback" />
|
||||
</Router>
|
||||
{!authToken ? (
|
||||
<Routes>
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/login-callback" element={<LoginCallback />} />
|
||||
<Route path="*" element={<Navigate to="/login" />} />
|
||||
</Routes>
|
||||
) : (
|
||||
<Layout>
|
||||
<Router>
|
||||
<Dashboard default path="/dashboard" />
|
||||
<Users path="/users" />
|
||||
<Apps path="/apps" />
|
||||
<AppSingle path="/apps/:id" />
|
||||
</Router>
|
||||
<Routes>
|
||||
<Route path="/dashboard" element={<Dashboard />} />
|
||||
<Route path="/users" element={<Users />} />
|
||||
<Route path="*" element={<Navigate to="/dashboard" />} />
|
||||
</Routes>
|
||||
</Layout>
|
||||
)}
|
||||
|
||||
{/* {isValid(auth) ? <Redirect from="/" to="/dashboard" noThrow /> : <Redirect from="/" to="/" noThrow />} */}
|
||||
|
||||
{/* Place to load notifications */}
|
||||
<div
|
||||
aria-live="assertive"
|
||||
|
|
|
|||
Reference in a new issue