fix: tag validation

This commit is contained in:
Timothy J. Baek 2024-03-29 18:00:08 -07:00
parent f96beeee8f
commit 2fbb92aceb

View file

@ -1,6 +1,7 @@
<script lang="ts">
import { createEventDispatcher, getContext } from 'svelte';
import { tags } from '$lib/stores';
import { toast } from 'svelte-sonner';
const dispatch = createEventDispatcher();
const i18n = getContext('i18n');
@ -10,9 +11,14 @@
let tagName = '';
const addTagHandler = async () => {
dispatch('add', tagName);
tagName = '';
showTagInput = false;
tagName = tagName.trim();
if (tagName !== '') {
dispatch('add', tagName);
tagName = '';
showTagInput = false;
} else {
toast.error('Invalid Tag');
}
};
</script>