1
1
import React , { useEffect , useState } from "react" ;
2
2
import { message } from "antd" ;
3
- import { useMeQuery ,
4
- useEventsQuery ,
5
- useAttendEventMutation ,
6
- useRecordInterestMutation ,
7
- Event as IEvent } from "../../generated/graphql" ;
8
-
9
- const EventRegistration : React . FC < { match : any } > = ( { match} : any ) => {
3
+ import {
4
+ useMeQuery ,
5
+ useEventsQuery ,
6
+ useAttendEventMutation ,
7
+ useRecordInterestMutation ,
8
+ Event as IEvent
9
+ } from "../../generated/graphql" ;
10
+
11
+ const EventRegistration : React . FC < { match : any } > = ( { match } : any ) => {
10
12
//style sheets for output
11
13
const divStyle = {
12
14
margin : "auto" ,
@@ -37,12 +39,12 @@ const EventRegistration: React.FC<{match: any}> = ({match}: any) => {
37
39
fontWeight : 100 ,
38
40
fontStyle : "italic" ,
39
41
}
40
-
42
+
41
43
const {
42
44
loading : userLoading ,
43
45
error : userError ,
44
46
} : any = useMeQuery ( ) ;
45
-
47
+
46
48
const {
47
49
loading : eventLoading ,
48
50
error : eventError ,
@@ -77,9 +79,9 @@ const EventRegistration: React.FC<{match: any}> = ({match}: any) => {
77
79
78
80
//once all mutations/queries are loaded, the actual attendance is tracked
79
81
useEffect ( ( ) => {
80
- if ( curEvents && attendEvent && result . data ) {
81
- if ( result . data . me . id !== null )
82
- if ( getEventId ( eventUrlKey ) !== - 1 ) {
82
+ if ( curEvents && attendEvent && result . data ) {
83
+ if ( result . data . me . id !== null )
84
+ if ( getEventId ( eventUrlKey ) !== - 1 ) {
83
85
attendEvent ( {
84
86
variables : {
85
87
eventId : Number ( getEventId ( eventUrlKey ) )
@@ -103,10 +105,10 @@ const EventRegistration: React.FC<{match: any}> = ({match}: any) => {
103
105
return - 1 ;
104
106
} ;
105
107
106
- if ( eventLoading || eventError || userLoading || userError )
108
+ if ( eventLoading || eventError || userLoading || userError )
107
109
return < p > Loading...</ p >
108
110
109
- if ( result . data == null || getEventId ( eventUrlKey ) == - 1 || ! attendEvent )
111
+ if ( result . data == null || getEventId ( eventUrlKey ) == - 1 || ! attendEvent )
110
112
return (
111
113
< div style = { divStyle } >
112
114
< p style = { errorStyle } > An error has occured.</ p >
@@ -124,7 +126,7 @@ const EventRegistration: React.FC<{match: any}> = ({match}: any) => {
124
126
) ;
125
127
} ;
126
128
127
- const EventInterest : React . FC < { match : any } > = ( { match} : any ) => {
129
+ const EventInterest : React . FC < { match : any } > = ( { match } : any ) => {
128
130
//style sheets for output
129
131
const divStyle = {
130
132
margin : "auto" ,
@@ -155,12 +157,12 @@ const EventInterest: React.FC<{match: any}> = ({match}: any) => {
155
157
fontWeight : 100 ,
156
158
fontStyle : "italic" ,
157
159
}
158
-
160
+
159
161
const {
160
162
loading : userLoading ,
161
163
error : userError ,
162
164
} : any = useMeQuery ( ) ;
163
-
165
+
164
166
const {
165
167
loading : eventLoading ,
166
168
error : eventError ,
@@ -175,7 +177,6 @@ const EventInterest: React.FC<{match: any}> = ({match}: any) => {
175
177
176
178
const onRecordInterestError : ( e : Error ) => void = ( e : Error ) : void => {
177
179
message . error ( "Upload failed. Please try again." ) ;
178
- console . log ( e ) ;
179
180
} ;
180
181
181
182
useEffect ( ( ) => {
@@ -200,17 +201,17 @@ const EventInterest: React.FC<{match: any}> = ({match}: any) => {
200
201
201
202
//once all mutations/queries are loaded, the actual attendance is tracked
202
203
useEffect ( ( ) => {
203
- if ( curEvents && recordInterest && result . data ) {
204
- if ( result . data . me . id !== null )
205
- if ( getEventId ( eventUrlKey ) !== - 1 ) {
204
+ if ( curEvents && recordInterest && result . data ) {
205
+ if ( result . data . me . id !== null )
206
+ if ( getEventId ( eventUrlKey ) !== - 1 ) {
206
207
try {
207
208
recordInterest ( {
208
209
variables : {
209
210
eventId : Number ( getEventId ( eventUrlKey ) )
210
211
}
211
212
} ) ;
212
213
}
213
- catch ( e ) {
214
+ catch ( e ) {
214
215
onRecordInterestError ( e ) ;
215
216
}
216
217
}
@@ -231,10 +232,10 @@ const EventInterest: React.FC<{match: any}> = ({match}: any) => {
231
232
return - 1 ;
232
233
} ;
233
234
234
- if ( eventLoading || eventError || userLoading || userError )
235
+ if ( eventLoading || eventError || userLoading || userError )
235
236
return < p > Loading...</ p >
236
237
237
- if ( result . data == null || getEventId ( eventUrlKey ) == - 1 || ! recordInterest )
238
+ if ( result . data == null || getEventId ( eventUrlKey ) == - 1 || ! recordInterest )
238
239
return (
239
240
< div style = { divStyle } >
240
241
< p style = { errorStyle } > An error has occured.</ p >
0 commit comments