From 7d40c9d4a9f19197fe7445ede793e16e3086b1ad Mon Sep 17 00:00:00 2001 From: yoon-jisung Date: Thu, 6 May 2021 18:52:13 +0900 Subject: [PATCH] test --- src/App.js | 73 ++++++++++++++++++++++--------------------- src/MyPages/MyPage.js | 41 ++++++++++++------------ src/main.css | 8 ----- 3 files changed, 58 insertions(+), 64 deletions(-) diff --git a/src/App.js b/src/App.js index 859cc24..a5c56d2 100644 --- a/src/App.js +++ b/src/App.js @@ -27,32 +27,30 @@ export default function App() { //로그인 상태 관리하기-------------------------------- useEffect(() => { - refreshTokenRequest() - if(accessToken.accessToken!==null){ - history.push('/Waiting') - } - },[]); + refreshTokenRequest(); + if (accessToken.accessToken !== null) { + history.push('/Waiting'); + } + }, []); const loginHandler = (data) => { issueAccessToken(data.data.accessToken); - history.push('/Waiting') + history.push('/Waiting'); }; - const handleGeuetLogin = () => { + const handleGuestLogin = () => { setUserInfo({ nickname: '게스트' }); - history.push('/Waiting') + history.push('/Waiting'); }; -//로그 아웃-------------------------------------------------------- + //로그 아웃-------------------------------------------------------- const hendleLogout = () => { axios - .get( - 'http://localhost:4000/user/logout', - { - headers:{ - 'Content-Type': 'application/json', - 'Clear-Site-Data': "cookies" - }, - } - ).then((res) => {}) + .get('http://localhost:4000/user/logout', { + headers: { + 'Content-Type': 'application/json', + 'Clear-Site-Data': 'cookies', + }, + }) + .then((res) => {}); setUserInfo({ id: null, nickname: null, @@ -60,13 +58,12 @@ export default function App() { profile_image: Character1, comment: null, room_id: null, - }) + }); setAccessToken({ accessToken: null }); - history.push('/') + history.push('/'); }; - -//토큰 관리---------------------------------------------------------------------------------------------- + //토큰 관리---------------------------------------------------------------------------------------------- const accessTokenRequest = (accessToken) => { // ! 유저 정보를 알려달라는 코드 axios @@ -99,10 +96,11 @@ export default function App() { withCredentials: true, }) .then((res) => { - if (res.data.message !== 'ok') {} + if (res.data.message !== 'ok') { + } const { nickname, email, profile_image } = res.data.data.userInfo; - console.log(res.data.data.accessToken) - setAccessToken({accessToken:res.data.data.accessToken}) + console.log(res.data.data.accessToken); + setAccessToken({ accessToken: res.data.data.accessToken }); setUserInfo({ nickname: nickname, email: email, @@ -114,23 +112,26 @@ export default function App() { const issueAccessToken = (token) => { setAccessToken({ accessToken: token }); accessTokenRequest(token); - history.push('/Waiting') + history.push('/Waiting'); console.log(token); }; -//구글 로그인---------------------------------------------------------------- + //구글 로그인---------------------------------------------------------------- const getAccessToken = async (authorizationCode) => { // ! 구글 로그인 - let resp = await axios.post('http://localhost:4000/googlelogin', - { - authorizationCode: authorizationCode, - },{ - withCredentials: true - }); - console.log(resp.data) - issueAccessToken(resp.data.accessToken) + let resp = await axios.post( + 'http://localhost:4000/googlelogin', + { + authorizationCode: authorizationCode, + }, + { + withCredentials: true, + } + ); + console.log(resp.data); + issueAccessToken(resp.data.accessToken); }; -//구글 로그인 코드 받기-------------------------------- + //구글 로그인 코드 받기-------------------------------- useEffect(() => { const url = new URL(window.location.href); const authorizationCode = url.searchParams.get('code'); diff --git a/src/MyPages/MyPage.js b/src/MyPages/MyPage.js index c431453..7ebc91f 100644 --- a/src/MyPages/MyPage.js +++ b/src/MyPages/MyPage.js @@ -8,7 +8,6 @@ import Character1 from '../images/Character1.png'; import Character2 from '../images/Character2.png'; import Character3 from '../images/Character3.png'; import Character4 from '../images/Character4.png'; -import axios from 'axios'; function MyPage({ accessToken, isLogIn, loginCheck, userInfo }) { const PhotoData = [Character1, Character2, Character3, Character4]; @@ -41,25 +40,27 @@ function MyPage({ accessToken, isLogIn, loginCheck, userInfo }) { } }; - - const MyPageSaveData= async () =>{ - const PhotoNum = PhotoData.findIndex(nowPhoto) - const SavePhoto = await axios.post(`http://localhost:4000/mypage/${id}/profile`, - { - authorization: accessToken, - new_profile: PhotoNum - }, - { - headers: { 'Content-Type': 'application/json' }, - Credentials: 'include', - }) - const SaveComment = await axios.post(`http://localhost:4000/mypage/${id}/comment`, - { - authorization: accessToken, - Comment: PhotoNum - }) - } - + const MyPageSaveData = async () => { + const PhotoNum = PhotoData.findIndex(nowPhoto); + const SavePhoto = await axios.post( + `http://localhost:4000/mypage/${id}/profile`, + { + authorization: accessToken, + new_profile: PhotoNum, + }, + { + headers: { 'Content-Type': 'application/json' }, + Credentials: 'include', + } + ); + const SaveComment = await axios.post( + `http://localhost:4000/mypage/${id}/comment`, + { + authorization: accessToken, + Comment: PhotoNum, + } + ); + }; return (
diff --git a/src/main.css b/src/main.css index 55dfe7e..58c13ff 100644 --- a/src/main.css +++ b/src/main.css @@ -930,23 +930,15 @@ canvas { } .card { -<<<<<<< HEAD -======= border: 2px solid #0f4d86; ->>>>>>> b3d2fa2f4bd5a1a35c87b3fda67e7f91c185472c background-color: white; border-radius: 15px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; -<<<<<<< HEAD - border: 5px solid #0f4d86; - border-radius: 15px; -======= width: 600px; height: 400px; ->>>>>>> b3d2fa2f4bd5a1a35c87b3fda67e7f91c185472c } .card h1 { text-align: center;