From e12fff0c107f0f78c5913e641ec2c9245c0fa147 Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Fri, 1 Sep 2023 11:13:38 -0300 Subject: [PATCH 1/3] Add unable contact server message --- src/components/Account/SignUp/SignUp.messages.js | 4 ++++ src/translations/src/cboard.json | 1 + 2 files changed, 5 insertions(+) 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", From 3135ecbc1771dfb01681a9490c4232893d6f25cb Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Fri, 1 Sep 2023 11:32:49 -0300 Subject: [PATCH 2/3] Remove catch on SignUp actions --- src/components/Account/SignUp/SignUp.actions.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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')); } From 35a00abfd30722396c6d631941cba2aa8a4e7d92 Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Fri, 1 Sep 2023 11:34:19 -0300 Subject: [PATCH 3/3] Handle Sign Up error --- src/components/Account/SignUp/SignUp.component.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 })); };