Skip to content
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

EvaSjoholm/Project-movies #328

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
5a55319
addin components and API url
EvaSjoholm Mar 27, 2023
f83600c
components details and some css
EvaSjoholm Mar 27, 2023
a22b7a0
added react-router in app.js
EvaSjoholm Mar 27, 2023
0a5e5b7
added useEffect and trying the API, some css
EvaSjoholm Mar 27, 2023
2eed33e
clean up error and erased components tryouts
EvaSjoholm Mar 27, 2023
fdb49ae
components fix
EvaSjoholm Mar 27, 2023
f4161a9
changed components and cleaned up error
EvaSjoholm Mar 27, 2023
7a033fe
added css and cleaned up app.js
EvaSjoholm Mar 27, 2023
1135606
changed API for cinema and edit code in component
EvaSjoholm Mar 27, 2023
0d8ca20
changes componenets
EvaSjoholm Mar 28, 2023
2b8b710
fixing errors from consol
EvaSjoholm Mar 28, 2023
cc87b76
uppdated components and url fix
EvaSjoholm Mar 28, 2023
c84eb62
fix to components
EvaSjoholm Mar 28, 2023
761f7b9
adding code and image tryouts
EvaSjoholm Mar 28, 2023
2731952
fix
EvaSjoholm Mar 28, 2023
6ec120a
cleaned up and changed code
EvaSjoholm Mar 28, 2023
e82ee4a
tvshow component editing
EvaSjoholm Mar 28, 2023
e6d1779
tvshow componenet error fix
EvaSjoholm Mar 28, 2023
ffff6f2
added component and css
EvaSjoholm Mar 28, 2023
8ac9649
erased code
EvaSjoholm Mar 28, 2023
b2f2fae
css design and adding in componenets fix
EvaSjoholm Mar 29, 2023
22af8d1
code clean up
EvaSjoholm Mar 29, 2023
c8074de
css to icon
EvaSjoholm Mar 29, 2023
d8bb537
component test and css
EvaSjoholm Mar 29, 2023
a9aa18d
css design
EvaSjoholm Mar 29, 2023
2c2b90c
css fix
EvaSjoholm Mar 29, 2023
07c6858
css fixing
EvaSjoholm Mar 29, 2023
15f80ae
edited header and css design
EvaSjoholm Mar 29, 2023
ad793ba
text edit
EvaSjoholm Mar 29, 2023
8579ab9
adding componenets tvSeries
EvaSjoholm Mar 30, 2023
1c73c7a
adding componenets tvSeries
EvaSjoholm Mar 30, 2023
6393318
fixing component tvseries
EvaSjoholm Mar 30, 2023
40718b6
component fix
EvaSjoholm Mar 30, 2023
94111b1
component fix tvseries
EvaSjoholm Mar 30, 2023
b113e70
erased tv component again
EvaSjoholm Mar 30, 2023
45bd57d
edited header and some css fix
EvaSjoholm Mar 30, 2023
42eb044
edited media query and css
EvaSjoholm Mar 30, 2023
0e9a62c
fixed api
EvaSjoholm Mar 30, 2023
1c166ac
fix
EvaSjoholm Mar 30, 2023
f5c68db
readme
EvaSjoholm Mar 30, 2023
4064777
back button and css add
EvaSjoholm Mar 30, 2023
9ce94b2
media query fix
EvaSjoholm Mar 30, 2023
0c910c5
css fix
EvaSjoholm Mar 30, 2023
2cfb71c
icon fix and css
EvaSjoholm Mar 30, 2023
3bcc801
Update README.md
EvaSjoholm Mar 30, 2023
58b1efd
tvdetail component with api fix to it
EvaSjoholm Mar 30, 2023
af682d7
tvdetail component add and fix to api
EvaSjoholm Mar 30, 2023
8edc23d
fixing tv components
EvaSjoholm Mar 30, 2023
a2c8904
fixing error
EvaSjoholm Mar 31, 2023
1eb6e10
fixed errors in componenets tvseries
EvaSjoholm Mar 31, 2023
a6f0544
Merge branch 'master' of https://github.com/EvaSjoholm/project-movies
EvaSjoholm Mar 31, 2023
57befc4
added fix to tvseries
EvaSjoholm Mar 31, 2023
6e666b6
css fix
EvaSjoholm Mar 31, 2023
78ca89a
css fix to tv page
EvaSjoholm Mar 31, 2023
6a4ee80
css fix to tv detail page
EvaSjoholm Mar 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Project Movies

Replace this readme with your own information about your project.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on a hard project to do alone! I mentioned a few comments below one other is just the background on the tv shows could be the same setup as the background of the movies for consistency. Other than that, great job on this project!

How to build multi-page application using React Router. Pass information such as product ids, blog post titles in the URL and pick this up in React router (dynamic content). Practice using APIs in React combining useState and useEffect.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
This project was ment for pair-programming but I did this solo due to time schedule conflicts.

## 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?
My main problem with this project was actually understanding API and how to change it to be able to interract and use the URL with React. I spent hours just trying to figure out the details of that,combining it with all the steps required for React Router and multi-pages that is asked for the app.
I needed a lot of help which former students was able to provide. I redid my code and saved a lot of tryouts in external platforms, but my knowledge is not due just yet in this level of React. I find it stimulating to work with but I need more given time to actually unerstand earlier works with props, map and useEffect. Adding API fetch and many componenets with Routes was way to difficult I felt doing solo.
I worked a lot with turtorials from Technigo, tried the Example project steps but found it very time consuming not sure if it's the best way. Then I booked session with technigo-coach and external help through friends, and former students work to be able to focus on understanding the steps and learning about React Routers wonders.

## 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://lighthearted-dolphin-81e027.netlify.app/
63 changes: 62 additions & 1 deletion code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.9.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
23 changes: 20 additions & 3 deletions code/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import React from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import { NotFound } from 'components/NotFound'
import { MovieList } from 'components/MovieList'
import { Header } from 'components/Header'
import { Details } from 'components/Details'
import { TVSeriesList } from 'components/TVseriesList'
import { TVseriesDetails } from 'components/TVseriesDetails'

export const App = () => {
return (
<div>
Find me in src/app.js!
</div>
<BrowserRouter>
<main>
<Header />
<Routes>
<Route path="/" element={<MovieList />} />
<Route path="/movies/:id" element={<Details />} />
<Route path="/tvseries" element={<TVSeriesList />} />
<Route path="/tvseries/:id" element={<TVseriesDetails />} />
<Route path="/404" element={<NotFound />} />
<Route path="*" element={<Navigate to="/404" />} />
</Routes>
</main>
</BrowserRouter>
);
}
Binary file added code/src/back-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions code/src/components/Details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useEffect, useState } from 'react';
import { useParams, Link } from 'react-router-dom';
import { NotFound } from './NotFound';

export const Details = () => {
const [movieDetails, setMovieDetails] = useState([])
const { id } = useParams()

const FetchDetails = () => {
fetch(`https://api.themoviedb.org/3/movie/${id}?api_key=7f5b30559b3d85aec06d3d1a010f4a39&language=en-US`)
.then((response) => response.json())
.then((data) => setMovieDetails(data))
.catch((error) => {
console.log(error)
if (error) {
return (<NotFound />

)
}
})
}

useEffect(() => {
FetchDetails()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return (
<div
className="background"
style={{ backgroundImage: `url(http://image.tmdb.org/t/p/original${movieDetails.backdrop_path})` }}>
<Link to="/" className="back-button">
<img src="./back-button.png" alt="back button" />
<p>Home</p>
</Link>
<div className="movie-detail">
<img src={`http://image.tmdb.org/t/p/w342${movieDetails.poster_path}`} alt="movie" />
<div className="details">
<h1>{movieDetails.title}</h1>
</div>
<p>{movieDetails.overview}</p>
</div>
</div>
)
}
17 changes: 17 additions & 0 deletions code/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import { NavLink } from 'react-router-dom'

export const Header = () => {
return (
<header>

<img className="movienation" src="./red.png" alt="movie-icon" width="112" height="25" />

<ul className="navlink-container">
<li className="navlink">
<NavLink to="/TVseries"><span role="img" className="emoji" aria-label="popcorn">🍿</span></NavLink>
</li>
</ul>
</header>
)
}
28 changes: 28 additions & 0 deletions code/src/components/Movie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';

export const Movie = ({ title, releaseDate, movieID, poster }) => {
const [isHover, setIsHover] = useState(false)

const handleMouseEnter = () => {
setIsHover(true);
};
const handleMouseLeave = () => {
setIsHover(false);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the hover effect its a nice touch


return (
<div
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}>

<Link to={`/movies/${movieID}`}>
<img src={`http://image.tmdb.org/t/p/w342${poster}`} alt="movie" />
<div className={isHover ? 'description' : 'hidden-description'}>
<h1>{title}</h1>
<p>Released {releaseDate}</p>
</div>
</Link>
</div>
)
}
35 changes: 35 additions & 0 deletions code/src/components/MovieList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { useEffect, useState } from 'react'
import { MOVIES_URL } from 'utils/Urls'
import { Movie } from 'components/Movie'

export const MovieList = () => {
const [list, setList] = useState([])

const FetchMovies = () => {
fetch(MOVIES_URL)
.then((response) => response.json())
.then((data) => {
console.log(data.results)
setList(data.results)
})
}
useEffect(() => {
FetchMovies()
}, [])

return (
<main>
{list.map((movie) => (
<div
className="movie-card"
key={movie.id}>
<Movie
title={movie.title}
releaseDate={movie.release_date}
movieID={movie.id}
poster={movie.poster_path} />
</div>
))}
</main>
)
}
17 changes: 17 additions & 0 deletions code/src/components/NotFound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';

export const NotFound = () => {
const navigate = useNavigate();
const returnToHomePage = () => {
navigate('/');
}

return (
<div className="not-found">
<img id="not-found" src="../not-found.png" alt="not-found" />
<p>Ooh noo.... Page not found </p>
<button type="button" onClick={returnToHomePage}>Return here</button>
</div>
);
}
28 changes: 28 additions & 0 deletions code/src/components/TVseries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { useState } from 'react';
import { Link } from 'react-router-dom';

export const TVSeries = ({ singleTvAirDate, singleTvID, originalName, poster }) => {
const [isHover, setIsHover] = useState(false)

const handleMouseEnter = () => {
setIsHover(true);
};
const handleMouseLeave = () => {
setIsHover(false);
};

return (
<div
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}>

<Link to={`/TVseries/${singleTvID}`}>
<img src={`https://image.tmdb.org/t/p/w342${poster}`} alt="TVseries" />
<div className={isHover ? 'description' : 'hidden-description'}>
<h1>{originalName}</h1>
<p>First aired {singleTvAirDate.first_air_date}</p>
</div>
</Link>
</div>
)
}
46 changes: 46 additions & 0 deletions code/src/components/TVseriesDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, { useEffect, useState } from 'react'
import { useParams, Link } from 'react-router-dom';
import { NotFound } from './NotFound';

export const TVseriesDetails = () => {
const [details, setDetails] = useState([])
const { id } = useParams()

const fetchTvDetails = () => {
fetch(`https://api.themoviedb.org/3/tv/${id}?api_key=7f5b30559b3d85aec06d3d1a010f4a39&language=en-US`)
.then((response) => response.json())
.then((data) => setDetails(data))
.catch((error) => {
console.log(error)
if (error) {
return (<NotFound />

)
}
})
}

useEffect(() => {
fetchTvDetails()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return (
<div
className="tv-background"
style={{ backgroundImage: `url(https://image.tmdb.org/t/p/w1280${details.backdrop_path})` }}>
<Link to="/" className="back-button">
<img src="./back-button.png" alt="back button" />
<p>Home</p>
</Link>
<div className="tv-detail">
<img src={`https://image.tmdb.org/t/p/w300${details.poster_path}`} alt="profile" />

<div className="tv-detail">
<h1>{details.title}</h1>
</div>
<p>{details.overview}</p>
</div>
</div>
)
};
Loading