-
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-98 - New: TV Popular list on the Home page;
- Loading branch information
Lucas Teixeira
committed
Nov 2, 2020
1 parent
80b5178
commit ce5edcc
Showing
8 changed files
with
106 additions
and
4 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,3 @@ | ||
export default interface Params { | ||
page?: 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,13 @@ | ||
export default interface RawResponse { | ||
poster_path?: string; | ||
overview: string; | ||
first_air_date: string; | ||
genre_ids: number[]; | ||
id: number; | ||
original_language: string; | ||
original_name: string; | ||
name: string; | ||
backdrop_path?: string; | ||
popularity: number; | ||
vote_count: 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,14 @@ | ||
export default interface Response { | ||
poster?: string; | ||
backdrop?: string; | ||
overview: string; | ||
releaseDate: string; | ||
genreIds: number[]; | ||
id: number; | ||
originalName: string; | ||
name: string; | ||
popularity: number; | ||
voteCount: number; | ||
favorite: boolean; | ||
mediaType: 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,50 @@ | ||
import tmdb from 'services/api/tmdb'; | ||
|
||
import { formatDate, formatTmdbImage } from 'shared/utils'; | ||
|
||
import { Type } from 'domains/Favorites/enums'; | ||
import Params from 'domains/Tv/api/Popular/Params'; | ||
import RawResponse from 'domains/Tv/api/Popular/RawResponse'; | ||
import Response from 'domains/Tv/api/Popular/Response'; | ||
|
||
const Popular = async (params?: Params): Promise<Response[]> => { | ||
const response = await rawPopular(params); | ||
|
||
return parseResponse(response); | ||
}; | ||
|
||
export const rawPopular = async (params?: Params): Promise<RawResponse[]> => { | ||
const response = await tmdb.get('/tv/popular', { | ||
params: { page: params?.page }, | ||
}); | ||
|
||
return response.data.results; | ||
}; | ||
|
||
const parseResponse = (rawResponse: RawResponse[]): Response[] => { | ||
let response = [] as Response[]; | ||
|
||
rawResponse.forEach(tv => { | ||
const parsedMovie = { | ||
overview: tv.overview, | ||
genreIds: tv.genre_ids, | ||
id: tv.id, | ||
originalName: tv.original_name, | ||
name: tv.name, | ||
popularity: tv.popularity, | ||
voteCount: tv.vote_count, | ||
|
||
releaseDate: formatDate({ value: tv.first_air_date }), | ||
poster: formatTmdbImage({ value: tv.poster_path }), | ||
backdrop: formatTmdbImage({ value: tv.backdrop_path }), | ||
favorite: false, | ||
mediaType: Type.TV, | ||
} as Response; | ||
|
||
response = [...response, parsedMovie]; | ||
}); | ||
|
||
return response; | ||
}; | ||
|
||
export default 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as Details } from './Details'; | ||
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
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