From 66412b7788f49def33fc2143f9e1bd5d25bac261 Mon Sep 17 00:00:00 2001 From: Alberto-Duarte Date: Tue, 25 Apr 2023 16:27:11 +0100 Subject: added more things jaja --- services/requests.tsx | 3 +- src/components/Genre.tsx | 27 ++++++++++ src/components/PreviewCard.tsx | 19 +++++++ src/pages/browse/index.tsx | 116 +++++++++++++++++++---------------------- src/styles/globals.css | 12 ++--- 5 files changed, 108 insertions(+), 69 deletions(-) create mode 100644 src/components/Genre.tsx create mode 100644 src/components/PreviewCard.tsx diff --git a/services/requests.tsx b/services/requests.tsx index da35bbc..f77581d 100644 --- a/services/requests.tsx +++ b/services/requests.tsx @@ -1,7 +1,8 @@ const API_KEY = '8216fbb9997cd81a67471e6cb5a6f2df' const requests = { - fetchTopRated: `/movie/top_rated?api_key=${API_KEY}` + fetchTopRated: `/movie/top_rated?api_key=${API_KEY}`, + fetchTrending: `/trending/movie/day?api_key=${API_KEY}`, } export default requests \ No newline at end of file diff --git a/src/components/Genre.tsx b/src/components/Genre.tsx new file mode 100644 index 0000000..e63a26a --- /dev/null +++ b/src/components/Genre.tsx @@ -0,0 +1,27 @@ +import { useEffect, useState } from "react" + +const Genres = ({id}) => { + + const baseURL = 'https://api.themoviedb.org/3' + const API_KEY = '8216fbb9997cd81a67471e6cb5a6f2df' + const [genres, setGenres] = useState() + + useEffect(() => { + fetch(`${baseURL}/movie/${id}?api_key=${API_KEY}`).then((res) => res.json()).then((data) => { + console.log('MOVIE', data.genres) + setGenres(data.genres) + }) + }, []) + + return ( +
+ {genres?.map((genre) => { + return ( +
{genre.name}
+ ) + })} +
+ ) +} + +export default Genres \ No newline at end of file diff --git a/src/components/PreviewCard.tsx b/src/components/PreviewCard.tsx new file mode 100644 index 0000000..5c4129f --- /dev/null +++ b/src/components/PreviewCard.tsx @@ -0,0 +1,19 @@ +const imageURL = 'https://image.tmdb.org/t/p/original'; +import Genre from "./Genre"; +const baseURL ='https://api.themoviedb.org/3/' + +const PreviewCard = ({ movie }) => { + return ( +
+
+
+

+ {movie.original_title} +

+ +
+
+ )} + + +export default PreviewCard \ No newline at end of file diff --git a/src/pages/browse/index.tsx b/src/pages/browse/index.tsx index 1b85fd3..90c13c2 100644 --- a/src/pages/browse/index.tsx +++ b/src/pages/browse/index.tsx @@ -1,100 +1,94 @@ import { link } from 'fs' import Link from 'next/link' -import { BellIcon, MagnifyingGlassIcon, PlayIcon, InformationCircleIcon, ArrowSmallDownIcon} from '@heroicons/react/24/solid' +import { BellIcon, MagnifyingGlassIcon, PlayIcon, ArrowSmallDownIcon} from '@heroicons/react/24/solid' +import { InformationCircleIcon} from '@heroicons/react/24/outline' import { useEffect, useState } from 'react' import requests from '../../../services/requests' +import Image from "next/image" +import PreviewCard from '@prueba/components/PreviewCard' + // import NetflixLogo from '../../../public/images/netflix_logo.svg' const baseURL ='https://api.themoviedb.org/3/' const imageURL = 'https://image.tmdb.org/t/p/original' export default function Home() { const [heroMovie, setHeroMovie] = useState() + const [trendingMovies, setTrendingMovies] = useState() useEffect(() => { fetch(`${baseURL}${requests.fetchTopRated}`).then(res => res.json()).then((data) => { - console.log('MOVIES', data.results[0]) - setHeroMovie(data.results[0]) + console.log(data.results) + setHeroMovie(data.results[3]) }) }, []) + useEffect(() => { + fetch(`${baseURL}${requests.fetchTrending}`).then(res => res.json()).then((data) => { + setTrendingMovies(data.results) + }) + }, []) + return ( -
-
+
+
- - Kids - -
- + + Kids + +
+ + + +
+
-
-
+
- SVG image -

MOVIES

+ SVG image +

MOVIES

-
+
{heroMovie?.original_title}
- SVG image -

#1 in TV Shows Today

+ SVG image +

#1 in TV Shows Today

-

+

{heroMovie?.overview}

-
- - +
+ +
-
+

Popular on Netflix

-
+
{ - MOVIES.map((movie, index) => ( -
- - -
- ))} + trendingMovies?.map((movie, index) => ( + + ))}
-
-
+
+
+
+
) } - - - -const MOVIES = [ - { - link:'../images/Card.png', - }, - { - link:'../images/Card.png', - }, - { - link:'../images/Card.png', - }, - { - link:'../images/Card.png', - }, - { - link:'../images/Card.png', - }, - { - link:'../images/Card.png', - } -] \ No newline at end of file diff --git a/src/styles/globals.css b/src/styles/globals.css index fd81e88..9fbd6c7 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -17,11 +17,9 @@ } body { - color: rgb(var(--foreground-rgb)); - background: linear-gradient( - to bottom, - transparent, - rgb(var(--background-end-rgb)) - ) - rgb(var(--background-start-rgb)); + background-color: black; } + + ::-webkit-scrollbar { + width: 0px; +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf