diff --git a/client/components/new-post/index.tsx b/client/components/new-post/index.tsx index c761912e..f3240b96 100644 --- a/client/components/new-post/index.tsx +++ b/client/components/new-post/index.tsx @@ -16,6 +16,7 @@ const Post = () => { const { setToast } = useToasts() const router = useRouter(); const [title, setTitle] = useState() + const [docs, setDocs] = useState([{ title: '', content: '', @@ -61,6 +62,30 @@ const Post = () => { } setSubmitting(true) + let hasErrored = false + + if (!title) { + setToast({ + text: 'Please fill out the post title', + type: 'error' + }) + setSubmitting(false) + hasErrored = true + } + + for (const doc of docs) { + if (!doc.title) { + setToast({ + text: 'Please fill out all the document titles', + type: 'error' + }) + setSubmitting(false) + hasErrored = true + } + } + + if (hasErrored) return + await sendRequest('/server-api/posts/create', { title, files: docs,