-
Notifications
You must be signed in to change notification settings - Fork 126
/
App.jsx
109 lines (101 loc) · 3.77 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React, { Component } from 'react';
import { VaBreadcrumbs } from '@department-of-veterans-affairs/web-components/react-bindings';
import RoutedSavableApp from 'platform/forms/save-in-progress/RoutedSavableApp';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
import { datadogRum } from '@datadog/browser-rum';
import { fetchFormStatus } from '../actions';
import formConfig from '../config/form';
import ErrorMessage from '../components/ErrorMessage';
class App extends Component {
componentDidMount() {
this.props.fetchFormStatus();
}
render() {
if (
// Prevent RUM from running on local/CI environments.
environment.BASE_URL.indexOf('localhost') < 0 &&
// Prevent re-initializing the SDK.
!window.DD_RUM?.getInitConfiguration() &&
!window.Mocha
) {
datadogRum.init({
applicationId: 'a0a53db3-74e7-4741-bd3f-35568fb66e8e',
clientToken: 'pubf630a1a21f35ff1cc9bf698739bcd3bc',
site: 'ddog-gov.com',
service: 'medical-supply-reordering',
env: environment.vspEnvironment(),
sessionSampleRate: 100,
sessionReplaySampleRate: 100,
trackInteractions: true,
trackUserInteractions: true,
trackResources: true,
trackLongTasks: true,
defaultPrivacyLevel: 'mask',
});
datadogRum.startSessionReplayRecording();
}
const {
location,
children,
isError,
pending,
isLoggedIn,
featureToggles,
} = this.props;
const showMainContent = !pending && !isError && !featureToggles.loading;
const supplyDescription = featureToggles.supply_reordering_sleep_apnea_enabled
? 'hearing aid or CPAP supplies'
: 'hearing aid batteries and accessories';
// Update form config on the fly based on feature toggle.
formConfig.title = `Order ${supplyDescription}`;
formConfig.saveInProgress.messages.inProgress = `You have a ${supplyDescription} order s in progress.`;
formConfig.saveInProgress.messages = {
inProgress: `You have a ${supplyDescription}} order in progress.`,
expired: `Your saved ${supplyDescription} order has expired. If you want to order ${supplyDescription}, please start a new order.`,
saved: `Your ${supplyDescription} order has been saved.`,
};
return (
<>
{!featureToggles.loading && (
<div className="large-screen:vads-u-padding-left--0 vads-u-padding-left--2">
<VaBreadcrumbs uswds="false" label="Breadcrumb">
<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 {supplyDescription}
</a>
</VaBreadcrumbs>
</div>
)}
{pending && (
<va-loading-indicator>
Loading your information...
</va-loading-indicator>
)}
{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,
featureToggles: state.featureToggles,
});
const mapDispatchToProps = dispatch => ({
...bindActionCreators({ fetchFormStatus }, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(App);