import React from 'react' import Icon from '../Icon' import * as helpers from '../../helpers' export default class EditPlaylistModal extends React.Component{ constructor(props){ super(props) this.state = { error: null, name: this.props.data.name, description: (this.props.data.description ? this.props.data.description : ''), is_public: this.props.data.is_public, is_collaborative: this.props.data.is_collaborative } } savePlaylist(e){ e.preventDefault(); if (!this.state.name || this.state.name == ''){ this.setState({error: 'Name is required'}) return false } else { this.props.uiActions.savePlaylist(this.props.data.uri, this.state.name, this.state.description, this.state.is_public, this.state.is_collaborative) this.props.uiActions.closeModal() return false } } renderFields(){ switch (helpers.uriSource(this.props.data.uri)){ 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
) break default: return (
Name this.setState({ name: e.target.value })} value={ this.state.name } />
) } } render(){ return (

Edit playlist

{this.state.error ?

{this.state.error}

: null}
this.savePlaylist(e)}> {this.renderFields()}
) } }