diff --git a/src/components/Account/SignUp/SignUp.actions.js b/src/components/Account/SignUp/SignUp.actions.js index bf831f789..4e291ba48 100644 --- a/src/components/Account/SignUp/SignUp.actions.js +++ b/src/components/Account/SignUp/SignUp.actions.js @@ -5,8 +5,5 @@ import { API_URL } from '../../../constants'; export function signUp(formValues) { const endpoint = `${API_URL}user`; - return axios - .post(endpoint, formValues) - .then(get('data')) - .catch(get('response.data')); + return axios.post(endpoint, formValues).then(get('data')); } diff --git a/src/components/Account/SignUp/SignUp.component.js b/src/components/Account/SignUp/SignUp.component.js index dbbe28832..002324a9f 100644 --- a/src/components/Account/SignUp/SignUp.component.js +++ b/src/components/Account/SignUp/SignUp.component.js @@ -52,7 +52,16 @@ export class SignUp extends Component { signUp(formValues) .then(signUpStatus => this.setState({ signUpStatus })) - .catch(signUpStatus => this.setState({ signUpStatus })) + .catch(error => { + const responseMessage = error?.response?.data?.message; + const message = responseMessage + ? responseMessage + : this.props.intl.formatMessage(messages.noConnection); + + this.setState({ + signUpStatus: { success: false, message: message } + }); + }) .finally(() => this.setState({ isSigningUp: false })); }; diff --git a/src/components/Account/SignUp/SignUp.messages.js b/src/components/Account/SignUp/SignUp.messages.js index b608d16a7..5ecfeb653 100644 --- a/src/components/Account/SignUp/SignUp.messages.js +++ b/src/components/Account/SignUp/SignUp.messages.js @@ -40,5 +40,9 @@ export default defineMessages({ privacy: { id: 'cboard.components.SignUp.privacy', defaultMessage: 'Privacy Policy' + }, + noConnection: { + id: 'cboard.components.SignUp.noConnection', + defaultMessage: 'Unable to connect to the server. Please try again later.' } }); diff --git a/src/translations/src/cboard.json b/src/translations/src/cboard.json index c7532a5ca..c2164cb4d 100644 --- a/src/translations/src/cboard.json +++ b/src/translations/src/cboard.json @@ -32,6 +32,7 @@ "cboard.components.SignUp.agreement": "I agree with the {terms} and the {privacy}", "cboard.components.SignUp.termsAndConditions": "Terms", "cboard.components.SignUp.privacy": "Privacy Policy", + "cboard.components.SignUp.noConnection": "Unable to connect to the server. Please try again later.", "cboard.components.ChangePassword.password": "New Password", "cboard.components.ChangePassword.passwordRepeat": "Repeat New Password", "cboard.components.ChangePassword.send": "Send",