@@ -24,21 +24,25 @@ export class EventDetailComponent {
2424 confirmed ( ) {
2525 switch ( this . buttonText ( ) ) {
2626 case 'Book' :
27- this . eventDetailService . bookEvent ( this . event ) . subscribe ( response => {
28- if ( response . success ) {
29- this . notificationService . alert ( {
30- message : 'Booked Successfully!' ,
31- buttons : [
32- {
33- text : 'OK' ,
34- role : 'cancel'
27+ if ( this . event . singleBooking ) {
28+ this . notificationService . alert ( {
29+ message : 'Booking this event will cancel your booking for other events within the same activity, do you still wanna book?' ,
30+ buttons : [
31+ {
32+ text : 'OK' ,
33+ handler : ( ) => {
34+ this . _bookEvent ( ) ;
3535 }
36- ]
37- } ) ;
38- // update the event list & activity detail page
39- this . utils . broadcastEvent ( 'update-event' , null ) ;
40- }
41- } ) ;
36+ } ,
37+ {
38+ text : 'Cancel' ,
39+ role : 'cancel'
40+ }
41+ ]
42+ } ) ;
43+ } else {
44+ this . _bookEvent ( ) ;
45+ }
4246 break ;
4347
4448 case 'Cancel Booking' :
@@ -67,10 +71,39 @@ export class EventDetailComponent {
6771 this . modalController . dismiss ( ) ;
6872 }
6973
74+ private _bookEvent ( ) {
75+ this . eventDetailService . bookEvent ( this . event ) . subscribe (
76+ response => {
77+ this . notificationService . alert ( {
78+ message : 'Booked Successfully!' ,
79+ buttons : [
80+ {
81+ text : 'OK' ,
82+ role : 'cancel'
83+ }
84+ ]
85+ } ) ;
86+ // update the event list & activity detail page
87+ this . utils . broadcastEvent ( 'update-event' , null ) ;
88+ } ,
89+ error => {
90+ this . notificationService . alert ( {
91+ message : 'Booking failed, please try again later!' ,
92+ buttons : [
93+ {
94+ text : 'OK' ,
95+ role : 'cancel'
96+ }
97+ ]
98+ } ) ;
99+ }
100+ ) ;
101+ }
102+
70103 buttonText ( ) {
71104 // for not booked event
72105 if ( ! this . event . isBooked ) {
73- if ( ! this . event . isPast && this . event . remainingCapacity > 0 ) {
106+ if ( ! this . event . isPast && this . event . remainingCapacity > 0 && this . event . canBook ) {
74107 return 'Book' ;
75108 }
76109 return false ;
0 commit comments