Browse Source

refactor: validateKind only accepts strings now

master
limina1 8 months ago
parent
commit
e923a4d27d
  1. 9
      src/lib/components/EventKindFilter.svelte

9
src/lib/components/EventKindFilter.svelte

@ -17,13 +17,12 @@ @@ -17,13 +17,12 @@
let showAddInput = $state(false);
let inputError = $state('');
function validateKind(value: string | number): number | null {
const strValue = String(value);
if (!strValue || strValue.trim() === '') {
function validateKind(value: string): number | null {
if (!value || value.trim() === '') {
inputError = '';
return null;
}
const kind = parseInt(strValue.trim());
const kind = parseInt(value.trim());
if (isNaN(kind)) {
inputError = 'Must be a number';
return null;
@ -42,7 +41,7 @@ @@ -42,7 +41,7 @@
function handleAddKind() {
const kind = validateKind(newKind);
if (kind !== null) {
if (kind != null) {
visualizationConfig.addEventKind(kind);
newKind = '';
showAddInput = false;

Loading…
Cancel
Save