-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
60 lines (53 loc) · 1.34 KB
/
App.js
File metadata and controls
60 lines (53 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import * as React from 'react';
import PropTypes from 'prop-types';
import { Global, css } from '@emotion/core'; // eslint-disable-line no-unused-vars
import { connect } from 'react-redux';
import Logo from '@hackoregon/component-library/assets/civic-logo-animated.svg';
// import styles from '@hackoregon/component-library/assets/global.styles.css';
import Routes from './Pages/routes';
import FlashMessage from './components/FlashMessage/FlashMessage';
import styles from './assets/styles/global.styles';
import { isLoggedIn, me } from './state/ducks/auth';
const style = css`
.logo-img {
display: block;
height: 60px;
}
`;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
};
}
componentDidMount() {
const { loadAuth } = this.props;
loadAuth().then(() => {
this.setState({ isLoading: false });
});
}
render() {
const { isLoading } = this.state;
return (
<div css={style}>
<Global styles={styles} />
<FlashMessage />
{isLoading ? <img src={Logo} alt="Logo" /> : <Routes />}
</div>
);
}
}
export default connect(
state => ({
isLoggedIn: isLoggedIn(state),
}),
dispatch => {
return {
loadAuth: () => dispatch(me()),
};
}
)(App);
App.propTypes = {
loadAuth: PropTypes.func,
};