import React, { Component } from 'react' // import { Link } from 'react-router-dom' import { connect } from 'react-redux' import actions from 'app/actions' import { timestamp, capitalize } from 'app/utils' import { Select, Checkbox } from 'app/common' const PARAGRAPH_TYPES = [ 'paragraph', 'intro_paragraph', 'blockquote', 'pullquote', 'big_text', 'hidden', ].map(name => ({ name, label: capitalize(name.replace('_', ' ')) })) class ParagraphForm extends Component { constructor(props){ super(props) this.handleChange = this.handleChange.bind(this) this.handleSelect = this.handleSelect.bind(this) this.handleSettingsSelect = this.handleSettingsSelect.bind(this) this.handleSubmit = this.handleSubmit.bind(this) } componentDidMount() { if (this.textareaRef && this.textareaRef.current) { this.textareaRef.current.focus() } } handleChange(e) { const { name, value } = e.target this.handleSelect(name, value) } handleSelect(name, value) { const { onUpdate, paragraph } = this.props onUpdate({ ...paragraph, [name]: value, }) } handleSettingsSelect(name, value) { const { onUpdate, paragraph } = this.props onUpdate({ ...paragraph, settings: { ...paragraph.settings, [name]: value, } }) } handleSubmit() { const { paragraph, onClose } = this.props actions.paragraph.update(paragraph) .then(response => { console.log(response) onClose() }) } render() { const { paragraph, y } = this.props console.log(paragraph) return (