-
Notifications
You must be signed in to change notification settings - Fork 31
[김영호] sprint11 #148
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
Merged
dongqui
merged 10 commits into
codeit-bootcamp-frontend:React-김영호
from
numi8462:React-김영호-sprint11
May 16, 2025
The head ref may contain hidden characters: "React-\uAE40\uC601\uD638-sprint11"
Merged
[김영호] sprint11 #148
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
70a973f
refactor(mentor): ButtonProps extends로 변경, ButtonLage -> LinkButton으로 수정
numi8462 ab7cdd4
refactor(mentor): DropdownItem 인터페이스 수정
numi8462 083bee6
refactor(mentor): InputProps extends 추가
numi8462 b5a52e7
refactor: handleFileInputChange 및 handleTagsInputChange 추가
numi8462 a2f8f89
feat: SignUpPage reacthookform 사용
numi8462 cecb754
feat: 회원가입 기능 구현
numi8462 1370e4b
feat: 로그인 기능 구현
numi8462 cadf565
refactor: dropdown handleClickOutside 로직 수정
numi8462 bdb02ee
refactor: 유효성 검사 onChange로 변경
numi8462 8f461af
refactor: signUp 함수 수정
numi8462 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
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,59 @@ | ||
| import { SignInFormData } from '../../pages/LoginPage'; | ||
| import { SignUpFormData } from '../../pages/SignUpPage'; | ||
| import { User } from '../../types/types'; | ||
| import requestor from '../client/requestor'; | ||
|
|
||
| interface AuthResponse { | ||
| accessToken: string; | ||
| refreshToken: string; | ||
| user: User; | ||
| } | ||
|
|
||
| class AuthService { | ||
| async signUp(data: SignUpFormData): Promise<AuthResponse> { | ||
| try { | ||
| const response = await requestor.post<AuthResponse>('/auth/signUp', data); | ||
| return response.data; | ||
| } catch (error: any) { | ||
| console.error('회원가입 실패:', error); | ||
| if (error.response && error.response.data) { | ||
| throw error.response.data; | ||
| } | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async login(data: SignInFormData) { | ||
| try { | ||
| const response = await requestor.post<AuthResponse>('/auth/signIn', data); | ||
| localStorage.setItem( | ||
| 'access_token', | ||
| JSON.stringify({ token: response.data.accessToken }) | ||
| ); | ||
| localStorage.setItem( | ||
| 'refresh_token', | ||
| JSON.stringify({ token: response.data.refreshToken }) | ||
| ); | ||
| localStorage.setItem('user', JSON.stringify(response.data.user)); | ||
|
|
||
| return response.data; | ||
| } catch (error: any) { | ||
| console.error('로그인 실패:', error); | ||
| if (error.response && error.response.data) { | ||
| throw error.response.data; | ||
| } | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| logout() { | ||
| // 로컬 스토리지에서 인증 관련 데이터 제거 | ||
| localStorage.removeItem('access_token'); | ||
| localStorage.removeItem('refresh_token'); | ||
| localStorage.removeItem('user'); | ||
| } | ||
| } | ||
|
|
||
| const authService = new AuthService(); | ||
|
|
||
| export default authService; |
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
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
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 |
|---|---|---|
| @@ -1,30 +1,29 @@ | ||
| import { ChangeEvent, FocusEventHandler, Ref } from 'react'; | ||
| import { InputHTMLAttributes, forwardRef } from 'react'; | ||
| import './Input.css'; | ||
|
|
||
| interface InputProps { | ||
| interface InputProps extends InputHTMLAttributes<HTMLInputElement> { | ||
| label: string; | ||
| id: string; | ||
| value: string; | ||
| type: string; | ||
| placeholder?: string; | ||
| ref?: Ref<HTMLInputElement>; | ||
| onChange: (e: ChangeEvent<HTMLInputElement>) => void; | ||
| onBlur?: FocusEventHandler<HTMLInputElement>; | ||
| error?: string; | ||
| } | ||
|
|
||
| function Input({ label, id, value, onChange, onBlur, ...rest }: InputProps) { | ||
| return ( | ||
| <div className="inputContainer"> | ||
| <label>{label}</label> | ||
| <input | ||
| id={id} | ||
| value={value} | ||
| onChange={onChange} | ||
| onBlur={onBlur} | ||
| {...rest} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
| const Input = forwardRef<HTMLInputElement, InputProps>( | ||
| ({ label, id, value, onChange, onBlur, error, ...rest }, ref) => { | ||
| return ( | ||
| <div className="inputContainer"> | ||
| <label htmlFor={id}>{label}</label> | ||
| <input | ||
| id={id} | ||
| value={value} | ||
| onChange={onChange} | ||
| onBlur={onBlur} | ||
| ref={ref} | ||
| className={error ? 'error' : ''} | ||
| {...rest} | ||
| /> | ||
| {error && <p className="error-message">{error}</p>} | ||
numi8462 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| export default Input; | ||
2 changes: 1 addition & 1 deletion
2
src/components/common/ButtonLarge.css → src/components/common/LinkButton.css
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| .ButtonLarge { | ||
| .LinkButton { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.