Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit fc00380

Browse files
committed
Fix: Error messaging sub-system was not wired to UI
Fix for #19 Also corrects #17
1 parent a8dbf32 commit fc00380

File tree

7 files changed

+120
-45
lines changed

7 files changed

+120
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![Release Version](https://img.shields.io/github/tag/topcoder-platform/topcoder-payment-tool.svg)
55

66
Based on
7-
[`topcoder-react-starter`](https://www.npmjs.com/package/topcoder-react-starter).
7+
[`topcoder-react-starter`](https://github.com/topcoder-platform/topcoder-react-starter).
88

99
To install, test, and run in development mode:
1010
```bash

__tests__/shared/__snapshots__/index.jsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`Matches shallow snapshot 1`] = `
77
title="Topcoder Payment Tool"
88
/>
99
<Routes />
10+
<Connect(ErrorMessageContainer) />
1011
</div>
1112
`;
1213

@@ -17,6 +18,7 @@ exports[`Matches shallow snapshot in dev mode 1`] = `
1718
title="Topcoder Payment Tool"
1819
/>
1920
<Routes />
21+
<Connect(ErrorMessageContainer) />
2022
<DevTools />
2123
</div>
2224
`;

package-lock.json

Lines changed: 29 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
"slick-carousel": "^1.8.1",
6060
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
6161
"topcoder-react-lib": "^0.6.0",
62-
"topcoder-react-ui-kit": "^0.5.2",
63-
"topcoder-react-utils": "^0.7.5"
62+
"topcoder-react-ui-kit": "^0.5.5",
63+
"topcoder-react-utils": "^0.7.8"
6464
},
6565
"devDependencies": {
6666
"autoprefixer": "^8.6.4",

src/shared/App.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Root component of the app.
33
*/
44

5+
import ErrorMessage from 'containers/ErrorMessage';
56
import React from 'react';
67
import Routes from 'routes';
78

@@ -19,6 +20,7 @@ export default function Application() {
1920
description="Topcoder Payment Tool"
2021
/>
2122
<Routes />
23+
<ErrorMessage />
2224
{ isomorphy.isDevBuild() ? <DevTools /> : undefined }
2325
</div>
2426
);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* ErrorMessage Container
3+
*
4+
* Description:
5+
* Connects the Redux store to the modal ErrorMessageContainer container.
6+
* NOTE: This is created and managed by utils/errors and should not
7+
* be used directly.
8+
*/
9+
import { actions } from 'topcoder-react-lib';
10+
import React from 'react';
11+
import PT from 'prop-types';
12+
import { connect } from 'react-redux';
13+
import { ErrorMessage } from 'topcoder-react-ui-kit';
14+
15+
function ErrorMessageContainer({ error, clearError }) {
16+
return (
17+
<div>
18+
{ error
19+
? (
20+
<ErrorMessage
21+
title={error.title}
22+
details={error.details}
23+
onOk={() => clearError()}
24+
/>
25+
) : undefined }
26+
</div>
27+
);
28+
}
29+
30+
/**
31+
* Default values for Props
32+
*/
33+
ErrorMessageContainer.defaultProps = {
34+
error: null,
35+
};
36+
37+
/**
38+
* Prop Validation
39+
*/
40+
ErrorMessageContainer.propTypes = {
41+
clearError: PT.func.isRequired,
42+
error: PT.shape({
43+
title: PT.string.isRequired,
44+
details: PT.string.isRequired,
45+
}),
46+
};
47+
48+
/**
49+
* Standard redux function, passes redux state into Container as props.
50+
* Is passed to connect(), not called directly.
51+
* @param {Object} state Redux state
52+
* @return {Object}
53+
*/
54+
const mapStateToProps = state => ({
55+
error: state.errors.alerts[0],
56+
});
57+
58+
/**
59+
* Standard redux function, passes redux actions into Container as props.
60+
* Is passed to connect(), not called directly.
61+
* @param {Function} dispatch Function to dispatch action to reducers
62+
* @return {Object}
63+
*/
64+
const mapDispatchToProps = dispatch => ({
65+
clearError: () => {
66+
dispatch(actions.errors.clearError());
67+
},
68+
});
69+
70+
export default connect(
71+
mapStateToProps,
72+
mapDispatchToProps,
73+
)(ErrorMessageContainer);

src/shared/containers/sandbox/payments/Editor/index.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,17 @@ class EditorContainer extends React.Component {
182182
* Handles the payment.
183183
*/
184184
async pay() {
185+
const {
186+
copilotPaymentAmount,
187+
paymentAmount,
188+
paymentTitle,
189+
setPageState,
190+
selectedBillingAccountId,
191+
selectedProjectId,
192+
tokenV3,
193+
challengeTechnologyTags,
194+
} = this.props;
185195
try {
186-
const {
187-
copilotPaymentAmount,
188-
paymentAmount,
189-
paymentTitle,
190-
setPageState,
191-
selectedBillingAccountId,
192-
selectedProjectId,
193-
tokenV3,
194-
challengeTechnologyTags,
195-
} = this.props;
196-
197196
let {
198197
paymentDescription,
199198
submissionGuidelines,
@@ -237,6 +236,7 @@ class EditorContainer extends React.Component {
237236
}
238237
setPageState(PAGE_STATE.PAID);
239238
} catch (error) {
239+
setPageState(PAGE_STATE.NEW_PAYMENT);
240240
logger.error(error);
241241
fireErrorMessage(
242242
'Failed to proceed the payment',

0 commit comments

Comments
 (0)