diff --git a/src/components/Estilo/TrocardePerfis.css b/src/components/Estilo/TrocardePerfis.css index 58282b9..77d85e1 100644 --- a/src/components/Estilo/TrocardePerfis.css +++ b/src/components/Estilo/TrocardePerfis.css @@ -1,10 +1,10 @@ .perfil-button, .selecionado{ margin: 8px; margin-left:0px; - padding: 10px 12px; + padding: 10px 19px; font-size: 15px; - width:68%; + width:70%; border: 2px solid #25396f; border-radius: 20px; cursor: pointer; @@ -22,6 +22,7 @@ margin: 20px; justify-content: flex-end; margin-left: 0px; + margin-left: 18px; } #primeiro-conjunto-botoes, #segundo-conjunto-botoes{ diff --git a/src/components/TrocardePerfis.jsx b/src/components/TrocardePerfis.jsx index a812b2b..815ad29 100644 --- a/src/components/TrocardePerfis.jsx +++ b/src/components/TrocardePerfis.jsx @@ -15,61 +15,63 @@ const TrocardePerfis = () => { let authHeader = getAuthorizationHeader(); console.log('AUTH HEADER', authHeader) - const handleUserInfo = async () => { - const userInfo = await UserInfos(authHeader); - setShowProfiles(userInfo.roles) - - }; -const handleProfileClick = (profile, route) => { - setSelectedProfile(profile); +const handleProfileClick = (route) => { + navigate(route); }; useEffect(() => { - setSelectedProfile(location.pathname) + const fetchData = async () => { + setSelectedProfile(location.pathname); + const userInfo = await UserInfos(authHeader); + setShowProfiles(userInfo?.roles || []); + }; - handleUserInfo(); -},[]) + fetchData(); +}, []); return (
+ +

Acesso aos modulos:

- {(showProfiles.includes('secretaria') || showProfiles.includes('admin')) && ( + {(showProfiles?.includes('secretaria') || showProfiles?.includes('admin')) && ( )} - {(showProfiles.includes('medico') || showProfiles.includes('admin')) && ( + {(showProfiles?.includes('medico') || showProfiles?.includes('admin')) && ( )}
- {(showProfiles.includes('financeiro') || showProfiles.includes('admin')) && ( + {(showProfiles?.includes('financeiro') || showProfiles?.includes('admin')) && ( )} - {showProfiles.includes('admin') && ( + {showProfiles?.includes('admin') && ( )}
diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index cad0c2f..a71df6f 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -117,7 +117,15 @@ function Login({ onEnterSystem }) { const UserData = await UserInfos(`bearer ${data.access_token}`); console.log(UserData, 'Dados do usuário'); + if(UserData?.roles?.includes('admin')){ navigate(`/admin/`); + } else if(UserData?.roles?.includes('secretaria')){ + navigate(`/secretaria/`); + } else if(UserData?.roles?.includes('medico')){ + navigate(`/medico/`); + } else if(UserData?.roles?.includes('financeiro')){ + navigate(`/financeiro/`); + } } } else {