1
|
|
|
import React, { useState, useMemo } from "react"; |
2
|
|
|
import { FormattedMessage } from "react-intl"; |
3
|
|
|
import JobCard, { JobCardProps } from "../JobCard"; |
4
|
|
|
import UnclaimedJobCard, { UnclaimedJobCardProps } from "../UnclaimedJobCard"; |
5
|
|
|
import { JobStatus } from "../../models/lookupConstants"; |
6
|
|
|
|
7
|
|
|
interface CompletedJobsAccordionProps { |
8
|
|
|
completedJobActions: JobCardProps[]; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
const CompletedJobsAccordion: React.FC<CompletedJobsAccordionProps> = ({ |
12
|
|
|
completedJobActions, |
13
|
|
|
}) => { |
14
|
|
|
const [isExpanded, setIsExpanded] = useState(false); |
15
|
|
|
|
16
|
|
|
return ( |
17
|
|
|
<section data-c-accordion-group data-c-margin="top(triple)"> |
18
|
|
|
<div data-c-accordion="" className={`${isExpanded && "active"}`}> |
19
|
|
|
<button |
20
|
|
|
aria-expanded={isExpanded} |
21
|
|
|
data-c-accordion-trigger |
22
|
|
|
tabIndex={0} |
23
|
|
|
type="button" |
24
|
|
|
onClick={(): void => { |
25
|
|
|
setIsExpanded(!isExpanded); |
26
|
|
|
}} |
27
|
|
|
> |
28
|
|
|
<div> |
29
|
|
|
<h3 data-c-font-size="h3" data-c-color="c3"> |
30
|
|
|
<FormattedMessage |
31
|
|
|
id="hrPortal.jobPageIndex.completedJobsHeader" |
32
|
|
|
description="Header for completed jobs accordion section." |
33
|
|
|
defaultMessage="My Completed Job Actions" |
34
|
|
|
/> |
35
|
|
|
</h3> |
36
|
|
|
</div> |
37
|
|
|
<span data-c-visibility="invisible"> |
38
|
|
|
<FormattedMessage |
39
|
|
|
id="hrPortal.jobPageIndex.clickToView" |
40
|
|
|
description="Accordion trigger message for screen readers." |
41
|
|
|
defaultMessage="Click to view..." |
42
|
|
|
/> |
43
|
|
|
</span> |
44
|
|
|
<p |
45
|
|
|
data-c-accordion-add |
46
|
|
|
data-c-font-style="underline" |
47
|
|
|
data-c-color="c2" |
48
|
|
|
> |
49
|
|
|
<FormattedMessage |
50
|
|
|
id="hrPortal.jobPageIndex.showAccordion" |
51
|
|
|
description="Accordion trigger message to show items." |
52
|
|
|
defaultMessage="Show" |
53
|
|
|
/> |
54
|
|
|
</p> |
55
|
|
|
<p |
56
|
|
|
data-c-accordion-remove |
57
|
|
|
data-c-font-style="underline" |
58
|
|
|
data-c-color="c2" |
59
|
|
|
> |
60
|
|
|
<FormattedMessage |
61
|
|
|
id="hrPortal.jobPageIndex.hideAccordion" |
62
|
|
|
description="Accordion trigger message to hide items." |
63
|
|
|
defaultMessage="Hide" |
64
|
|
|
/> |
65
|
|
|
</p> |
66
|
|
|
</button> |
67
|
|
|
<div |
68
|
|
|
aria-hidden="true" |
69
|
|
|
data-c-accordion-content |
70
|
|
|
data-c-padding="top(double)" |
71
|
|
|
> |
72
|
|
|
<div> |
73
|
|
|
{(completedJobActions.length !== 0 && |
74
|
|
|
completedJobActions.map( |
75
|
|
|
(jobAction): React.ReactElement => { |
76
|
|
|
return <JobCard key={jobAction.id} {...jobAction} />; |
77
|
|
|
}, |
78
|
|
|
)) || ( |
79
|
|
|
<p> |
80
|
|
|
<FormattedMessage |
81
|
|
|
id="hrPortal.jobPageIndex.noJobsCompleted" |
82
|
|
|
description="Message displayed if the completed jobs list is empty." |
83
|
|
|
defaultMessage="No jobs completed yet!" |
84
|
|
|
/> |
85
|
|
|
</p> |
86
|
|
|
)} |
87
|
|
|
</div> |
88
|
|
|
</div> |
89
|
|
|
</div> |
90
|
|
|
</section> |
91
|
|
|
); |
92
|
|
|
}; |
93
|
|
|
|
94
|
|
|
interface JobIndexHrProps { |
95
|
|
|
jobActions: JobCardProps[]; |
96
|
|
|
unclaimedJobs: UnclaimedJobCardProps[]; |
97
|
|
|
departmentName: string; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
const JobIndexHr: React.FunctionComponent<JobIndexHrProps> = ({ |
101
|
|
|
jobActions, |
102
|
|
|
unclaimedJobs, |
103
|
|
|
departmentName, |
104
|
|
|
}) => { |
105
|
|
|
const notCompletedJobActions: JobCardProps[] = useMemo( |
106
|
|
|
() => |
107
|
|
|
jobActions.filter(jobAction => jobAction.status.key !== JobStatus.Completed), |
108
|
|
|
[jobActions], |
109
|
|
|
); |
110
|
|
|
|
111
|
|
|
const completedJobActions: JobCardProps[] = useMemo( |
112
|
|
|
() => |
113
|
|
|
jobActions.filter(jobAction => jobAction.status.key === JobStatus.Completed), |
114
|
|
|
[jobActions], |
115
|
|
|
); |
116
|
|
|
|
117
|
|
|
const sortByCurrentDate = ( |
118
|
|
|
a: UnclaimedJobCardProps, |
119
|
|
|
b: UnclaimedJobCardProps, |
120
|
|
|
): number => { |
121
|
|
|
if (b.reviewRequested && a.reviewRequested) { |
122
|
|
|
return b.reviewRequested.getTime() - a.reviewRequested.getTime(); |
123
|
|
|
} |
124
|
|
|
return 0; |
125
|
|
|
}; |
126
|
|
|
|
127
|
|
|
return ( |
128
|
|
|
<section> |
129
|
|
|
<div |
130
|
|
|
data-c-background="gray(10)" |
131
|
|
|
data-c-border="bottom(thin, solid, black)" |
132
|
|
|
> |
133
|
|
|
<div data-c-container="large" data-c-padding="tb(triple)"> |
134
|
|
|
{/* |
135
|
|
|
<p> |
136
|
|
|
<FormattedMessage |
137
|
|
|
id="hrPortal.jobPageIndex.welcomeMessage" |
138
|
|
|
description="Welcome message at beginning of page." |
139
|
|
|
defaultMessage="Welcome! Introductory copy that explains how this page works, and what an HR advisor needs to do to claim a job action as their own. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium ducimus laboriosam sequi, quis autem minima esse quasi aspernatur vero provident quos eligendi, ea officia exercitationem. Obcaecati impedit quae veritatis corrupti!" |
140
|
|
|
/> |
141
|
|
|
</p> |
142
|
|
|
*/} |
143
|
|
|
<h2 data-c-font-size="h2" data-c-margin="bottom(normal)"> |
144
|
|
|
<FormattedMessage |
145
|
|
|
id="hrPortal.jobPageIndex.jobActionsHeader" |
146
|
|
|
description="Header for my job actions section." |
147
|
|
|
defaultMessage="My Job Actions" |
148
|
|
|
/> |
149
|
|
|
</h2> |
150
|
|
|
<p data-c-margin="bottom(double)"> |
151
|
|
|
<FormattedMessage |
152
|
|
|
id="hrPortal.jobPageIndex.jobActionsMessage" |
153
|
|
|
description="Message before list of users job actions." |
154
|
|
|
defaultMessage="This is a list of all job actions you are currently participating in. Looking for an older job? Check the 'My Completed Job Actions' section below your active jobs." |
155
|
|
|
/> |
156
|
|
|
</p> |
157
|
|
|
|
158
|
|
|
{/* Users Job Actions List */} |
159
|
|
|
{/* Not Completed */} |
160
|
|
|
{(notCompletedJobActions.length !== 0 && |
161
|
|
|
notCompletedJobActions.map( |
162
|
|
|
(jobAction): React.ReactElement => { |
163
|
|
|
return <JobCard key={jobAction.id} {...jobAction} />; |
164
|
|
|
}, |
165
|
|
|
)) || ( |
166
|
|
|
<p> |
167
|
|
|
<FormattedMessage |
168
|
|
|
id="hrPortal.jobPageIndex.jobActionsEmpty" |
169
|
|
|
description="Message displayed if the jobs actions list is empty." |
170
|
|
|
defaultMessage="Claim a job below!" |
171
|
|
|
/> |
172
|
|
|
</p> |
173
|
|
|
)} |
174
|
|
|
|
175
|
|
|
{/* Completed */} |
176
|
|
|
<CompletedJobsAccordion completedJobActions={completedJobActions} /> |
177
|
|
|
|
178
|
|
|
<hr data-c-margin="tb(triple)" data-c-hr="gray" /> |
179
|
|
|
<h2 data-c-font-size="h2" data-c-margin="top(triple) bottom(double)"> |
180
|
|
|
<FormattedMessage |
181
|
|
|
id="hrPortal.jobPageIndex.preDepartmentName" |
182
|
|
|
description="Message before department name." |
183
|
|
|
defaultMessage="All Jobs in" |
184
|
|
|
/> |
185
|
|
|
{` ${departmentName}`} |
186
|
|
|
</h2> |
187
|
|
|
<p data-c-margin="bottom(double)"> |
188
|
|
|
<FormattedMessage |
189
|
|
|
id="hrPortal.jobPageIndex.unclaimedJobsMessage" |
190
|
|
|
description="Message before list of unclaimed jobs." |
191
|
|
|
defaultMessage="This is the list of all active job actions in your department. From here you can 'claim' a job, which will move it into your jobs list above and allow you to begin working with the hiring manager on finding the best talent possible. If you claim a job by accident, no fear, for you can click into the job summary and remove yourself using the 'Relinquish This Job' button." |
192
|
|
|
/> |
193
|
|
|
</p> |
194
|
|
|
|
195
|
|
|
{/* Unclaimed Jobs List */} |
196
|
|
|
<section data-c-grid="gutter"> |
197
|
|
|
{unclaimedJobs.length !== 0 && |
198
|
|
|
unclaimedJobs.sort(sortByCurrentDate).map( |
199
|
|
|
(unclaimedJob): React.ReactElement => { |
200
|
|
|
return ( |
201
|
|
|
<UnclaimedJobCard key={unclaimedJob.id} {...unclaimedJob} /> |
202
|
|
|
); |
203
|
|
|
}, |
204
|
|
|
)} |
205
|
|
|
</section> |
206
|
|
|
{unclaimedJobs.length === 0 && ( |
207
|
|
|
<p> |
208
|
|
|
<FormattedMessage |
209
|
|
|
id="hrPortal.jobPageIndex.unclaimedJobsEmpty" |
210
|
|
|
description="Message displayed if the unclaimed jobs list is empty." |
211
|
|
|
defaultMessage="There are currently no active jobs available." |
212
|
|
|
/> |
213
|
|
|
</p> |
214
|
|
|
)} |
215
|
|
|
</div> |
216
|
|
|
</div> |
217
|
|
|
</section> |
218
|
|
|
); |
219
|
|
|
}; |
220
|
|
|
|
221
|
|
|
export default JobIndexHr; |
222
|
|
|
|