add alert subject field, fix post only subject

This commit is contained in:
Tom
2023-05-11 21:19:57 +02:00
parent 94e8546afd
commit 5334ac637a
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -258,6 +258,11 @@ const Board = () => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
event.preventDefault(); event.preventDefault();
if (subjectRef.current.value === "") {
setErrorMessage('Subject field is mandatory');
return;
}
setPublishCommentOptions((prevPublishCommentOptions) => ({ setPublishCommentOptions((prevPublishCommentOptions) => ({
...prevPublishCommentOptions, ...prevPublishCommentOptions,
author: { author: {
@@ -273,7 +278,7 @@ const Board = () => {
useEffect(() => { useEffect(() => {
if (publishCommentOptions.content && triggerPublishComment) { if (publishCommentOptions.subject && triggerPublishComment) {
(async () => { (async () => {
await publishComment(); await publishComment();
resetFields(); resetFields();
+6 -1
View File
@@ -183,6 +183,11 @@ const Catalog = () => {
const handleSubmit = async (event) => { const handleSubmit = async (event) => {
event.preventDefault(); event.preventDefault();
if (subjectRef.current.value === "") {
setErrorMessage('Subject field is mandatory');
return;
}
setPublishCommentOptions((prevPublishCommentOptions) => ({ setPublishCommentOptions((prevPublishCommentOptions) => ({
...prevPublishCommentOptions, ...prevPublishCommentOptions,
author: { author: {
@@ -198,7 +203,7 @@ const Catalog = () => {
useEffect(() => { useEffect(() => {
if (publishCommentOptions.content && triggerPublishComment) { if (publishCommentOptions.subject && triggerPublishComment) {
(async () => { (async () => {
await publishComment(); await publishComment();
resetFields(); resetFields();