Skip to content
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

refactor: uuid 형식 문자열로 url 관리 , nextQuiz, previousQuiz, app.tsx 초기렌더… #15

Merged
merged 4 commits into from
Feb 8, 2025

Conversation

nemo0824
Copy link
Collaborator

@nemo0824 nemo0824 commented Feb 7, 2025

refactor: 기존 number형태의 url 을 uuid형식의 문자열로 관리, nextQuizBtn, previousQuizBtn, handleStartQuiz 수정,

src/App.tsx Outdated
const { fetchQuizzesData, quizzesList } = useQuizStore();
useEffect(() => {
fetchQuizzesData();
console.log(quizzesList, 'quizList');
Copy link

Choose a reason for hiding this comment

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

Suggested change
console.log(quizzesList, 'quizList');

pr을 생성하기 전과 후에 변경사항을 살펴보는 건 기본입니다.

Comment on lines 34 to 35
_id: string;
id: string;
Copy link

Choose a reason for hiding this comment

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

얘는 왜 아이디가 두 갠가요..?

Copy link

@new-deni new-deni left a comment

Choose a reason for hiding this comment

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

블로그 글을 보면 보통 아래쪽에 이전글 다음글 버튼이 있죠? 지금 재원님이 하신 방식은 블로그로 치면 글이 백 개면 백개, 천 개면 천 개를 처음에 모두 받아오고 프론트에서 계속 관리하는 셈이에요. 과연 이렇게 할까요? 생각해보시고 변경하는 데 너무 오래 걸릴 것 같으면 일단 이렇게 계속 진행하세요~

pr에 디버깅용 콘솔로그는 남지 않게 해주세요. 조금만 성의를 들이면 됩니다.

…드를 이용 데이터가져오기, currentQuiz값기준으로 prev,next값 한번에가져오기,

useEffect(() => {
if (location.pathname === '/' || !quizId) return;
fetchQuizData(quizId);
const isCurrentLoaded = currentQuiz.id === quizId;
const isPrevNextLoaded = prevQuiz.id === quizId || nextQuiz?.id === quizId;
Copy link

Choose a reason for hiding this comment

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

이전 퀴즌의 아이디가 현재 퀴즈 아이디와 같거나 다음 퀴즈의 아이디가 현재 퀴즈 아이디와 같다면 이전 다음 퀴즈가 로드되어 있다
이게 무슨 뜻인가요..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

변수명 신경써서 진행하겠습니다!


useEffect(() => {
if (location.pathname === '/' || !quizId) return;
fetchQuizData(quizId);
const isCurrentLoaded = currentQuiz.id === quizId;
Copy link

Choose a reason for hiding this comment

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

현재 퀴즈의 아이디와 의도한 퀴즈 아이디(파람에서 추출한 아이디)가 다르다면 그건 에러를 던져야 할 상황인 것 같아요.

Comment on lines 32 to 40
if (prevQuiz) {
const currentValue = currentQuiz;
setQuizState({
currentQuiz: prevQuiz,
nextQuiz: currentValue,
prevQuiz: undefined,
});
}
navigate(`/quizzes/${prevQuiz.id}`);
Copy link

Choose a reason for hiding this comment

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

navigate을 하면 퀴즈 아이디를 보고 스토어가 알아서 현재 퀴즈를 반환해주면 좋겠네요.

Comment on lines 43 to 44
prevQuiz: {} as QuizType,
nextQuiz: {} as QuizType,
Copy link

Choose a reason for hiding this comment

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

currentQuiz에 더해 거짓말하는 코드가 점점 늘어나네요.
기존 퀴즈, 다음 퀴즈 들고 있는 로직은 없애는 게 나을 것 같아요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 이전값과 다음값 가지고있는 로직은 없애도록 하겠습니다.

Copy link

sonarqubecloud bot commented Feb 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link

@new-deni new-deni left a comment

Choose a reason for hiding this comment

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

처음보다 꽤 깔끔해졌네요 👍

@nemo0824
Copy link
Collaborator Author

nemo0824 commented Feb 8, 2025

감사합니다!

@nemo0824 nemo0824 merged commit 617019f into main Feb 8, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants