From fd10d23829d7bbb1e051c8b0f58a02cb8a7a9da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=80=E1=85=A5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=B2?= Date: Wed, 26 Jun 2024 17:20:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=82=B4=EC=9A=A9=EC=9D=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B1=B0=EB=82=98=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EC=9D=84=20=EC=97=85=EB=A1=9C=EB=93=9C=20?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EB=A1=9C=20=EC=9E=91=EC=84=B1=20=EC=8B=9C=EB=8F=84=EC=8B=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=EC=9D=B4=20=EB=90=98=EB=8D=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/querys/useContentQuery.jsx | 10 +++++++++- src/service/contents.js | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hooks/querys/useContentQuery.jsx b/src/hooks/querys/useContentQuery.jsx index 182aa3d..fea224f 100644 --- a/src/hooks/querys/useContentQuery.jsx +++ b/src/hooks/querys/useContentQuery.jsx @@ -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]); }, @@ -54,6 +58,10 @@ export const useUploadContentMutation = ({ alert("글이 성공적으로 업로드되었습니다."); closeModal(); }, + onError: () => { + setIsLoading(false); + alert("글 업로드에 실패하였습니다."); + }, }); return mutate; }; diff --git a/src/service/contents.js b/src/service/contents.js index 059c34a..e5bf068 100644 --- a/src/service/contents.js +++ b/src/service/contents.js @@ -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; };