diff --git a/web/src/lib/components/add-show-card.svelte b/web/src/lib/components/add-show-card.svelte new file mode 100644 index 0000000..8a4f34c --- /dev/null +++ b/web/src/lib/components/add-show-card.svelte @@ -0,0 +1,72 @@ + + + + + {result.name} + {#if result.year != null} + ({result.year}) + {/if} + + {result?.overview} + + + {#if result.poster_path != null} + {result.name}'s Poster Image + {:else} + + {/if} + + + + {#if errorMessage} +

{errorMessage}

+ {/if} +
+
\ No newline at end of file diff --git a/web/src/routes/dashboard/tv/add-show/+page.svelte b/web/src/routes/dashboard/tv/add-show/+page.svelte index 45604da..22d7d20 100644 --- a/web/src/routes/dashboard/tv/add-show/+page.svelte +++ b/web/src/routes/dashboard/tv/add-show/+page.svelte @@ -13,11 +13,12 @@ import * as RadioGroup from '$lib/components/ui/radio-group/index.js'; import {goto} from '$app/navigation'; import {base} from '$app/paths'; + import AddShowCard from '$lib/components/add-show-card.svelte'; let searchTerm: string = $state(''); let metadataProvider: string = $state('tmdb'); let results: - | (MetaDataProviderShowSearchResult & { added?: boolean; downloaded?: boolean })[] + | MetaDataProviderShowSearchResult[] | null = $state(null); async function search() { @@ -35,32 +36,6 @@ } } - async function addShow(show: MetaDataProviderShowSearchResult & { added?: boolean }) { - let url = new URL(env.PUBLIC_API_URL + '/tv/shows'); - url.searchParams.append('show_id', String(show.external_id)); - url.searchParams.append('metadata_provider', show.metadata_provider); - const response = await fetch(url, { - method: 'POST', - credentials: 'include' - }); - - if (response.ok) { - goto(base + '/dashboard/tv/' + await response.json().then((data) => data.id)); - - if (results) { - const index = results.findIndex( - (item) => - item.external_id === show.external_id && - item.metadata_provider === show.metadata_provider - ); - if (index !== -1) { - results[index].added = true; - results = [...results]; - } - } - } - return response; - }
@@ -141,33 +116,7 @@ md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5" > {#each results as result (result.external_id)} - - - - {result.name} - {#if result.year != null} - ({result.year}) - {/if} - - {result?.overview} - - - {#if result.poster_path != null} - {result.name}'s Poster Image - {:else} - - {/if} - - - - - + {/each} {/if}