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