diff --git a/src/components/Auth/ChoseRole/ChoseRole.tsx b/src/components/Auth/ChoseRole/ChoseRole.tsx index 334e2bbdf6582d738c62608511cfc49ff848b5f6..558f33a91552709b544484aeb6e34176d91d6830 100644 --- a/src/components/Auth/ChoseRole/ChoseRole.tsx +++ b/src/components/Auth/ChoseRole/ChoseRole.tsx @@ -5,6 +5,7 @@ import { setRole } from 'api/setRole'; import { useHistory } from 'react-router-dom'; import { AuthRoutes } from 'api/routes'; import { AuthContext } from 'components/Auth/AuthContext'; +import { getRole } from 'api/getRole'; /** * Page that let's users decide role between available roles. @@ -17,11 +18,10 @@ export const ChoseRole: FC = () => { 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}`); + setRole(role).then(() => + history.push(`${AuthRoutes.dashboard}${AuthRoutes.home}`), + ); }; useEffect(() => {