refactor: clean code and remove unnecessary dependencies
This commit is contained in:
1 parent
eceae6fec7
commit
ebf599eed6
92 files changed
+1152
-2842
No files matched your search
@@ -2,32 +2,31 @@
|
||||
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
import List from '@/components/List';
|
||||
import NoResults from '@/components/NoResults';
|
||||
|
||||
import useSimilar from './useSimilar';
|
||||
|
||||
export default function Container() {
|
||||
const Container = () => {
|
||||
const params = useSearchParams();
|
||||
|
||||
const title = params.get('title');
|
||||
const type = params.get('type');
|
||||
const movieId = params.get('movieId') || undefined;
|
||||
const title = params.get('title') as string;
|
||||
const showId = params.get('id') as string;
|
||||
const showType = params.get('type') as Show['type'];
|
||||
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = useSimilar({ movieId, type: type as ShowType });
|
||||
const { shows, fetchNextPage, isFetched } = useSimilar({ showId, showType });
|
||||
|
||||
return (
|
||||
<>
|
||||
{Boolean(title) && (
|
||||
<span className='inline-flex w-full h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground mb-2'>
|
||||
Similar: {decodeURIComponent(title || '')}
|
||||
Similar: {decodeURIComponent(title)}
|
||||
</span>
|
||||
)}
|
||||
<List type={type as ShowType} pages={top?.pages || []} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} />
|
||||
{isFetched && !top?.pages?.[0]?.results?.length && (
|
||||
<div className='h-40 w-full flex items-center justify-center text-xl text-muted-foreground'>
|
||||
Nothing was found
|
||||
</div>
|
||||
)}
|
||||
<List shows={shows} fetchNextPage={fetchNextPage} />
|
||||
{isFetched && !shows.length && <NoResults />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default Container;
|
||||
Reference in new issue
Block a user