Skip to content

Commit

Permalink
fix(huds): evita buscar firma si no valido un profesional (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
negro89 committed Oct 11, 2022
1 parent 9c3f118 commit 3d3e3aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion modules/descargas/informe-rup/informe-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class InformeRupBody extends HTMLComponent {
const prof = this.prestacion.estadoActual.createdBy;
const firmaHTMLComponent = new InformeRupFirma(prof, this.prestacion.solicitud.organizacion);
await firmaHTMLComponent.process();
return firmaHTMLComponent.render();
return firmaHTMLComponent.profesional ? firmaHTMLComponent.render() : null;
} else {
return null;
}
Expand Down
49 changes: 28 additions & 21 deletions modules/descargas/informe-rup/informe-firma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,45 @@ import { Profesional } from '../../../core/tm/schemas/profesional';
export class InformeRupFirma extends HTMLComponent {
template = `
<footer id="last">
<!-- Firmas -->
<span class="contenedor-firmas">
<div class="contenedor-bloque-texto">
{{#if firma}}
<img src="data:image/png;base64,{{{firma}}}">
{{/if}}
<hr class="lg">
<h6 class="bolder">
{{ detalle }} <br>
{{ detalle2 }} <br>
{{{ matriculas }}}
</h6>
<h6 class="subdata-italic"> </h6>
</div>
</span>
</footer>
<!-- Firmas -->
<span class="contenedor-firmas">
<div class="contenedor-bloque-texto">
{{#if firma}}
<img src="data:image/png;base64,{{{firma}}}">
{{/if}}
{{#if matriculas}}
<hr class="lg">
<h6 class="bolder">
{{ detalle }} <br>
{{ detalle2 }} <br>
{{{ matriculas }}}
</h6>
<h6 class="subdata-italic"> </h6>
{{/if}}
</div>
</span>
</footer>
`;

constructor(public profesional, public organizacion) {
super();
}

async process() {
this.profesional = (this.profesional._id) ? await Profesional.findOne({ _id: this.profesional._id }) : await Profesional.findOne({ documento: this.profesional.documento });
const imagenFirma = await this.getFirma(this.profesional);
const matriculas = await this.getMatriculas();
this.profesional = (this.profesional.id) ? await Profesional.findOne({ _id: this.profesional.id }) : await Profesional.findOne({ documento: this.profesional.documento });
let firma;
let matriculas;
let detalle;

const detalle = this.profesional.apellido + ', ' + this.profesional.nombre;
if (this.profesional) {
firma = await this.getFirma(this.profesional);
matriculas = await this.getMatriculas();
detalle = this.profesional.apellido + ', ' + this.profesional.nombre;
}
const detalle2 = this.organizacion.nombre.substring(0, this.organizacion.nombre.indexOf('-'));

this.data = {
firma: imagenFirma,
firma,
detalle,
detalle2,
matriculas
Expand Down

0 comments on commit 3d3e3aa

Please sign in to comment.