diff --git a/src/components/ReplyModal.jsx b/src/components/ReplyModal.jsx index 6fd761a1..99f84809 100644 --- a/src/components/ReplyModal.jsx +++ b/src/components/ReplyModal.jsx @@ -137,6 +137,14 @@ const ReplyModal = ({ isOpen, closeModal }) => { const handleSubmit = async (event) => { event.preventDefault(); + if ( + commentRef.current.value === "" && + linkRef.current.value === "" + ) { + setErrorMessage("Please enter a comment or link."); + return; + } + setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, author: { @@ -152,7 +160,7 @@ const ReplyModal = ({ isOpen, closeModal }) => { useEffect(() => { - if (publishCommentOptions.content && triggerPublishComment) { + if (publishCommentOptions && triggerPublishComment) { (async () => { await publishComment(); resetFields(); diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index ed636d7c..b8933b7d 100644 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -278,7 +278,7 @@ const Board = () => { useEffect(() => { - if (publishCommentOptions.subject && triggerPublishComment) { + if (publishCommentOptions && triggerPublishComment) { (async () => { await publishComment(); resetFields(); diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index d22444ac..18f2f4b9 100644 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -203,7 +203,7 @@ const Catalog = () => { useEffect(() => { - if (publishCommentOptions.subject && triggerPublishComment) { + if (publishCommentOptions && triggerPublishComment) { (async () => { await publishComment(); resetFields(); diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index c7cf58b7..c30c1c87 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -210,6 +210,15 @@ const Thread = () => { const handleSubmit = async (event) => { event.preventDefault(); + if ( + commentRef.current.value === "" && + linkRef.current.value === "" + ) { + setErrorMessage("Please enter a comment or link."); + return; + } + + setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, author: { @@ -225,7 +234,7 @@ const Thread = () => { useEffect(() => { - if (publishCommentOptions.content && triggerPublishComment) { + if (publishCommentOptions && triggerPublishComment) { (async () => { await publishComment(); resetFields();