-
Notifications
You must be signed in to change notification settings - Fork 19
/
ColocatedTaskListView.jsx
155 lines (139 loc) · 4.53 KB
/
ColocatedTaskListView.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { sprintf } from 'sprintf-js';
import { css } from 'glamor';
import TaskTable from './components/TaskTable';
import QueueOrganizationDropdown from './components/QueueOrganizationDropdown';
import AppSegment from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/AppSegment';
import {
newTasksByAssigneeCssIdSelector,
onHoldTasksByAssigneeCssIdSelector,
completeTasksByAssigneeCssIdSelector
} from './selectors';
import { hideSuccessMessage } from './uiReducer/uiActions';
import { clearCaseSelectSearch } from '../reader/CaseSelect/CaseSelectActions';
import COPY from '../../COPY.json';
import {
fullWidth,
marginBottom
} from './constants';
import Alert from '../components/Alert';
import TabWindow from '../components/TabWindow';
const containerStyles = css({
position: 'relative'
});
class ColocatedTaskListView extends React.PureComponent {
componentDidMount = () => {
this.props.clearCaseSelectSearch();
};
componentWillUnmount = () => this.props.hideSuccessMessage();
render = () => {
const {
success,
organizations,
numNewTasks,
numOnHoldTasks
} = this.props;
const tabs = [
{
label: sprintf(COPY.COLOCATED_QUEUE_PAGE_NEW_TAB_TITLE, numNewTasks),
page: <NewTasksTab />
},
{
label: sprintf(COPY.QUEUE_PAGE_ON_HOLD_TAB_TITLE, numOnHoldTasks),
page: <OnHoldTasksTab />
},
{
label: COPY.QUEUE_PAGE_COMPLETE_TAB_TITLE,
page: <CompleteTasksTab />
}
];
return <AppSegment filledBackground styling={containerStyles}>
{success && <Alert type="success" title={success.title} message={success.detail} styling={marginBottom(1)} />}
<h1 {...fullWidth}>{COPY.COLOCATED_QUEUE_PAGE_TABLE_TITLE}</h1>
<QueueOrganizationDropdown organizations={organizations} />
<TabWindow name="tasks-tabwindow" tabs={tabs} />
</AppSegment>;
};
}
const mapStateToProps = (state) => {
const { success } = state.ui.messages;
return {
success,
organizations: state.ui.organizations,
numNewTasks: newTasksByAssigneeCssIdSelector(state).length,
numOnHoldTasks: onHoldTasksByAssigneeCssIdSelector(state).length
};
};
const mapDispatchToProps = (dispatch) => bindActionCreators({
clearCaseSelectSearch,
hideSuccessMessage
}, dispatch);
export default (connect(mapStateToProps, mapDispatchToProps)(ColocatedTaskListView));
const NewTasksTab = connect(
(state) => ({
tasks: newTasksByAssigneeCssIdSelector(state),
belongsToHearingSchedule: state.ui.organizations.find((org) => org.name === 'Hearing Management')
}))(
(props) => {
return <React.Fragment>
<p className="cf-margin-top-0">{COPY.COLOCATED_QUEUE_PAGE_NEW_TASKS_DESCRIPTION}</p>
<TaskTable
includeHearingBadge
includeDetailsLink
includeTask
includeRegionalOffice={props.belongsToHearingSchedule}
includeType
includeDocketNumber
includeDaysWaiting
includeReaderLink
tasks={props.tasks}
/>
</React.Fragment>;
});
const OnHoldTasksTab = connect(
(state) => ({
tasks: onHoldTasksByAssigneeCssIdSelector(state),
belongsToHearingSchedule: state.ui.organizations.find((org) => org.name === 'Hearing Management')
}))(
(props) => {
return <React.Fragment>
<p className="cf-margin-top-0">{COPY.COLOCATED_QUEUE_PAGE_ON_HOLD_TASKS_DESCRIPTION}</p>
<TaskTable
includeHearingBadge
includeDetailsLink
includeTask
includeRegionalOffice={props.belongsToHearingSchedule}
includeType
includeDocketNumber
includeDaysOnHold
includeReaderLink
includeNewDocsIcon
useOnHoldDate
tasks={props.tasks}
/>
</React.Fragment>;
});
const CompleteTasksTab = connect(
(state) => ({
tasks: completeTasksByAssigneeCssIdSelector(state),
belongsToHearingSchedule: state.ui.organizations.find((org) => org.name === 'Hearing Management')
}))(
(props) => {
return <React.Fragment>
<p className="cf-margin-top-0">{COPY.QUEUE_PAGE_COMPLETE_TASKS_DESCRIPTION}</p>
<TaskTable
includeHearingBadge
includeDetailsLink
includeTask
includeRegionalOffice={props.belongsToHearingSchedule}
includeType
includeDocketNumber
includeCompletedDate
includeCompletedToName
includeReaderLink
tasks={props.tasks}
/>
</React.Fragment>;
});