@@ -25,7 +25,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
2525 } ,
2626 {
2727 name : 'Date and Time' ,
28- width : 140 ,
28+ width : 120 ,
2929 valuePath : 'order.completed_at' ,
3030 extraValuePaths : [ 'order' ] ,
3131 cellComponent : 'ui-table/cell/events/view/tickets/attendees/cell-date' ,
@@ -34,7 +34,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
3434 } ,
3535 {
3636 name : 'Ticket Price' ,
37- width : 90 ,
37+ width : 50 ,
3838 valuePath : 'ticket.price' ,
3939 extraValuePaths : [ 'event' , 'discountCode' ] ,
4040 cellComponent : 'ui-table/cell/events/view/tickets/attendees/cell-price' ,
@@ -44,23 +44,23 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
4444 {
4545 name : 'First Name' ,
4646 valuePath : 'firstname' ,
47- width : 100
47+ width : 60
4848 } ,
4949 {
5050 name : 'Last Name' ,
5151 valuePath : 'lastname' ,
52- width : 90
52+ width : 60
5353 } ,
5454 {
5555 name : 'Email' ,
5656 valuePath : 'email' ,
57- width : 120
57+ width : 130
5858 } ,
5959 {
6060 name : 'Actions' ,
6161 valuePath : 'id' ,
62- width : 90 ,
63- extraValuePaths : [ 'order' , 'isCheckedIn' ] ,
62+ width : 130 ,
63+ extraValuePaths : [ 'order' , 'isCheckedIn' , 'event' , 'checkinTimes' , 'checkoutTimes' ] ,
6464 cellComponent : 'ui-table/cell/events/view/tickets/attendees/cell-action' ,
6565 actions : {
6666 toggleCheckIn : this . toggleCheckIn . bind ( this )
@@ -70,16 +70,23 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
7070 }
7171
7272 @action
73- toggleCheckIn ( attendee_id ) {
73+ toggleCheckIn ( attendee_id , date , isCheckedInCurrently ) {
7474 const attendee = this . store . peekRecord ( 'attendee' , attendee_id , { backgroundReload : false } ) ;
75- attendee . toggleProperty ( 'isCheckedIn' ) ;
76- if ( attendee . isCheckedIn ) {
77- const newCheckinTimes = attendee . get ( 'checkinTimes' ) === null ? `${ moment ( ) . toISOString ( ) } ` : `${ attendee . get ( 'checkinTimes' ) } ,${ moment ( ) . toISOString ( ) } ` ;
75+ let myTime = moment ( ) . toISOString ( ) ;
76+ if ( moment ( date , 'MM-DD-YYYY' ) . format ( 'MM-DD-YYYY' ) !== moment ( ) . format ( 'MM-DD-YYYY' ) ) {
77+ myTime = moment ( date , 'MM-DD-YYYY' ) ;
78+ myTime = myTime . format ( 'YYYY-MM-DD' ) + 'T13:00:00.000Z' ;
79+ }
80+ if ( ! isCheckedInCurrently ) {
81+ const newCheckinTimes = attendee . get ( 'checkinTimes' ) === null ? `${ myTime } ` : `${ attendee . get ( 'checkinTimes' ) } ,${ myTime } ` ;
7882 attendee . set ( 'checkinTimes' , newCheckinTimes ) ;
83+ } else {
84+ const newCheckoutTimes = attendee . get ( 'checkoutTimes' ) === null ? `${ myTime } ` : `${ attendee . get ( 'checkoutTimes' ) } ,${ myTime } ` ;
85+ attendee . set ( 'checkoutTimes' , newCheckoutTimes ) ;
7986 }
8087 attendee . save ( )
81- . then ( savedAttendee => {
82- const message = savedAttendee . isCheckedIn ? this . l10n . t ( 'Attendee Checked-In Successfully' ) : this . l10n . t ( 'Attendee Checked-Out Successfully' ) ;
88+ . then ( ( ) => {
89+ const message = ! isCheckedInCurrently ? this . l10n . t ( 'Attendee Checked-In Successfully' ) : this . l10n . t ( 'Attendee Checked-Out Successfully' ) ;
8390 this . notify . success ( message ) ;
8491 this . refreshModel . bind ( this ) ( ) ;
8592 } )
0 commit comments