-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Git-abby/genreNavs
chore: Genre navbars implemented
- Loading branch information
Showing
13 changed files
with
291 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { getAllGenres, getMoviesByGenre } from "../services/api"; | ||
|
||
// Styling | ||
import "../css/GenresNavbar.css"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
function GenresNavbar() { | ||
// For navigating routes | ||
const navigate = useNavigate(); | ||
|
||
// To store genres | ||
const [genres, setGenres] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchGenres = async () => { | ||
const data = await getAllGenres(); | ||
|
||
setGenres(data.genres); | ||
console.log(genres); | ||
}; | ||
fetchGenres(); | ||
}, []); | ||
|
||
const onGenreClick = async (genre_id) => { | ||
navigate(`genre/${genre_id}`); | ||
}; | ||
return ( | ||
<div className="genres-navbar"> | ||
{genres.map((genre) => ( | ||
<button | ||
key={genre.id} | ||
className="genre-button" | ||
onClick={() => onGenreClick(genre.id)}> | ||
{genre.name} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default GenresNavbar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from "react"; | ||
import '../css/GoogleButton.css' | ||
|
||
function GoogleButton({onclickFunction}) { | ||
return ( | ||
<button type="button" onClick={onclickFunction} className="login-with-google-btn"> | ||
Sign in with Google | ||
</button> | ||
); | ||
} | ||
|
||
export default GoogleButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import { getMoviesByGenre } from "../../services/api"; | ||
import MovieCard from "../MovieCard"; | ||
|
||
// Styling | ||
import "../../css/ByGenreMovies.css" | ||
|
||
function ByGenreMovies() { | ||
// Getting genreId from UseParam through route we setup | ||
const { genreId } = useParams(); | ||
|
||
// movie and loading state | ||
const [loading, setLoading] = useState(true); | ||
const [movies, setMovies] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchMovies = async () => { | ||
setLoading(true); | ||
const data = await getMoviesByGenre(genreId); | ||
// console.log(data); | ||
setMovies(data); | ||
setLoading(false); | ||
}; | ||
|
||
fetchMovies(); | ||
}, [genreId]); | ||
console.log(genreId); | ||
return ( | ||
<div> | ||
{loading ? ( | ||
<p>Loading movies...</p> | ||
) : ( | ||
<div className="movies-container"> | ||
{movies.map((movie) => ( | ||
<MovieCard key={movie.id} movie={movie} /> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default ByGenreMovies; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ const SingleMovie = () => { | |
<p> | ||
<strong>Overview: </strong> {movie.overview} | ||
</p> | ||
|
||
</div> | ||
</div> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
.movies-container { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); | ||
gap: 20px; | ||
padding: 20px; | ||
} | ||
|
Empty file.
Oops, something went wrong.