diff --git a/backend/api/viewsets/CreditTrade.py b/backend/api/viewsets/CreditTrade.py index c1c4cc5f4..a20047cc7 100644 --- a/backend/api/viewsets/CreditTrade.py +++ b/backend/api/viewsets/CreditTrade.py @@ -124,4 +124,6 @@ def batch_process(self, request): credit_trade.update_user_id = request.user.id CreditTradeService.approve(credit_trade) - return Response(None, status=status.HTTP_200_OK) + return Response({"message": + "Approved Credit Transfers have been processed."}, + status=status.HTTP_200_OK) diff --git a/frontend/src/actions/creditTransfersActions.js b/frontend/src/actions/creditTransfersActions.js index 0d03519b7..ace6bc010 100644 --- a/frontend/src/actions/creditTransfersActions.js +++ b/frontend/src/actions/creditTransfersActions.js @@ -316,7 +316,7 @@ const processApprovedCreditTransfersRequest = () => ({ const processApprovedCreditTransfersSuccess = data => ({ name: 'SUCCESS_APPROVED_CREDIT_TRANSFERS', type: ActionTypes.SUCCESS, - data + message: data.message }); const processApprovedCreditTransfersError = error => ({ diff --git a/frontend/src/admin/historical_data_entry/HistoricalDataEntryContainer.js b/frontend/src/admin/historical_data_entry/HistoricalDataEntryContainer.js index 99e5f3786..e462ea2fe 100644 --- a/frontend/src/admin/historical_data_entry/HistoricalDataEntryContainer.js +++ b/frontend/src/admin/historical_data_entry/HistoricalDataEntryContainer.js @@ -141,6 +141,7 @@ class HistoricalDataEntryContainer extends Component { ({ addErrors: state.rootReducer.creditTransfer.errors, commitErrors: state.rootReducer.creditTransfers.errors, + commitMessage: state.rootReducer.creditTransfers.message, fuelSuppliers: state.rootReducer.fuelSuppliersRequest.fuelSuppliers, historicalData: { items: state.rootReducer.creditTransfers.items, diff --git a/frontend/src/admin/historical_data_entry/components/HistoricalDataEntryPage.js b/frontend/src/admin/historical_data_entry/components/HistoricalDataEntryPage.js index bfe2192ed..eabb3c65b 100644 --- a/frontend/src/admin/historical_data_entry/components/HistoricalDataEntryPage.js +++ b/frontend/src/admin/historical_data_entry/components/HistoricalDataEntryPage.js @@ -10,6 +10,7 @@ import HistoricalDataEntryFormButtons from './HistoricalDataEntryFormButtons'; import HistoricalDataTable from './HistoricalDataTable'; import ModalDeleteCreditTransfer from '../../../credit_transfers/components/ModalDeleteCreditTransfer'; import ModalProcessApprovedCreditTransfer from '../../../credit_transfers/components/ModalProcessApprovedCreditTransfer'; +import SuccessAlert from '../../../app/components/SuccessAlert'; const buttonActions = [Lang.BTN_CANCEL, Lang.BTN_COMMIT]; const formActions = [Lang.BTN_ADD_TO_QUEUE]; @@ -37,6 +38,9 @@ const HistoricalDataEntryPage = (props) => { Object.keys(props.commitErrors).length > 0 && } + {!isFetching && props.commitMessage && + + } {!isFetching && { HistoricalDataEntryPage.propTypes = { addErrors: PropTypes.shape({}).isRequired, commitErrors: PropTypes.shape({}).isRequired, + commitMessage: PropTypes.string.isRequired, deleteCreditTransfer: PropTypes.func.isRequired, fields: PropTypes.shape({ creditsFrom: PropTypes.shape({ diff --git a/frontend/src/app/components/SuccessAlert.js b/frontend/src/app/components/SuccessAlert.js new file mode 100644 index 000000000..d7ebb3d76 --- /dev/null +++ b/frontend/src/app/components/SuccessAlert.js @@ -0,0 +1,15 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +const SuccessAlert = props => ( +
+

Success!

+

{props.message}

+
+); + +SuccessAlert.propTypes = { + message: PropTypes.string.isRequired +}; + +export default SuccessAlert; diff --git a/frontend/src/reducers/creditTransferReducer.js b/frontend/src/reducers/creditTransferReducer.js index 097119d05..272717bc2 100644 --- a/frontend/src/reducers/creditTransferReducer.js +++ b/frontend/src/reducers/creditTransferReducer.js @@ -17,7 +17,7 @@ const creditTransfer = (state = { return Object.assign({}, state, { isFetching: false, didInvalidate: true, - item: {} //action.data + item: {} // action.data }); case ActionTypes.UPDATE_CREDIT_TRANSFER: return Object.assign({}, state, { @@ -95,6 +95,13 @@ const creditTransfers = (state = { didInvalidate: true, errors: {} }); + case ActionTypes.SUCCESS: + return Object.assign({}, state, { + didInvalidate: true, + isFetching: false, + success: true, + message: action.message + }); default: return state; }