fix: disable empty fields

This commit is contained in:
Timothy J. Baek 2024-10-04 16:18:44 -07:00
parent 5017ca90ff
commit a53537ccde
2 changed files with 15 additions and 0 deletions

View File

@ -40,6 +40,13 @@
<form
class="flex flex-col w-full"
on:submit|preventDefault={() => {
if (name.trim() === '' || content.trim() === '') {
toast.error($i18n.t('Please fill in all fields.'));
name = '';
content = '';
return;
}
dispatch('submit', {
name,
content

View File

@ -15,6 +15,14 @@
const submitHandler = async () => {
loading = true;
if (name.trim() === '' || description.trim() === '') {
toast.error($i18n.t('Please fill in all fields.'));
name = '';
description = '';
loading = false;
return;
}
const res = await createNewKnowledge(localStorage.token, name, description).catch((e) => {
toast.error(e);
});