From 06fad98ee18c9a1dc44be2a9fcba5752e4f40e55 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Fri, 1 Apr 2022 16:59:06 -0700 Subject: [PATCH] client: add new-post error if no files are present --- client/components/new-post/index.tsx | 15 ++++++++++++--- server/src/database.ts | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/components/new-post/index.tsx b/client/components/new-post/index.tsx index fa3f3dc3..679946f8 100644 --- a/client/components/new-post/index.tsx +++ b/client/components/new-post/index.tsx @@ -74,7 +74,14 @@ const Post = () => { text: 'Please fill out the post title', type: 'error' }) - setSubmitting(false) + hasErrored = true + } + + if (!docs.length) { + setToast({ + text: 'Please add at least one document', + type: 'error' + }) hasErrored = true } @@ -84,12 +91,14 @@ const Post = () => { text: 'Please fill out all the document titles', type: 'error' }) - setSubmitting(false) hasErrored = true } } - if (hasErrored) return + if (hasErrored) { + setSubmitting(false) + return + } await sendRequest('/server-api/posts/create', { title, diff --git a/server/src/database.ts b/server/src/database.ts index deae23a2..17f0bc31 100644 --- a/server/src/database.ts +++ b/server/src/database.ts @@ -12,9 +12,9 @@ export const sequelize = new Sequelize({ }) if (config.memory_db) { - console.log(`Database path: ${databasePath}`) -} else { console.log("Using in-memory database") +} else { + console.log(`Database path: ${databasePath}`) } export const umzug = new Umzug({