Skip to content
Snippets Groups Projects
Verified Commit 6b871da1 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Fetch role only when promise ran.

parent 225689a2
No related branches found
No related tags found
2 merge requests!60New component to search senior (see #12). Enhance responsiveness and solve #10 and #11,!57Replace context with api.
...@@ -5,6 +5,7 @@ import { setRole } from 'api/setRole'; ...@@ -5,6 +5,7 @@ import { setRole } from 'api/setRole';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { AuthRoutes } from 'api/routes'; import { AuthRoutes } from 'api/routes';
import { AuthContext } from 'components/Auth/AuthContext'; import { AuthContext } from 'components/Auth/AuthContext';
import { getRole } from 'api/getRole';
/** /**
* Page that let's users decide role between available roles. * Page that let's users decide role between available roles.
...@@ -17,11 +18,10 @@ export const ChoseRole: FC = () => { ...@@ -17,11 +18,10 @@ export const ChoseRole: FC = () => {
const { setIsAuth } = useContext(AuthContext); const { setIsAuth } = useContext(AuthContext);
const choseAndForward = (role: string): void => { const choseAndForward = (role: string): void => {
// Set role in the server.
setRole(role);
setIsAuth(true); setIsAuth(true);
// Push to homepage. setRole(role).then(() =>
history.push(`${AuthRoutes.dashboard}${AuthRoutes.home}`); history.push(`${AuthRoutes.dashboard}${AuthRoutes.home}`),
);
}; };
useEffect(() => { useEffect(() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment