updates
This commit is contained in:
parent
5cd3af719d
commit
331765d21e
@ -7,8 +7,20 @@ import { writeFileSync } from 'node:fs';
|
||||
import type { Item } from '$lib/types/item';
|
||||
import { getFormString, getRequiredFormString } from '$lib/shared';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
const items: Item[] = await sql`SELECT * FROM items;`;
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
const searchQuery = url.searchParams.get('search') as string;
|
||||
console.log(searchQuery);
|
||||
|
||||
let items: Item[];
|
||||
if (!searchQuery) {
|
||||
items = await sql`SELECT * FROM items;`;
|
||||
} else {
|
||||
items = await sql`
|
||||
SELECT * FROM items
|
||||
WHERE levenshtein(description, ${searchQuery}) <= 3
|
||||
ORDER BY levenshtein(description, ${searchQuery})
|
||||
`;
|
||||
}
|
||||
return {
|
||||
items
|
||||
};
|
||||
|
||||
@ -26,9 +26,15 @@
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4">
|
||||
<div class="justify-between flex">
|
||||
<h1 class="text-3xl mb-2 mt-2">Found Items</h1>
|
||||
<form action="">
|
||||
<Field.Field orientation="horizontal" class="max-w-sm">
|
||||
<Input type="search" name="search" id="search" placeholder="Search..." />
|
||||
<Button variant="default" type="submit">Search</Button>
|
||||
</Field.Field>
|
||||
</form>
|
||||
<!-- <h1 class="text-3xl mb-2 mt-2">Found Items</h1>-->
|
||||
<div class="inline-block">
|
||||
<Button variant="default" class="" onclick={openCreateDialog}>
|
||||
<Button variant="secondary" class="" onclick={openCreateDialog}>
|
||||
Submit a Found Item
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user