2019-11-04 05:00:29 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Form, FormGroup, Input } from 'reactstrap';
|
|
|
|
import { gettext } from '../../../utils/constants';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
toggle: PropTypes.func.isRequired,
|
|
|
|
addInstitution: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
class SysAdminAddInstitutionDialog extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
value: '',
|
|
|
|
isSubmitBtnActive: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleChange = (e) => {
|
|
|
|
const value = e.target.value;
|
2019-11-18 09:26:28 +00:00
|
|
|
this.setState({
|
|
|
|
value: value,
|
2020-11-02 05:56:35 +00:00
|
|
|
isSubmitBtnActive: value.trim() != ''
|
2019-11-18 09:26:28 +00:00
|
|
|
});
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-11-04 05:00:29 +00:00
|
|
|
|
|
|
|
handleSubmit = () => {
|
|
|
|
this.toggle();
|
|
|
|
this.props.addInstitution(this.state.value.trim());
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-11-04 05:00:29 +00:00
|
|
|
|
|
|
|
toggle = () => {
|
|
|
|
this.props.toggle();
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-11-04 05:00:29 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Modal isOpen={true} toggle={this.toggle}>
|
|
|
|
<ModalHeader toggle={this.toggle}>{gettext('Add institution')}</ModalHeader>
|
|
|
|
<ModalBody>
|
|
|
|
<Form>
|
|
|
|
<p>{gettext('Name')}</p>
|
|
|
|
<FormGroup>
|
|
|
|
<Input
|
|
|
|
value={this.state.value}
|
|
|
|
onChange={this.handleChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</Form>
|
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
<Button color="primary" onClick={this.handleSubmit} disabled={!this.state.isSubmitBtnActive}>{gettext('Submit')}</Button>
|
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SysAdminAddInstitutionDialog.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default SysAdminAddInstitutionDialog;
|