From 148e73856bccbe437c46bde5721714d1abb13e1d Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Fri, 5 Apr 2019 15:06:08 +0200 Subject: [PATCH] #1 booking: use directly the event short name+reservationId from url --- .../booking/booking.component.html | 4 +-- .../reservation/booking/booking.component.ts | 28 ++++++++++++------- src/app/reservation/reservation.component.ts | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/app/reservation/booking/booking.component.html b/src/app/reservation/booking/booking.component.html index 695a9ffa..3cb73922 100644 --- a/src/app/reservation/booking/booking.component.html +++ b/src/app/reservation/booking/booking.component.html @@ -2,7 +2,7 @@
-
+
- +
diff --git a/src/app/reservation/booking/booking.component.ts b/src/app/reservation/booking/booking.component.ts index 8f2b6c35..a806f5a3 100644 --- a/src/app/reservation/booking/booking.component.ts +++ b/src/app/reservation/booking/booking.component.ts @@ -12,6 +12,8 @@ export class BookingComponent implements OnInit { reservation: any; contactAndTicketsForm: FormGroup; + eventShortName: string; + reservationId: string; constructor( private route: ActivatedRoute, @@ -21,14 +23,20 @@ export class BookingComponent implements OnInit { ngOnInit() { this.route.parent.params.subscribe(params => { - this.reservationService.getReservationInfo(params['eventShortName'], params['reservationId']).subscribe(resInfo => { + + this.eventShortName = params['eventShortName']; + this.reservationId = params['reservationId']; + + this.reservationService.getReservationInfo(this.eventShortName, this.reservationId).subscribe(resInfo => { + + if (resInfo.viewState && (resInfo.viewState as string).endsWith("/overview")) { - this.router.navigate(['event', params['eventShortName'], 'reservation', params['reservationId'], 'overview']) + this.router.navigate(['event', this.eventShortName, 'reservation', this.reservationId, 'overview']) return; } if (resInfo.viewState && (resInfo.viewState as string).endsWith("/success")) { - this.router.navigate(['event', params['eventShortName'], 'reservation', params['reservationId'], 'success']) + this.router.navigate(['event', this.eventShortName, 'reservation', this.reservationId, 'success']) return; } @@ -58,20 +66,20 @@ export class BookingComponent implements OnInit { } - public submitForm(eventShortName: string, reservationId: string, contactAndTicketsInfo: any) { - console.log(`${eventShortName} ${reservationId}`, contactAndTicketsInfo); - this.reservationService.validateToOverview(eventShortName, reservationId, contactAndTicketsInfo).subscribe(res => { + public submitForm(contactAndTicketsInfo: any) { + console.log(`${this.eventShortName} ${this.reservationId}`, contactAndTicketsInfo); + this.reservationService.validateToOverview(this.eventShortName, this.reservationId, contactAndTicketsInfo).subscribe(res => { console.log(res); if (res.viewState && (res.viewState as string).endsWith("/overview")) { - this.router.navigate(['event', eventShortName, 'reservation', reservationId, 'overview']) + this.router.navigate(['event', this.eventShortName, 'reservation', this.reservationId, 'overview']) } }) } - public cancelPendingReservation(eventShortName: string, reservationId: string) { - this.reservationService.cancelPendingReservation(eventShortName, reservationId).subscribe(res => { + public cancelPendingReservation() { + this.reservationService.cancelPendingReservation(this.eventShortName, this.reservationId).subscribe(res => { console.log(res); - this.router.navigate(['event', eventShortName]); + this.router.navigate(['event', this.eventShortName]); }); } diff --git a/src/app/reservation/reservation.component.ts b/src/app/reservation/reservation.component.ts index 3c7bc0da..024c22cb 100644 --- a/src/app/reservation/reservation.component.ts +++ b/src/app/reservation/reservation.component.ts @@ -20,7 +20,7 @@ export class ReservationComponent implements OnInit { this.route.params.subscribe(params => { this.eventService.getEvent(params['eventShortName']).subscribe(event => { this.event = event; - }) + }); }); }