Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91,351 changes: 58,418 additions & 32,933 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"private": true,
"dependencies": {
"@apollo/client": "^3.3.13",
"@aws-amplify/auth": "^3.4.29",
"@aws-amplify/interactions": "^3.3.29",
"@aws-amplify/storage": "^3.3.29",
"@aws-amplify/ui": "^2.0.2",
"@aws-amplify/ui-react": "^1.2.7",
"@aws-amplify/auth": "^4.2.0",
"@aws-amplify/core": "^3.8.24",
"@aws-amplify/interactions": "^4.0.8",
"@aws-amplify/storage": "^4.3.3",
"@aws-amplify/ui": "^2.0.3",
"@aws-amplify/ui-components": "^1.7.1",
"@aws-amplify/ui-react": "^1.2.8",
"@emotion/styled": "^11.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
Expand All @@ -23,8 +25,8 @@
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"aws-amplify": "^3.4.3",
"aws-amplify-react": "^4.2.30",
"aws-amplify": "^4.2.2",
"aws-amplify-react": "^5.0.8",
"bootstrap": "^4.6.0",
"clsx": "^1.1.1",
"eslint-plugin-react": "^7.23.1",
Expand Down
48 changes: 30 additions & 18 deletions src/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { useState, useEffect } from 'react';
import { ApolloError } from '@apollo/client';
import { withAuthenticator } from 'aws-amplify-react';
import Amplify, { Auth, Hub } from 'aws-amplify';
import { ApolloError } from '@apollo/client/errors';
import { Auth, Hub } from 'aws-amplify';

import Sidebar from '../Components/Sidebar';
import Content from '../Components/Content';
import Navigation from '../Navigation/Navigation';

import './App.scss';
import { useGetCoursesQuery } from '../__generated__/types';
import { environment } from '../environment';
import Sidebar from '../Components/Sidebar';

Amplify.configure({
Auth: {
identityPoolId: 'us-east-1:07057d76-612a-4045-8522-f38a759cf216',
region: 'us-east-1',
userPoolId: 'us-east-1_POfbbYTKF',
userPoolWebClientId: '24sdf1brebo58s89ja0b63c51d',
oauth: {
domain: 'flipted-ios-test.auth.us-east-1.amazoncognito.com',
scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'],
redirectSignIn: environment.redirectSignIn,
redirectSignOut: environment.redirectSignout,
responseType: 'token',
},
Auth.configure({
identityPoolId: 'us-east-1:07057d76-612a-4045-8522-f38a759cf216',
region: 'us-east-1',
userPoolId: 'us-east-1_POfbbYTKF',
userPoolWebClientId: '24sdf1brebo58s89ja0b63c51d',
oauth: {
domain: 'https://flipted-ios-test.auth.us-east-1.amazoncognito.com',
scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'],
redirectSignIn: 'https://destin-flipted.herokuapp.com/',
redirectSignOut: 'https://destin-flipted.herokuapp.com/',
responseType: 'token',
},
});

console.log(`Redirect Sign In ${environment.redirectSignIn}`);
console.log(`Redirect Sign Out ${environment.redirectSignout}`);

const federated = {
google_client_id: '993811506351-76rvcgqvlsg96vvr0fio76p0il5t4quq.apps.googleusercontent.com',
};

// Entry point of the Flitped App
function App() {
const [, setUser] = useState(null);
Expand All @@ -48,26 +54,32 @@ function App() {
.then((userSession) => {
const accessToken = userSession.getAccessToken();
const jwt = accessToken.getJwtToken();

localStorage.setItem('accessToken', JSON.stringify(accessToken));
localStorage.setItem('jwt', jwt);
console.log('Obtained user session and saved JWT');

return Auth.currentAuthenticatedUser();
})
.then((authUser) => {
console.log('Set auth user');

setUser(authUser);
setFirstName(authUser.attributes.given_name);
})
.catch(() => console.log('Not signed in'));
.catch((e) => console.log(`Error!!: ${e}`));
}
useEffect(() => {
Hub.listen('auth', ({ payload: { event, data } }) => {
switch (event) {
case 'signIn':
case 'oauthSignIn':
case 'cognitoHostedUI':
console.log('Signed in!');
storeToken();
break;
case 'signOut':
console.log('Signed out!');
setUser(null);
break;
case 'signIn_failure':
Expand Down Expand Up @@ -109,6 +121,6 @@ function App() {
);
}

export default withAuthenticator(App, undefined, undefined, undefined, undefined, {
export default withAuthenticator(App, undefined, undefined, federated, undefined, {
hiddenDefaults: ['phone_number'],
});
2 changes: 1 addition & 1 deletion src/Components/Content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
};

export default function Content({ courses, refetchCourses }: Props) {
const { loading, error, data } = useUserQuery();
const { loading, error, data } = useUserQuery({ fetchPolicy: 'network-only' });

if (loading || error || !data) {
return <></>;
Expand Down
4 changes: 2 additions & 2 deletions src/Components/MarketHome/StudentInfoPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function StudentInfoPage() {
studentId,
courseId: classId,
},
}).catch((e) => console.log(e));
}).catch((e: any) => console.log(e));
};

const handleChange = () => {
Expand All @@ -52,7 +52,7 @@ export function StudentInfoPage() {
courseId: classId,
blocked: !checked,
},
}).catch((e) => console.log(e));
}).catch((e: any) => console.log(e));
setChecked(!checked);
};
const { loading, error, data } = useStudentQuery({
Expand Down
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import { BrowserRouter as Router } from 'react-router-dom';
import { ApolloProvider } from '@apollo/client';
import { ApolloProvider } from '@apollo/client/react';

import App from './App';
import reportWebVitals from './reportWebVitals';
import apolloClient from './clients/apollo-client';
Expand Down