Skip to content

Conversation

@wldnjs990
Copy link
Collaborator

✅ 요약

🪄 변경사항

  • 편지작성의 답장전송을 제외하고 API 테스트를 완료했습니다.(답장은 우편함 pr을 받고 난 후에 테스트 예정)
  • 랜덤편지 API 테스트 완료했습니다.(편지 24시간이 지났을때 후처리는 못 보긴 했는데 이건 백엔드분들과 처리를 어떻게 해야할지 상의해봐야 할 거 같습니다!)
  • 편지 매칭 로직을 만들었습니다.(카운트다운 로직) 그런데 멘토링 중에 시분초로 관리하던 로직을 초로만 관리하는 방안을 추천받아 초로 시간을 관리하는 로직으로 리팩토링 했습니다.

🖼️ 결과 화면 (선택)

image
지금 랜덤편지 하나를 답장 완료한 상태라 쿨타임 화면밖에 안보입니당😅 추후에 다른 화면도 올리겠습니다!

💬 리뷰어에게 전할 말 (선택)

  • 흑흑 많은 일들이 있었습니다..
  • api랑 싸워서 이겼습니다💪💪

@wldnjs990 wldnjs990 added ✨ Feature 기능 개발 이슈 🔨 Refactor 리팩토링 이슈 labels Mar 4, 2025
@wldnjs990 wldnjs990 self-assigned this Mar 4, 2025
@wldnjs990 wldnjs990 linked an issue Mar 4, 2025 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@tifsy tifsy left a comment

Choose a reason for hiding this comment

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

전투를 치르셨네요.. 수고 많으셨습니다! 🥹

아래는 공통적으로 리뷰 드리고 싶었던 점입니다! 💪🏻

  • try-catch로 api 호출을 감싸 예상치 못한 에러를 체크
  • !res 대신 res.status 로 어떤 에러인지 파악할 수 있도록
  • catch (error) 후에 throw error; 처리

export { getRandomLetters };
const postRandomLettersApprove = async (approveRequest: ApproveRequest, callBack?: () => void) => {
try {
console.log('엔드포인트 : /api/random-letters/approve');
Copy link
Collaborator

Choose a reason for hiding this comment

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

테스트용 console.log는 나중에 한 번에 삭제하거나 해야겠네용

console.log('엔드포인트 : /api/random-letters/approve');
console.log('request', approveRequest);
const res = await client.post('/api/random-letters/approve', approveRequest);
if (!res) throw new Error('랜덤편지 매칭수락 도중 에러가 발생했습니다.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

!res 로는 어떤 에러인지 알기가 어려우니 res.status 로 확인하는 건 어떨까요?

if (res.status !== 200) { throw new Error('랜덤편지 매칭수락 도중 에러가 발생했습니다.'); }

이런 식으로요!

if (callBack) callBack();
return res;
} catch (error) {
console.error(error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

throw error; 까지 처리해주시면 좋을 것 같습니다!

<ArrowLeftIcon className="h-6 w-6 text-white" />
<button onClick={() => navigate(-1)}>
<ArrowLeftIcon className="h-6 w-6 text-white" />
</button>
Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 늘 까먹지만 aria-label 붙여주시면 좋을 것 같습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

확실히 코드가 짧아졌네요! 아주 좋습니다 💃🏻🕺🏻

// createdAt: new Date(),
// },
// ];

Copy link
Collaborator

Choose a reason for hiding this comment

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

더미 데이터 삭제 대신 주석 처리로 남겨두신 이유가 궁금해요!

setMatchedLetter(res.data.data);
setOpenSelectedDetailModal(true);
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

try-catch로 api 호출을 감싸는 게 좋아보입니다!

setMatchedLetter(data);
}
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

datanull 이거나 undefined일 경우에 오류를 방지하는 로직이 있으면 어떨까요?

if (res?.status === 200) {
setPrevLetter(res.data.data);
} else {
alert('이전 편지 데이터를 받아오는 도중 오류가 발생했습니다(잘못된 편지 접근입니다.)');
Copy link
Collaborator

Choose a reason for hiding this comment

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

console.log 가 아니라 alert 로 하신 이유가 있을까요? 사용자에게 보여줘야 할 부분은 아닌 것 같아서 여쭤봅니다!

getPrevLetter(letterId, setPrevLetter);
// MEMO : letterId는 쿼리파라미터를 통해 얻을수 있음 => 최초답장, 답장만 prevLetter을 받는 로직을 실행함
if (!letterId) return;
if (location.state && location.state?.randomMatched) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

location.state?.randomMatched 만 사용해도 될 것 같습니당

@wldnjs990 wldnjs990 merged commit 3071137 into develop Mar 4, 2025
@wldnjs990 wldnjs990 deleted the 49-feat-write/randomLetter/letterDetail-nd branch March 4, 2025 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발 이슈 🔨 Refactor 리팩토링 이슈

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat:편지 작성 + 랜덤편지 + 편지상세 페이지 2차 기능 구현

3 participants