-
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.
WJ-17 - New: Get movie details; WJ-17 - New: Merge favorite and details;
- Loading branch information
Lucas Teixeira
committed
Sep 5, 2020
1 parent
5a3ce30
commit 1301f05
Showing
11 changed files
with
104 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default interface RawResponse { | ||
id: string; | ||
user_id: string; | ||
movie_id: string; | ||
movie_id: number; | ||
created_at: string; | ||
updated_at: string; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export default interface Response { | ||
import DetailsResponse from 'domains/Movie/api/Details/Response'; | ||
|
||
export default interface Response extends Omit<DetailsResponse, 'id'> { | ||
id: string; | ||
userId: string; | ||
movieId: string; | ||
movieId: number; | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
export default interface RawResponse { | ||
poster_path?: string; | ||
budget: number; | ||
overview: string; | ||
release_date: string; | ||
genres: [ | ||
{ | ||
id: number; | ||
name: string; | ||
}, | ||
]; | ||
id: number; | ||
original_title: string; | ||
original_language: string; | ||
title: string; | ||
backdrop_path?: string; | ||
popularity: number; | ||
vote_count: number; | ||
video: boolean; | ||
vote_average: number; | ||
} |
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,19 @@ | ||
export default interface Response { | ||
poster?: string; | ||
backdrop?: string; | ||
budget: number; | ||
overview: string; | ||
releaseDate: string; | ||
genres: [ | ||
{ | ||
id: number; | ||
name: string; | ||
}, | ||
]; | ||
id: number; | ||
originalTitle: string; | ||
title: string; | ||
popularity: number; | ||
voteCount: number; | ||
voteAverage: number; | ||
} |
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,40 @@ | ||
import tmdb from 'services/api/tmdb'; | ||
|
||
import RawResponse from 'domains/Movie/api/Details/RawResponse'; | ||
import Response from 'domains/Movie/api/Details/Response'; | ||
import formatDate from 'shared/utils/formatDate'; | ||
import formatTmdbImage from 'shared/utils/formatTmdbImage'; | ||
|
||
const Details = async (movieId: number): Promise<Response> => { | ||
const response = await rawPopular(movieId); | ||
|
||
return parseResponse(response); | ||
}; | ||
|
||
export const rawPopular = async (movieId: number): Promise<RawResponse> => { | ||
const response = await tmdb.get(`/movie/${movieId}`); | ||
|
||
return response.data; | ||
}; | ||
|
||
const parseResponse = (movie: RawResponse): Response => { | ||
const parsedMovie = { | ||
overview: movie.overview, | ||
budget: movie.budget, | ||
genres: movie.genres, | ||
id: movie.id, | ||
originalTitle: movie.original_title, | ||
title: movie.title, | ||
popularity: movie.popularity, | ||
voteCount: movie.vote_count, | ||
voteAverage: movie.vote_average, | ||
|
||
releaseDate: formatDate({ value: movie.release_date }), | ||
poster: formatTmdbImage({ value: movie.poster_path }), | ||
backdrop: formatTmdbImage({ value: movie.backdrop_path }), | ||
} as Response; | ||
|
||
return parsedMovie; | ||
}; | ||
|
||
export default Details; |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as Details } from './Details'; | ||
export { default as NowPlaying } from './NowPlaying'; | ||
export { default as Popular } from './Popular'; |
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