diff --git a/src/.App.js.swo b/src/.App.js.swo deleted file mode 100644 index 4df6e14..0000000 Binary files a/src/.App.js.swo and /dev/null differ diff --git a/src/App.js b/src/App.js index dabe6cc..eb86eec 100644 --- a/src/App.js +++ b/src/App.js @@ -27,12 +27,11 @@ export default function App() { //로그인 상태 관리하기-------------------------------- useEffect(() => { - //refreshTokenRequest() - if(accessToken.accessToken!==null){ - history.push('/Waiting') - } - },[]); + if (accessToken.accessToken !== null) { + history.push('/Waiting'); + } + }, []); const loginHandler = (data) => { issueAccessToken(data.data.accessToken); @@ -47,10 +46,8 @@ export default function App() { const hendleLogout = () => { axios - .get( - 'http://localhost:4000/user/logout', - {withCredentials: true} - ).then((res) => {}) + .get('http://localhost:4000/user/logout', { withCredentials: true }) + .then((res) => {}); setUserInfo({ id: null, nickname: null, @@ -75,8 +72,16 @@ export default function App() { withCredentials: true, }) .then((res) => { +<<<<<<< HEAD +======= const { nickname, email, profile_image, comment, id } = res.data.data; +>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90 // ! + return res.data.data; + }) + .then((data) => { + console.log('여기야야야야양', data); + const { nickname, email, profile_image, comment, id } = data; setUserInfo({ id: id, nickname: nickname, @@ -87,6 +92,12 @@ export default function App() { }); }; + useEffect(() => { + return () => { + localStorage.setItem('userInfo', JSON.stringify(userInfo)); + }; + }, [userInfo]); + const refreshTokenRequest = () => { // ! 일정 주기로 함수 계속 보냄 axios @@ -94,18 +105,31 @@ export default function App() { withCredentials: true, }) .then((res) => { + if (res.data.message !== 'ok') { + } + const { + nickname, + email, + profile_image, + id, + comment, + } = res.data.data.userInfo; +<<<<<<< HEAD + setAccessToken({ accessToken: res.data.data.accessToken }); +======= if (res.data.message !== 'ok') {} const { nickname, email, profile_image, id,comment } = res.data.data.userInfo; console.log(res.data.data.accessToken) setAccessToken({accessToken:res.data.data.accessToken}) +>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90 setUserInfo({ - id : id, + id: id, nickname: nickname, email: email, - comment:comment, + comment: comment, profile_image: profile_image, }); }); @@ -129,12 +153,21 @@ export default function App() { withCredentials: true, } ); +<<<<<<< HEAD + +======= +>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90 issueAccessToken(resp.data.accessToken); }; //구글 로그인 코드 받기-------------------------------- useEffect(() => { const url = new URL(window.location.href); const authorizationCode = url.searchParams.get('code'); +<<<<<<< HEAD + + console.log('userInfo:', userInfo); +======= +>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90 if (authorizationCode) { getAccessToken(authorizationCode); } diff --git a/src/GamePages/InGame.js b/src/GamePages/InGame.js index fe6f3ab..daca810 100644 --- a/src/GamePages/InGame.js +++ b/src/GamePages/InGame.js @@ -24,6 +24,7 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) { const [isPresenter, setIsPresenter] = useState(false); const [winner, setWinner] = useState([]); const [userlist, setUserlist] = useState([]); + const [inputPresenter, setInputPresenter] = useState(false); //뒤로가기 버튼 방지 const [locationKeys, setLocationKeys] = useState([]); @@ -116,7 +117,26 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) { socket.emit('set answer', { answer }); }; + const endGame = () => { + setResultPopup(true); + setInputPresenter(false); + }; + //! --------------------------method-------------------------- + useEffect(() => { + const localUserInfo = JSON.parse(localStorage.getItem('userInfo')); + console.log('정답', localUserInfo.nickname); + console.log('출제자', presenter, presenter.nickname); + + if (presenter.nickname === localUserInfo.nickname) { + setInputPresenter(true); + console.log('너가출제자123213', localUserInfo.nickname); + } + }); + + useEffect(() => { + console.log('inputPresenter:내가발표자'); + }, [inputPresenter]); @@ -153,7 +173,6 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) { socket.on('renew userlist', (list) => { - console.log('d우ㅠ저소ㅓ켓'); setUserlist([...list]); }); }, []); @@ -203,7 +222,12 @@ export default function InGame({ accessToken, isLogIn, loginCheck, userInfo }) { {resultPopup ? : null} - +
    {users.map((el) => { -
  • -
    {el.nickname}
    -
  • ; + return ( +
  • + {inputPresenter ?

    출제자

    : null} + user_profile +
    +
    닉네임 : {el.nickname}
    +
    자기소개
    +
    +
  • + ); })} - {/*
  • - user_profile -
    -
    - 닉네임 : {userInfo.nickname} -
    -
    자기소개
    -
    -
  • -
  • - user_profile -
    닉네임 : {userInfo.nickname}
    -
  • -
  • - user_profile -
    닉네임 : {userInfo.nickname}
    -
  • -
  • - user_profile -
    닉네임 : {userInfo.nickname}
    -
  • */}
); diff --git a/src/MyPages/MyPage.js b/src/MyPages/MyPage.js index 2e0a639..73d336e 100644 --- a/src/MyPages/MyPage.js +++ b/src/MyPages/MyPage.js @@ -57,6 +57,33 @@ function MyPage({ accessToken, refreshTokenRequest, userInfo }) { console.log('photobox', isPhotoBoxOpen); }; +<<<<<<< HEAD + const MyPageSaveData = async (PhotoNum) => { + refreshTokenRequest(); + const SavePhoto = await axios.post( + `http://localhost:4000/mypage/${id}/profile`, + { new_profile: PhotoNum }, + { + headers: { + Authorization: `Bearer ${accessToken.accessToken}`, + 'Content-Type': 'application/json', + }, + withCredentials: true, + } + ); + const SaveComment = await axios.post( + `http://localhost:4000/mypage/${id}/comment`, + { Comment: '아니라어민어리ㅏㅁㄴ얼' }, + { + headers: { + Authorization: `Bearer ${accessToken.accessToken}`, + 'Content-Type': 'application/json', + }, + withCredentials: true, + } + ); + }; +======= // const MyPageSaveData = async (PhotoNum) => { // await refreshTokenRequest(); // const SavePhoto = await axios.post( @@ -82,6 +109,7 @@ function MyPage({ accessToken, refreshTokenRequest, userInfo }) { // } // ); // }; +>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90 return (
@@ -90,7 +118,11 @@ function MyPage({ accessToken, refreshTokenRequest, userInfo }) { nowPhoto={nowPhoto} nickname={nickname} PhotoNum={PhotoNum} +<<<<<<< HEAD + MyPageSaveData={MyPageSaveData} +======= // MyPageSaveData={MyPageSaveData} +>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90 />
diff --git a/src/main.css b/src/main.css index 897202b..dbb2e05 100644 --- a/src/main.css +++ b/src/main.css @@ -850,7 +850,7 @@ $button-active-blue: #1669f2; */ .inGameUserProfile { display: flex; - border: 3px solid #0f4d86; + border: 3px solid #e71a1a; border-radius: 15px; list-style: none; width: 300px; @@ -1053,7 +1053,6 @@ canvas { } .result { - border: 2px solid black; border-radius: 15px; width: 600px; height: 500px; @@ -1192,6 +1191,9 @@ canvas { top: 10%; } +.inGame_user { + border: 2px solid red; +} .Back { position: absolute; top: 0;