diff --git a/app/(site)/components/Trending/index.tsx b/app/(site)/components/Trending/index.tsx
new file mode 100644
index 0000000..04d15ed
--- /dev/null
+++ b/app/(site)/components/Trending/index.tsx
@@ -0,0 +1,22 @@
+'use client';
+
+import Marquee from '@/components/Marquee';
+import { Badge } from '@/components/ui/badge';
+import { FC } from 'react';
+import useTrending from './useTrending';
+
+const Trending: FC<{ label: string; type: 'trending' | 'streaming' | 'theater' | 'rent' }> = ({ label, type }) => {
+ const isMobile = typeof window === 'undefined' ? true : matchMedia('(max-width: 600px)').matches;
+ const { data: movies, isFetched } = useTrending({ type, enabled: !isMobile });
+
+ return (
+ isFetched && (
+ <>
+ {label}
+
+ >
+ )
+ );
+};
+
+export default Trending;
diff --git a/app/(site)/components/Trending/useTrending.ts b/app/(site)/components/Trending/useTrending.ts
new file mode 100644
index 0000000..5c6655e
--- /dev/null
+++ b/app/(site)/components/Trending/useTrending.ts
@@ -0,0 +1,13 @@
+import { useQuery } from '@tanstack/react-query';
+
+import { popularByType, trendingMovies } from '@/lib/api';
+
+const useTrending = ({ type, enabled }: { enabled?: boolean; type: 'trending' | 'streaming' | 'theater' | 'rent' }) => {
+ return useQuery({
+ enabled,
+ queryKey: ['trending', type],
+ queryFn: () => (type === 'trending' ? trendingMovies() : popularByType({ type }))
+ });
+};
+
+export default useTrending;
diff --git a/app/(site)/container.tsx b/app/(site)/container.tsx
index 0e3ebeb..97fbf9d 100644
--- a/app/(site)/container.tsx
+++ b/app/(site)/container.tsx
@@ -4,18 +4,41 @@ import Preview from '@/components/Movie/Preview';
import Carousel from './components/Carousel';
import useRandomMovie from './useRandomMovie';
+import Trending from './components/Trending';
-export default function Container() {
+const Random = () => {
const { movies, movie, index, onIndexChange, fetchNextPage } = useRandomMovie();
return (
- <>
- }
- />
-
- >
+ }
+ />
+ );
+};
+
+export default function Container() {
+ return (
+
);
}
diff --git a/app/layout.tsx b/app/layout.tsx
index 06bbc89..e478f68 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -34,10 +34,10 @@ export default function RootLayout({ children }: { children: ReactNode }) {
-
+
-
{children}
+
{children}