Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnrees committed Jun 19, 2020
1 parent b0517f6 commit 00e1953
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ApolloProvider client={gqlClient}>
Expand Down
10 changes: 8 additions & 2 deletions src/layouts/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -175,7 +181,7 @@ export const Header = ({
<MenuItem
className={classes.menuItem}
component="a"
href="/"
href={`/${localStorage.getItem("team")}`}
onClick={handleClose}
>
<ListItemIcon>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SignIn: React.FC<ISignIn> = ({ fullPage, topSpacing, title }) => {
set(state => {
state.data.currentUser = email;
});
window.location.href = "/";
window.location.href = `/${localStorage.getItem("team")}`;
};
const signInComponent = () => {
return (
Expand Down
11 changes: 6 additions & 5 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -83,11 +84,11 @@ export default compose(
: route({
title: "Login",
view: <Login />
})
),
});
}),

"*": map(async (req, context: IContext) => {
console.log({ req });
console.log(context.currentUser);
return context.currentUser
? lazy(() => import("./authenticated"))
: (redirect(
Expand Down

0 comments on commit 00e1953

Please sign in to comment.