import React from 'react' import classnames from 'classnames' import PropTypes from 'prop-types' class PopinFixedHeader extends React.Component { constructor (props) { super(props) this.state = { editTitle: false, editTitleValue: '' } } componentDidUpdate (prevProps) { if (prevProps.title !== this.props.title) this.setState({editTitleValue: this.props.title}) } onChangeTitle = e => { const newTitle = e.target.value this.setState({editTitleValue: newTitle}) } handleClickChangeTitleBtn = () => { if (this.state.editTitle) this.props.onValidateChangeTitle(this.state.editTitleValue) this.setState(prevState => ({editTitle: !prevState.editTitle})) } render () { const { customClass, customColor, faIcon, title, idRoleUserWorkspace, onClickCloseBtn } = this.props return (
{this.state.editTitle ? :
{title}
}
{idRoleUserWorkspace >= 2 &&
{this.state.editTitle ? : }
}
) } } export default PopinFixedHeader PopinFixedHeader.propTypes = { faIcon: PropTypes.string.isRequired, onClickCloseBtn: PropTypes.func.isRequired, customClass: PropTypes.string, customColor: PropTypes.string, title: PropTypes.string, idRoleUserWorkspace: PropTypes.number, onValidateChangeTitle: PropTypes.func } PopinFixedHeader.defaultProps = { customClass: '', customColor: '', title: '', idRoleUserWorkspace: 1, onChangeTitle: () => {} }