Skip to content

Commit

Permalink
Merge pull request #219 from amichard/success-message
Browse files Browse the repository at this point in the history
Success Alert after Commit. The PR belongs to release-v0.1.0
  • Loading branch information
kuanfandevops authored Apr 17, 2018
2 parents d409bf3 + 04d5828 commit 12969f6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
4 changes: 3 additions & 1 deletion backend/api/viewsets/CreditTrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion frontend/src/actions/creditTransfersActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const processApprovedCreditTransfersRequest = () => ({
const processApprovedCreditTransfersSuccess = data => ({
name: 'SUCCESS_APPROVED_CREDIT_TRANSFERS',
type: ActionTypes.SUCCESS,
data
message: data.message
});

const processApprovedCreditTransfersError = error => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class HistoricalDataEntryContainer extends Component {
<HistoricalDataEntryPage
addErrors={this.props.addErrors}
commitErrors={this.props.commitErrors}
commitMessage={this.props.commitMessage}
deleteCreditTransfer={this._deleteCreditTransfer}
fields={this.state.fields}
fuelSuppliers={this.props.fuelSuppliers}
Expand All @@ -160,13 +161,15 @@ class HistoricalDataEntryContainer extends Component {

HistoricalDataEntryContainer.defaultProps = {
addErrors: {},
commitErrors: {}
commitErrors: {},
commitMessage: ''
};

HistoricalDataEntryContainer.propTypes = {
addCreditTransfer: PropTypes.func.isRequired,
addErrors: PropTypes.shape({}),
commitErrors: PropTypes.shape({}),
commitMessage: PropTypes.string,
deleteCreditTransfer: PropTypes.func.isRequired,
fuelSuppliers: PropTypes.arrayOf(PropTypes.shape()).isRequired,
getApprovedCreditTransfersIfNeeded: PropTypes.func.isRequired,
Expand All @@ -184,6 +187,7 @@ HistoricalDataEntryContainer.propTypes = {
const mapStateToProps = state => ({
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -37,6 +38,9 @@ const HistoricalDataEntryPage = (props) => {
Object.keys(props.commitErrors).length > 0 &&
<Errors errors={props.commitErrors} />
}
{!isFetching && props.commitMessage &&
<SuccessAlert message={props.commitMessage} />
}
{!isFetching &&
<HistoricalDataTable
fuelSuppliers={props.fuelSuppliers}
Expand Down Expand Up @@ -65,6 +69,7 @@ const HistoricalDataEntryPage = (props) => {
HistoricalDataEntryPage.propTypes = {
addErrors: PropTypes.shape({}).isRequired,
commitErrors: PropTypes.shape({}).isRequired,
commitMessage: PropTypes.string.isRequired,
deleteCreditTransfer: PropTypes.func.isRequired,
fields: PropTypes.shape({
creditsFrom: PropTypes.shape({
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/app/components/SuccessAlert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

const SuccessAlert = props => (
<div className="alert alert-success">
<h1>Success!</h1>
<p>{props.message}</p>
</div>
);

SuccessAlert.propTypes = {
message: PropTypes.string.isRequired
};

export default SuccessAlert;
9 changes: 8 additions & 1 deletion frontend/src/reducers/creditTransferReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 12969f6

Please sign in to comment.