-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from folio-org/UIOR-46-Close-order
UIOR-46 Close Order
- Loading branch information
Showing
5 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/components/PurchaseOrder/CloseOrder/CloseOrderModal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Button } from '@folio/stripes/components'; | ||
|
||
import CloseOrderModalForm from './CloseOrderModalForm'; | ||
|
||
class CloseOrderModal extends Component { | ||
static propTypes = { | ||
orderId: PropTypes.string.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
openModal: false, | ||
}; | ||
} | ||
|
||
openModal = () => { | ||
this.setState({ | ||
openModal: true, | ||
}); | ||
} | ||
|
||
closeModal = () => { | ||
this.setState({ | ||
openModal: false, | ||
}); | ||
} | ||
|
||
render() { | ||
const { orderId } = this.props; | ||
|
||
return ( | ||
<Fragment> | ||
<Button | ||
buttonStyle="primary" | ||
marginBottom0 | ||
onClick={this.openModal} | ||
style={{ marginRight: '10px' }} | ||
> | ||
<FormattedMessage id="ui-orders.paneBlock.closeBtn" /> | ||
</Button> | ||
<CloseOrderModalForm | ||
close={this.closeModal} | ||
orderId={orderId} | ||
open={this.state.openModal} | ||
/> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default CloseOrderModal; |
66 changes: 66 additions & 0 deletions
66
src/components/PurchaseOrder/CloseOrder/CloseOrderModalForm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import PropTypes from 'prop-types'; | ||
import { Field } from 'redux-form'; | ||
|
||
import stripesForm from '@folio/stripes/form'; | ||
import { | ||
Col, | ||
Modal, | ||
ModalFooter, | ||
Row, | ||
Select, | ||
TextArea, | ||
} from '@folio/stripes/components'; | ||
|
||
const CloseOrderModalForm = ({ close, open, orderId }) => { | ||
const cancelBtn = <FormattedMessage id="ui-orders.closeOrderModal.cancel" />; | ||
const submitBtn = <FormattedMessage id="ui-orders.closeOrderModal.submit" />; | ||
const footer = ( | ||
<ModalFooter | ||
secondaryButton={{ | ||
label: cancelBtn, | ||
onClick: close, | ||
}} | ||
primaryButton={{ | ||
label: submitBtn, | ||
onClick: close, | ||
}} | ||
/> | ||
); | ||
|
||
return ( | ||
<Modal | ||
footer={footer} | ||
label={<FormattedMessage id="ui-orders.closeOrderModal.title" values={{ orderId }} />} | ||
open={open} | ||
> | ||
<Row> | ||
<Col xs={12}> | ||
<Field | ||
component={Select} | ||
label={<FormattedMessage id="ui-orders.closeOrderModal.reason" />} | ||
name="reason" | ||
/> | ||
<Field | ||
component={TextArea} | ||
label={<FormattedMessage id="ui-orders.closeOrderModal.notes" />} | ||
name="notes" | ||
/> | ||
</Col> | ||
</Row> | ||
</Modal> | ||
); | ||
}; | ||
|
||
CloseOrderModalForm.propTypes = { | ||
close: PropTypes.func.isRequired, | ||
open: PropTypes.bool.isRequired, | ||
orderId: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default stripesForm({ | ||
form: 'closeOrderModalForm', | ||
navigationCheck: true, | ||
enableReinitialize: true, | ||
})(CloseOrderModalForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import CloseOrderModal from './CloseOrderModal'; | ||
import CloseOrderModalForm from './CloseOrderModalForm'; | ||
|
||
export { CloseOrderModal, CloseOrderModalForm }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters