diff --git a/assets/js/components/ApplyModal.jsx b/assets/js/components/ApplyModal.jsx index 17db0d8740f9a4c8468579152b04dd8ffb601bf8..dd32c9c3887d61bfef22457274aa24f590b75fb4 100755 --- a/assets/js/components/ApplyModal.jsx +++ b/assets/js/components/ApplyModal.jsx @@ -11,59 +11,10 @@ import { } from 'semantic-ui-react'; import ModalAlert from './../components/ModalAlert'; import Server from './../lib/Server'; +import GeneralModal from './GeneralModal'; -export default class ApplyModal extends React.Component { - static propTypes = { - data: PropTypes.object.isRequired, - active: PropTypes.bool.isRequired, - buttonTitle: PropTypes.string.isRequired, - resume: PropTypes.string, - studentId: PropTypes.number.isRequired, - updateStatus: PropTypes.func.isRequired, - }; - - constructor(props) { - super(props); - /* istanbul ignore next */ - this.state = { - modalOpen: false, - coverLetter: '', - load: false, - }; - this.handleChange = this.handleChange.bind(this); - this.handleOpen = this.handleOpen.bind(this); - this.handleApply = this.handleApply.bind(this); - } - - componentWillUpdate() { - this.fixBody(); - } - - componentDidUpdate() { - this.fixBody(); - } - - fixBody = () => { - const anotherModal = document.getElementsByClassName('ui page modals') - .length; - if (anotherModal > 0) - document.body.classList.add('scrolling', 'dimmable', 'dimmed'); - }; - - handleChange(event) { - this.setState({ coverLetter: event.target.value }); - } - - handleOpen() { - this.setState({ modalOpen: true }); - } - - handleClose = () => - this.setState({ - modalOpen: false, - load: false, - }); - +export default class ApplyModal extends GeneralModal { + handleApply = () => { if (this.props.resume) { this.setState({ load: true }); diff --git a/assets/js/components/GeneralModal.jsx b/assets/js/components/GeneralModal.jsx new file mode 100644 index 0000000000000000000000000000000000000000..de77b992a58959bb1a3800fc4a805f02995ebb5b --- /dev/null +++ b/assets/js/components/GeneralModal.jsx @@ -0,0 +1,61 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import ModalAlert from './../components/ModalAlert'; + +export default class GeneralModal extends React.Component { + static propTypes = { + data: PropTypes.object.isRequired, + active: PropTypes.bool.isRequired, + buttonTitle: PropTypes.string.isRequired, + resume: PropTypes.string, + studentId: PropTypes.number.isRequired, + updateStatus: PropTypes.func.isRequired, + }; + + constructor(props) { + super(props); + /* istanbul ignore next */ + this.state = { + modalOpen: false, + coverLetter: '', + load: false, + }; + this.handleChange = this.handleChange.bind(this); + this.handleOpen = this.handleOpen.bind(this); + this.handleApply = this.handleApply.bind(this); + } + + componentWillUpdate() { + this.fixBody(); + } + + componentDidUpdate() { + this.fixBody(); + } + + fixBody = () => { + const anotherModal = document.getElementsByClassName('ui page modals') + .length; + if (anotherModal > 0) + document.body.classList.add('scrolling', 'dimmable', 'dimmed'); + }; + + handleChange(event) { + this.setState({ coverLetter: event.target.value }); + } + + handleOpen() { + this.setState({ modalOpen: true }); + } + + handleClose = () => + this.setState({ + modalOpen: false, + load: false, + }); + + handleApply = () => { + this.setState({ load: true }); + }; +} + diff --git a/assets/js/components/InfoModal.jsx b/assets/js/components/InfoModal.jsx index 18921da2fa3602e1d40875d4afe398766837798b..228223a2c559df569c1c60c726214abba81d7f17 100644 --- a/assets/js/components/InfoModal.jsx +++ b/assets/js/components/InfoModal.jsx @@ -2,62 +2,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Modal, Button } from 'semantic-ui-react'; import ModalAlert from './../components/ModalAlert'; +import GeneralModal from './GeneralModal'; -export default class InfoModal extends React.Component { - static propTypes = { - data: PropTypes.object.isRequired, - active: PropTypes.bool.isRequired, - buttonTitle: PropTypes.string.isRequired, - resume: PropTypes.string, - studentId: PropTypes.number.isRequired, - updateStatus: PropTypes.func.isRequired, - }; - - constructor(props) { - super(props); - /* istanbul ignore next */ - this.state = { - modalOpen: false, - coverLetter: '', - load: false, - }; - this.handleChange = this.handleChange.bind(this); - this.handleOpen = this.handleOpen.bind(this); - this.handleApply = this.handleApply.bind(this); - } - - componentWillUpdate() { - this.fixBody(); - } - - componentDidUpdate() { - this.fixBody(); - } - - fixBody = () => { - const anotherModal = document.getElementsByClassName('ui page modals') - .length; - if (anotherModal > 0) - document.body.classList.add('scrolling', 'dimmable', 'dimmed'); - }; - - handleChange(event) { - this.setState({ coverLetter: event.target.value }); - } - - handleOpen() { - this.setState({ modalOpen: true }); - } - - handleClose = () => - this.setState({ - modalOpen: false, - load: false, - }); - - handleApply = () => { - this.setState({ load: true }); - }; +export default class InfoModal extends GeneralModal { render() { return (