-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: posts #182
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: posts #182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors how posts and drafts are handled across the codebase by introducing unified PostType/DraftType, updating type guards, centralizing category/config definitions, and overhauling form components to use React Hook Form and React Query consistently.
- Introduce
DraftType/PostTypein types and updatehandlePost.tsguards - Extract and organize write/edit configurations and category options into separate modules
- Refactor
Input,WriteForm, andEditFormto leverage React Query mutations and unified callback patterns
Reviewed Changes
Copilot reviewed 85 out of 88 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/utils/src/handlePost.ts | Added isDraft/isPost, updated type guards for unified PostType and DraftType |
| packages/types/src/evidences.ts | Renamed types to PostType/PostResponse, updated status type |
| packages/shared/src/input.tsx | Simplified Input component by removing custom email logic and using form errors |
| apps/client/src/widgets/write/ui/index.tsx | Refactored WriteForm to use useMutation, unified draft/submit flows |
| apps/client/src/views/detail/index.tsx | Updated DetailView to use context and React Query delete mutation |
Comments suppressed due to low confidence (4)
apps/client/src/widgets/write/ui/index.tsx:84
- [nitpick] Function names should use camelCase. Rename
ChangeStatusDrafttohandleSetDraftStatus(or similar) to follow project naming conventions and clarify its purpose.
const ChangeStatusDraft = useCallback(() => {
packages/types/src/evidences.ts:48
- The
PostResponseinterface is missing a property for other evidence (e.g.,otherEvidence: Others[]) but code referencesotherEvidenceinPostsWidget. Add that array to the type to match usage.
export interface PostResponse {
apps/client/src/views/detail/index.tsx:124
- The
handleModalOpenfunction is referenced here but no longer defined. Define it (e.g.,const handleModalOpen = () => setModalOpen(true)) or update the onClick handler to use the correct function.
onClick={handleModalOpen}
apps/client/src/widgets/write/model/writeConfig.ts:87
- The
onSubmitsignature for the 'others' case no longer matches the expected(data, type)pattern used elsewhere. It should accept a secondsubmitTypeparameter or theConfiginterface updated to match this implementation.
onSubmit: async (data: FormValues) => {
|
✅ CI success |
bae080311
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로직을 좀 많이 깔끔하게 분리해야할거 같아요
|
✅ CI success |
|
✅ CI success |
|
✅ CI success |
|
✅ CI success |
#️⃣연관된 이슈
#180
📝작업 내용
ScoreFormType
-> 추가
SCORE_CATEGORIES
-> 다른 파일로 분리 및 교내외인성영역관련수상 카테고리 추가
Calculate
-> Page, View 분리
파일, 함수명 일관성 유지
send -> post
update -> patch
Book -> reading
타입가드 추가 및 사용
-> isActivity, isReading, isOthers, isDraft, isPost
에러 처리 일관성 유지
error as AxiosError -> isAxiosError(error)
Certification 타입명 변경
-> request, response
겹치는 파일, 타입, 안쓰는 타입 제거
evidenceMock 구조 실제 데이터와 일치하게 변경
signin, signup 타입 분리
write, edit에서 사용하는 configType 하나로 통일
-> major, humanities, reading, others
input 공통 컴포넌트 내의 email 제한 로직 삭제
-> react-hook-form 에러 메시지 사용하도록 변경
-> 의존성 주입을 통해 email 제한 로직을 추가하도록 하거나 해야 할 듯
💬리뷰 요구사항(선택)
post, draft type 처리 로직을 잘 살펴봐주세요.
새로고침 시 게시글의 내용물이 없어지는 문제가 있어서 새로고침을 못 하도록 막거나 refetch하는 로직을 추가해야 할 것 같은데 코멘트 꼭 달아주세요.