diff --git a/src/components/Auth/ChoseRole/ChoseRole.tsx b/src/components/Auth/ChoseRole/ChoseRole.tsx index ce2688cef4be323d88f8f1377f84698f6924595f..334e2bbdf6582d738c62608511cfc49ff848b5f6 100644 --- a/src/components/Auth/ChoseRole/ChoseRole.tsx +++ b/src/components/Auth/ChoseRole/ChoseRole.tsx @@ -1,9 +1,10 @@ -import React, { FC, useEffect, useState } from 'react'; +import React, { FC, useContext, useEffect, useState } from 'react'; import Button from '@material-ui/core/Button'; import { getRoles } from 'api/getRoles'; import { setRole } from 'api/setRole'; import { useHistory } from 'react-router-dom'; import { AuthRoutes } from 'api/routes'; +import { AuthContext } from 'components/Auth/AuthContext'; /** * Page that let's users decide role between available roles. @@ -13,10 +14,12 @@ import { AuthRoutes } from 'api/routes'; export const ChoseRole: FC = () => { const history = useHistory(); const [userRoles, setUserRoles] = useState<string[]>(['']); + const { setIsAuth } = useContext(AuthContext); const choseAndForward = (role: string): void => { // Set role in the server. setRole(role); + setIsAuth(true); // Push to homepage. history.push(`${AuthRoutes.dashboard}${AuthRoutes.home}`); };