Skip to content

Commit

Permalink
Refectoring the display of message error
Browse files Browse the repository at this point in the history
  • Loading branch information
lomamech committed Mar 4, 2024
1 parent bc9267f commit a9628fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions client/src/js/services/NotifyService.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function NotifyService($translate) {
service.danger = danger;
service.info = info;
service.warn = warn;
service.errorMessage = errorMessage;

service.handleError = handleError;

Expand All @@ -76,6 +77,10 @@ function NotifyService($translate) {
setNotification(key, ttl, formatOptions.warn);
}

function errorMessage(key, ttl) {
setNotification(key, ttl, formatOptions.error);
}

/**
* This method is not simply a formatting alias - it accepts an error object
* and parses it to show relevant information in the notification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ function MultiPayrollIndiceParamModalController(Notify, MultiplePayroll, Instanc
vm.submit = (form) => {
if (form.$invalid) { return 0; }
vm.param.lang = Languages.key;
return MultiplePayroll.parameters.create(vm.param).then(() => {
return MultiplePayroll.parameters.create(vm.param).then((res) => {
Notify.success('FORM.INFO.OPERATION_SUCCESS');
return vm.close(true);
})
.catch(Notify.handleError);
.catch((error) => {
if (error.status === 400) {
Notify.errorMessage(error.data.code);
return vm.close(true);
}

Notify.handleError(error);
});
};

}

0 comments on commit a9628fc

Please sign in to comment.