import * as React from 'react'; import I18n from 'i18n-js'; import { Draggable } from 'react-beautiful-dnd'; import { DescriptionText } from '../../shared/CustomTexts'; import DragZone from '../../shared/DragZone'; import PostBoardLabel from '../../shared/PostBoardLabel'; import Separator from '../../shared/Separator'; import BoardForm from './BoardForm'; interface Props { id: number; name: string; description?: string; index: number; settingsAreUpdating: boolean; handleUpdate( id: number, description: string, name: string, onSuccess: Function, ): void; handleDelete(id: number): void; } interface State { editMode: boolean; } class BoardsEditable extends React.Component { constructor(props) { super(props); this.state = { editMode: false, }; this.toggleEditMode = this.toggleEditMode.bind(this); this.handleUpdate = this.handleUpdate.bind(this); } toggleEditMode() { this.setState({editMode: !this.state.editMode}); } handleUpdate(id: number, name: string, description: string) { this.props.handleUpdate( id, name, description, () => this.setState({editMode: false}), ); } render() { const { id, name, description, index, settingsAreUpdating, handleDelete, } = this.props; const { editMode } = this.state; return ( {(provided, snapshot) => (
  • { editMode === false ?
    {description}
    : {I18n.t('common.buttons.cancel')} }
  • )}
    ); } } export default BoardsEditable;