diff --git a/actions/getGenreMovies.js b/actions/getGenreMovies.js index e60b963..3bd50e6 100644 --- a/actions/getGenreMovies.js +++ b/actions/getGenreMovies.js @@ -4,6 +4,7 @@ import * as TYPES from './types'; import tmdbAPI from 'services/tmdbAPI'; import LINKS from 'utils/constants/links'; import { TMDB_API_VERSION } from 'config/tmdb'; +import { SORT_BY_OPTIONS } from 'utils/constants/select-search'; const getGenreMovies = (genreId, page, sort) => async ( dispatch, @@ -15,11 +16,13 @@ const getGenreMovies = (genreId, page, sort) => async ( } try { dispatch({type: TYPES.SET_MOVIES_LOADING}); + const { vote_count } = SORT_BY_OPTIONS.find((s) => s.value === sort); const response = await tmdbAPI.get(`/${TMDB_API_VERSION}/discover/movie`, { params: { with_genres: genreId, page, - sort_by: sort + sort_by: sort, + "vote_count.gte":vote_count && vote_count.gte || 0, } }); await dispatch({ diff --git a/utils/constants/select-search.js b/utils/constants/select-search.js index 5608cb5..cb8d43c 100644 --- a/utils/constants/select-search.js +++ b/utils/constants/select-search.js @@ -7,11 +7,18 @@ const YES_OR_NO_OPTIONS = [ const SORT_BY_OPTIONS = [ {value: 'popularity.desc', name: 'Popularity'}, - {value: 'vote_average.desc', name: 'Votes Average'}, + { + value: 'vote_average.desc', + name: 'Votes Average', + vote_count : { + gte : 200 + } + }, {value: 'original_title.asc', name: 'Original Title'}, {value: 'release_date.desc', name: 'Release Date'} ]; + export { YES_OR_NO_OPTIONS, SORT_BY_OPTIONS