[JDDEV-82] [JDDEV-65] 자소서 제출 구현#61
Conversation
📝 WalkthroughWalkthroughThe PR adds answer persistence to the virtual application write flow. It introduces an ChangesVirtual Apply Answer Persistence
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@jobdri/src/components/apply/InputSection.tsx`:
- Around line 125-129: The getAnswers mapping currently falls back to the loop
index for questionId, which can produce non-DB IDs and recreate QUESTION_4041;
update the getAnswers implementation in InputSection.tsx to use only
question.questionId (no index fallback) and fail-fast when it's missing—e.g.,
throw an error or set/return a validation failure that blocks submit if
question.questionId is undefined for any question; ensure answersById is still
used for answer values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a85fba20-67c8-45a3-a9d6-7aa211e257f6
📒 Files selected for processing (3)
jobdri/src/app/apply/virtual/[id]/write/WritePageClient.tsxjobdri/src/components/apply/InputSection.tsxjobdri/src/lib/api/questions.ts
| getAnswers: () => | ||
| questions.map((question, index) => ({ | ||
| questionId: question.questionId ?? index, | ||
| answer: answersById[question.id] ?? "", | ||
| })), |
There was a problem hiding this comment.
Remove index fallback for questionId in answer payload.
Line 127 falling back to index can send non-DB IDs and bring back the same submission failure (QUESTION_4041) this PR is fixing. Fail fast (or block submit) when a question lacks a backend questionId.
💡 Suggested fix
getAnswers: () =>
- questions.map((question, index) => ({
- questionId: question.questionId ?? index,
- answer: answersById[question.id] ?? "",
- })),
+ {
+ const invalid = questions.find(
+ (question) => typeof question.questionId !== "number",
+ );
+ if (invalid) {
+ throw new Error("질문 ID가 누락되어 제출할 수 없습니다.");
+ }
+
+ return questions.map((question) => ({
+ questionId: question.questionId as number,
+ answer: answersById[question.id] ?? "",
+ }));
+ },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| getAnswers: () => | |
| questions.map((question, index) => ({ | |
| questionId: question.questionId ?? index, | |
| answer: answersById[question.id] ?? "", | |
| })), | |
| getAnswers: () => { | |
| const invalid = questions.find( | |
| (question) => typeof question.questionId !== "number", | |
| ); | |
| if (invalid) { | |
| throw new Error("질문 ID가 누락되어 제출할 수 없습니다."); | |
| } | |
| return questions.map((question) => ({ | |
| questionId: question.questionId as number, | |
| answer: answersById[question.id] ?? "", | |
| })); | |
| }, |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@jobdri/src/components/apply/InputSection.tsx` around lines 125 - 129, The
getAnswers mapping currently falls back to the loop index for questionId, which
can produce non-DB IDs and recreate QUESTION_4041; update the getAnswers
implementation in InputSection.tsx to use only question.questionId (no index
fallback) and fail-fast when it's missing—e.g., throw an error or set/return a
validation failure that blocks submit if question.questionId is undefined for
any question; ensure answersById is still used for answer values.
🔗 관련 이슈
📝 개요
⌨️ 작업 상세 내용
버그 수정
saveApply에서 스코프에 없는 변수questions를 참조하던 문제 수정questionId로 사용해QUESTION_4041에러가 발생하던 문제 수정API 연동
/mock-applies/{id}/questions/answers요청 바디를 스펙에 맞게 변경{ answers: [{ questionId, answer }] }/questions/candidates, GET/questions응답에서 백엔드 question ID(questionId/id)를 파싱해 저장하도록 수정컴포넌트 수정
InputSectionHandle에getAnswers()메서드 추가 — ref를 통해 부모에서 작성된 답변 수집 가능WritePageClient제출 시saveApply호출 추가💡 코드 설명 및 참고사항
변경 사항
saveApply함수 버그 수정 — 존재하지 않는 변수questions참조 →answers파라미터로 교체/questions/answers요청 바디를 API 스펙에 맞게 수정 ({ answers: [{ questionId, answer }] })QuestionApiItem/QuestionItem에questionId필드 추가 — 인덱스 대신 DB ID를 답변 제출 시 사용fetchQuestions(candidates),fetchSelectedQuestions모두 백엔드 question ID를 매핑하도록 수정InputSectionHandle에getAnswers()추가 — 부모 컴포넌트에서 답변 수집 가능WritePageClient에서 제출 시saveApply호출 연동 (글자 수 부족 모달의 "확정하기"도 동일하게 처리)📸 스크린샷 (UI 변경 시)
🔍 리뷰 요구사항 (Reviewers)