diff --git a/src/app/reservamodal/reservamodal.page.html b/src/app/reservamodal/reservamodal.page.html index c4540c6..ebf8401 100644 --- a/src/app/reservamodal/reservamodal.page.html +++ b/src/app/reservamodal/reservamodal.page.html @@ -5,5 +5,5 @@ - +{{codigoReserva}} diff --git a/src/app/reservamodal/reservamodal.page.ts b/src/app/reservamodal/reservamodal.page.ts index 402e260..3569021 100644 --- a/src/app/reservamodal/reservamodal.page.ts +++ b/src/app/reservamodal/reservamodal.page.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { NavParams } from '@ionic/angular'; @Component({ selector: 'app-reservamodal', @@ -7,9 +8,11 @@ import { Component, OnInit } from '@angular/core'; }) export class ReservamodalPage implements OnInit { - constructor() { } + codigoReserva: string; + constructor(private navParams: NavParams) { } ngOnInit() { + this.codigoReserva = this.navParams.get('codigo'); } } diff --git a/src/app/services/codigoreserva.service.spec.ts b/src/app/services/codigoreserva.service.spec.ts new file mode 100644 index 0000000..8b2e33c --- /dev/null +++ b/src/app/services/codigoreserva.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { CodigoreservaService } from './codigoreserva.service'; + +describe('CodigoreservaService', () => { + let service: CodigoreservaService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(CodigoreservaService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/codigoreserva.service.ts b/src/app/services/codigoreserva.service.ts new file mode 100644 index 0000000..4caa80b --- /dev/null +++ b/src/app/services/codigoreserva.service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class CodigoreservaService { + + codigo: string; + length: number; + + constructor() { + + } + + generarAleatorio(){ + this.length = 7; + var result = []; + var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + var charactersLength = characters.length; + for ( var i = 0; i < this.length; i++ ) { + result.push(characters.charAt(Math.floor(Math.random() * + charactersLength))); + } + return result.join(""); +} + +} diff --git a/src/app/view-evento-cliente/view-evento-cliente.page.html b/src/app/view-evento-cliente/view-evento-cliente.page.html index 20f320f..3d0724c 100644 --- a/src/app/view-evento-cliente/view-evento-cliente.page.html +++ b/src/app/view-evento-cliente/view-evento-cliente.page.html @@ -27,7 +27,7 @@ - + Reserva diff --git a/src/app/view-evento-cliente/view-evento-cliente.page.ts b/src/app/view-evento-cliente/view-evento-cliente.page.ts index d38fbb6..5a0935d 100644 --- a/src/app/view-evento-cliente/view-evento-cliente.page.ts +++ b/src/app/view-evento-cliente/view-evento-cliente.page.ts @@ -1,9 +1,11 @@ +import { stringify } from '@angular/compiler/src/util'; import { Component, OnInit } from '@angular/core'; import { ModalController } from '@ionic/angular'; import { DiscotecaI } from '../interfaces/discoteca-i'; import { Eventoi } from '../interfaces/eventoi'; import { Reservai } from '../interfaces/reservai'; import { ReservamodalPage } from '../reservamodal/reservamodal.page'; +import { CodigoreservaService } from '../services/codigoreserva.service'; import { FeedService } from '../services/feed.service'; @Component({ @@ -16,16 +18,27 @@ export class ViewEventoClientePage implements OnInit { evento: Eventoi; discoteca: DiscotecaI; reserva: Reservai; - constructor(private feedService: FeedService, private modalController: ModalController) { } + codigoReserva: string; + + constructor(private feedService: FeedService, private modalController: ModalController, + private codigoReservaService: CodigoreservaService) { } ngOnInit() { this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex); this.discoteca = this.feedService.discotecaEvento; } + generarCodigo(){ + this.codigoReserva = stringify(this.codigoReservaService.generarAleatorio()); + console.log(this.codigoReserva); + } + openReserva(){ this.modalController.create({ component: ReservamodalPage, + componentProps : { + codigo: this.codigoReserva + } }).then(modal => modal.present());