Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GlobalStyles } from '@/styles/GlobalStyles';
import theme from '@/styles/theme';
import { BottomNavigationStyleConfig as BottomNavigation } from 'chakra-ui-bottom-navigation';

// [May]: 여기 정의해두셔도 괜찮지만, 따로 파일 분리해도 좋을거같습니다..!
const queryClient = new QueryClient({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving the definition of queryClient to a separate file. This will help in maintaining the code and improving readability.

defaultOptions: {
queries: {
Expand All @@ -19,6 +20,7 @@ const queryClient = new QueryClient({
},
});

// [May]: 여기 정의해두셔도 괜찮지만, 따로 파일 분리해도 좋을거같습니다..!
const chakraTheme = extendTheme({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to separate the chakraTheme into a different file for better code organization and readability.

components: {
BottomNavigation,
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Question/hooks/useAnswer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { useMutation } from '@tanstack/react-query';
import { createAnswer } from '@/pages/Question/api/fetchAnswer';
import { CreateAnswerRequest, CreateAnswerResponse } from '../types/answer';
import { useNavigate } from 'react-router';

export const useCreateAnswer = () => {
const navigate = useNavigate();

return useMutation<CreateAnswerResponse, unknown, CreateAnswerRequest>({
mutationFn: createAnswer,
onSuccess: (data) => {
console.log('Answer created successfully:', data);
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console.log in production code. If you need to log the success message, consider using a logging library that can be toggled for production or development environments.

// [Should] 단순히 로그를 찍는것보다 회원가입 / 로그인 페이지로 리다이렉트 시켜주는게 사용자 경험에 더 좋을거같습니다
onError: (error) => {
console.error('Failed to create answer:', error);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using console.error in production code. Consider using a more user-friendly way to display errors, such as a toast notification or a message in the UI.

navigate('/login');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might not be appropriate to always redirect to the login page when an error occurs. The error could be due to other reasons, not necessarily because the user is not logged in. Consider handling different types of errors differently.

},
});
};
4 changes: 4 additions & 0 deletions src/pages/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export const RegisterPage = () => {
return;
}

// [Question] 백엔드랑 합의된 로그인 / 회원가입 유효성 검사가 존재하나요?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid adding questions or suggestions as comments in the code. Instead, consider discussing these points with your team or through the PR comments section.

// [Should] 존재한다면 zod등을 이용해서 유효성 검사 및 사용자에게 피드백(비밀번호가 형식에 안맞음 등,,)을 알려주는게 좋을거같습니다.
// 현재 비밀번호 유효성 검사에 실패하여 회원가입이 실패되는데, 유저 입장에서는 무었때문에 거절 당한지 알수가없습니다

// 모든 조건이 충족되면 로컬스토리지에 저장
localStorage.setItem('registerEmail', data.email);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing sensitive information like passwords in local storage is not secure. Consider using more secure methods to handle passwords.

localStorage.setItem('registerPassword', data.password);
Expand Down