From 5334ac637a7d9c96ab92f7a2a2d82f571e610660 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 11 May 2023 21:19:57 +0200 Subject: [PATCH] add alert subject field, fix post only subject --- src/components/views/Board.jsx | 7 ++++++- src/components/views/Catalog.jsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index cbe85158..ed636d7c 100644 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -257,6 +257,11 @@ const Board = () => { const handleSubmit = async (event) => { event.preventDefault(); + + if (subjectRef.current.value === "") { + setErrorMessage('Subject field is mandatory'); + return; + } setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, @@ -273,7 +278,7 @@ const Board = () => { useEffect(() => { - if (publishCommentOptions.content && triggerPublishComment) { + if (publishCommentOptions.subject && triggerPublishComment) { (async () => { await publishComment(); resetFields(); diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index fdb7a5a6..d22444ac 100644 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -182,6 +182,11 @@ const Catalog = () => { const handleSubmit = async (event) => { event.preventDefault(); + + if (subjectRef.current.value === "") { + setErrorMessage('Subject field is mandatory'); + return; + } setPublishCommentOptions((prevPublishCommentOptions) => ({ ...prevPublishCommentOptions, @@ -198,7 +203,7 @@ const Catalog = () => { useEffect(() => { - if (publishCommentOptions.content && triggerPublishComment) { + if (publishCommentOptions.subject && triggerPublishComment) { (async () => { await publishComment(); resetFields();