Skip to content

Commit

Permalink
fix: 내용을 추가하지 않거나 파일을 업로드 하지 않은 상태로 작성 시도시 작성이 되던 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
geongyu09 committed Jun 26, 2024
1 parent 5f671d3 commit fd10d23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/hooks/querys/useContentQuery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const useUploadContentMutation = ({
mutationFn: () => {
if (!file) {
alert("파일을 선택해주세요");
return;
throw new Error("파일을 선택해주세요");
}
if (!title || !content) {
alert("제목과 내용을 입력해주세요");
throw new Error("제목과 내용을 입력해주세요");
}
return uploadContent(title, content, file[0]);
},
Expand All @@ -54,6 +58,10 @@ export const useUploadContentMutation = ({
alert("글이 성공적으로 업로드되었습니다.");
closeModal();
},
onError: () => {
setIsLoading(false);
alert("글 업로드에 실패하였습니다.");
},
});
return mutate;
};
Expand Down
1 change: 1 addition & 0 deletions src/service/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const uploadContent = async (title, content, file) => {
const { data, error: insertError } = await supabase
.from(TABLE_NAME)
.insert([{ title, content, thumbnail, id: newId }]);
console.log(data, insertError);
if (insertError) throw new Error(insertError.message);
return data;
};
Expand Down

0 comments on commit fd10d23

Please sign in to comment.