Skip to content

Conversation

@5wintaek
Copy link
Collaborator

@5wintaek 5wintaek commented Jun 4, 2024

✅ 작업 내용

  • proxy 설정
  • api 연결 및 파일 분리
  • RetryButton 클릭 이벤트 추가
  • 로그인 여부에 따라 분기처리 (userId를 기준으로 분기처리)
  • 로그인 후 포인트가 쌓이도록 수정
  • 전반적으로 불필요한 코드 삭제 및 중복코드 줄일 수 있는 방향으로 리팩토링

📌 이슈 사항

1️⃣ ResultPage 랜덤 불리언 생성

  • ResultPage에서 true,false 에 따라 페이지가 다르게 렌더링 하게 표현을 했는데요. QuizPage에서 문제를 풀면 무조건 true 로만 나오기 때문에 임의로 randomBoolean을 하나 만들어서 true,false 일 때 다르게 렌더링했습니다.

✍ 궁금한 것

1️⃣ QuizPage

navigate('/result', { state: correct });correct 라는 state가 존재하지 않는데 이렇게 쓴 이유가 궁금합니다 !

const handleClickOnBtn = async () => {
    try {
      // ? const res = await postAnswer(); 이렇게 찍고
      // ? console.log(res); true 뜸
      // ? navigate('/result'); 이렇게 해도 작동 잘 됌 , state : correct 왜 넣은지 모르겠음
      // ? console.log(correct);  찍으면 undefiend 뜸
      const { correct } = await postAnswer();
      navigate('/result', { state: correct });
    } catch (error) {
      throw new Error(String(error));
    }
  };

2️⃣ postAnswer.api

corrtIc 조건 처리를 해주었는데 왜 이렇게 하셨는지 궁금해요 ! 코드리뷰 부탁드려용

const { data } = await api.post(`/api/v1/quiz/${quizId}/solve/${userId}`, {
      answer: corretIc ? 1 : 0,
    });
    // ?  correctIC 나 failIC 를 눌렀을 떄 둘 다 true가 뜨는데 correctIC 조건 처리를 왜 하는지 모르겠다.

@5wintaek 5wintaek added ⚒️ refactor 코드 리팩토링 🐡 taek 승택 labels Jun 4, 2024
@5wintaek 5wintaek merged commit 4072a7b into 5wintaek/my-refactor Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚒️ refactor 코드 리팩토링 🐡 taek 승택

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants