-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week 8 '23 Movie Project Vio & Emma #321
base: master
Are you sure you want to change the base?
Changes from all commits
495e3ab
ae67950
1c181e3
6384d29
c60fbc2
7f387cc
305a143
997cedb
d755731
c826603
20a55d4
e820989
c9c4813
7990fd0
5b6280a
c00003d
d5b68ab
e76bbd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
# Project Movies | ||
|
||
Replace this readme with your own information about your project. | ||
|
||
Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
This week we created our very own movies site. We built our first multi-page React application and used a new API. The project was done in pairs. | ||
The app should have at least two pages - one showing a list of movies and one showing details about selected movie. | ||
|
||
## The problem | ||
|
||
Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
|
||
## View it live | ||
|
||
Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. | ||
https://movie-project-by-vio-and-emma.netlify.app/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
import React from 'react'; | ||
import { React } from 'react'; | ||
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom' | ||
import { List } from 'components/List' | ||
import NotFound from 'components/NotFound'; | ||
import { Details } from 'components/Details'; | ||
|
||
import Footer from 'components/Footer'; | ||
|
||
export const App = () => { | ||
return ( | ||
<div> | ||
Find me in src/app.js! | ||
</div> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path="/" element={<List />} /> | ||
<Route path="/details/:movieId" element={<Details />} /> | ||
<Route path="/404" element={<NotFound />} /> | ||
<Route path="*" element={<Navigate to="/404" replace />} /> | ||
</Routes> | ||
<Footer /> | ||
</BrowserRouter> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { DETAILS_URL } from 'utils/urls'; | ||
|
||
export const Details = () => { | ||
const [movie, setMovie] = useState([]) | ||
const { movieId } = useParams(); | ||
const navigate = useNavigate() | ||
|
||
useEffect(() => { | ||
fetch(DETAILS_URL(movieId)) | ||
.then((res) => res.json()) | ||
.then((data) => setMovie(data)) | ||
}, [movieId]) | ||
console.log(movie) | ||
const onGoBackButtonClick = () => { | ||
navigate(-1); | ||
} | ||
|
||
return ( | ||
<div className="background"> | ||
<img className="background-img" src={`https://image.tmdb.org/t/p/w1280/${movie.backdrop_path}`} alt={movie.original_title} /> | ||
<button className="backButton" type="button" onClick={onGoBackButtonClick}> | ||
Back to movies | ||
</button> | ||
<div className="details-container"> | ||
<img className="poster" src={`https://image.tmdb.org/t/p/w342${movie.poster_path}`} alt={movie.title} /> | ||
<div className="movie-text"> | ||
<h2>{movie.title}</h2> | ||
<p><strong>Release date:</strong> {movie.release_date}</p> | ||
<p><strong>Rating:</strong> ⭐ {Math.round(movie.vote_average * 10) / 10}</p> | ||
<p><strong>About:</strong> {movie.overview}</p> | ||
<p><strong>Budget:</strong> {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(movie.budget)}</p> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
|
||
const Footer = () => { | ||
return ( | ||
<footer> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice feature with the logo, adds to the overall retro feel styling. in desktop version it might be a little difficult to find the back button since nothing indicates you can scroll down. |
||
<img className="logo" src="/tmdb-logo.svg" alt="TMDB logo" /> | ||
<p>This product uses the TMDB API but is not endorsed or certified by TMDB.</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good that you thought about mentioning this |
||
</footer> | ||
) | ||
} | ||
|
||
export default Footer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { React, useState, useEffect } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { BASE_URL } from 'utils/urls'; | ||
|
||
export const List = () => { | ||
const [movies, setMovies] = useState([]); | ||
useEffect(() => { | ||
fetch(BASE_URL) | ||
.then((response) => response.json()) | ||
.then((data) => setMovies(data.results)) | ||
}, []) | ||
return ( | ||
<section className="main-container"> | ||
{movies.map((movie) => ( | ||
<div className="movie-card" key={movie.id}> | ||
<Link | ||
to={`/details/${movie.id}`} | ||
alt={movie.title}> | ||
<img className="main-poster" src={`https://image.tmdb.org/t/p/w342${movie.poster_path}`} alt={movie.title} /> | ||
<div className="movie-card-info"> | ||
<h1>{movie.title}</h1> | ||
<h2>Release date: {movie.release_date}</h2> | ||
</div> | ||
</Link> | ||
</div> | ||
))} | ||
</section> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
const NotFound = () => { | ||
const navigate = useNavigate() | ||
const onGoToHomeButtonClick = () => { | ||
navigate('/'); | ||
} | ||
|
||
const onGoBackButtonClick = () => { | ||
navigate(-1) | ||
} | ||
|
||
return ( | ||
<div className="error"> | ||
<h2 className="error-msg">No movies here!</h2> | ||
<button className="homeButton" type="button" onClick={onGoToHomeButtonClick}>Go Home</button> | ||
<button className="backButton" type="button" onClick={onGoBackButtonClick}>Go Back</button> | ||
</div> | ||
) | ||
} | ||
|
||
export default NotFound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We noticed that the List page and the details page show different release dates, even though you seem to be fetching from the same place in the API. Any idea why this is happening?