diff --git a/public/index.html b/public/index.html index e0bdf2c..608d78e 100644 --- a/public/index.html +++ b/public/index.html @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - Hampton Council Planning + RIPA diff --git a/src/index.tsx b/src/index.tsx index c4fd3a7..80fb5a8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -79,7 +79,8 @@ const InnerApp = () => { const App = () => { const currentUser = useStore(state => state.data.currentUser); - const team = getTeam("southwark"); + localStorage.setItem("team", window.location.pathname.split("/")[1]); + const team = getTeam(localStorage.getItem("team")); return ( diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index a883f3e..0695b7a 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -149,7 +149,10 @@ const Dashboard = ({ applications = [] }) => { ))} - + Start a new application diff --git a/src/pages/MyApplication.tsx b/src/pages/MyApplication.tsx index a62c012..0309028 100644 --- a/src/pages/MyApplication.tsx +++ b/src/pages/MyApplication.tsx @@ -121,7 +121,7 @@ const MyApplication = ({ sections = [] }) => { py={1.5} > diff --git a/src/pages/Section.tsx b/src/pages/Section.tsx index f1ef8f0..de8a8c2 100644 --- a/src/pages/Section.tsx +++ b/src/pages/Section.tsx @@ -294,7 +294,10 @@ const Section = ({ id }) => { return ( - + Back diff --git a/src/routes/index.tsx b/src/routes/index.tsx index a9aa213..53fdc4b 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,4 +1,13 @@ -import { compose, lazy, map, mount, redirect, route, withView } from "navi"; +import { + compose, + lazy, + map, + mount, + redirect, + route, + withData, + withView +} from "navi"; import * as React from "react"; import { NotFoundBoundary, View } from "react-navi"; @@ -33,40 +42,53 @@ const Layout = ({ currentUser, team }) => { }; export default compose( - withView((req, context: IContext) => ( + withView((_req, context: IContext) => ( )), mount({ - "/login": map(async (req, context: IContext) => - context.currentUser - ? redirect( - req.params.redirectTo - ? decodeURIComponent(req.params.redirectTo) - : "/" - ) - : route({ - title: "Login", - view: - }) - ), + "/": redirect(`/${localStorage.getItem("team") || "opensystemslab"}`), - "/logout": map(async (req, context: IContext) => { + "/logout": map(() => { // context.gqlClient.resetStore(); // localStorage.removeItem("token"); api.getState().set(state => { state.data = {}; }); - return redirect("/login"); + return redirect(`/${localStorage.getItem("team")}/login`); }), - "*": map(async (req, context: IContext) => - context.currentUser - ? lazy(() => import("./authenticated")) - : redirect( - `/login/?redirectTo=${encodeURIComponent(req.originalUrl)}`, - { exact: false } - ) + "/:team": compose( + withData(req => ({ + team: req.params.team + })), + + mount({ + "/login": map(async (req, context: IContext) => + context.currentUser + ? redirect( + req.params.redirectTo + ? decodeURIComponent(req.params.redirectTo) + : `/${req.params.team}` + ) + : route({ + title: "Login", + view: + }) + ), + + "*": map(async (req, context: IContext) => { + console.log({ req }); + return context.currentUser + ? lazy(() => import("./authenticated")) + : (redirect( + `/${req.params.team}/login/?redirectTo=${encodeURIComponent( + req.originalUrl + )}`, + { exact: false } + ) as any); + }) + }) ) }) ); diff --git a/src/themes/teams.ts b/src/themes/teams.ts index 6e239df..cdd3dbf 100644 --- a/src/themes/teams.ts +++ b/src/themes/teams.ts @@ -8,6 +8,13 @@ import ScotlandLogo from "./logos/Scotland.svg"; import SouthwarkLogo from "./logos/Southwark.svg"; const teams = { + opensystemslab: { + name: "Open Systems Lab", + logo: SouthwarkLogo, + theme: { + primary: "#000" + } + }, southwark: { name: "Southwark", logo: SouthwarkLogo,