mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 11:45:17 +02:00
feat: Add search functionality to navbar
This commit is contained in:
parent
18b4dfa922
commit
eadf001b39
2 changed files with 23 additions and 13 deletions
|
@ -100,9 +100,12 @@
|
|||
<li>
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<input type="text" class="grow" placeholder="Search" />
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
on:click={() => goToSearch()}
|
||||
fill="currentColor"
|
||||
class="w-4 h-4 opacity-70"
|
||||
><path
|
||||
|
|
|
@ -12,21 +12,22 @@
|
|||
let adventureArray: Adventure[] = data.props?.adventures as Adventure[];
|
||||
|
||||
const filter: SubmitFunction = async ({ formData }) => {
|
||||
const radioValue = formData.get("visited");
|
||||
const typeValue = formData.get("type");
|
||||
visitedValue = formData.get("visited") as string;
|
||||
typeValue = formData.get("type") as string;
|
||||
const value = new URLSearchParams(location.search).get("value");
|
||||
console.log(value);
|
||||
|
||||
console.log(
|
||||
`/api/search?value=${value}&type=${typeValue}&visited=${radioValue}`
|
||||
`/api/search?value=${value}&type=${typeValue}&visited=${visitedValue}`
|
||||
);
|
||||
let data = await fetch(
|
||||
`/api/search?value=${value}&type=${typeValue}&visited=${radioValue}`
|
||||
|
||||
let response = await fetch(
|
||||
`/api/search?value=${value}&type=${typeValue}&visited=${visitedValue}`
|
||||
);
|
||||
console.log(data);
|
||||
adventureArray = [];
|
||||
let res = await data.json();
|
||||
console.log(response);
|
||||
|
||||
let res = await response.json();
|
||||
adventureArray = res.adventures as Adventure[];
|
||||
console.log(radioValue);
|
||||
console.log("TEST" + visitedValue + " " + typeValue);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -38,7 +39,7 @@
|
|||
value="all"
|
||||
class="radio radio-primary"
|
||||
bind:group={visitedValue}
|
||||
checked
|
||||
checked={visitedValue === "all"}
|
||||
/>
|
||||
All
|
||||
<input
|
||||
|
@ -47,6 +48,7 @@
|
|||
name="visited"
|
||||
value="false"
|
||||
class="radio radio-primary"
|
||||
checked={visitedValue === "false"}
|
||||
/>
|
||||
Not Visited
|
||||
<input
|
||||
|
@ -55,6 +57,7 @@
|
|||
name="visited"
|
||||
value="true"
|
||||
class="radio radio-primary"
|
||||
checked={visitedValue === "true"}
|
||||
/>
|
||||
Visited
|
||||
<br />
|
||||
|
@ -64,6 +67,7 @@
|
|||
value=""
|
||||
class="radio radio-primary"
|
||||
bind:group={typeValue}
|
||||
checked={typeValue === ""}
|
||||
/>
|
||||
All
|
||||
<input
|
||||
|
@ -72,22 +76,25 @@
|
|||
value="activity"
|
||||
class="radio radio-primary"
|
||||
bind:group={typeValue}
|
||||
checked={typeValue === "activity"}
|
||||
/>
|
||||
Activity
|
||||
<input
|
||||
type="radio"
|
||||
name="type"
|
||||
bind:group={typeValue}
|
||||
value="location"
|
||||
class="radio radio-primary"
|
||||
bind:group={typeValue}
|
||||
checked={typeValue === "location"}
|
||||
/>
|
||||
Location
|
||||
<input
|
||||
type="radio"
|
||||
bind:group={typeValue}
|
||||
name="type"
|
||||
value="name"
|
||||
class="radio radio-primary"
|
||||
bind:group={typeValue}
|
||||
checked={typeValue === "name"}
|
||||
/>
|
||||
Name
|
||||
<!-- submit button -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue