Skip to content

Commit

Permalink
Merge pull request #70 from AJD-Archive/fix/69
Browse files Browse the repository at this point in the history
챌린지 생성 오류 수정
  • Loading branch information
MyungJiwoo authored Sep 23, 2024
2 parents ed47192 + bbbf840 commit 4e00eb3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pages/CreateChallengePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,16 @@ const CreateChallengePage = () => {
// * 제출시 빈 칸이 있나 확인하는 함수 (있다면 true, 대표 이미지는 선택이라 제외)
const validateFormData = (formData: Challenge): boolean => {
return Object.entries(formData).some(([key, value]) => {
// representImage 필드는 검사에서 제외
if (key === 'representImage') return false;
// representImage, authorName, authorProfileImage 필드는 검사에서 제외
if (key === 'representImage' || key === 'authorName' || key === 'authorProfileImage')
return false;
return value === '';
});
};

// * 폼 제출 핸들러
const handleSubmit = async () => {
console.log(formData);
// 빈 작성란이 있으면 모달창 띄우기
if (validateFormData(formData)) {
openModal('normal'); // 모달 띄우기 (yes/no 모달)
Expand Down

0 comments on commit 4e00eb3

Please sign in to comment.