This file contains hidden or 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
| const TMDB_IMAGE_BASE_URL = (width = 300) => `https://image.tmdb.org/t/p/w${width}`; | |
| const updateMoviePictureUrls = (movieResult, width = 300) => ({ | |
| ...movieResult, | |
| backdrop_path: `${TMDB_IMAGE_BASE_URL(width)}${movieResult.backdrop_path}`, | |
| poster_path: `${TMDB_IMAGE_BASE_URL(width)}${movieResult.poster_path}`, | |
| }); | |
| export const getMoviesList = (moviesResponse) => { |
This file contains hidden or 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
| import React from 'react'; | |
| import {Row, Col} from 'react-bootstrap'; | |
| import MovieCard from '../movie-card/movie-card.component'; | |
| import LoaderComponent from '../../common/loader.component'; | |
| const styles = { | |
| movieColumn: { | |
| marginBottom: 20 | |
| } | |
| } |
This file contains hidden or 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
| @import url('https://fonts.googleapis.com/css?family=Roboto'); | |
| body { | |
| margin: 0; | |
| padding: 0; | |
| font-family: 'Roboto', sans-serif; | |
| } |
This file contains hidden or 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
| import React from 'react'; | |
| import {Card, CardTitle, CardMedia} from 'material-ui'; | |
| // These are inline styles | |
| // You can pass styles as objects using this convention | |
| const styles = { | |
| cardTitle: { | |
| whiteSpace: 'nowrap', | |
| textOverflow: 'ellipsis', | |
| overflow: 'hidden' |
This file contains hidden or 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
| import {combineReducers} from 'redux'; | |
| import { createReducer, createAsyncReducer } from '../common/redux.helpers'; | |
| import { keys as movieActionKeys } from './movie-browser.actions'; | |
| // Placeholder reducer for our movie modal | |
| const movieModalReducer = createReducer({ isOpen: false }, { | |
| }); | |
| // This will create a new state with both the existing |
This file contains hidden or 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
| import {createAsyncActionCreator} from '../common/redux.helpers'; | |
| import * as movieService from './movie-browser.service'; | |
| export const keys = { | |
| 'GET_TOP_MOVIES': 'GET_TOP_MOVIES', | |
| 'SEARCH_MOVIES': 'SEARCH_MOVIES', | |
| 'GET_MOVIE_DETAILS': 'GET_MOVIE_DETAILS', | |
| }; | |
| export const getTopMovies = (page) => createAsyncActionCreator( |
This file contains hidden or 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
| // WARNING: Don't check your actual API key into GitHub | |
| const MOVIE_DB_API_KEY = 'MY_API_KEY_HERE'; | |
| const MOVIE_DB_BASE_URL = 'https://api.themoviedb.org/3'; | |
| const createMovieDbUrl = (relativeUrl, queryParams) => { | |
| let baseUrl = `${MOVIE_DB_BASE_URL}${relativeUrl}?api_key=${MOVIE_DB_API_KEY}&language=en-US`; | |
| if (queryParams) { | |
| Object.keys(queryParams) | |
| .forEach(paramName => baseUrl += `&${paramName}=${queryParams[paramName]}`); | |
| } |
This file contains hidden or 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
| // Helper function to enables passing an object with | |
| // the action.type as the key and the reducer function as the value | |
| export const createReducer = (initialState = {}, actionHandlerKeyFuncs = {}) => { | |
| return (state = initialState, action) => { | |
| const actionHandler = actionHandlerKeyFuncs[action.type]; | |
| return actionHandler ? actionHandler(state, action) : state; | |
| } | |
| }; | |
| // Creates a basic action |
This file contains hidden or 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
| import {combineReducers} from 'redux'; | |
| import { createReducer } from '../common/redux.helpers'; | |
| const movieModalReducer = createReducer({ isOpen: false }, { | |
| }); | |
| const movieBrowserReducer = combineReducers({ | |
| movieModal: movieModalReducer | |
| }); |
This file contains hidden or 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
| // Helper function to enables passing an object with | |
| // the action.type as the key and the reducer function as the value | |
| export const createReducer = (initialState = {}, actionHandlerKeyFuncs = {}) => { | |
| return (state = initialState, action) => { | |
| const actionHandler = actionHandlerKeyFuncs[action.type]; | |
| return actionHandler ? actionHandler(state, action) : state; | |
| } | |
| }; |