Skip to content

Commit 1f9bfc1

Browse files
🚧 apply prettier format
1 parent a424f50 commit 1f9bfc1

24 files changed

+221
-126
lines changed

config-overrides.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module.exports = config => {
2-
require("react-app-rewire-postcss")(config, {
2+
require('react-app-rewire-postcss')(config, {
33
plugins: loader => [
4-
require("postcss-import-ext-glob"),
5-
require("postcss-import"),
6-
require("postcss-for"),
7-
require("postcss-inherit"),
8-
require("postcss-nested")
9-
]
4+
require('postcss-import-ext-glob'),
5+
require('postcss-import'),
6+
require('postcss-for'),
7+
require('postcss-inherit'),
8+
require('postcss-nested'),
9+
],
1010
});
1111

1212
return config;

src/App.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ body {
3737
.study-contacts {
3838
grid-column: 10 / span 3;
3939
}
40+
41+
.View--Login {
42+
background-image: url(https://portal.kidsfirstdrc.org/static/media/background-science.68317e4e.jpg);
43+
}
44+
45+
.Card--Login {
46+
@inherit: .Card;
47+
width: 620px;
48+
}

src/App.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@ import React from 'react';
22
import Routes from './Routes';
33
import {ApolloProvider} from 'react-apollo';
44
import {client} from './state/client';
5-
import {GridContainer} from './components/Grid';
6-
import {Header} from 'kf-uikit';
75

86
const App = () => (
97
<ApolloProvider client={client}>
10-
11-
<GridContainer>
12-
<Header />
13-
</GridContainer>
14-
158
<main className="App">
169
<Routes />
1710
</main>
18-
1911
</ApolloProvider>
2012
);
2113

src/App.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom";
3-
import App from "./App";
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
44

5-
it("renders without crashing", () => {
6-
const div = document.createElement("div");
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div');
77
ReactDOM.render(<App />, div);
88
ReactDOM.unmountComponentAtNode(div);
99
});

src/Routes/PrivateRoute.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import jwtDecode from 'jwt-decode';
3-
import { Route, Redirect, withRouter } from 'react-router-dom';
3+
import {Route, Redirect, withRouter} from 'react-router-dom';
44

55
export const hasToken = () => {
66
const token = localStorage.getItem('egoToken');
@@ -9,14 +9,17 @@ export const hasToken = () => {
99
}
1010
const user = jwtDecode(token).context.user;
1111
return (
12-
user.status === 'Approved' && jwtDecode(token).exp > Math.floor(new Date().getTime() / 1000)
12+
user.status === 'Approved' &&
13+
jwtDecode(token).exp > Math.floor(new Date().getTime() / 1000)
1314
);
1415
};
1516

16-
const PrivateRoute = ({ component: Component, ...rest }) => (
17+
const PrivateRoute = ({component: Component, ...rest}) => (
1718
<Route
1819
{...rest}
19-
render={props => (hasToken() ? <Component {...props} /> : <Redirect to="/login" />)}
20+
render={props =>
21+
hasToken() ? <Component {...props} /> : <Redirect to="/login" />
22+
}
2023
/>
2124
);
2225

src/Routes/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
2-
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
2+
import {BrowserRouter as Router, Route, Switch} from 'react-router-dom';
33
import PrivateRoute from './PrivateRoute';
44

5-
import { LoginView, StudyListView, FileUploadView } from '../views';
5+
import {LoginView, StudyListView, FileUploadView} from '../views';
66

77
const Routes = () => (
88
<Router>

src/components/FileUpload/FileUploadTarget.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { Component } from 'react';
1+
import React, {Component} from 'react';
22
import classes from 'classnames';
33
import PropTypes from 'prop-types';
44

55
class FileUploadTarget extends Component {
66
constructor(props) {
77
super(props);
8-
this.state = { dragging: false, count: 0 };
8+
this.state = {dragging: false, count: 0};
99
}
1010

1111
preventDefaults = e => {
@@ -19,38 +19,38 @@ class FileUploadTarget extends Component {
1919

2020
handleDragEnter = e => {
2121
this.preventDefaults(e);
22-
let { count } = this.state;
23-
this.setState({ count: ++count });
22+
let {count} = this.state;
23+
this.setState({count: ++count});
2424

2525
if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
26-
this.setState({ dragging: true });
26+
this.setState({dragging: true});
2727
}
2828
};
2929

3030
handleDragLeave = e => {
3131
this.preventDefaults(e);
32-
let { count } = this.state;
33-
this.setState({ count: --count });
32+
let {count} = this.state;
33+
this.setState({count: --count});
3434

3535
if (this.state.count === 0) {
36-
this.setState({ dragging: false });
36+
this.setState({dragging: false});
3737
}
3838
};
3939

4040
handleDrop = e => {
4141
this.preventDefaults(e);
42-
this.setState({ dragging: false });
42+
this.setState({dragging: false});
4343

4444
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
4545
this.props.onDrop(e.dataTransfer.files);
4646
e.dataTransfer.clearData();
47-
this.setState({ count: 0 });
47+
this.setState({count: 0});
4848
}
4949
};
5050

5151
render() {
52-
const { className, instructions, handleSelectedFile } = this.props;
53-
const { handleDragOver, handleDragEnter, handleDragLeave, handleDrop } = this;
52+
const {className, instructions, handleSelectedFile} = this.props;
53+
const {handleDragOver, handleDragEnter, handleDragLeave, handleDrop} = this;
5454
const fileUploadFormClass = classes(
5555
'upload-target',
5656
'w-full',
@@ -80,7 +80,11 @@ class FileUploadTarget extends Component {
8080
</small>
8181
</p>
8282
) : null}
83-
<input type="file" className="Button Button--default" onChange={handleSelectedFile} />
83+
<input
84+
type="file"
85+
className="Button Button--default"
86+
onChange={handleSelectedFile}
87+
/>
8488
</form>
8589
);
8690
}

src/components/FileUpload/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as FileUploadTarget } from "./FileUploadTarget";
1+
export {default as FileUploadTarget} from './FileUploadTarget';

src/components/Grid/GridContainer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import classes from 'classnames';
55
/**
66
* Container for a 12 column css grid
77
*/
8-
const GridContainer = ({ className, children, collapsed }) => {
9-
const GridContainerClass = classes(className, { 'grid-container--collapsed': collapsed });
8+
const GridContainer = ({className, children, collapsed}) => {
9+
const GridContainerClass = classes(className, {
10+
'grid-container--collapsed': collapsed,
11+
});
1012

1113
return <section className={GridContainerClass}>{children}</section>;
1214
};

src/components/Grid/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as GridContainer } from "./GridContainer";
1+
export {default as GridContainer} from './GridContainer';

src/components/Loading/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import React from 'react';
2-
import { branch, renderComponent } from 'recompose';
2+
import {branch, renderComponent} from 'recompose';
33

4-
export const LoadingPlaceholder = () => <h1 className="col-12">LOADING ....</h1>;
4+
export const LoadingPlaceholder = () => (
5+
<h1 className="col-12">LOADING ....</h1>
6+
);
57

68
export const renderWhileLoading = (component, propName = 'data') =>
7-
branch(props => props[propName] && props[propName].loading, renderComponent(component));
9+
branch(
10+
props => props[propName] && props[propName].loading,
11+
renderComponent(component),
12+
);

src/components/Login/Login.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
import GoogleLogin from 'react-google-login';
3+
import {GOOGLE_APP_ID, EGO_API} from '../../common/globals';
4+
import {withRouter} from 'react-router';
5+
6+
const onSuccess = (repsonse, history) => {
7+
fetch(EGO_API + '/oauth/google/token', {
8+
method: 'GET',
9+
mode: 'cors',
10+
headers: {
11+
token: repsonse.tokenId,
12+
'content-type': 'application/json',
13+
},
14+
})
15+
.then(resp => {
16+
return resp.text();
17+
})
18+
.then(text => {
19+
localStorage.setItem('egoToken', text);
20+
history.push('/');
21+
return text;
22+
})
23+
.catch(err => {
24+
console.log('Problem getting Ego token');
25+
console.log(err);
26+
});
27+
};
28+
29+
const onFailure = repsonse => {
30+
console.log('Problem sign in');
31+
};
32+
33+
const LoginContainer = ({history}) => (
34+
<GoogleLogin
35+
clientId={GOOGLE_APP_ID}
36+
buttonText="Sign in with Google"
37+
onSuccess={response => onSuccess(response, history)}
38+
onFailure={onFailure}
39+
/>
40+
);
41+
42+
export default withRouter(LoginContainer);

src/components/Login/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default as Login} from './Login';

src/components/StudyCard/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import classes from 'classnames';
4-
import { Card } from 'kf-uikit';
4+
import {Card} from 'kf-uikit';
55

66
/**
77
* Displays all studies for each Investigator
88
*/
99

10-
const StudyCard = ({ children, className, title }) => {
10+
const StudyCard = ({children, className, title}) => {
1111
let studyCardClass = classes('study-card', className);
1212

1313
return (
14-
<Card {...{ title }} className={studyCardClass}>
14+
<Card {...{title}} className={studyCardClass}>
1515
{children}
1616
</Card>
1717
);

src/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@import "../node_modules/kf-uikit/dist/styles.css";
2-
@import "./App.css";
1+
@import '../node_modules/kf-uikit/dist/styles.css';
2+
@import './App.css';
33
@import-glob "./components/**/*.css";

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import './index.css';
22
import React from 'react';
33
import App from './App';
4-
import { render } from "react-dom";
4+
import {render} from 'react-dom';
55

6-
const RootHtml = () => (<App />);
6+
const RootHtml = () => <App />;
77

8-
render(<RootHtml />, document.getElementById("root"));
8+
render(<RootHtml />, document.getElementById('root'));
99

1010
if (module.hot) {
11-
module.hot.accept("./App", () => {
12-
render(<RootHtml />, document.getElementById("root"));
11+
module.hot.accept('./App', () => {
12+
render(<RootHtml />, document.getElementById('root'));
1313
});
1414
}

src/state/client.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ApolloClient } from 'apollo-client';
2-
import { ApolloLink } from 'apollo-link';
3-
import { createUploadLink } from 'apollo-upload-client';
4-
import { createHttpLink } from 'apollo-link-http';
5-
import { setContext } from 'apollo-link-context';
6-
import { InMemoryCache } from 'apollo-cache-inmemory';
7-
import { KF_STUDY_API } from '../common/globals';
1+
import {ApolloClient} from 'apollo-client';
2+
import {ApolloLink} from 'apollo-link';
3+
import {createUploadLink} from 'apollo-upload-client';
4+
import {createHttpLink} from 'apollo-link-http';
5+
import {setContext} from 'apollo-link-context';
6+
import {InMemoryCache} from 'apollo-cache-inmemory';
7+
import {KF_STUDY_API} from '../common/globals';
88

99
const authLink = setContext((_, { headers }) => {
1010
const token = localStorage.getItem('egoToken');
@@ -17,6 +17,9 @@ const authLink = setContext((_, { headers }) => {
1717
});
1818

1919
export const client = new ApolloClient({
20-
link: ApolloLink.from([authLink, createUploadLink({ uri: `${KF_STUDY_API}/graphql` })]),
20+
link: ApolloLink.from([
21+
authLink,
22+
createUploadLink({uri: `${KF_STUDY_API}/graphql`}),
23+
]),
2124
cache: new InMemoryCache(),
2225
});

src/state/nodes/allStudies/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import gql from 'graphql-tag';
2+
3+
// Example query to get studies
4+
export const STUDY_QUERY = gql`
5+
{
6+
allStudies {
7+
edges {
8+
node {
9+
id
10+
kfId
11+
name
12+
}
13+
}
14+
}
15+
}
16+
`;
17+

src/state/nodes/allStudiesNode.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ export const ALL_STUDIES_QUERY = gql`
1414
}
1515
}
1616
`;
17-

src/state/nodes/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { ALL_STUDIES_QUERY } from './allStudiesNode';
2-
export { GET_STUDY_BY_ID } from './studyNode';
3-
export { CREATE_FILE } from './filesNode';
1+
export {ALL_STUDIES_QUERY} from './allStudiesNode';
2+
export {GET_STUDY_BY_ID} from './studyNode';
3+
export {CREATE_FILE} from './filesNode';

0 commit comments

Comments
 (0)