import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import Link from '../../components/Link' import ReactGA from 'react-ga' import Modal from './Modal'; import Icon from '../../components/Icon'; import * as coreActions from '../../services/core/actions' import * as uiActions from '../../services/ui/actions' import * as helpers from '../../helpers'; class CreatePlaylist extends React.Component{ constructor(props){ super(props) this.state = { name: '', description: '', scheme: 'spotify', is_public: true, is_collaborative: false } } componentDidMount(){ this.props.uiActions.setWindowTitle("Create playlist"); } createPlaylist(e){ e.preventDefault(); if (!this.state.name || this.state.name == ''){ this.setState({error: 'Name is required'}) return false } else { this.props.coreActions.createPlaylist( this.state.scheme, this.state.name, this.state.description, this.state.is_public, this.state.is_collaborative ); window.history.back(); } return false } renderFields(){ switch (this.state.scheme){ case 'spotify': return (
Name
this.setState({ name: e.target.value })} value={ this.state.name } />
Description
this.setState({ description: e.target.value })} value={ this.state.description } />
Options
) default: return (
Name
this.setState({ name: e.target.value })} value={ this.state.name } />
) } } render(){ return (

Create playlist

this.createPlaylist(e)}>
Provider
{this.renderFields()}
) } } const mapStateToProps = (state, ownProps) => { return {} } const mapDispatchToProps = (dispatch) => { return { coreActions: bindActionCreators(coreActions, dispatch), uiActions: bindActionCreators(uiActions, dispatch) } } export default connect(mapStateToProps, mapDispatchToProps)(CreatePlaylist)