Last active
November 11, 2016 16:59
-
-
Save mauricedb/e753646ba915a5a9038204339957c466 to your computer and use it in GitHub Desktop.
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, { PropTypes } from 'react'; | |
import LoginPage from './login-page'; | |
import PlayingMovie from './playing-movie'; | |
import MainPage from './main-page'; | |
const App = ({ user, movies, playing, loginAsUser, startPlaying, stopPlaying }) => { | |
let component = null; | |
if (!user) { | |
component = <LoginPage loginAsUser={loginAsUser} />; | |
} else if (playing) { | |
component = <PlayingMovie movie={playing} stopPlaying={stopPlaying} />; | |
} else { | |
component = <MainPage user={user} movies={movies} startPlaying={startPlaying} />; | |
} | |
return ( | |
<div className="container"> | |
{component} | |
</div> | |
); | |
}; | |
App.propTypes = { | |
user: PropTypes.object, | |
movies: PropTypes.array, | |
playing: PropTypes.object, | |
loginAsUser: PropTypes.func.isRequired, | |
startPlaying: PropTypes.func.isRequired, | |
stopPlaying: PropTypes.func.isRequired, | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment