Skip to content

Commit

Permalink
#1 booking: use directly the event short name+reservationId from url
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Apr 5, 2019
1 parent d7fc81a commit 148e738
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/app/reservation/booking/booking.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<app-stepper [currentStep]="2"></app-stepper>
<hr>
<div *ngIf="reservation">
<form [formGroup]="contactAndTicketsForm" (submit)="submitForm(reservation.event.shortName, reservation.reservationId, contactAndTicketsForm.value)">
<form [formGroup]="contactAndTicketsForm" (submit)="submitForm(contactAndTicketsForm.value)">

<div class="page-header">
<h2 translate="reservation-page.your-details"></h2>
Expand Down Expand Up @@ -65,7 +65,7 @@ <h3><fa-icon [icon]="['fa', 'ticket-alt']" size="xs" [classes]="['rotate-45']"><
<button type="submit" class="block-button btn btn-success" translate="reservation-page.continue"></button>
</div>
<div class="col-md-4 order-0 col-12 ">
<button type="button" class="block-button btn btn-outline-dark" (click)="cancelPendingReservation(reservation.event.shortName, reservation.reservationId)" translate="reservation-page.cancel"></button>
<button type="button" class="block-button btn btn-outline-dark" (click)="cancelPendingReservation()" translate="reservation-page.cancel"></button>
</div>
</div>
</form>
Expand Down
28 changes: 18 additions & 10 deletions src/app/reservation/booking/booking.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class BookingComponent implements OnInit {

reservation: any;
contactAndTicketsForm: FormGroup;
eventShortName: string;
reservationId: string;

constructor(
private route: ActivatedRoute,
Expand All @@ -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;
}

Expand Down Expand Up @@ -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]);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/reservation/reservation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ReservationComponent implements OnInit {
this.route.params.subscribe(params => {
this.eventService.getEvent(params['eventShortName']).subscribe(event => {
this.event = event;
})
});
});
}

Expand Down

0 comments on commit 148e738

Please sign in to comment.