Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Additionally, if you want to extend your project you might want read the code in
- https://github.com/jorgecortesdev/cf-3-myFlix-client/pull/10/files
- https://github.com/jorgecortesdev/cf-3-myFlix-client/pull/11/files
- https://github.com/jorgecortesdev/cf-3-myFlix-client/pull/12/files
- https://github.com/jorgecortesdev/cf-3-myFlix-client/pull/13/files

#### Branches

Expand Down
5 changes: 3 additions & 2 deletions src/components/Cards/MiniMovieCard/MiniMovieCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { moviePropTypes } from '../../../propTypes';

import './MiniMovieCard.scss';

// TODO: add the movie length to the API and implement it here.
import { toHoursAndMinutes } from '../../../utils/movies';

export const MiniMovieCard = ({ movie }) => {
return (
<div className="movie-information">
Expand All @@ -28,7 +29,7 @@ export const MiniMovieCard = ({ movie }) => {
<div>
<span className="movie-details__rating">{movie.MPA}</span>
<ul className="movie-details__list">
<li>1h 56m</li>
<li>{toHoursAndMinutes(movie.Runtime)}</li>
<li>{movie.ReleaseYear}</li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/HomePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const HomePage = () => {
Genre: movie.Genre,
Director: movie.Director,
Actors: movie.Actors,
Runtime: movie.Runtime,
};
});

Expand Down
7 changes: 5 additions & 2 deletions src/pages/MoviePage/MoviePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { MoviesSlider } from '../../components/MoviesSlider';
import { GenreBadge } from '../../components/Badges';
import { DirectorLink, ActorLink } from '../../components/Links';

import { toHoursAndMinutes } from '../../utils/movies';

export const MoviePage = () => {
const { movieId } = useParams();

Expand All @@ -31,8 +33,9 @@ export const MoviePage = () => {
<h1 className="mb-0">{movie.Title}</h1>
<div className="d-flex justify-content-between align-items-end">
<div className="d-flex gap-2 align-items-center">
<span className="fs-6 text-body-secondary">{movie.ReleaseYear}</span>&bull;
<span className="fs-6 text-body-secondary">{movie.MPA}</span>
<span className="fs-6 text-body-secondary">{movie.MPA}</span>&bull;
<span className="fs-6 text-body-secondary">{toHoursAndMinutes(movie.Runtime)}</span>&bull;
<span className="fs-6 text-body-secondary">{movie.ReleaseYear}</span>
</div>
<GenreBadge genre={movie.Genre} />
</div>
Expand Down
1 change: 1 addition & 0 deletions src/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export const moviePropTypes = PropTypes.shape({
Genre: genrePropTypes.isRequired,
Director: directorPropTypes.isRequired,
Actors: PropTypes.arrayOf(actorPropTypes),
Runtime: PropTypes.number.isRequired,
});
5 changes: 5 additions & 0 deletions src/utils/movies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const toHoursAndMinutes = (totalMinutes) => {
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes % 60;
return `${hours}h${minutes > 0 ? ` ${minutes}m` : ''}`;
};