Skip to content

Commit

Permalink
[#205] Fix modal display when isAllowedRejectReason is false
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan committed Nov 12, 2024
1 parent 9ac84ee commit 6a4a174
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/actions/RecordsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function loadAllowedRejectReason() {
dispatch(loadAllowedRejectReasonSuccess(response.data));
})
.catch((error) => {
dispatch(loadAllowedRejectReasonError(error));
dispatch(loadAllowedRejectReasonError(error.response.data));
});
};
}
Expand Down
59 changes: 30 additions & 29 deletions src/components/button/RejectButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const RejectButton = ({
variant = "danger",
size = "sm",
disabled = true,
onClick = () => {},
onClick = (rejectReason) => {},
}) => {
const { i18n } = useI18n();
const dispatch = useDispatch();
Expand All @@ -39,37 +39,38 @@ const RejectButton = ({
{children}
</Button>
) : (
<Button className={className} size={size} disabled={disabled} variant={variant} onClick={onClick}>
<Button className={className} size={size} disabled={disabled} variant={variant} onClick={() => onClick(null)}>
{children}
</Button>
)}

<Modal show={showModal} onHide={handleClose} className="justify-content-center align-content-center">
<Modal.Header className="bg-warning">
<Modal.Title className="h5">{i18n("reject-dialog-title")}</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form>
<Form.Group controlId="formRejectionReason">
<Form.Control
as="textarea"
rows={4}
placeholder={i18n("records.rejection-reason-placeholder")}
value={rejectionReason}
onChange={handleInputChange}
/>
</Form.Group>
</Form>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={handleClose}>
{i18n("close")}
</Button>
<Button variant="danger" onClick={handleReject}>
{i18n("reject")}
</Button>
</Modal.Footer>
</Modal>
{isAllowedRejectReason && (
<Modal show={showModal} onHide={handleClose} className="justify-content-center align-content-center">
<Modal.Header className="bg-warning">
<Modal.Title className="h5">{i18n("reject-dialog-title")}</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form>
<Form.Group controlId="formRejectionReason">
<Form.Control
as="textarea"
rows={4}
placeholder={i18n("records.rejection-reason-placeholder")}
value={rejectionReason}
onChange={handleInputChange}
/>
</Form.Group>
</Form>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={handleClose}>
{i18n("close")}
</Button>
<Button variant="danger" onClick={handleReject}>
{i18n("reject")}
</Button>
</Modal.Footer>
</Modal>
)}
</>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/record/RecordController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class RecordController extends React.Component {
});
};

_onReject = (reason) => {
_onReject = (rejectionReason) => {
this._handlePhaseChange(RECORD_PHASE.REJECTED, () => {
this._handleRejectReason(reason, () => {
this._handleRejectReason(rejectionReason, () => {
this.props.updateRecord(this.state.record, this.props.currentUser);
this._transitionToRecords();
});
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/RecordsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function (state = initialState, action) {
...state,
isAllowedRejectReason: {
status: ACTION_STATUS.PENDING,
data: state.isAllowedRejectReason,
data: action.isAllowedRejectReason,
error: "",
},
};
Expand Down

0 comments on commit 6a4a174

Please sign in to comment.