From 25337776a170879152df28758b7118fd6c28bf48 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Fri, 7 Jun 2024 20:40:05 +0000 Subject: [PATCH] Fix search filter UI --- src/routes/search/+page.svelte | 135 ++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 46 deletions(-) diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index f3601d3..9d0261b 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -5,8 +5,29 @@ import type { SubmitFunction } from "@sveltejs/kit"; import type { PageData } from "./$types"; - // let visitedValue = "all"; - // let typeValue = ""; + let typeValue: string = ""; + let visitedValue: string = "all"; + + async function filterResults() { + console.log(typeValue); + console.log(visitedValue); + + if (!typeValue) { + typeValue = ""; + } + const value = new URLSearchParams(location.search).get("value"); + console.log(value); + console.log( + `/api/search?value=${value}&type=${typeValue}&visited=${visitedValue}` + ); + let data = await fetch( + `/api/search?value=${value}&type=${typeValue}&visited=${visitedValue}` + ); + console.log(data); + adventureArray = []; + let res = await data.json(); + adventureArray = res.adventures as Adventure[]; + } export let data: PageData; let adventureArray: Adventure[] = data.props?.adventures as Adventure[]; @@ -34,51 +55,73 @@
-
- - All - - Not Visited - - Visited +

Filtering Options

+
+
+ + + +

- - All - - Activity - - Location - - Name - - - +
+ + + + +
+ +
+

Search Results

{#if adventureArray.length > 0}