1
1
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
- import { Auth , Hub } from 'aws-amplify' ;
3
2
import { useState , useEffect } from 'react' ;
4
3
import { withAuthenticator } from 'aws-amplify-react' ;
4
+ import Amplify , { Auth , Hub } from 'aws-amplify' ;
5
+ import { ApolloError } from '@apollo/client/errors' ;
6
+
5
7
import Sidebar from '../Components/Sidebar' ;
6
8
import Content from '../Components/Content' ;
7
9
import Navigation from '../Navigation/Navigation' ;
8
10
9
11
import './App.scss' ;
10
12
import { useGetCoursesQuery } from '../__generated__/types' ;
13
+ import { environment } from '../environment' ;
14
+
15
+ Amplify . configure ( {
16
+ Auth : {
17
+ identityPoolId : 'us-east-1:07057d76-612a-4045-8522-f38a759cf216' ,
18
+ region : 'us-east-1' ,
19
+ userPoolId : 'us-east-1_POfbbYTKF' ,
20
+ userPoolWebClientId : '24sdf1brebo58s89ja0b63c51d' ,
21
+ oauth : {
22
+ domain : 'flipted-ios-test.auth.us-east-1.amazoncognito.com' ,
23
+ scope : [ 'phone' , 'email' , 'profile' , 'openid' , 'aws.cognito.signin.user.admin' ] ,
24
+ redirectSignIn : environment . redirectSignIn ,
25
+ redirectSignOut : environment . redirectSignout ,
26
+ responseType : 'token' ,
27
+ } ,
28
+ } ,
29
+ } ) ;
11
30
12
31
// Entry point of the Flitped App
13
32
function App ( ) {
14
33
const [ , setUser ] = useState ( null ) ;
15
34
const [ fname , setFirstName ] = useState ( '' ) ;
16
- const { loading, error, data : courseData , refetch } = useGetCoursesQuery ( ) ;
35
+
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
+ const handleError = ( _error : ApolloError ) => {
38
+ // eslint-disable-next-line
39
+ void refetch ( ) ;
40
+ } ;
41
+
42
+ const { loading, error, data : courseData , refetch } = useGetCoursesQuery ( {
43
+ onError : handleError ,
44
+ } ) ;
17
45
18
46
function storeToken ( ) : void {
19
47
Auth . currentSession ( )
@@ -35,6 +63,7 @@ function App() {
35
63
Hub . listen ( 'auth' , ( { payload : { event, data } } ) => {
36
64
switch ( event ) {
37
65
case 'signIn' :
66
+ case 'oauthSignIn' :
38
67
case 'cognitoHostedUI' :
39
68
storeToken ( ) ;
40
69
break ;
@@ -54,7 +83,9 @@ function App() {
54
83
} , [ ] ) ;
55
84
56
85
if ( loading ) return < div > Loading...</ div > ;
57
- if ( error ) return < div > `Error! ${ error . message } `</ div > ;
86
+ if ( error ) {
87
+ return < > </ > ;
88
+ }
58
89
if ( ! courseData ) {
59
90
return < > </ > ;
60
91
}
@@ -78,4 +109,6 @@ function App() {
78
109
) ;
79
110
}
80
111
81
- export default withAuthenticator ( App ) ;
112
+ export default withAuthenticator ( App , undefined , undefined , undefined , undefined , {
113
+ hiddenDefaults : [ 'phone_number' ] ,
114
+ } ) ;
0 commit comments