diff --git a/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryNotes.jsx b/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryNotes.jsx index 74fd79592..ded8d273f 100644 --- a/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryNotes.jsx +++ b/app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryNotes.jsx @@ -1,77 +1,60 @@ -import React, { Fragment } from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; import NotesList from '../note/NotesList'; import { editingStoryPropTypesShape } from '../../../models/beta/story'; import ExpandedStorySection from './ExpandedStorySection'; -class ExpandedStoryNotes extends React.Component { - constructor(props) { - super(props); +const ExpandedStoryNotes = ({ story, onCreate, onDelete, disabled }) => { + const [value, setValue] = useState(''); - this.state = { - value: '' - }; - - this.handleChange = this.handleChange.bind(this); - this.handleSave = this.handleSave.bind(this); + const handleChange = (event) => { + setValue(event.target.value); }; - handleChange(event) { - this.setState({ value: event.target.value }) - } - - handleSave() { - const { onCreate } = this.props; + const handleSave = () => { + onCreate(value); + setValue(''); + }; - onCreate(this.state.value); - this.setState({ value: '' }); - } + const hasAnEmptyValue = () => { + return !value.trim(); + }; - hasAnEmptyValue() { - return !this.state.value.trim() - } + const notesForm = () => ( + <> +