diff --git a/src/routes/(console)/project-[project]/functions/templates/+page.svelte b/src/routes/(console)/project-[project]/functions/templates/+page.svelte index fd669866c..36ca98eea 100644 --- a/src/routes/(console)/project-[project]/functions/templates/+page.svelte +++ b/src/routes/(console)/project-[project]/functions/templates/+page.svelte @@ -29,7 +29,9 @@ if (add) { target.searchParams.append(filter, value); } else { - const previous = target.searchParams.getAll(filter).filter((n) => n !== value); + const previous = target.searchParams + .getAll(filter) + .filter((n) => n.toLowerCase() !== value.toLowerCase()); target.searchParams.delete(filter); previous.forEach((n) => target.searchParams.append(filter, n)); } @@ -39,8 +41,7 @@ function clearSearch() { const target = new URL($page.url); - target.searchParams.delete('page'); - target.searchParams.delete('search'); + target.search = ''; goto(target.toString()); } @@ -90,6 +91,24 @@ goto(target.toString(), { keepFocus: true }); } + function isChecked(useCase: string) { + return $page.url.searchParams + .getAll('useCase') + .some((param) => param.toLowerCase() === useCase.toLowerCase()); + } + + function getErrorMessage() { + const searchParams = $page.url.searchParams; + const paramsArray = Array.from(searchParams.entries()); + + if (paramsArray.length === 1) { + const [_, value] = paramsArray[0]; + return `Sorry, we couldn't find "${value}".`; + } else if (paramsArray.length > 1) { + return `Sorry, we couldn't find any results with the applied filters.`; + } + } + $: buttonDisabled = isServiceLimited( 'functions', $organization?.billingPlan, @@ -121,9 +140,7 @@ applyFilter('useCase', useCase, e)} /> {useCase} @@ -248,8 +265,7 @@
- Sorry we couldn't find "{$page.url.searchParams.get('search')}" + {getErrorMessage()}

There are no templates that match your search.