From f7c39397655c41b1a04305eee694bcc8c34e7b6d Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Fri, 9 Dec 2022 19:49:57 -0800 Subject: [PATCH] Change pagination showing, added type for search. --- .../components/search/textSearch/index.svelte | 32 ++++++++++++------- src/lib/types.ts | 11 +++++-- src/routes/collection/+page.svelte | 24 +++++++------- src/routes/search/+page.server.ts | 4 +-- src/routes/wishlist/+page.svelte | 24 +++++++------- 5 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/lib/components/search/textSearch/index.svelte b/src/lib/components/search/textSearch/index.svelte index 09891a1..bbbf60e 100644 --- a/src/lib/components/search/textSearch/index.svelte +++ b/src/lib/components/search/textSearch/index.svelte @@ -1,7 +1,7 @@ + const submitSearch: SubmitFunction = ({ form, data, action, cancel }) => { + const { name } = Object.fromEntries(data); + if (!disclosureOpen && name?.length === 0) { + toast.send('Please enter a search term', { + duration: 3000, + type: ToastType.ERROR, + dismissible: true + }); + cancel(); + return; + } -
{ gameStore.removeAll(); boredState.update((n) => ({ ...n, loading: true })); return async ({ result }) => { @@ -126,14 +129,19 @@ gameStore.removeAll(); gameStore.addAll(result?.data?.games); totalItems = result?.data?.totalCount; - // toast.send('Sucess!', { duration: 3000, type: ToastType.INFO, dismissible: true }); + // toast.send('Success!', { duration: 3000, type: ToastType.INFO, dismissible: true }); await applyAction(result); } else { await applyAction(result); } }; - }} -> + }; + + // TODO: Keep all Pagination Values on back and forth browser + // TODO: Add cache for certain number of pages so back and forth doesn't request data again + + + + {#if $collectionStore.length !== 0} + + {/if}