Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
#1 add success page, add flow up to success
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Mar 26, 2019
1 parent a4070bf commit e8cf451
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { EventListComponent } from './event-list/event-list.component';
import { EventDisplayComponent } from './event-display/event-display.component';
import { ReservationComponent } from './reservation/reservation.component';
import { OverviewComponent } from './overview/overview.component';
import { SuccessComponent } from './success/success.component';

const routes: Routes = [
{ path: '', component: EventListComponent },
{ path: 'event/:eventShortName', component: EventDisplayComponent },
{ path: 'event/:eventShortName/reservation/:reservationId/book', component: ReservationComponent },
{ path: 'event/:eventShortName/reservation/:reservationId/overview', component: OverviewComponent }
{ path: 'event/:eventShortName/reservation/:reservationId/overview', component: OverviewComponent },
{ path: 'event/:eventShortName/reservation/:reservationId/success', component: SuccessComponent }
];

@NgModule({
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import { faInfoCircle, faGift, faTicketAlt } from '@fortawesome/free-solid-svg-i
import { faCalendarAlt, faCalendarPlus, faCalendarCheck, faCompass, faClock } from '@fortawesome/free-regular-svg-icons';
import { ReservationComponent } from './reservation/reservation.component';
import { OverviewComponent } from './overview/overview.component';
import { SuccessComponent } from './success/success.component';

@NgModule({
declarations: [
AppComponent,
EventListComponent,
EventDisplayComponent,
ReservationComponent,
OverviewComponent
OverviewComponent,
SuccessComponent
],
imports: [
BrowserModule,
Expand Down
18 changes: 15 additions & 3 deletions src/app/overview/overview.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<p>
overview works!
</p>
<div *ngIf="overview">

<form [formGroup]="overviewForm" (submit)="confirm(overview.event.shortName, overview.reservationId, overviewForm.value)">

<p><label><input formControlName="privacyPolicyAccepted" type="checkbox"> Privacy</label></p>
<p><label><input formControlName="termAndConditionsAccepted" type="checkbox"> Term and conditions</label></p>

<button type="button" (click)="backToBooking(overview.event.shortName, overview.reservationId)">Back</button>
<button type="submit">Next</button>

<pre>{{overviewForm.value | json}}</pre>
</form>


</div>
49 changes: 48 additions & 1 deletion src/app/overview/overview.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ReservationService } from '../shared/reservation.service';
import { FormBuilder, FormGroup } from '@angular/forms';

@Component({
selector: 'app-overview',
Expand All @@ -7,9 +10,53 @@ import { Component, OnInit } from '@angular/core';
})
export class OverviewComponent implements OnInit {

constructor() { }
overview: any;
overviewForm: FormGroup;

constructor(
private route: ActivatedRoute,
private router: Router,
private reservationService: ReservationService,
private formBuilder: FormBuilder) { }

ngOnInit() {
this.route.params.subscribe(params => {

this.reservationService.getOverview(params['eventShortName'], params['reservationId']).subscribe(resInfo => {
console.log(resInfo);

// TODO: move as a guard(?)
if (resInfo.viewState && (resInfo.viewState as string).endsWith("/book")) {
this.router.navigate(['event', params['eventShortName'], 'reservation', params['reservationId'], 'book'])
return;
}
if (resInfo.viewState && (resInfo.viewState as string).endsWith("/success")) {
this.router.navigate(['event', params['eventShortName'], 'reservation', params['reservationId'], 'success'])
return;
}
//

this.overview = resInfo;

this.overviewForm = this.formBuilder.group({
termAndConditionsAccepted: null,
privacyPolicyAccepted: null
});

});
});
}

backToBooking(eventShortName: string, reservationId: string) {
this.reservationService.backToBooking(eventShortName, reservationId).subscribe(res => {
this.router.navigate(['event', eventShortName, 'reservation', reservationId, 'book'])
});
}

confirm(eventShortName: string, reservationId: string, overviewFormValue) {
this.reservationService.confirmOverview(eventShortName, reservationId, overviewFormValue).subscribe(res => {
console.log(res);
});
}

}
5 changes: 4 additions & 1 deletion src/app/reservation/reservation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ export class ReservationComponent implements OnInit {
this.reservationService.getReservationInfo(params['eventShortName'], params['reservationId']).subscribe(resInfo => {

if (resInfo.viewState && (resInfo.viewState as string).endsWith("/overview")) {
//redirect to overwiew!
this.router.navigate(['event', params['eventShortName'], 'reservation', params['reservationId'], 'overview'])
return;
}
if (resInfo.viewState && (resInfo.viewState as string).endsWith("/success")) {
this.router.navigate(['event', params['eventShortName'], 'reservation', params['reservationId'], 'success'])
return;
}

this.reservation = resInfo;
this.contactAndTicketsForm = this.formBuilder.group({
Expand Down
13 changes: 12 additions & 1 deletion src/app/shared/reservation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class ReservationService {
return this.http.post(`/api/v2/public/event/${eventShortName}/reserve-tickets`, reservation);
}


public getReservationInfo(eventShortName: string, reservationId: string): Observable<any> {
return this.http.get(`/api/v2/public/event/${eventShortName}/reservation/${reservationId}/book`);
}
Expand All @@ -25,4 +24,16 @@ export class ReservationService {
public validateToOverview(eventShortName: string, reservationId: string, contactsAndTicket: any): Observable<any> {
return this.http.post(`/api/v2/public/event/${eventShortName}/reservation/${reservationId}/validate-to-overview`, contactsAndTicket);
}

public getOverview(eventShortName: string, reservationId: string): Observable<any> {
return this.http.get(`/api/v2/public/event/${eventShortName}/reservation/${reservationId}/overview`);
}

public confirmOverview(eventShortName: string, reservationId: string, overviewForm: any): Observable<any> {
return this.http.post(`/api/v2/public/event/${eventShortName}/reservation/${reservationId}`, overviewForm);
}

public backToBooking(eventShortName: string, reservationId: string) : Observable<any> {
return this.http.post(`/api/v2/public/event/${eventShortName}/reservation/${reservationId}/back-to-booking`, {});
}
}
3 changes: 3 additions & 0 deletions src/app/success/success.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
success works!
</p>
Empty file.
25 changes: 25 additions & 0 deletions src/app/success/success.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SuccessComponent } from './success.component';

describe('SuccessComponent', () => {
let component: SuccessComponent;
let fixture: ComponentFixture<SuccessComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SuccessComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SuccessComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/success/success.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-success',
templateUrl: './success.component.html',
styleUrls: ['./success.component.scss']
})
export class SuccessComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}

0 comments on commit e8cf451

Please sign in to comment.