diff --git a/src/App.tsx b/src/App.tsx
index 083c43a..6ef9e27 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -50,7 +50,7 @@ const routes = (
-
+
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
index 2028df5..1134d4d 100644
--- a/src/pages/Home.tsx
+++ b/src/pages/Home.tsx
@@ -8,7 +8,7 @@ const Home: React.FC = () => {
return (
- { history.push({ pathname: '/perfil/1' }); }}>Ir para o perfil de outra pessoa
+ { history.push({ pathname: '/usuario/56520ae7-faf8-4444-a82b-7f3990ab02d8' }); }}>Ir para o perfil de outra pessoa
);
diff --git a/src/pages/Perfil.tsx b/src/pages/Perfil.tsx
index 8e86944..73b6ada 100644
--- a/src/pages/Perfil.tsx
+++ b/src/pages/Perfil.tsx
@@ -66,31 +66,41 @@ const Perfil: React.FC = (props) => {
const logoff = () => {
LocalStorage.clearToken()
user.setIsLoggedIn(false);
- history.push('/login')
+ history.push({ pathname: '/login' });
}
useEffect(() => {
const loadUserData = async () => {
let userId = ''
-
+
// verify if user is authenticated
- const refreshSessionRes = await sessionsService.refreshSession()
+ if (props.match.params.id) {
+ userId = props.match.params.id
+ } else {
+ const refreshSessionRes = await sessionsService.refreshSession()
- if (refreshSessionRes.error) {
- redirectUserToLogin()
- return
- }
-
- if (refreshSessionRes.userId) {
- userId = refreshSessionRes.userId
+ if (refreshSessionRes.error) {
+ redirectUserToLogin()
+ return
+ }
+
+ if (refreshSessionRes.userId) {
+ userId = refreshSessionRes.userId
+ }
}
// get user info by ID
const getByIdRes = await usersService.getById(userId)
if (getByIdRes.error) {
- setMessageToast(getByIdRes.error.errorMessage)
- setShowToast(true)
+ if (isVisitor && props.match.params.id) {
+ setMessageToast('Usuário não existe!')
+ setShowToast(true)
+ history.push({ pathname: '/home' })
+ } else {
+ setMessageToast(getByIdRes.error.errorMessage)
+ setShowToast(true)
+ }
return
}