mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-24 01:35:35 +02:00
add season route and update season pages
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
Dashboard
|
||||
</h1>
|
||||
<div class="min-h-[100vh] flex-1 items-center justify-center rounded-xl p-4 md:min-h-min">
|
||||
<div class="mx-auto sm:max-w-[200px] md:max-w-[500px] lg:max-w-[750px] xl:max-w-[1200px]">
|
||||
<div class="mx-auto max-w-[80vw] sm:max-w-[200px] md:max-w-[500px] lg:max-w-[750px] xl:max-w-[1200px]">
|
||||
<h3 class="my-4 scroll-m-20 text-center text-2xl font-semibold tracking-tight">
|
||||
Trending Shows
|
||||
</h3>
|
||||
|
||||
@@ -12,12 +12,9 @@
|
||||
import ShowPicture from "$lib/components/show-picture.svelte";
|
||||
|
||||
const apiUrl = env.PUBLIC_API_URL
|
||||
const SeasonNumber = page.params.SeasonNumber;
|
||||
let seasonFiles: PublicSeasonFile[] = $state(page.data.files);
|
||||
let season: Season = $state(page.data.season);
|
||||
let show: Show = getContext('show');
|
||||
let season: Season = $derived(
|
||||
show().seasons.find((item) => item.number === parseInt(SeasonNumber))
|
||||
);
|
||||
|
||||
console.log('loaded files', seasonFiles);
|
||||
</script>
|
||||
@@ -48,14 +45,14 @@
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Separator class="hidden md:block"/>
|
||||
<Breadcrumb.Item>
|
||||
<Breadcrumb.Page>Season {SeasonNumber}</Breadcrumb.Page>
|
||||
<Breadcrumb.Page>Season {season.number}</Breadcrumb.Page>
|
||||
</Breadcrumb.Item>
|
||||
</Breadcrumb.List>
|
||||
</Breadcrumb.Root>
|
||||
</div>
|
||||
</header>
|
||||
<h1 class="scroll-m-20 text-center text-4xl font-extrabold tracking-tight lg:text-5xl">
|
||||
{getFullyQualifiedShowName(show())} Season {SeasonNumber}
|
||||
{getFullyQualifiedShowName(show())} Season {season.number}
|
||||
</h1>
|
||||
<div class="flex flex-1 flex-col gap-4 p-4">
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
@@ -6,33 +6,45 @@ const apiUrl = env.PUBLIC_API_URL;
|
||||
|
||||
export const load: PageLoad = async ({fetch, params}) => {
|
||||
const url = `${apiUrl}/tv/seasons/${params.SeasonId}/files`;
|
||||
const url2 = `${apiUrl}/tv/seasons/${params.SeasonId}`;
|
||||
|
||||
|
||||
try {
|
||||
console.log(`Fetching data from: ${url}`);
|
||||
console.log(`Fetching data from: ${url} and ${url2}`);
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
credentials: 'include'
|
||||
});
|
||||
const response2 = await fetch(url2, {
|
||||
method: 'GET',
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error(`API request failed with status ${response.status}: ${errorText}`);
|
||||
return {
|
||||
error: `Failed to load TV show files. Status: ${response.status}`,
|
||||
files: []
|
||||
};
|
||||
}
|
||||
|
||||
if (!response2.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error(`API request failed with status ${response.status}: ${errorText}`);
|
||||
}
|
||||
|
||||
|
||||
const filesData = await response.json();
|
||||
const seasonData = await response2.json();
|
||||
console.log('received season_files data: ', filesData);
|
||||
console.log('received season data: ', seasonData);
|
||||
return {
|
||||
files: filesData
|
||||
files: filesData,
|
||||
season: seasonData
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('An error occurred while fetching TV show files:', error);
|
||||
return {
|
||||
error: `An unexpected error occurred: ${error.message || 'Unknown error'}`,
|
||||
files: []
|
||||
files: [],
|
||||
season: null
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user