import React, { PropTypes } from 'react' import linkState from 'boost/linkState' import api from 'boost/api' import { pick } from 'lodash' export default class CreateNewFolder extends React.Component { constructor (props) { super(props) this.state = { name: '', public: false } } handleCloseButton (e) { this.props.close() } handlePublicButtonClick (value) { console.log(value) return e => { this.setState({public: value}) } } handleConfirmButton (e) { let { user, close } = this.props let input = pick(this.state, ['public', 'name']) input.UserId = user.id api.createFolder(input) .then(res => { console.log(res.body) close() }) .catch(err => { console.log(err) var alert if (err.code === 'ECONNREFUSED') { alert = { type: 'error', message: 'Can\'t connect to API server.' } } else if (err.status != null) { alert = { type: 'error', message: err.response.body.message } } else { throw err } this.setState({alert: alert}) }) } render () { let alert = this.state.alert let alertEl = alert != null ? (
{alert.message}
) : null return (