fix: refs #6379 add Error & locale
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-02-09 13:04:27 +01:00
parent 4075375d6e
commit e0de498f65
3 changed files with 9 additions and 6 deletions

View File

@ -206,5 +206,6 @@
"Incorrect pin": "Incorrect pin.",
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
"Name should be uppercase": "Name should be uppercase",
"You cannot update these fields": "You cannot update these fields"
"You cannot update these fields": "You cannot update these fields",
"CountryFK cannot be empty": "CountryFK cannot be empty"
}

View File

@ -340,5 +340,6 @@
"Name should be uppercase": "El nombre debe ir en mayúscula",
"Bank entity must be specified": "La entidad bancaria es obligatoria",
"An email is necessary": "Es necesario un email",
"You cannot update these fields": "No puedes actualizar estos campos"
"You cannot update these fields": "No puedes actualizar estos campos",
"CountryFK cannot be empty": "CountryFK cannot be empty"
}

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('driverRouteEmail', {
description: 'Sends the driver route email with an attached PDF',
@ -47,10 +48,10 @@ module.exports = Self => {
account = await models.Account.findById(workerFk);
}
if (user?.active && !account) ctx.args.recipient = reportMail;
else if (user?.active && account) ctx.args.recipient = user.emailUser().email;
else // throws an error?
if (user?.active && account) ctx.args.recipient = user.emailUser().email;
else ctx.args.recipient = reportMail;
if (!ctx.args.recipient) throw new UserError('An email is necessary');
Self.sendTemplate(ctx, 'driver-route');
};
};