-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: loaded draft setting logic #391
fix: loaded draft setting logic #391
Conversation
📝 Walkthrough📝 WalkthroughWalkthrough
Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/app/[lng]/write/NoticeEditor.tsx
(1 hunks)
🔇 Additional comments (1)
src/app/[lng]/write/NoticeEditor.tsx (1)
Line range hint 150-170
: 날짜 유효성 검사 추가 필요
currentDeadline
값이 유효하지 않은 경우에 대한 처리가 필요합니다.
다음 스크립트로 날짜 형식 검증이 필요한 다른 부분을 확인할 수 있습니다:
다음과 같이 수정하는 것을 제안합니다:
const {
title: koreanTitle,
content: koreanContent,
enTitle: englishTitle,
enContent: englishContent,
currentDeadline: deadline,
} = notice;
+ const validDeadline = deadline ? dayjs(deadline).isValid() ? dayjs(deadline) : undefined : undefined;
dispatch({ type: 'SET_KOREAN_TITLE', koreanTitle });
dispatch({ type: 'SET_KOREAN_CONTENT', koreanContent });
dispatch({
type: 'SET_ADDITIONAL_KOREAN_CONTENT',
additionalKoreanContent: '',
});
if (englishTitle === undefined || englishContent === undefined) return;
dispatch({ type: 'SET_ENGLISH_TITLE', englishTitle });
dispatch({ type: 'SET_ENGLISH_CONTENT', englishContent });
dispatch({
type: 'SET_ADDITIONAL_ENGLISH_CONTENT',
additionalEnglishContent: '',
});
- dispatch({ type: 'SET_DEADLINE', deadline: dayjs(deadline) });
+ dispatch({ type: 'SET_DEADLINE', deadline: validDeadline });
영어공지 데이터를 추가하려면 reducer에서
TOGGLE_ENGLISH_VERSION
실행이 필요했었습니다. 이를 추가했습니다.PR 390과 유사한 문제도 있길래 함께 해결했습니다.
잘못 사용된 early return을 없앴고, 영어공지 로딩 로직을 수정했으며, deadline 로딩 로직을 추가했습니다.
개인적인 의견으로, editorStateReducer의 구조에 문제가 있습니다. 영어공지 draft 로딩이 필요할 경우
TOGGLE_ENGLISH_VERSION
실행 후에야 내용을 변경할 수 있는데, state.english 값을 곧바로 수정 가능한 action을 만들어 사용하는게 코드 가독성 면에서 좋아보입니다. 비슷한 코드를 다른 곳(공지 수정 로직)에서 또 사용해야 하기도 하구요.Summary by CodeRabbit
새로운 기능
버그 수정
문서화
NoticeEditorProps
인터페이스 업데이트로 공지사항 속성 구조 개선.