feat: show page

This commit is contained in:
ner committed 2024-11-06 22:12:19 +02:00
1 parent abe1c795a1
commit 183c7231a1
26 files changed
+210 -176

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { FC } from 'react';
import Preview from '@/components/Preview';
import Trending from '@/components/Trending';
interface Props {
showId: Show['id'];
showType: Show['type'];
}
const Container: FC<Props> = ({ showId, showType }) => (
<div className='flex flex-1 flex-col'>
<div className='xs:mb-4'>
<Preview
showId={showId}
showType={showType}
className='rounded-lg bg-background'
posterClassName='md:rounded-lg'
/>
<div className='h-2 w-full' />
</div>
<div className='hidden w-full rounded-lg xs:block'>
<Trending preview showId={showId} showType={showType} />
<div className='h-2 w-full' />
</div>
</div>
);
export default Container;
+34
View File
@@ -0,0 +1,34 @@
import { FC } from 'react';
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
import { redirect } from 'next/navigation';
import detailsQuery from '@/data/queries/details';
import getQueryClient from '@/lib/queryClient';
import Container from './container';
interface Props {
params: { show: [Show['type'], Show['id']] };
}
const ShowPage: FC<Props> = async ({ params: { show } }) => {
const queryClient = getQueryClient();
const [showType, showId] = show as [Show['type'], Show['id']];
if (!showType || !showId) return redirect('/');
try {
await queryClient.fetchQuery(detailsQuery({ showId, showType }));
} catch (_) {
return redirect('/');
}
return (
<HydrationBoundary state={dehydrate(queryClient)}>
<Container showId={showId} showType={showType} />
</HydrationBoundary>
);
};
export default ShowPage;