import React from 'react'; import PropTypes from 'prop-types'; import {connect} from 'react-redux'; import {isEqual, get} from 'lodash'; import {getUserInterfaceLanguage} from 'appConfig'; import * as actions from '../../../actions'; import * as selectors from '../../../selectors'; import {ASSIGNMENTS} from '../../../constants'; import {gettext, getItemInArrayById} from '../../../utils'; import {Row, TextInput, ColouredValueInput} from '../../UI/Form'; import {AbsoluteDate} from '../..'; export class EditPriorityComponent extends React.Component { constructor(props) { super(props); this.state = {priority: {}}; this.dom = {popupContainer: null}; this.onChange = this.onChange.bind(this); } componentWillMount() { const priorityQcode = get(this.props, 'original.priority'); const priority = priorityQcode ? getItemInArrayById(this.props.priorities, priorityQcode, 'qcode') : null; this.setState({priority}); } onChange(field, value) { this.setState({priority: value}); if (isEqual( get(value, 'qcode') || null, get(this.props, 'original.priority') || null) ) { this.props.disableSaveInModal(); } else { this.props.enableSaveInModal(); } } submit() { return this.props.onSubmit( this.props.original, { ...this.props.original, priority: get(this.state.priority, 'qcode') || null, } ); } render() { const slugline = get(this.props, 'original.planning.slugline') || ''; const scheduled = get(this.props, 'original.planning.scheduled') || ''; const deskId = get(this.props, 'original.assigned_to.desk') || null; const desk = deskId ? getItemInArrayById(this.props.desks, deskId) : {}; const userId = get(this.props, 'original.assigned_to.user') || null; const user = userId ? getItemInArrayById(this.props.users, userId) : {}; const provider = get(this.props, 'original.assigned_to.coverage_provider') || {}; const infoProps = { labelLeft: true, borderBottom: false, readOnly: true, }; return (