Skip to content

Conversation

@hanguswls
Copy link
Collaborator

@hanguswls hanguswls commented Jan 9, 2025

🔍 개요

글 저장 기능 구현

✨ 작업 내용

  • useCreatePost 훅 추가: 글 데이터 상태 관리 및 저장 로직 구현
  • useMarkdownEditor 리팩토링: props 기반 상태 동기화 및 이미지 업로드 로직 개선
  • CreatePost 컴포넌트: PostTitleInput, MarkdownEditor, CategorySelector, NicknameAndPasswordInput 상태 연동
  • API 개선: createPost 함수 추가 및 response 처리 보완

✅ 체크리스트

  • 코드가 제대로 빌드되는지 확인했습니다.
  • 문서(예: README, API 문서)가 업데이트되었거나 업데이트가 필요하지 않습니다.
  • PR에 연결된 이슈가 있는 경우, 해당 이슈 번호를 링크했습니다.

🔗 관련 이슈

Related to #4

💬 리뷰 요구사항 (option)

관련 커밋: 1b18d71

  • MarkdownEditor와 ToolBar 핸들러 이름 변경(onIconButtonClick)이 괜찮은지 확인해주세요
    컴포넌트 내에서 바로 로직을 처리하는게 아니라 부모로부터 전달받은 콜백 실행이라 handleIconButtonClick보다 onIconButtonClick으로 바꿨어요. 근데 잘못 바꾼 것 같기도하고 잘 모르겠어요

📎 추가 정보 (option)

  • 글 저장 기능에 태그는 포함되어있지 않아요. 태그 훅, api, 컴포넌트를 수정한 PR 또 올려야해요

- 글 데이터(post)의 상태 관리
- 필드별 데이터 업데이트를 위한 handlePostChange 함수 구현
- 저장 버튼 클릭 시 createPost API 호출
- 필수 입력값 검증 로직(validateRequiredFields)에 이미지 업로드 관련 로직 포함
- selectedCategory 상태를 제거하고, 부모로부터 props로 관리되도록 수정
- NicknamePasswordInput 안의 author와 password 상태를 제거하고, 부모로부터 props로 관리되도록 수정
- useMarkdownEditor 훅의 로직을 props 기반으로 동작하도록 변경
- initialMarkdown, imageIds, onContentChange, onImageIdsChange를 props로 받아 상태와 동기화
- 마크다운 텍스트 처리 공통 로직을 추출하여 getSelectionContext와 updateContent 함수로 구현
- 이미지 업로드 시 content 업데이트 로직 수정
- CreatePost 컴포넌트에서 useMarkdownEditor 훅을 props 기반으로 호출하여 부모 상태와 동기화
- handleIconButtonClick을 onIconButtonClick으로 수정
- 글 생성 함수(createPost) 구현
- post.d.ts에 CreatePostParams 추가
- api.ts에 response body가 없는 경우 상태 코드만 반환하도록 수정
@hanguswls hanguswls added the feature 기능 추가 또는 수정 label Jan 9, 2025
@hanguswls hanguswls requested a review from thanhhien234 January 9, 2025 08:34
@hanguswls hanguswls self-assigned this Jan 9, 2025
@vercel
Copy link

vercel bot commented Jan 9, 2025

@hanguswls is attempting to deploy a commit to the TiumLab Team on Vercel.

A member of the Team first needs to authorize it.

@hanguswls hanguswls merged commit be92a42 into DevBadgers:develop Jan 9, 2025
1 check failed
@hanguswls hanguswls deleted the feature/4-save-post branch January 10, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 기능 추가 또는 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants