refactor: clean code and remove unnecessary dependencies

This commit is contained in:
ner committed 2024-09-30 18:54:13 +03:00
1 parent eceae6fec7
commit ebf599eed6
92 files changed
+1152 -2842

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
'use client';
import { FC, useState } from 'react';
import Nav from '@/components/ui/nav';
import Marquee from './components/Marquee';
import { tabs } from './constants';
import useTrending from './useTrending';
const Trending: FC = () => {
const [active, setActive] = useState(tabs[0]);
const isMobile = typeof window === 'undefined' ? true : matchMedia('(max-width: 600px)').matches;
const { data: trending, isFetched } = useTrending({ type: 'trending', enabled: !isMobile });
const { data: streaming } = useTrending({ type: 'streaming', enabled: !isMobile });
const { data: theater } = useTrending({ type: 'theater', enabled: !isMobile });
const shows = { trending, streaming, theater }[active.type] || [];
return (
isFetched && (
<div>
<Nav tabs={tabs} active={active} onChange={(active) => setActive(active)} className='mb-3' />
<Marquee key={active.type} shows={shows} />
</div>
)
);
};
export default Trending;