From a03582e68d3fadc71b2c094553df9ac41b0f8558 Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Thu, 27 May 2021 17:32:56 +0200 Subject: [PATCH] =?UTF-8?q?bug=20fix=20creaci=C3=B3n=20de=20eventos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/prompt-evento/prompt-evento.page.ts | 24 +++++++++++++++++++-- src/app/reservamodal/reservamodal.page.ts | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/prompt-evento/prompt-evento.page.ts b/src/app/prompt-evento/prompt-evento.page.ts index c60bf3a..9adfc6b 100644 --- a/src/app/prompt-evento/prompt-evento.page.ts +++ b/src/app/prompt-evento/prompt-evento.page.ts @@ -11,6 +11,8 @@ import { Eventoi } from '../interfaces/eventoi'; styleUrls: ['./prompt-evento.page.scss'], }) export class PromptEventoPage implements OnInit{ + + evento: Eventoi; submitted = false; editarEvento = false; eventoForm = new FormGroup({ @@ -36,9 +38,14 @@ export class PromptEventoPage implements OnInit{ onSubmit(){ this.submitted = true; if (this.eventoForm.valid){ - this.asignarEvento(this.tab1Service.eventos[this.tab1Service.eventoIndex]); + if (this.tab1Service.editarEvento == true){ + this.asignarEvento(this.tab1Service.eventos[this.tab1Service.eventoIndex])} + else{ + this.asignarEvento(this.initEventoVacio()); + }; } } + asignarEvento(evento: Eventoi){ evento.nombre = this.eventoForm.get('nombre').value; evento.descripcion = this.eventoForm.get('descripcion').value; @@ -49,7 +56,6 @@ export class PromptEventoPage implements OnInit{ if (!this.tab1Service.editarEvento){ hora = hora.split("T")[1];} hora = hora.split(":")[0]+(":")+hora.split(":")[1]; - console.log(hora); evento.hora = hora; evento.precio1 = this.eventoForm.get('precio1').value; evento.precio2 = this.eventoForm.get('precio2').value; @@ -84,5 +90,19 @@ export class PromptEventoPage implements OnInit{ return this.eventoForm.get('descripcion'); } + initEventoVacio(): Eventoi{ + let evento = { + id: 0, + discotecaID: this.tab1Service.discotecaI.discotecaID, + nombre: this.tab1Service.discotecaI.localizacion, + localizacion: '', + fecha: null, + hora: null, + precio1: 0, + precio2: 0, + descripcion: '' + } + return evento; + } } diff --git a/src/app/reservamodal/reservamodal.page.ts b/src/app/reservamodal/reservamodal.page.ts index 892dd1d..9bb76a2 100644 --- a/src/app/reservamodal/reservamodal.page.ts +++ b/src/app/reservamodal/reservamodal.page.ts @@ -15,6 +15,9 @@ export class ReservamodalPage implements OnInit { ngOnInit() { this.codigoReserva = this.navParams.get('codigo'); this.descuento = this.navParams.get('descuento'); + if(!this.descuento){ + this.descuento = 0; + } } }