-
Notifications
You must be signed in to change notification settings - Fork 126
/
TotalRatedDisabilities.jsx
42 lines (37 loc) · 1.2 KB
/
TotalRatedDisabilities.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
import React from 'react';
import PropTypes from 'prop-types';
import {
errorMessage,
missingTotalMessage,
totalRatingMessage,
} from './TotalRatingStates';
import { isServerError, isClientError } from '../util';
const TotalRatedDisabilities = ({ error, loading, totalDisabilityRating }) => {
const errorCode = error ? error.code : null;
let content;
// If the data from the parent is loading ( loading prop ), show a loading indicator
// If there is an error, display an error message,
// If there is no rating, display a no rating message
// If there is a rating, display the rating and content
if (loading) {
content = (
<va-loading-indicator message="Loading your total disability rating..." />
);
} else if (errorCode && isServerError(errorCode)) {
content = errorMessage();
} else if (
!totalDisabilityRating ||
(errorCode && isClientError(errorCode))
) {
content = missingTotalMessage();
} else {
content = totalRatingMessage(totalDisabilityRating);
}
return content;
};
TotalRatedDisabilities.propTypes = {
error: PropTypes.object,
loading: PropTypes.bool,
totalDisabilityRating: PropTypes.number,
};
export default TotalRatedDisabilities;