-
Notifications
You must be signed in to change notification settings - Fork 19
/
JudgeDecisionReviewTaskListView.jsx
109 lines (95 loc) · 3.04 KB
/
JudgeDecisionReviewTaskListView.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 from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { sprintf } from 'sprintf-js';
import { css } from 'glamor';
import TaskTable from './components/TaskTable';
import QueueJudgeAssignOrReviewDropdown from './components/QueueJudgeAssignOrReviewDropdown';
import AppSegment from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/AppSegment';
import Link from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/Link';
import Alert from '../components/Alert';
import {
resetErrorMessages,
resetSuccessMessages,
resetSaveState
} from './uiReducer/uiActions';
import { clearCaseSelectSearch } from '../reader/CaseSelect/CaseSelectActions';
import { judgeDecisionReviewTasksSelector } from './selectors';
import { fullWidth } from './constants';
import COPY from '../../COPY.json';
const containerStyles = css({
position: 'relative'
});
class JudgeDecisionReviewTaskListView extends React.PureComponent {
componentWillUnmount = () => {
this.props.resetSaveState();
this.props.resetSuccessMessages();
this.props.resetErrorMessages();
}
componentDidMount = () => {
this.props.clearCaseSelectSearch();
this.props.resetErrorMessages();
};
render = () => {
const {
userId,
messages,
tasks
} = this.props;
const reviewableCount = tasks.length;
let tableContent;
if (reviewableCount === 0) {
tableContent = <p {...css({ textAlign: 'center',
marginTop: '3rem' })}>
{COPY.NO_CASES_IN_QUEUE_MESSAGE}<b><Link to="/search">{COPY.NO_CASES_IN_QUEUE_LINK_TEXT}</Link></b>.
</p>;
} else {
tableContent = <TaskTable
includeHearingBadge
includeTask
includeDetailsLink
includeDocumentId
includeType
includeDocketNumber
includeIssueCount
includeDaysWaiting
tasks={this.props.tasks}
/>;
}
return <AppSegment filledBackground styling={containerStyles}>
<h1 {...fullWidth}>{sprintf(COPY.JUDGE_CASE_REVIEW_TABLE_TITLE, reviewableCount)}</h1>
<QueueJudgeAssignOrReviewDropdown userId={userId} />
{messages.error && <Alert type="error" title={messages.error.title}>
{messages.error.detail}
</Alert>}
{messages.success && <Alert type="success" title={messages.success.title}>
{messages.success.detail || COPY.JUDGE_QUEUE_TABLE_SUCCESS_MESSAGE_DETAIL}
</Alert>}
{tableContent}
</AppSegment>;
};
}
JudgeDecisionReviewTaskListView.propTypes = {
tasks: PropTypes.array.isRequired
};
const mapStateToProps = (state) => {
const {
ui: {
messages
}
} = state;
return {
tasks: judgeDecisionReviewTasksSelector(state),
messages
};
};
const mapDispatchToProps = (dispatch) => (
bindActionCreators({
clearCaseSelectSearch,
resetErrorMessages,
resetSuccessMessages,
resetSaveState
}, dispatch)
);
export default connect(mapStateToProps, mapDispatchToProps)(JudgeDecisionReviewTaskListView);