-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[마이페이지] 로그아웃 버튼 클릭 시 모달 나타내기 #474
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
45a36c9
fix: delete modal 확인 버튼 시 clickedItem에 따른 옵서녈 실행 수정
f95957d
refactor: 넘겨받는 확인 버튼 멘트 props로 바꾸기
3a978fb
feat: 로그아웃 모달 추가하기
8e6477f
Merge branch 'develop' into feat/#444-logout_modal
hoeun0723 ac5581d
Merge branch 'develop' into feat/#444-logout_modal
8cd798c
Merge branch 'feat/#444-logout_modal' of https://github.com/SWEET-DEV…
1cea0a0
Merge branch 'develop' into feat/#444-logout_modal
0858034
fix: 안쓰는 import 문 삭제
da11359
fix: suspense 재 적용
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ import useGetMyPage from '../../hooks/queries/member/useGetMypage'; | |
import { MyPageType } from '../../types/member'; | ||
import * as S from './MyPage.style'; | ||
import { useNavigate } from 'react-router'; | ||
import { useState } from 'react'; | ||
import DeleteModal from '../../components/common/Modal/DeleteModal'; | ||
import { logOutInstance } from '../../apis/client'; | ||
interface MyPage { | ||
memberData: MyPageType; | ||
} | ||
|
@@ -15,6 +18,8 @@ const MAX_USERNAME_LENGTH = 5; | |
|
||
const MyPage = () => { | ||
const navigate = useNavigate(); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const fetchAuth = async () => logOutInstance.post(`/oauth/logout`); | ||
|
||
const memberData = useGetMyPage(); | ||
|
||
|
@@ -35,6 +40,17 @@ const MyPage = () => { | |
); | ||
}; | ||
|
||
const isLogout = () => { | ||
fetchAuth().then((response: any) => { | ||
console.log(response); | ||
}); | ||
localStorage.clear(); | ||
navigate('/'); | ||
}; | ||
const handleButtonClick = () => { | ||
setIsModalOpen(true); | ||
}; | ||
|
||
const renderUserName = () => { | ||
const userName = memberData?.data?.memberInfo.nickname; | ||
const translatedUserName = | ||
|
@@ -49,22 +65,33 @@ const MyPage = () => { | |
}; | ||
|
||
return ( | ||
<S.MyPageWrapper> | ||
<S.TopImage /> | ||
<S.ProfileWrapper> | ||
<S.UserButtonWrapper> | ||
<S.UserWrapper> | ||
<ProfileImage image={memberData?.data?.memberInfo.profileImage} /> | ||
{renderUserName()} | ||
</S.UserWrapper> | ||
<BtnLogout>로그아웃</BtnLogout> | ||
</S.UserButtonWrapper> | ||
<BtnFill onClick={goOnboarding} customStyle={{ width: '30.3rem', height: '5.2rem' }}> | ||
새로운 선물 준비하기 | ||
</BtnFill> | ||
</S.ProfileWrapper> | ||
{renderGiftRoom()} | ||
</S.MyPageWrapper> | ||
<> | ||
{isModalOpen && ( | ||
<DeleteModal | ||
setIsModalOpen={setIsModalOpen} | ||
onClickDelete={isLogout} | ||
okButtonText='네, 할게요.' | ||
> | ||
정말 로그아웃하시겠어요? | ||
Comment on lines
+70
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 재사용성 👍👍👍 |
||
</DeleteModal> | ||
)} | ||
<S.MyPageWrapper> | ||
<S.TopImage /> | ||
<S.ProfileWrapper> | ||
<S.UserButtonWrapper> | ||
<S.UserWrapper> | ||
<ProfileImage image={memberData?.data?.memberInfo.profileImage} /> | ||
{renderUserName()} | ||
</S.UserWrapper> | ||
<BtnLogout handleButtonClick={handleButtonClick}>로그아웃</BtnLogout> | ||
</S.UserButtonWrapper> | ||
<BtnFill onClick={goOnboarding} customStyle={{ width: '30.3rem', height: '5.2rem' }}> | ||
새로운 선물 준비하기 | ||
</BtnFill> | ||
</S.ProfileWrapper> | ||
{renderGiftRoom()} | ||
</S.MyPageWrapper> | ||
</> | ||
); | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저희 리팩토링 때 같이 navigate 좀 더 안전하게 사용하는 법 연구해봐요!!
노션에 적어두겠습니다잇!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정말 맞아요 !!! 따로 빼야 좋은데 좋은 리마인드 감사합니다 !!