|
1
|
|
|
import React, { useEffect } from "react"; |
|
2
|
|
|
import { useIntl, FormattedMessage } from "react-intl"; |
|
3
|
|
|
import { useDispatch, useSelector } from "react-redux"; |
|
4
|
|
|
import ReactDOM from "react-dom"; |
|
5
|
|
|
import RootContainer from "../RootContainer"; |
|
6
|
|
|
import { |
|
7
|
|
|
Job, |
|
8
|
|
|
JobPosterKeyTask, |
|
9
|
|
|
Criteria, |
|
10
|
|
|
Skill, |
|
11
|
|
|
Manager, |
|
12
|
|
|
Department, |
|
13
|
|
|
} from "../../models/types"; |
|
14
|
|
|
import { hrJobSummary } from "../../helpers/routes"; |
|
15
|
|
|
import { RootState } from "../../store/store"; |
|
16
|
|
|
import { |
|
17
|
|
|
getJob, |
|
18
|
|
|
getTasksByJob, |
|
19
|
|
|
getCriteriaByJob, |
|
20
|
|
|
} from "../../store/Job/jobSelector"; |
|
21
|
|
|
import { getSkills } from "../../store/Skill/skillSelector"; |
|
22
|
|
|
import { |
|
23
|
|
|
fetchJob, |
|
24
|
|
|
fetchJobTasks, |
|
25
|
|
|
fetchCriteria, |
|
26
|
|
|
} from "../../store/Job/jobActions"; |
|
27
|
|
|
import { getDepartments as fetchDepartments } from "../../store/Department/deptActions"; |
|
28
|
|
|
import { getDepartments } from "../../store/Department/deptSelector"; |
|
29
|
|
|
import { getManagerById } from "../../store/Manager/managerSelector"; |
|
30
|
|
|
import { fetchManager } from "../../store/Manager/managerActions"; |
|
31
|
|
|
import { JobReviewDisplay } from "../JobBuilder/Review/JobReview"; |
|
32
|
|
|
import { fetchSkills } from "../../store/Skill/skillActions"; |
|
33
|
|
|
import Icon from "../Icon"; |
|
34
|
|
|
import JobReviewActivityFeed from "../JobBuilder/Review/JobReviewActivityFeed"; |
|
35
|
|
|
|
|
36
|
|
|
interface JobReviewHrPageProps { |
|
37
|
|
|
jobId: number; |
|
38
|
|
|
job: Job | null; |
|
39
|
|
|
skills: Skill[]; |
|
40
|
|
|
keyTasks: JobPosterKeyTask[]; |
|
41
|
|
|
criteria: Criteria[]; |
|
42
|
|
|
departments: Department[]; |
|
43
|
|
|
manager: Manager | null; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
const JobReviewHrPage: React.FunctionComponent<JobReviewHrPageProps> = ({ |
|
47
|
|
|
jobId, |
|
48
|
|
|
job, |
|
49
|
|
|
skills, |
|
50
|
|
|
keyTasks, |
|
51
|
|
|
criteria, |
|
52
|
|
|
departments, |
|
53
|
|
|
manager, |
|
54
|
|
|
}): React.ReactElement => { |
|
55
|
|
|
const { locale } = useIntl(); |
|
56
|
|
|
if (locale !== "en" && locale !== "fr") { |
|
57
|
|
|
throw new Error("Unexpected locale"); |
|
58
|
|
|
} |
|
59
|
|
|
return ( |
|
60
|
|
|
<div data-c-container="form" data-c-padding="top(triple) bottom(triple)"> |
|
61
|
|
|
{job !== null ? ( |
|
62
|
|
|
<> |
|
63
|
|
|
<h3 |
|
64
|
|
|
data-c-font-size="h3" |
|
65
|
|
|
data-c-font-weight="bold" |
|
66
|
|
|
data-c-margin="bottom(double)" |
|
67
|
|
|
> |
|
68
|
|
|
<FormattedMessage |
|
69
|
|
|
id="jobReviewHr.reviewYourPoster" |
|
70
|
|
|
defaultMessage="Review Your Job Poster for:" |
|
71
|
|
|
description="Title for Review Job Poster section." |
|
72
|
|
|
/>{" "} |
|
73
|
|
|
<span data-c-colour="c2">{job[locale].title}</span> |
|
74
|
|
|
</h3> |
|
75
|
|
|
<p> |
|
76
|
|
|
<FormattedMessage |
|
77
|
|
|
id="jobReviewHr.headsUp" |
|
78
|
|
|
defaultMessage="Just a heads up! We've rearranged some of your information to help you |
|
79
|
|
|
understand how an applicant will see it once published." |
|
80
|
|
|
description="Description under primary title of review section" |
|
81
|
|
|
/> |
|
82
|
|
|
</p> |
|
83
|
|
|
<JobReviewActivityFeed jobId={job.id} isHrAdvisor /> |
|
84
|
|
|
<JobReviewDisplay |
|
85
|
|
|
job={job} |
|
86
|
|
|
manager={manager} |
|
87
|
|
|
tasks={keyTasks} |
|
88
|
|
|
criteria={criteria} |
|
89
|
|
|
skills={skills} |
|
90
|
|
|
departments={departments} |
|
91
|
|
|
hideBuilderLinks |
|
92
|
|
|
/> |
|
93
|
|
|
</> |
|
94
|
|
|
) : ( |
|
95
|
|
|
<div data-c-alignment="base(centre)"> |
|
96
|
|
|
<Icon |
|
97
|
|
|
icon="fa fa-spinner fa-spin" |
|
98
|
|
|
accessibleText="Data is loading..." |
|
99
|
|
|
sematicIcon |
|
100
|
|
|
/> |
|
101
|
|
|
</div> |
|
102
|
|
|
)} |
|
103
|
|
|
<div data-c-grid="gutter"> |
|
104
|
|
|
<div data-c-grid-item="base(1of1)"> |
|
105
|
|
|
<hr data-c-margin="top(normal) bottom(normal)" /> |
|
106
|
|
|
</div> |
|
107
|
|
|
<div |
|
108
|
|
|
data-c-alignment="base(centre) tp(left)" |
|
109
|
|
|
data-c-grid-item="tp(1of2)" |
|
110
|
|
|
> |
|
111
|
|
|
<a href={hrJobSummary(locale, jobId)} title=""> |
|
112
|
|
|
<FormattedMessage |
|
113
|
|
|
id="jobReviewHr.summaryLink" |
|
114
|
|
|
defaultMessage="Return to Summary" |
|
115
|
|
|
description="Text for the Return to Summary link." |
|
116
|
|
|
/> |
|
117
|
|
|
</a> |
|
118
|
|
|
</div> |
|
119
|
|
|
</div> |
|
120
|
|
|
</div> |
|
121
|
|
|
); |
|
122
|
|
|
}; |
|
123
|
|
|
|
|
124
|
|
|
const JobReviewHrDataFetcher: React.FC<{ jobId: number }> = ({ jobId }) => { |
|
125
|
|
|
const dispatch = useDispatch(); |
|
126
|
|
|
|
|
127
|
|
|
// Request and select the job |
|
128
|
|
|
useEffect(() => { |
|
129
|
|
|
dispatch(fetchJob(jobId)); |
|
130
|
|
|
}, [dispatch, jobId]); |
|
131
|
|
|
const job = useSelector((state: RootState) => getJob(state, { jobId })); |
|
132
|
|
|
|
|
133
|
|
|
// Request and select the job tasks |
|
134
|
|
|
useEffect(() => { |
|
135
|
|
|
dispatch(fetchJobTasks(jobId)); |
|
136
|
|
|
}, [dispatch, jobId]); |
|
137
|
|
|
const tasks = useSelector((state: RootState) => |
|
138
|
|
|
getTasksByJob(state, { jobId }), |
|
139
|
|
|
); |
|
140
|
|
|
|
|
141
|
|
|
// Request and select job criteria |
|
142
|
|
|
useEffect(() => { |
|
143
|
|
|
dispatch(fetchCriteria(jobId)); |
|
144
|
|
|
}, [dispatch, jobId]); |
|
145
|
|
|
const criteria = useSelector((state: RootState) => |
|
146
|
|
|
getCriteriaByJob(state, { jobId }), |
|
147
|
|
|
); |
|
148
|
|
|
|
|
149
|
|
|
// Load all skills |
|
150
|
|
|
useEffect(() => { |
|
151
|
|
|
dispatch(fetchSkills()); |
|
152
|
|
|
}, [dispatch]); |
|
153
|
|
|
const skills = useSelector(getSkills); |
|
154
|
|
|
|
|
155
|
|
|
// Load all departments |
|
156
|
|
|
useEffect(() => { |
|
157
|
|
|
dispatch(fetchDepartments()); |
|
158
|
|
|
}, [dispatch]); |
|
159
|
|
|
const departments = useSelector(getDepartments); |
|
160
|
|
|
|
|
161
|
|
|
// Load manager after Job has loaded |
|
162
|
|
|
// eslint-disable-next-line camelcase |
|
163
|
|
|
const managerId = job?.manager_id; |
|
164
|
|
|
useEffect(() => { |
|
165
|
|
|
if (managerId) { |
|
166
|
|
|
dispatch(fetchManager(managerId)); |
|
167
|
|
|
} |
|
168
|
|
|
}, [dispatch, managerId]); |
|
169
|
|
|
const manager = useSelector((state: RootState) => |
|
170
|
|
|
managerId ? getManagerById(state, { managerId }) : null, |
|
171
|
|
|
); |
|
172
|
|
|
|
|
173
|
|
|
return ( |
|
174
|
|
|
<JobReviewHrPage |
|
175
|
|
|
jobId={jobId} |
|
176
|
|
|
job={job} |
|
177
|
|
|
manager={manager} |
|
178
|
|
|
keyTasks={tasks} |
|
179
|
|
|
criteria={criteria} |
|
180
|
|
|
skills={skills} |
|
181
|
|
|
departments={departments} |
|
182
|
|
|
/> |
|
183
|
|
|
); |
|
184
|
|
|
}; |
|
185
|
|
|
|
|
186
|
|
|
export default JobReviewHrDataFetcher; |
|
187
|
|
|
|
|
188
|
|
|
const container = document.getElementById("job-review-hr"); |
|
189
|
|
|
if (container !== null) { |
|
190
|
|
|
if ("jobId" in container.dataset) { |
|
191
|
|
|
const jobId = Number(container.dataset.jobId as string); |
|
192
|
|
|
ReactDOM.render( |
|
193
|
|
|
<RootContainer> |
|
194
|
|
|
<JobReviewHrDataFetcher jobId={jobId} /> |
|
195
|
|
|
</RootContainer>, |
|
196
|
|
|
container, |
|
197
|
|
|
); |
|
198
|
|
|
} |
|
199
|
|
|
} |
|
200
|
|
|
|