creates routes folder for AppROuter and PrivateRoute; [BUG] fix error after login

This commit is contained in:
Ruidy Nemausat 2020-04-18 20:49:26 +02:00
parent 1bf2da3d32
commit 7115d28044
6 changed files with 19 additions and 13 deletions

View file

@ -1,12 +1,9 @@
import React from "react";
import { Router } from "react-router-dom";
import { useAuth0 } from "./authentication/auth0";
import * as createHistory from "history";
// import history from "./utils/history";
import { history } from "./utils/history";
import MainLayout from "./layouts/MainLayout";
import { AppRouter } from "./utils/router";
export const history = createHistory.createBrowserHistory();
import { AppRouter } from "./routes/AppRouter";
export default function App() {
const { loading } = useAuth0();

View file

@ -4,9 +4,9 @@ import App from "./App";
import * as serviceWorker from "./serviceWorker";
import { Auth0Provider } from "./authentication/auth0";
import config from "./authentication/config.json";
import history from "./utils/history";
import { history } from "./utils/history";
const onRedirectCallback = appState => {
const onRedirectCallback = (appState) => {
history.push(
appState && appState.targetUrl
? appState.targetUrl
@ -18,6 +18,7 @@ ReactDOM.render(
<Auth0Provider
domain={config.domain}
client_id={config.clientId}
audience={config.audience}
redirect_uri={window.location.origin}
onRedirectCallback={onRedirectCallback}
>

View file

@ -5,13 +5,14 @@ import { ProjectController } from "../controllers/ProjectController";
import { UserController } from "../controllers/UserController";
import { TicketController } from "../controllers/TicketController";
import { NotFoundPage } from "../pages/NotFoundPage";
import { TestPage } from "../pages/TestPage";
export const AppRouter = () => {
return (
<Switch>
{/* <PrivateRoute exact path="/test">
<Route exact path="/test">
<TestPage />
</PrivateRoute> */}
</Route>
<Route exact path="/">
<HomeController />

View file

@ -1,2 +1,2 @@
import { createBrowserHistory } from "history";
export default createBrowserHistory;
import * as createHistory from "history";
export const history = createHistory.createBrowserHistory();

View file

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
@ -13,7 +13,14 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
"jsx": "react",
"sourceMap": true,
"declaration": false,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"importHelpers": true,
"typeRoots": ["node_modules/@types"]
},
"include": ["src"]
}