-
Notifications
You must be signed in to change notification settings - Fork 125
/
App.jsx
66 lines (60 loc) · 2.02 KB
/
App.jsx
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
61
62
63
64
65
66
import React, { Component } from 'react';
import Breadcrumbs from '@department-of-veterans-affairs/component-library/Breadcrumbs';
import RoutedSavableApp from 'platform/forms/save-in-progress/RoutedSavableApp';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { fetchFormStatus } from '../actions';
import formConfig from '../config/form';
import LoadingIndicator from '@department-of-veterans-affairs/component-library/LoadingIndicator';
import ErrorMessage from '../components/ErrorMessage';
class App extends Component {
componentDidMount() {
this.props.fetchFormStatus();
}
render() {
const { location, children, isError, pending, isLoggedIn } = this.props;
const showMainContent = !pending && !isError;
return (
<>
<Breadcrumbs>
<a href="/">Home</a>
{/* this will get updated when this route is added */}
<a href="/health-care">Health care</a>
<a href="/health-care/order-hearing-aid-batteries-and-accessories">
Order hearing aid batteries and accessories
</a>
<span className="vads-u-color--black">
<strong>Order form 2346</strong>
</span>
</Breadcrumbs>
{pending && (
<LoadingIndicator setFocus message="Loading your information..." />
)}
{isError &&
!pending &&
isLoggedIn && (
<div className="row vads-u-margin-bottom--3">
<ErrorMessage />
</div>
)}
{showMainContent && (
<RoutedSavableApp formConfig={formConfig} currentLocation={location}>
{children}
</RoutedSavableApp>
)}
</>
);
}
}
const mapStateToProps = state => ({
isLoggedIn: state.user.login.currentlyLoggedIn,
isError: state.mdot.isError,
pending: state.mdot.pending,
});
const mapDispatchToProps = dispatch => ({
...bindActionCreators({ fetchFormStatus }, dispatch),
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(App);