-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from codestates-seb/dev-client#70/profile
[FE]테스트 전 구글로그인, 현금기능 재확인 및 기능 추가Dev client#70/profile
- Loading branch information
Showing
12 changed files
with
135 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { GoogleOAuthProvider, GoogleLogin, useGoogleOneTapLogin } from '@react-oauth/google'; | ||
import { useDispatch } from 'react-redux'; | ||
import { setLoginState } from '../../reducer/member/loginSlice'; | ||
|
||
const GoogleSignInComponent: React.FC = () => { | ||
|
||
const dispatch = useDispatch(); // Redux의 dispatch 함수를 사용하기 위해 가져옵니다. | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const handleSuccess = (credentialResponse: any) => { | ||
console.log(credentialResponse); | ||
|
||
const token = credentialResponse.token; // 실제 응답에서 토큰의 경로가 어떤지 확인하고 수정해야 합니다. | ||
localStorage.setItem('authToken', token); // 토큰을 localStorage에 저장 | ||
|
||
// 로그인 성공 시 전역 상태를 업데이트합니다. | ||
dispatch(setLoginState({ | ||
memberId: credentialResponse.memberId, // memberId는 예시입니다. 실제 값에 맞게 수정해야 합니다. | ||
isLoggedIn: 1, | ||
})); | ||
}; | ||
|
||
const handleError = () => { | ||
console.log('Login Failed'); | ||
}; | ||
|
||
// One-tap 로그인 (선택적) | ||
useGoogleOneTapLogin({ | ||
onSuccess: handleSuccess, | ||
onError: handleError, | ||
}); | ||
|
||
return ( | ||
<GoogleOAuthProvider clientId=" | ||
690344785644-2oj84rcukd2rhu3o56gbq6rahap16m37.apps.googleusercontent.com"> | ||
<GoogleLogin | ||
onSuccess={handleSuccess} | ||
onError={handleError} | ||
useOneTap | ||
/> | ||
</GoogleOAuthProvider> | ||
); | ||
}; | ||
|
||
export default GoogleSignInComponent; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters