2019-11-02 09:02:26 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Alert, Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Input, InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
|
|
|
|
import { gettext } from '../../../utils/constants';
|
|
|
|
import { Utils } from '../../../utils/utils';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
dialogTitle: PropTypes.string.isRequired,
|
|
|
|
updateValue: PropTypes.func.isRequired,
|
|
|
|
toggleDialog: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
class UpdateUser extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
value: this.props.value,
|
|
|
|
isSubmitBtnActive: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleInputChange = (e) => {
|
2019-11-18 09:26:28 +00:00
|
|
|
const value = e.target.value;
|
2019-11-02 09:02:26 +00:00
|
|
|
this.setState({
|
|
|
|
value: value
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleKeyPress = (e) => {
|
|
|
|
if (e.key == 'Enter') {
|
|
|
|
this.handleSubmit();
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSubmit = () => {
|
2019-11-18 09:26:28 +00:00
|
|
|
this.props.updateValue(this.state.value.trim());
|
2019-11-02 09:02:26 +00:00
|
|
|
this.props.toggleDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { dialogTitle, toggleDialog } = this.props;
|
|
|
|
return (
|
|
|
|
<Modal isOpen={true} toggle={toggleDialog}>
|
|
|
|
<ModalHeader toggle={toggleDialog}>{this.props.dialogTitle}</ModalHeader>
|
|
|
|
<ModalBody>
|
|
|
|
<Form>
|
|
|
|
<FormGroup>
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
value={this.state.value}
|
|
|
|
onKeyPress={this.handleKeyPress}
|
|
|
|
onChange={this.handleInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</Form>
|
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
<Button color="secondary" onClick={toggleDialog}>{gettext('Cancel')}</Button>
|
|
|
|
<Button color="primary" onClick={this.handleSubmit}>{gettext('Submit')}</Button>
|
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateUser.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default UpdateUser;
|