feat: show page
This commit is contained in:
1 parent
abe1c795a1
commit
183c7231a1
26 files changed
+210
-176
No files matched your search
File renamed without changes.
@@ -0,0 +1,36 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { FC } from 'react';
|
||||||
|
|
||||||
|
import Preview from '@/components/Preview';
|
||||||
|
import Trending from '@/components/Trending';
|
||||||
|
|
||||||
|
import Carousel from './(components)/Carousel';
|
||||||
|
import useRandomMovie from './useRandomMovie';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
page: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Container: FC<Props> = ({ page }) => {
|
||||||
|
const { movie, movies, onIndexChange, fetchNextPage } = useRandomMovie({ page });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='flex flex-1 flex-col'>
|
||||||
|
<div className='xs:mb-4'>
|
||||||
|
<Preview
|
||||||
|
show={movie}
|
||||||
|
className='rounded-md bg-background'
|
||||||
|
poster={<Carousel shows={movies} onIndexChange={onIndexChange} onEndReached={fetchNextPage} />}
|
||||||
|
/>
|
||||||
|
<div className='h-2 w-full' />
|
||||||
|
</div>
|
||||||
|
<div className='hidden w-full rounded-lg xs:block'>
|
||||||
|
<Trending showId={movie.id} showType={movie.type} />
|
||||||
|
<div className='h-2 w-full' />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Container;
|
||||||
File renamed without changes.
File renamed without changes.
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
|
|
||||||
import Random from '@/components/Random';
|
|
||||||
import Trending from '@/components/Trending';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
page: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Container: FC<Props> = ({ page }) => (
|
|
||||||
<div className='flex flex-1 flex-col'>
|
|
||||||
<div className='xs:mb-4'>
|
|
||||||
<Random page={page} />
|
|
||||||
<div className='h-2 w-full' />
|
|
||||||
</div>
|
|
||||||
<div className='hidden w-full rounded-lg xs:block'>
|
|
||||||
<Trending />
|
|
||||||
<div className='h-2 w-full' />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default Container;
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { useSearchParams } from 'next/navigation';
|
|
||||||
|
|
||||||
import List from '@/components/List';
|
|
||||||
import NoResults from '@/components/NoResults';
|
|
||||||
|
|
||||||
import useSimilar from './useSimilar';
|
|
||||||
|
|
||||||
const Container = () => {
|
|
||||||
const params = useSearchParams();
|
|
||||||
|
|
||||||
const title = params.get('title') as string;
|
|
||||||
const showId = params.get('id') as string;
|
|
||||||
const showType = params.get('type') as Show['type'];
|
|
||||||
|
|
||||||
const { shows, fetchNextPage, isFetched } = useSimilar({ showId, showType });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{Boolean(title) && (
|
|
||||||
<span className='mb-2 inline-flex h-10 w-full items-center justify-center rounded-md bg-muted p-1 text-muted-foreground'>
|
|
||||||
Similar: {decodeURIComponent(title)}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<List shows={shows} fetchNextPage={fetchNextPage} />
|
|
||||||
{isFetched && !shows.length && <NoResults />}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Container;
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
|
||||||
|
|
||||||
import similarQuery from '@/data/queries/similar';
|
|
||||||
import getQueryClient from '@/lib/queryClient';
|
|
||||||
|
|
||||||
import Container from './container';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
searchParams: { id: string; type: Show['type'] };
|
|
||||||
}
|
|
||||||
|
|
||||||
const Similar: FC<Props> = ({ searchParams }) => {
|
|
||||||
const queryClient = getQueryClient();
|
|
||||||
|
|
||||||
const { id, type } = searchParams || {};
|
|
||||||
|
|
||||||
queryClient.prefetchInfiniteQuery(similarQuery({ showId: id, showType: type }));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
|
||||||
<Container />
|
|
||||||
</HydrationBoundary>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Similar;
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import similarQuery from '@/data/queries/similar';
|
|
||||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
showId: string;
|
|
||||||
showType: Show['type'];
|
|
||||||
}
|
|
||||||
|
|
||||||
const useSimilar = ({ showId, showType = 'movie' }: Props) => useInfiniteList(similarQuery({ showId, showType }));
|
|
||||||
|
|
||||||
export default useSimilar;
|
|
||||||
@@ -45,7 +45,7 @@ export const DesktopNavigation = () => {
|
|||||||
const active = paths.find(({ path }) => path === currentPath);
|
const active = paths.find(({ path }) => path === currentPath);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Nav tabs={paths} active={active || paths[0]}>
|
<Nav tabs={paths} active={active}>
|
||||||
{({ path, title }) => (
|
{({ path, title }) => (
|
||||||
<Link href={path} prefetch={path !== '/'}>
|
<Link href={path} prefetch={path !== '/'}>
|
||||||
<div>{title}</div>
|
<div>{title}</div>
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ const Header: FC<Props> = ({ className }) => (
|
|||||||
</Link>
|
</Link>
|
||||||
<DesktopNavigation />
|
<DesktopNavigation />
|
||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<ToggleTheme />
|
|
||||||
<ToggleSearch />
|
<ToggleSearch />
|
||||||
|
<ToggleTheme />
|
||||||
<User />
|
<User />
|
||||||
<MobileNavigation />
|
<MobileNavigation />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Bookmark, Copy, Heart, Play, Star } from 'lucide-react';
|
import { Bookmark, Heart, Link, Play, Star } from 'lucide-react';
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import ButtonsGroup from '@/components/ui/buttons-group';
|
import ButtonsGroup from '@/components/ui/buttons-group';
|
||||||
import useShowState, { useMutateShowState } from '@/hooks/useShowState';
|
import useShowState, { useMutateShowState } from '@/hooks/useShowState';
|
||||||
|
import { useToast } from '@/hooks/useToast';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
show: Show & Partial<Details>;
|
show: Show & Partial<Details>;
|
||||||
className: string;
|
className: string;
|
||||||
onClose?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Actions = ({ onClose, show, className }: Props) => {
|
const Actions = ({ show, className }: Props) => {
|
||||||
const router = useRouter();
|
const { toast } = useToast();
|
||||||
|
|
||||||
const state = useShowState({ showId: show.id, showType: show.type });
|
const state = useShowState({ showId: show.id, showType: show.type });
|
||||||
const toggle = useMutateShowState(show);
|
const toggle = useMutateShowState(show);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('flex gap-2 flex-wrap md:flex-grow-0 flex-grow', className)}>
|
<div className={cn('flex gap-2 flex-grow-0', className)}>
|
||||||
<ButtonsGroup className='pointer-events-none'>
|
<ButtonsGroup className='pointer-events-none'>
|
||||||
<Button aria-label='Show rating' variant='outline'>
|
<Button aria-label='Show rating' variant='outline'>
|
||||||
<Star size={14} />
|
<Star size={14} />
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant='outline'>{show.rating.toFixed(1)}</Button>
|
<Button variant='outline' className='w-[43px]'>
|
||||||
|
{show.rating.toFixed(1)}
|
||||||
|
</Button>
|
||||||
</ButtonsGroup>
|
</ButtonsGroup>
|
||||||
<ButtonsGroup>
|
<ButtonsGroup>
|
||||||
<Button
|
<Button
|
||||||
aria-label='Toggle favorite'
|
aria-label='Toggle favorite'
|
||||||
|
title='Toggle favorite'
|
||||||
variant='outline'
|
variant='outline'
|
||||||
disabled={toggle.list === 'favorite' && toggle.isPending}
|
disabled={toggle.list === 'favorite' && toggle.isPending}
|
||||||
onClick={() => toggle.mutate({ list: 'favorite', value: !state?.favorite })}
|
onClick={() => toggle.mutate({ list: 'favorite', value: !state?.favorite })}
|
||||||
@@ -39,6 +40,7 @@ const Actions = ({ onClose, show, className }: Props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
aria-label='Toggle watch list'
|
aria-label='Toggle watch list'
|
||||||
|
title='Toggle watch list'
|
||||||
variant='outline'
|
variant='outline'
|
||||||
disabled={toggle.list === 'watchlist' && toggle.isPending}
|
disabled={toggle.list === 'watchlist' && toggle.isPending}
|
||||||
onClick={() => toggle.mutate({ list: 'watchlist', value: !state?.watchlist })}
|
onClick={() => toggle.mutate({ list: 'watchlist', value: !state?.watchlist })}
|
||||||
@@ -46,18 +48,20 @@ const Actions = ({ onClose, show, className }: Props) => {
|
|||||||
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
|
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonsGroup>
|
</ButtonsGroup>
|
||||||
<ButtonsGroup>
|
<Button
|
||||||
<Button
|
aria-label='Copy link'
|
||||||
onClick={() => {
|
title='Copy link'
|
||||||
onClose?.();
|
variant='outline'
|
||||||
router.push(`/similar?id=${show.id}&title=${encodeURIComponent(show.title)}&type=${show.type}`);
|
className='h-8 px-3'
|
||||||
}}
|
onClick={() =>
|
||||||
aria-label='Similar show'
|
navigator.clipboard
|
||||||
variant='outline'
|
.writeText(`${location.origin}/${show.type}/${show.id}`)
|
||||||
>
|
.then(() => toast({ description: 'Link has been copied' }))
|
||||||
<Copy size={14} />
|
}
|
||||||
Similar
|
>
|
||||||
</Button>
|
<Link size={14} />
|
||||||
|
</Button>
|
||||||
|
<ButtonsGroup className='ml-auto sm:ml-0'>
|
||||||
<Button
|
<Button
|
||||||
aria-label='Watch'
|
aria-label='Watch'
|
||||||
className='bg-red-600 transition-all duration-200 hover:bg-red-600 hover:shadow-lg hover:shadow-red-600/60 dark:bg-red-700'
|
className='bg-red-600 transition-all duration-200 hover:bg-red-600 hover:shadow-lg hover:shadow-red-600/60 dark:bg-red-700'
|
||||||
|
|||||||
@@ -12,18 +12,21 @@ import { cn } from '@/lib/utils';
|
|||||||
import Actions from './components/Actions';
|
import Actions from './components/Actions';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
show?: Show;
|
show?: Show & Partial<Details>;
|
||||||
|
showType?: Show['type'];
|
||||||
|
showId?: Show['id'];
|
||||||
className?: string;
|
className?: string;
|
||||||
|
posterClassName?: string;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
poster?: ReactNode;
|
poster?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Preview: FC<Props> = ({ show: baseShow, className, onClose, poster }) => {
|
const Preview: FC<Props> = ({ show: baseShow, showType, showId, className, posterClassName, onClose, poster }) => {
|
||||||
const { data: detailedShow } = useDetails({ showId: baseShow?.id, showType: baseShow?.type });
|
const { data: detailedShow } = useDetails({ showId: showId || baseShow?.id, showType: showType || baseShow?.type });
|
||||||
|
|
||||||
if (!baseShow) return null;
|
if (!baseShow && !detailedShow) return null;
|
||||||
|
|
||||||
const show: (Show & Partial<Details>) | undefined = detailedShow || baseShow;
|
const show: Show & Partial<Details> = (detailedShow || baseShow)!;
|
||||||
|
|
||||||
const isModal = Boolean(onClose);
|
const isModal = Boolean(onClose);
|
||||||
|
|
||||||
@@ -35,7 +38,7 @@ const Preview: FC<Props> = ({ show: baseShow, className, onClose, poster }) => {
|
|||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{poster || <Poster className='mx-auto md:rounded-none md:rounded-l-xl' show={show} />}
|
{poster || <Poster className={cn('mx-auto md:rounded-none md:rounded-l-xl', posterClassName)} show={show} />}
|
||||||
<div className={cn('flex grow flex-col bg-background', { 'p-0 pt-1 md:p-2': isModal })}>
|
<div className={cn('flex grow flex-col bg-background', { 'p-0 pt-1 md:p-2': isModal })}>
|
||||||
<span className='order-3 mb-4 text-3xl md:order-1 md:line-clamp-2'>{show.title}</span>
|
<span className='order-3 mb-4 text-3xl md:order-1 md:line-clamp-2'>{show.title}</span>
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ const Preview: FC<Props> = ({ show: baseShow, className, onClose, poster }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Actions className='order-1 mb-4 mt-1 md:order-2 md:mt-0' show={show} onClose={onClose} />
|
<Actions className='order-1 mb-4 mt-1 md:order-2 md:mt-0' show={show} />
|
||||||
|
|
||||||
<p key={show.id} className='order-4 md:order-4 md:line-clamp-3' title={show.overview}>
|
<p key={show.id} className='order-4 md:order-4 md:line-clamp-3' title={show.overview}>
|
||||||
{show.overview}
|
{show.overview}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { FC } from 'react';
|
|
||||||
|
|
||||||
import Preview from '../Preview';
|
|
||||||
|
|
||||||
import Carousel from './components/Carousel';
|
|
||||||
import useRandomMovie from './useRandomMovie';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
page: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Random: FC<Props> = ({ page }) => {
|
|
||||||
const { movie, movies, onIndexChange, fetchNextPage } = useRandomMovie({ page });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Preview
|
|
||||||
show={movie}
|
|
||||||
className='rounded-md bg-background'
|
|
||||||
poster={<Carousel shows={movies} onIndexChange={onIndexChange} onEndReached={fetchNextPage} />}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Random;
|
|
||||||
@@ -10,5 +10,13 @@ export const tabs = [
|
|||||||
{
|
{
|
||||||
title: 'In theaters',
|
title: 'In theaters',
|
||||||
type: 'theater'
|
type: 'theater'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Similar',
|
||||||
|
type: 'similar'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Recommendations',
|
||||||
|
type: 'recommendations'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -2,26 +2,47 @@
|
|||||||
|
|
||||||
import { FC, useState } from 'react';
|
import { FC, useState } from 'react';
|
||||||
|
|
||||||
|
import useSimilar from '@/components/Trending/useSimilar';
|
||||||
import Nav from '@/components/ui/nav';
|
import Nav from '@/components/ui/nav';
|
||||||
|
|
||||||
import Gallery from './components/Gallery';
|
import Gallery from './components/Gallery';
|
||||||
import { tabs } from './constants';
|
import { tabs as initialTabs } from './constants';
|
||||||
import useTrending from './useTrending';
|
import useTrending from './useTrending';
|
||||||
|
|
||||||
const Trending: FC = () => {
|
interface Props {
|
||||||
|
showType: Show['type'];
|
||||||
|
showId: Show['id'];
|
||||||
|
preview?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Trending: FC<Props> = ({ showId, showType, preview }) => {
|
||||||
|
const tabs = preview ? initialTabs.filter(({ type }) => ['similar', 'recommendations'].includes(type)) : initialTabs;
|
||||||
|
|
||||||
const [active, setActive] = useState(tabs[0]);
|
const [active, setActive] = useState(tabs[0]);
|
||||||
|
|
||||||
const { data: streaming, isFetched } = useTrending({ type: 'streaming' });
|
const streaming = useTrending({ type: 'streaming', enabled: !preview });
|
||||||
const { data: trending } = useTrending({ type: 'trending' });
|
const trending = useTrending({ type: 'trending', enabled: active.type === 'trending' });
|
||||||
const { data: theater } = useTrending({ type: 'theater' });
|
const theater = useTrending({ type: 'theater', enabled: active.type === 'theater' });
|
||||||
|
const similar = useSimilar({
|
||||||
|
showId,
|
||||||
|
showType,
|
||||||
|
type: 'similar',
|
||||||
|
enabled: active.type === 'similar'
|
||||||
|
});
|
||||||
|
const recommendations = useSimilar({
|
||||||
|
showId,
|
||||||
|
showType,
|
||||||
|
type: 'recommendations',
|
||||||
|
enabled: active.type === 'recommendations'
|
||||||
|
});
|
||||||
|
|
||||||
const shows = { trending, streaming, theater }[active.type] || [];
|
const tab = { trending, streaming, theater, similar, recommendations }[active.type]!;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
isFetched && (
|
(streaming.isFetched || similar.isFetched) && (
|
||||||
<div className='hidden md:block'>
|
<div className='hidden md:block'>
|
||||||
<Nav tabs={tabs} active={active} onChange={(active) => setActive(active)} className='mb-3' />
|
<Nav tabs={tabs} active={active} onChange={(active) => setActive(active)} className='mb-3' />
|
||||||
<Gallery key={active.type} shows={shows} />
|
{!tab.isPending && <Gallery key={active.type} shows={tab.data || []} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
|
import similarQuery from '@/data/queries/similar';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
showId: Show['id'];
|
||||||
|
showType: Show['type'];
|
||||||
|
type?: 'similar' | 'recommendations';
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useSimilar = ({ showId, showType = 'movie', type = 'similar', enabled }: Props) =>
|
||||||
|
useQuery({ ...similarQuery({ showId, showType, type }), enabled });
|
||||||
|
|
||||||
|
export default useSimilar;
|
||||||
@@ -2,6 +2,6 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
|
|
||||||
import trendingQuery, { TrendingQueryProps } from '@/data/queries/trending';
|
import trendingQuery, { TrendingQueryProps } from '@/data/queries/trending';
|
||||||
|
|
||||||
const useTrending = ({ type }: TrendingQueryProps) => useQuery(trendingQuery({ type }));
|
const useTrending = ({ type, enabled }: TrendingQueryProps) => useQuery(trendingQuery({ type, enabled }));
|
||||||
|
|
||||||
export default useTrending;
|
export default useTrending;
|
||||||
@@ -8,13 +8,13 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ButtonsGroup: FC<Props> = ({ children, className }) => (
|
const ButtonsGroup: FC<Props> = ({ children, className }) => (
|
||||||
<div className={cn('flex bg-input gap-[1px] rounded-md md:flex-grow-0 flex-grow group', className)}>
|
<div className={cn('flex bg-input gap-[1px] rounded-md group', className)}>
|
||||||
{Children.map(children, (child) => {
|
{Children.map(children, (child) => {
|
||||||
if (!isValidElement(child)) return null;
|
if (!isValidElement(child)) return null;
|
||||||
|
|
||||||
return cloneElement(child as ReactElement<{ className?: string }>, {
|
return cloneElement(child as ReactElement<{ className?: string }>, {
|
||||||
className: cn(
|
className: cn(
|
||||||
'h-8 gap-1 flex-grow md:px-3 px-2 [&:not(:first-child):not(:last-child)]:border-x-0 rounded-none first:border-r-0 first:rounded-l-md last:border-l-0 last:rounded-r-md',
|
'h-8 gap-1 flex-grow px-3 [&:not(:first-child):not(:last-child)]:border-x-0 rounded-none first:border-r-0 first:rounded-l-md last:border-l-0 last:rounded-r-md',
|
||||||
child.props.className
|
child.props.className
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const Cursor: FC<CursorProps> = ({ width, left, opacity, onTransitionEnd }) => (
|
|||||||
export type NavProps<T extends Tab> = {
|
export type NavProps<T extends Tab> = {
|
||||||
tabs: T[];
|
tabs: T[];
|
||||||
className?: string;
|
className?: string;
|
||||||
active: T;
|
active?: T;
|
||||||
onChange?: (tab: T) => void;
|
onChange?: (tab: T) => void;
|
||||||
children?: (tab: T) => ReactNode;
|
children?: (tab: T) => ReactNode;
|
||||||
};
|
};
|
||||||
@@ -39,7 +39,7 @@ function Nav<T extends Tab>({ tabs, active, className, children, onChange }: Nav
|
|||||||
{tabs.map((tab) => {
|
{tabs.map((tab) => {
|
||||||
const { title } = tab;
|
const { title } = tab;
|
||||||
|
|
||||||
const isActive = title === active.title;
|
const isActive = title === active?.title;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
@@ -48,7 +48,7 @@ function Nav<T extends Tab>({ tabs, active, className, children, onChange }: Nav
|
|||||||
onClick={() => onChange?.(tab)}
|
onClick={() => onChange?.(tab)}
|
||||||
className={cn('z-10 px-2.5 py-0.5 font-normal text-[15px] leading-[20px] cursor-pointer', {
|
className={cn('z-10 px-2.5 py-0.5 font-normal text-[15px] leading-[20px] cursor-pointer', {
|
||||||
'cursor-default text-secondary': isActive,
|
'cursor-default text-secondary': isActive,
|
||||||
'mix-blend-difference text-white': !transitionEnded
|
'mix-blend-difference text-white': active && !transitionEnded
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{children?.(tab) || <div>{title}</div>}
|
{children?.(tab) || <div>{title}</div>}
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ class Http {
|
|||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}, new URLSearchParams())
|
}, new URLSearchParams())
|
||||||
);
|
).toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${base}${url}?${serializedParams}`, {
|
const response = await fetch(`${base}${url}${serializedParams ? `?${serializedParams}` : ''}`, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: this.authorization || '',
|
Authorization: this.authorization || '',
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const detailsQuery = ({ showId, showType }: DetailsQueryProps) => ({
|
|||||||
movieAdvisor
|
movieAdvisor
|
||||||
.get<(Movie | Series) & Details>(`/${showType}/${showId}`)
|
.get<(Movie | Series) & Details>(`/${showType}/${showId}`)
|
||||||
.then((response) => ({ ...response, ...mapMovieSeriesToShow(response, showType) }))
|
.then((response) => ({ ...response, ...mapMovieSeriesToShow(response, showType) }))
|
||||||
|
.catch((error) => Promise.reject(error))
|
||||||
});
|
});
|
||||||
|
|
||||||
export default detailsQuery;
|
export default detailsQuery;
|
||||||
@@ -2,21 +2,21 @@ import movieAdvisor from '../clients/movieAdvisor';
|
|||||||
import mapMoviesSeriesResponseToShows from '../dto/Show';
|
import mapMoviesSeriesResponseToShows from '../dto/Show';
|
||||||
|
|
||||||
export type SimilarQueryProps = {
|
export type SimilarQueryProps = {
|
||||||
showId: string;
|
showId: Show['id'];
|
||||||
showType: Show['type'];
|
showType: Show['type'];
|
||||||
|
type?: 'similar' | 'recommendations';
|
||||||
};
|
};
|
||||||
|
|
||||||
const similarQuery = ({ showId, showType }: SimilarQueryProps) => ({
|
const similarQuery = ({ showId, showType, type }: SimilarQueryProps) => ({
|
||||||
queryKey: ['similar', showId, showType],
|
queryKey: [type, showId, showType],
|
||||||
initialPageParam: '1',
|
queryFn: () =>
|
||||||
queryFn: ({ pageParam = '1' }: { pageParam?: string }) =>
|
|
||||||
movieAdvisor
|
movieAdvisor
|
||||||
.get<TMDBPagination<Movie> | TMDBPagination<Series>>(`/${showType}/${showId}/recommendations`, {
|
.get<TMDBPagination<Movie> | TMDBPagination<Series>>(`/${showType}/${showId}/${type}`, {
|
||||||
params: {
|
params: {
|
||||||
page: pageParam
|
page: 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((response) => mapMoviesSeriesResponseToShows(response, showType))
|
.then((response) => mapMoviesSeriesResponseToShows(response, showType).results)
|
||||||
});
|
});
|
||||||
|
|
||||||
export default similarQuery;
|
export default similarQuery;
|
||||||
@@ -3,9 +3,11 @@ import mapMoviesSeriesResponseToShows from '../dto/Show';
|
|||||||
|
|
||||||
export type TrendingQueryProps = {
|
export type TrendingQueryProps = {
|
||||||
type: 'trending' | 'streaming' | 'theater';
|
type: 'trending' | 'streaming' | 'theater';
|
||||||
|
enabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const trendingQuery = ({ type }: TrendingQueryProps) => ({
|
const trendingQuery = ({ type, enabled }: TrendingQueryProps) => ({
|
||||||
|
enabled,
|
||||||
queryKey: ['trending', `type-${type}`],
|
queryKey: ['trending', `type-${type}`],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
const params: Record<string, string | number> = {};
|
const params: Record<string, string | number> = {};
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()})).then((()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e})));self.define=(n,a)=>{const c=e||("document"in self?document.currentScript.src:"")||location.href;if(s[c])return;let t={};const r=e=>i(e,c),o={module:{uri:c},exports:t,require:r};s[c]=Promise.all(n.map((e=>o[e]||r(e)))).then((e=>(a(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"3650532e2f08fa7dd4f3148b67a043b4"},{url:"/_next/static/9JDTz7i_DQHWmljD2-v5s/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/9JDTz7i_DQHWmljD2-v5s/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/209-0e9125d7ac790983.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/251-5145a38a71055548.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/67-1d329c33cb27b190.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/777-8dcc0dbf9ac697b1.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.a4d728274961d42c.js",revision:"a4d728274961d42c"},{url:"/_next/static/chunks/app/(site)/favorites/page-773b03aaf7689724.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/(site)/page-a493a7c7dbccfccc.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/(site)/popular/page-e32c904c8836dcd3.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/(site)/similar/page-b89e89d3ebe63ccf.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/(site)/starring/page-4a15d78d34546f4d.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/(site)/top/page-a42e14eb2409a484.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/(site)/watch-list/page-d1af0327cd0c9414.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/app/layout-96b83cfc2c667906.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/main-a339d49e77d6dbd3.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-134a99c33ababfb0.js",revision:"9JDTz7i_DQHWmljD2-v5s"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/a61ed9eb64fa65b2.css",revision:"a61ed9eb64fa65b2"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285bf54b5"},{url:"/_next/static/media/dd843ebd3ff03195-s.p.woff2",revision:"333341dc4117f45b7fcee6b5223a56db"},{url:"/_next/static/media/e9ecf55e71a874cd-s.woff2",revision:"62348655e2d5baedLine truncated
|
if(!self.define){let e,s={};const a=(a,c)=>(a=new URL(a+".js",c).href,s[a]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()})).then((()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e})));self.define=(c,n)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let t={};const r=e=>a(e,i),o={module:{uri:i},exports:t,require:r};s[i]=Promise.all(c.map((e=>o[e]||r(e)))).then((e=>(n(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"a3958db6876681eddff18d3d8bc16dea"},{url:"/_next/static/1bHbPMsTKkas2hcjL8h1W/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/1bHbPMsTKkas2hcjL8h1W/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/159-3cd0432f95afe395.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/209-63778326bdf06d12.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/407-65a600b1664df8c5.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/620-2892144f62945cee.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/702-84b21ec277be624f.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/722-d99683acb9e8a904.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.03827864fd0a0451.js",revision:"03827864fd0a0451"},{url:"/_next/static/chunks/app/(site)/%5B...show%5D/page-253ab2608b9fe59a.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/(root)/page-ca0238ee859d1ddf.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/favorites/page-6217cca7628705a7.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/popular/page-8a74cbdf4bdce8ea.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/starring/page-b085eaeb88d7ff4c.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/top/page-23f6c38dac4796d1.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/watch-list/page-32589cc7a57d2425.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/layout-fcf4960a58d6a189.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/main-a4445f80bcd7630f.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-677ecc4b75eea214.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/7a6e6b71a2dc9012.css",revision:"7a6e6b71a2dc9012"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285Line truncated
|
||||||
Reference in new issue
Block a user