Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show profile errors #5525

Merged
merged 7 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export default {
setMyTimezoneAutomatically: 'Set my timezone automatically',
timezone: 'Timezone',
growlMessageOnSave: 'Your profile was successfully saved',
error: {
messageOn400: 'First name shouldn\'t be longer than 50 characters',
messageOn401: 'Last name shouldn\'t be longer than 50 characters',
},
Beamanator marked this conversation as resolved.
Show resolved Hide resolved
},
addSecondaryLoginPage: {
addPhoneNumber: 'Add phone number',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export default {
setMyTimezoneAutomatically: 'Configura mi zona horaria automáticamente',
timezone: 'Zona horaria',
growlMessageOnSave: 'Tu perfil se ha guardado correctamente',
error: {
messageOn400: 'El nombre no debe tener más de 50 caracteres',
messageOn401: 'El apellido no debe tener más de 50 caracteres',
},
},
addSecondaryLoginPage: {
addPhoneNumber: 'Agregar número de teléfono',
Expand Down
29 changes: 21 additions & 8 deletions src/libs/actions/PersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,27 @@ function mergeLocalPersonalDetails(details) {
* @param {boolean} shouldGrowl
*/
function setPersonalDetails(details, shouldGrowl) {
API.PersonalDetails_Update({details: JSON.stringify(details)});
if (details.timezone) {
NameValuePair.set(CONST.NVP.TIMEZONE, details.timezone);
}
mergeLocalPersonalDetails(details);
if (shouldGrowl) {
Growl.show(translateLocal('profilePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000);
}
API.PersonalDetails_Update({details: JSON.stringify(details)})
.then((response) => {
if (response.jsonCode === 200) {
if (details.timezone) {
NameValuePair.set(CONST.NVP.TIMEZONE, details.timezone);
}
mergeLocalPersonalDetails(details);
}

if (shouldGrowl) {
if (response.jsonCode === 400) {
Growl.error(translateLocal('profilePage.error.messageOn400'), 3000);
} else if (response.jsonCode === 401) {
Growl.error(translateLocal('profilePage.error.messageOn401'), 3000);
Beamanator marked this conversation as resolved.
Show resolved Hide resolved
} else {
Growl.show(translateLocal('profilePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000);
}
}
}).catch((error) => {
console.debug('Error while setting personal details', error);
});
}

/**
Expand Down