From 00e1953c7272f6ecc907c4adc1189a2da5cbe4d7 Mon Sep 17 00:00:00 2001 From: John Rees Date: Fri, 19 Jun 2020 10:26:35 +0100 Subject: [PATCH] fixes --- src/index.tsx | 7 +++++-- src/layouts/Application.tsx | 10 ++++++++-- src/pages/SignIn.tsx | 2 +- src/routes/index.tsx | 11 ++++++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index a613833..a23c5d8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -79,8 +79,11 @@ const InnerApp = () => { const App = () => { const currentUser = useStore(state => state.data.currentUser); - localStorage.setItem("team", window.location.pathname.split("/")[1]); - const team = getTeam(localStorage.getItem("team") || "default"); + const t = window.location.pathname.split("/")[1]; + if (t) { + localStorage.setItem("team", t); + } + const team = getTeam(t || "default"); return ( diff --git a/src/layouts/Application.tsx b/src/layouts/Application.tsx index 5b2cd53..a757679 100644 --- a/src/layouts/Application.tsx +++ b/src/layouts/Application.tsx @@ -98,7 +98,13 @@ export const Header = ({ address = "", breadcrumbs = [] }) => { - const nav = [{ text: "My planning applications", link: "/" }, address]; + const nav = [ + { + text: "My planning applications", + link: `/${localStorage.getItem("team")}` + }, + address + ]; const active = useStore(state => state.data.activeStep + 1) || 1; const [anchorEl, setAnchorEl] = React.useState(null); @@ -175,7 +181,7 @@ export const Header = ({ diff --git a/src/pages/SignIn.tsx b/src/pages/SignIn.tsx index 0efb123..33adb2e 100644 --- a/src/pages/SignIn.tsx +++ b/src/pages/SignIn.tsx @@ -29,7 +29,7 @@ const SignIn: React.FC = ({ fullPage, topSpacing, title }) => { set(state => { state.data.currentUser = email; }); - window.location.href = "/"; + window.location.href = `/${localStorage.getItem("team")}`; }; const signInComponent = () => { return ( diff --git a/src/routes/index.tsx b/src/routes/index.tsx index e7a16ff..edb623b 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -73,8 +73,9 @@ export default compose( })), mount({ - "/login": map(async (req, context: IContext) => - context.currentUser + "/login": map(async (req, context: IContext) => { + console.log(decodeURIComponent(req.params.redirectTo)); + return context.currentUser ? redirect( req.params.redirectTo ? decodeURIComponent(req.params.redirectTo) @@ -83,11 +84,11 @@ export default compose( : route({ title: "Login", view: - }) - ), + }); + }), "*": map(async (req, context: IContext) => { - console.log({ req }); + console.log(context.currentUser); return context.currentUser ? lazy(() => import("./authenticated")) : (redirect(