-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import PocketBase from 'pocketbase'; | ||
|
||
const pb = new PocketBase('http://127.0.0.1:8090'); | ||
const pb = new PocketBase('https://sustain-app.pockethost.io'); | ||
|
||
export default pb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import type { PageServerLoad } from './$types'; | ||
import pb from '$lib/server/db'; | ||
|
||
export const load = (async ({ url }) => { | ||
const query = url.searchParams.get('search'); | ||
const items = [ | ||
{ name: "Pork", amount: 3, exp: 7, imgID: "/image/item/pork.png" }, | ||
{ name: "Chicken", amount: 2, exp: 6, imgID: "/image/item/chicken.png" }, | ||
{ name: "Beef", amount: 3, exp: 7, imgID: "/image/item/beef.png" }, | ||
{ name: "Frog", amount: 3, exp: 7, imgID: "/image/item/frog.png" }, | ||
{ name: "Salmon", amount: 3, exp: 7, imgID: "/image/item/salmon.png" }, | ||
{ name: "Carrot", amount: 2, exp: 4, imgID: "/image/item/carrot.png" }, | ||
{ name: "Broccoli", amount: 4, exp: 6, imgID: "/image/item/broccoli.png" }, | ||
{ name: "Potato", amount: 6, exp: 7, imgID: "/image/item/potato.png" }, | ||
{ name: "Milk", amount: 1, exp: 7, imgID: "/image/item/milk.png" }, | ||
{ name: "Cheese", amount: 4, exp: 7, imgID: "/image/item/cheese.png" }, | ||
{ name: "Yoghurt", amount: 2, exp: 7, imgID: "/image/item/yoghurt.png" }, | ||
] | ||
let filter = {}; | ||
if (query) { | ||
filter = { | ||
filter: `name ~ "%${query}%"`, | ||
} | ||
} | ||
const records = structuredClone(await pb.collection('ingredients').getFullList(filter)); | ||
|
||
// console.log(records) | ||
// const items = [ | ||
// { name: "Pork", amount: 3, exp: 7, imgID: "/image/item/pork.png" }, | ||
// { name: "Chicken", amount: 2, exp: 6, imgID: "/image/item/chicken.png" }, | ||
// { name: "Beef", amount: 3, exp: 7, imgID: "/image/item/beef.png" }, | ||
// { name: "Frog", amount: 3, exp: 7, imgID: "/image/item/frog.png" }, | ||
// { name: "Salmon", amount: 3, exp: 7, imgID: "/image/item/salmon.png" }, | ||
// { name: "Carrot", amount: 2, exp: 4, imgID: "/image/item/carrot.png" }, | ||
// { name: "Broccoli", amount: 4, exp: 6, imgID: "/image/item/broccoli.png" }, | ||
// { name: "Potato", amount: 6, exp: 7, imgID: "/image/item/potato.png" }, | ||
// { name: "Milk", amount: 1, exp: 7, imgID: "/image/item/milk.png" }, | ||
// { name: "Cheese", amount: 4, exp: 7, imgID: "/image/item/cheese.png" }, | ||
// { name: "Yoghurt", amount: 2, exp: 7, imgID: "/image/item/yoghurt.png" }, | ||
// ] | ||
return { | ||
items: items.filter(item => item.name.toLowerCase().includes(query?.toLowerCase() ?? '')), | ||
items: records, | ||
}; | ||
}) satisfies PageServerLoad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters