Sfoglia il codice sorgente

fix: disable empty fields

Timothy J. Baek 7 mesi fa
parent
commit
a53537ccde

+ 7 - 0
src/lib/components/workspace/Knowledge/Collection/AddTextContentModal.svelte

@@ -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

+ 8 - 0
src/lib/components/workspace/Knowledge/CreateCollection.svelte

@@ -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);
 		});