-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/19 login #21
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
Open
dlcks0601
wants to merge
13
commits into
develop
Choose a base branch
from
feature/19-login
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/19 login #21
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5a6adfa
[Feat] redux-persist 의존성 설치
dlcks0601 e5824cc
[Refactor] redux-persist 보호
dlcks0601 49a3a61
[Refactor] 토큰 관련 함수 추가
dlcks0601 2aa6881
[Feat] 로그인, 로그아웃 버튼 구현
dlcks0601 8fb9ba9
[Refactor] 헤더 컴포넌트에 버튼 추가
dlcks0601 2d12e1c
[Refactor] 디자인 수정
dlcks0601 bd36cd3
[Feat] authSlice 리팩토링
dlcks0601 0455727
[Refactor] userSlice에 맞게 수정
dlcks0601 080f372
[Feat] 리듀서 통합
dlcks0601 c5af478
[Refactor] presist + redux
dlcks0601 f2ca30c
[Refactor] auth 타입 변경
dlcks0601 243bfb7
[Delete] authSlice 삭제 -> userSlice 생성
dlcks0601 7ad4f9d
[Refactor] 필요없는 타입 삭제
dlcks0601 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,95 @@ | ||
| // src/components/Header.tsx | ||
| import { useNavigate } from 'react-router'; | ||
| import { useSelector, useDispatch } from 'react-redux'; | ||
| import { RootState } from '@/store/rootReducer'; | ||
| import { logout } from '@/hooks/userSlice'; | ||
| import { removeToken } from '@/apis/http.api'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| function AuthButton() { | ||
| const navigate = useNavigate(); | ||
| const dispatch = useDispatch(); | ||
| const isLoggedIn = useSelector((state: RootState) => state.user.isLoggedIn); | ||
|
|
||
| const handleLogin = () => { | ||
| // 로그인 페이지로 이동 | ||
| navigate('/login'); | ||
| }; | ||
|
|
||
| const handleLogout = () => { | ||
| // Redux 상태 초기화 | ||
| dispatch(logout()); | ||
| // 토큰 제거 | ||
| removeToken(); | ||
| // 로그아웃 후 메인 페이지 이동(필요하다면) | ||
| navigate('/'); | ||
| }; | ||
|
|
||
| return isLoggedIn ? ( | ||
| <LogoutBox onClick={handleLogout}> | ||
| <div className='group'> | ||
| <div className='overlap-group'> | ||
| <div className='text-wrapper'>로그아웃</div> | ||
| </div> | ||
| </div> | ||
| </LogoutBox> | ||
| ) : ( | ||
| <LoginBox onClick={handleLogin}> | ||
| <div className='group'> | ||
| <div className='overlap-group'> | ||
| <div className='text-wrapper'>로그인</div> | ||
| </div> | ||
| </div> | ||
| </LoginBox> | ||
|
Comment on lines
+29
to
+43
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. LoginButton과 LogoutButton의 두 구조가 완전하게 동일하네요. |
||
| ); | ||
| } | ||
|
|
||
| export default AuthButton; | ||
|
|
||
| // Styled Components 동일 | ||
| const ButtonBox = styled.div` | ||
| height: 52px; | ||
| width: 114px; | ||
| .group { | ||
| height: 100%; | ||
| position: relative; | ||
| } | ||
| .overlap-group { | ||
| border-radius: 30px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| height: 100%; | ||
| width: 100%; | ||
| cursor: pointer; | ||
| transition: background-color 0.2s ease-in-out; | ||
| } | ||
| .text-wrapper { | ||
| color: #ffffff; | ||
| font-family: 'Pretendard-ExtraBold', Helvetica; | ||
| font-size: 15px; | ||
| line-height: 12px; | ||
| white-space: nowrap; | ||
| } | ||
| `; | ||
|
|
||
| const LoginBox = styled(ButtonBox)` | ||
| .overlap-group { | ||
| background-color: #32c040; | ||
| } | ||
| .overlap-group:hover { | ||
| background-color: #28a034; | ||
| } | ||
| `; | ||
|
|
||
| const LogoutBox = styled(ButtonBox)` | ||
| .overlap-group { | ||
| background-color: #9a9a9a; | ||
| } | ||
| .overlap-group:hover { | ||
| background-color: #7f7f7f; | ||
| } | ||
| `; | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
이런 식으로 간단하게 표기해볼 수도 있겠네요 🤔