feat: WorkerDetailPage에 근로자 서류 등록 + 파일 업로드 실연동 - #228
Merged
Conversation
fowoco/server를 다시 훑어보니 POST /api/v1/files(FileController), POST/PATCH
/workers/{id}/documents(WorkerDocumentController)가 이미 구현돼 있는데 클라이언트가
전혀 안 쓰고 있었다. DocumentListPage의 FileUploadModal(HWP/HWPX 전용)은 서버가
지원 안 하는 형식이라 그대로 못 붙이고, 대신 서버가 실제 지원하는 image/PDF
업로드 + 서류 등록 흐름을 WorkerDetailPage에 새로 붙였다.
등록 API는 생성 시점에 file_id를 안 받아서, 파일이 있으면 업로드 → 등록 →
등록 응답의 version으로 PATCH해서 file_id를 연결하는 3단계로 처리한다.
client.ts의 apiFetch가 body 존재 시 무조건 Content-Type: application/json을
강제하던 걸 FormData는 건너뛰도록 고쳐서 multipart 업로드가 가능해지게 했다.
DocumentDetailPage의 확인/반려(PATCH)는 여전히 데모 상태 — 목록 API에 version이
없어 기존 문서의 expected_version을 알 방법이 없는 문제는 이번 스코프 밖(#57).
Closes #227
5 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
서버에 이미 구현돼 있지만 클라이언트가 안 쓰던 API 2개를 연결:
POST /api/v1/files— 파일 업로드 (image/jpeg·png·webp, application/pdf, 최대 20MB)POST/PATCH /api/v1/workers/{workerId}/documents(/{documentId})— 서류 상태 등록/수정DocumentListPage의FileUploadModal(HWP/HWPX 전용)은 서버가 지원 안 하는 형식이라 그대로 연결 불가 — 대신 서버가 실제 지원하는 image/PDF 업로드 흐름을WorkerDetailPage에 새로 붙였다.변경 사항
src/api/files.ts신규:uploadFile()src/api/documents.ts:registerWorkerDocument(),patchWorkerDocument(),WorkerDocumentResponse추가src/api/client.ts:apiFetch가 body 존재 시 무조건Content-Type: application/json을 강제하던 걸,FormData면 건너뛰도록 수정 (브라우저가 자동으로 올바른 multipart boundary 헤더를 설정하게 함)WorkerDetailPage의 "서류" 카드에 "+ 서류 등록" 버튼 +RegisterDocumentModal추가 — 서류 유형/제출 상태/유효기간/파일 첨부(선택) 입력file_id발급) → 서류 등록 → 등록 응답의version으로 PATCH하여file_id연결까지 3단계로 처리 (등록 API는 생성 시점에 file_id를 받지 않음)스코프 제외
DocumentDetailPage의 확인/반려 액션은 여전히 데모 —GET /documents목록에version이 없고 단건 조회도 없어 기존 문서의expected_version을 알 방법이 없음([Screen] 티켓 관리 화면 신규 설계 및 구현 (/tickets) #57, 이번 PR로 해결 안 됨)검증
npm run lintnpx vitest run(343 tests passed)npm run buildCloses #227