[최성락] Sprint11#317
Merged
Lanace merged 13 commits intocodeit-bootcamp-frontend:Next-최성락from Jan 28, 2025
Hidden character warning
The head ref may contain hidden characters: "Next-\ucd5c\uc131\ub77d-sprint11"
Merged
Conversation
Lanace
approved these changes
Jan 28, 2025
Collaborator
Lanace
left a comment
There was a problem hiding this comment.
코드도 너무 깔끔하고 일관되게 짜주셔서 보기도 너무 좋았습니다ㅎㅎ
그러다보니 리뷰할것도 별로 없었네요...;;ㅠ
잘 짜주셔서 감사합니다~!!
고생하셨구 멘토링떄 뵐게여ㅎㅎ
Comment on lines
+15
to
32
| const { | ||
| register, | ||
| handleSubmit, | ||
| formState: { errors }, | ||
| reset, | ||
| } = useForm<LoginRequest>({ | ||
| resolver: zodResolver(loginSchema), | ||
| }); | ||
|
|
||
| const handleSubmit = async (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| await onSubmit({ email, password }); | ||
| const onFormSubmit: SubmitHandler<LoginRequest> = async (data) => { | ||
| try { | ||
| await onSubmit(data); | ||
| reset(); | ||
| } catch (err) { | ||
| console.error("서버오류", err); | ||
| alert("로그인 중 오류가 발생했습니다. 다시 시도해주세요."); | ||
| } | ||
| }; |
Collaborator
There was a problem hiding this comment.
네 맞아요ㅎㅎ 이렇게 사용하는거에요.
엄청 잘 하셨는데여! 👍
Comment on lines
+14
to
+21
| useEffect(() => { | ||
| if (typeof window !== "undefined") { | ||
| const accessToken = localStorage.getItem("ACCESS_TOKEN_KEY"); | ||
| if (accessToken) { | ||
| router.replace("/"); | ||
| } | ||
| } | ||
| }, [router]); |
Collaborator
There was a problem hiding this comment.
이미 useEffect에 왔다는거부터가 클라이언트 컴포넌트라서... window가 없을 수 없었을거에요ㅎㅎ;;
그래서 가급적이면 이런 redirect 처리는 서버쪽에서 처리해주는게 가장 좋아요~
Comment on lines
+70
to
+71
| accessToken: string; | ||
| refreshToken: string; |
Collaborator
There was a problem hiding this comment.
이거 2개의 필드가 계속해서 나오는데, 차라리 인터페이스를 분리하고 합성해서 쓰는식은 어떨까요?
export interface AuthTokens {
accessToken: string;
refreshToken: string;
}
export interface SignupResponse extends AuthTokens {
user: {
id: number;
email: string;
image: null;
nickname: string;
updatedAt: string;
createdAt: string;
};
}
export interface LoginResponse extends AuthTokens {
user: {
id: number;
email: string;
image: null;
nickname: string;
updatedAt: string;
createdAt: string;
};
}
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
요구사항
회원가입
로그인
메인
주요 변경사항
멘토에게