diff --git a/src/app/comprobantes/comprobantes.component.ts b/src/app/comprobantes/comprobantes.component.ts index 39235bf..17a3def 100644 --- a/src/app/comprobantes/comprobantes.component.ts +++ b/src/app/comprobantes/comprobantes.component.ts @@ -74,13 +74,25 @@ export class ComprobantesComponent implements OnInit { .saveComprobantes({cabecera: this.cabecera, cuerpo: this.cuerpo}) .subscribe(data => { - this.modal.alert('Comprobante guardado con éxito'); - this.saveLoading = false; - this.router.navigateByUrl('/home'); + this.modal.alert('Comprobante guardado con éxito').result.then( () => { + + this.saveLoading = false; + this.router.navigateByUrl('/home'); + }); }, err => { - this.modal.alert('Algo salió mal...'); + if (err.status == 510) { + + this.modal.alert('Ya existe el comprobante').result.then(() => { + + this.router.navigateByUrl('/home'); + }); + } else { + + this.modal.alert('Algo salió mal...'); + } + this.saveLoading = false; console.log(err); }); diff --git a/src/app/modal/modal.service.ts b/src/app/modal/modal.service.ts index cf9c6e0..3f0ac3d 100644 --- a/src/app/modal/modal.service.ts +++ b/src/app/modal/modal.service.ts @@ -12,6 +12,8 @@ export class ModalService { modalComponent: ModalAlertComponent; alert(texto: string) { - return this.modalService.open(ModalAlertComponent).componentInstance.textoModal = texto; + let modal = this.modalService.open(ModalAlertComponent) + modal.componentInstance.textoModal = texto; + return modal; } }