From 7115d28044f470c54f335d1649cb87db312137d3 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Sat, 18 Apr 2020 20:49:26 +0200 Subject: [PATCH] creates routes folder for AppROuter and PrivateRoute; [BUG] fix error after login --- client/src/App.tsx | 7 ++----- client/src/index.jsx | 5 +++-- client/src/{utils/router.tsx => routes/AppRouter.tsx} | 5 +++-- client/src/{utils => routes}/PrivateRoute.jsx | 0 client/src/utils/history.ts | 4 ++-- client/tsconfig.json | 11 +++++++++-- 6 files changed, 19 insertions(+), 13 deletions(-) rename client/src/{utils/router.tsx => routes/AppRouter.tsx} (90%) rename client/src/{utils => routes}/PrivateRoute.jsx (100%) diff --git a/client/src/App.tsx b/client/src/App.tsx index 9415eaa..eedadba 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -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(); diff --git a/client/src/index.jsx b/client/src/index.jsx index 6668661..1acf58f 100644 --- a/client/src/index.jsx +++ b/client/src/index.jsx @@ -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( diff --git a/client/src/utils/router.tsx b/client/src/routes/AppRouter.tsx similarity index 90% rename from client/src/utils/router.tsx rename to client/src/routes/AppRouter.tsx index 1a316fe..db6dd71 100644 --- a/client/src/utils/router.tsx +++ b/client/src/routes/AppRouter.tsx @@ -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 ( - {/* + - */} + diff --git a/client/src/utils/PrivateRoute.jsx b/client/src/routes/PrivateRoute.jsx similarity index 100% rename from client/src/utils/PrivateRoute.jsx rename to client/src/routes/PrivateRoute.jsx diff --git a/client/src/utils/history.ts b/client/src/utils/history.ts index 6a454a1..cecd79d 100644 --- a/client/src/utils/history.ts +++ b/client/src/utils/history.ts @@ -1,2 +1,2 @@ -import { createBrowserHistory } from "history"; -export default createBrowserHistory; +import * as createHistory from "history"; +export const history = createHistory.createBrowserHistory(); diff --git a/client/tsconfig.json b/client/tsconfig.json index af10394..2ca2076 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -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"] }