Created
July 25, 2017 16:17
-
-
Save harveyslash/fd36226c3094f464003ffdedcc5453df 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, Component} from 'react'; | |
import * as action from '../actions/action'; | |
import $ from 'jquery'; | |
import {connect} from 'react-redux'; | |
import {bindActionCreators} from 'redux'; | |
import UserPanel from './UserPanel'; | |
import Navlink from './Navlink'; | |
import Footer from './Footer'; | |
import UserMenu from './UserMenu'; | |
import CollegeDesc from './beatestcolleges'; | |
import CollegeRegisterUser from './collegeuserpanel'; | |
import CollegeUserLogin from './collegeuserloginpanel'; | |
import {browserHistory} from "react-router"; | |
const initialState = { | |
user: null, | |
loginPanelVisibility: 'none', | |
registrationPanelVisibility: 'none', | |
userMenuVisibility: 'none' | |
} | |
const collegeBannerStyle = { | |
paddingTop: '100px', | |
marginBottom: '-80px', | |
paddingLeft: '50px', | |
background: '#f5f0f0', | |
opacity: '0.85' | |
}; | |
const h1Style = { | |
borderBottom: 'none', | |
marginTop: '20px', | |
marginLeft: '-40px' | |
}; | |
class CollegeSignupContainer extends Component { | |
constructor(props) { | |
super(props); | |
console.log(props); | |
this.state = initialState; | |
this.getUser = this.getUser.bind(this); | |
this.getUser(); | |
} | |
getUser(){ | |
$.get('/user', (data) => { | |
if(typeof data === 'object') { | |
this.props.actions.login(data.user); | |
browserHistory.push("/user_profile"); | |
} | |
}); | |
} | |
render() { | |
return( | |
<div> | |
{(() => { | |
if(this.props.loginPanelVisibility === 'block') { | |
return <CollegeUserLogin loginPanelVisibility={this.props.loginPanelVisibility} | |
toggleLoginPanelVisibility={this.props.actions.toggleLoginPanelVisibility} | |
login={this.props.actions.login} | |
college={this.props.params.collegeId} | |
registrationPanelVisibility={this.props.registrationPanelVisibility} | |
toggleRegistrationPanelVisibility={this.props.actions.toggleRegistrationPanelVisibility} /> | |
} | |
})()} | |
<div className="one"> | |
<Navlink toggleLoginPanelVisibility={this.props.actions.toggleLoginPanelVisibility} toggleUserMenuVisibility={this.props.actions.toggleUserMenuVisibility} | |
onPage="index" user={this.props.user} login={this.props.actions.login} /> | |
{(() => { | |
if(this.props.params.collegeId == 10) { | |
return <div className="row" style={collegeBannerStyle}> | |
<div className="col-lg-2"></div> | |
<div className="col-lg-2"><img src="../../colleges/iit_kgp.png" width="100" height="100" /></div> | |
<div className="col-lg-7"><h1 style={h1Style}>Welcome, students of IIT Kharagpur!</h1></div> | |
<div className="col-lg-1"></div> | |
</div> | |
} | |
})()} | |
{(() => { | |
if(this.props.params.collegeId == 6) { | |
return <div className="row" style={collegeBannerStyle}> | |
<div className="col-lg-1"></div> | |
<div className="col-lg-3"><img src="../../colleges/iem.png" width="100" height="100" /><img src="../../colleges/uem-logo.png" width="100" height="100" /></div> | |
<div className="col-lg-7"><h1 style={h1Style}>Welcome, students of IEM & UEM Kolkata!</h1></div> | |
<div className="col-lg-1"></div> | |
</div> | |
} | |
})()} | |
<UserMenu userMenuVisibility={this.props.userMenuVisibility} | |
toggleUserMenuVisibility={this.props.actions.toggleUserMenuVisibility} | |
logout={this.props.actions.logout} /> | |
<CollegeDesc /> | |
<CollegeRegisterUser loginPanelVisibility={this.props.loginPanelVisibility} | |
toggleLoginPanelVisibility={this.props.actions.toggleLoginPanelVisibility} | |
login={this.props.actions.login} | |
college={this.props.params.collegeId} | |
registrationPanelVisibility={this.props.registrationPanelVisibility} | |
toggleRegistrationPanelVisibility={this.props.actions.toggleRegistrationPanelVisibility} /> | |
</div> | |
<Footer /> | |
</div> | |
) | |
} | |
} | |
CollegeSignupContainer.propTypes = { | |
loginPanelVisibility: PropTypes.string, | |
registrationPanelVisibility: PropTypes.string, | |
userMenuVisibility: PropTypes.string, | |
user: PropTypes.object | |
} | |
function mapStateToProps(state, props) { | |
return { | |
loginPanelVisibility: state.loginPanelVisibility, | |
registrationPanelVisibility: state.registrationPanelVisibility, | |
userMenuVisibility: state.userMenuVisibility, | |
user: state.user | |
}; | |
} | |
function mapDispatchToProps(dispatch) { | |
return { | |
actions: bindActionCreators(action, dispatch) | |
} | |
} | |
export default connect(mapStateToProps, mapDispatchToProps)(CollegeSignupContainer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment