From e58fc5d4a832256ee998360d66b32da882d40a8c Mon Sep 17 00:00:00 2001 From: Pedro Guilherme Faria Duarte Date: Mon, 3 Feb 2020 08:51:08 -0300 Subject: [PATCH] =?UTF-8?q?Corrigido=20o=20bug=20que=20n=C3=A3o=20permitia?= =?UTF-8?q?=20a=20exibi=C3=A7=C3=A3o=20do=20email=20do=20usuario=20na=20pa?= =?UTF-8?q?gina=20de=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- browser/src/pages/Profile/index.js | 50 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/browser/src/pages/Profile/index.js b/browser/src/pages/Profile/index.js index 8b33402..ba47a45 100644 --- a/browser/src/pages/Profile/index.js +++ b/browser/src/pages/Profile/index.js @@ -1,12 +1,12 @@ -import React, { useState, useEffect } from "react"; -import { toast } from "react-toastify"; +import React, { useState, useEffect } from 'react'; +import { toast } from 'react-toastify'; // Icon -import { MdKeyboardBackspace } from "react-icons/md"; +import { MdKeyboardBackspace } from 'react-icons/md'; // Global styles -import { Container } from "../../components/Container"; -import { ArrorBack } from "../../components/ArrorBack"; +import { Container } from '../../components/Container'; +import { ArrorBack } from '../../components/ArrorBack'; // Style import { @@ -14,11 +14,11 @@ import { UserInfo, Info, TagsContainer, - StatesContainer -} from "./styles"; + StatesContainer, +} from './styles'; // Services -import api from "../../services/Api"; +import api from '../../services/Api'; function Profile({ history }) { const [profile, setProfile] = useState({ @@ -29,16 +29,16 @@ function Profile({ history }) { following: [], idusuario: null, name: null, - email: null + email: null, }); - const meuID = sessionStorage.getItem("@findev/session"); + const meuID = sessionStorage.getItem('@findev/session'); async function handlerFollower() { try { - const { data: followingResponse } = await api.post("follower", { + const { data: followingResponse } = await api.post('follower', { seguidorID: meuID, - idusuario: profile.idusuario + idusuario: profile.idusuario, }); if (followingResponse.code === 6) { @@ -56,9 +56,9 @@ function Profile({ history }) { async function handlerUnFollower() { try { const { data: seguindoResponse } = await api.delete( - "follower/unfollowing", + 'follower/unfollowing', { - params: { seguidorID: meuID, idusuario: profile.idusuario } + params: { seguidorID: meuID, idusuario: profile.idusuario }, } ); @@ -74,14 +74,14 @@ function Profile({ history }) { } function handlerBackPage() { - history.push("/devs"); + history.push('/devs'); } useEffect(() => { async function loadDev() { try { - const response = await api.get("user", { - params: { id: history.location.state.id } + const response = await api.get('user', { + params: { id: history.location.state.id }, }); if (response.data.code === 6) { @@ -90,7 +90,7 @@ function Profile({ history }) { } if (response.data.length === 0) { - history.push("/login"); + history.push('/login'); return; } @@ -100,10 +100,10 @@ function Profile({ history }) { avatar_url, followers, following, - _id: idusuario + _id: idusuario, } = response.data; - const { name, email } = response.data; + const { name, email } = response.data.user; setProfile({ techs, @@ -113,17 +113,17 @@ function Profile({ history }) { following, idusuario, name, - email + email, }); } catch (error) { - toast.error("TESTE" + error.message); + toast.error('TESTE' + error.message); } } function handlerVerifySession() { - const sessionID = sessionStorage.getItem("@findev/session"); + const sessionID = sessionStorage.getItem('@findev/session'); if (!sessionID) { - history.push("/"); + history.push('/'); } else { loadDev(); } @@ -164,7 +164,7 @@ function Profile({ history }) { ) ) : ( - "" + '' )}