-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from kabisa/try-out-test-helper
Try out test helper
- Loading branch information
Showing
63 changed files
with
1,475 additions
and
995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
import { Redirect, Route } from "react-router-dom"; | ||
import { | ||
Redirect, | ||
Route, | ||
RouteComponentProps, | ||
RouteProps, | ||
} from "react-router-dom"; | ||
import { PATH_CHOOSE_TEAM, PATH_LOGIN } from "../routes"; | ||
import { Auth } from "../support"; | ||
|
||
export default function AuthenticatedRoute({ | ||
type Props = { | ||
allowNoTeam?: boolean; | ||
component: React.ComponentType<RouteComponentProps>; | ||
} & RouteProps; | ||
|
||
const AuthenticatedRoute: React.FC<Props> = ({ | ||
allowNoTeam, | ||
component: Component, | ||
...rest | ||
}: any) { | ||
return ( | ||
<Route | ||
{...rest} | ||
render={(props) => { | ||
if (!Auth.isLoggedIn()) { | ||
return <Redirect to={PATH_LOGIN} />; | ||
} | ||
}) => ( | ||
<Route | ||
{...rest} | ||
render={(props) => { | ||
if (!Auth.isLoggedIn()) { | ||
return <Redirect to={PATH_LOGIN} />; | ||
} | ||
|
||
if (Auth.hasTeam() || allowNoTeam) { | ||
return <Component {...props} />; | ||
} | ||
if (Auth.hasTeam() || allowNoTeam) { | ||
return <Component {...props} />; | ||
} | ||
|
||
return <Redirect to={PATH_CHOOSE_TEAM} />; | ||
}} | ||
/> | ||
); | ||
} | ||
return <Redirect to={PATH_CHOOSE_TEAM} />; | ||
}} | ||
/> | ||
); | ||
export default AuthenticatedRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.