diff --git a/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte b/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte index 557110d8..3bbc13a7 100644 --- a/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte +++ b/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte @@ -49,6 +49,13 @@ const ast = buildAstFromQuery($queryStore); + if (ast.children.includes(null)) { + alert( + "No query entered in one of the queries. You can enter a query or remove the query fields.", + ); + return; + } + options?.spots?.forEach((spot: SpotOption) => { const name = spot.name; const measureItem: MeasureOption | undefined = $measureStore.find( diff --git a/packages/lib/src/stores/negotiate.ts b/packages/lib/src/stores/negotiate.ts index f4cd44ea..0e06c3cb 100644 --- a/packages/lib/src/stores/negotiate.ts +++ b/packages/lib/src/stores/negotiate.ts @@ -53,28 +53,30 @@ export const buildHumanReadableRecursively = ( } queryLayer.children.forEach((child: AstElement, index: number): void => { - if ("type" in child && "value" in child && "key" in child) { - if (typeof child.value === "string") { - humanReadableQuery += `(${child.key} ${child.type} ${child.value})`; + if (child !== null) { + if ("type" in child && "value" in child && "key" in child) { + if (typeof child.value === "string") { + humanReadableQuery += `(${child.key} ${child.type} ${child.value})`; + } + if ( + typeof child.value === "object" && + "min" in child.value && + "max" in child.value + ) { + humanReadableQuery += `(${child.key} ${child.type} ${child.value.min} and ${child.value.max})`; + } } - if ( - typeof child.value === "object" && - "min" in child.value && - "max" in child.value - ) { - humanReadableQuery += `(${child.key} ${child.type} ${child.value.min} and ${child.value.max})`; - } - } - humanReadableQuery = buildHumanReadableRecursively( - child, - humanReadableQuery, - ); + humanReadableQuery = buildHumanReadableRecursively( + child, + humanReadableQuery, + ); - if (index === queryLayer.children.length - 1) { - } - if (index < queryLayer.children.length - 1) { - humanReadableQuery += ` ${queryLayer.operand} `; + if (index === queryLayer.children.length - 1) { + } + if (index < queryLayer.children.length - 1) { + humanReadableQuery += ` ${queryLayer.operand} `; + } } });