1
|
|
|
import React from "react"; |
2
|
|
|
import { useIntl, defineMessages, FormattedMessage } from "react-intl"; |
3
|
|
|
import { JobStatus } from "../models/lookupConstants"; |
4
|
|
|
import { Link } from "../models/app"; |
5
|
|
|
|
6
|
|
|
interface Activity { |
7
|
|
|
count: number; |
8
|
|
|
new: Link; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
const statuses = defineMessages({ |
12
|
|
|
Approved: { |
13
|
|
|
id: "jobCard.status.approved", |
14
|
|
|
description: "Text displayed for a Job Status of Approved.", |
15
|
|
|
defaultMessage: "Approved", |
16
|
|
|
}, |
17
|
|
|
Closed: { |
18
|
|
|
id: "jobCard.status.closed", |
19
|
|
|
description: "Text displayed for a Job Status of Closed.", |
20
|
|
|
defaultMessage: "Closed", |
21
|
|
|
}, |
22
|
|
|
Complete: { |
23
|
|
|
id: "jobCard.status.complete", |
24
|
|
|
description: "Text displayed for a Job Status of Complete.", |
25
|
|
|
defaultMessage: "Complete", |
26
|
|
|
}, |
27
|
|
|
Draft: { |
28
|
|
|
id: "jobCard.status.draft", |
29
|
|
|
description: "Text displayed for a Job Status of Draft.", |
30
|
|
|
defaultMessage: "Draft", |
31
|
|
|
}, |
32
|
|
|
Published: { |
33
|
|
|
id: "jobCard.status.published", |
34
|
|
|
description: "Text displayed for a Job Status of Published.", |
35
|
|
|
defaultMessage: "Published", |
36
|
|
|
}, |
37
|
|
|
Review: { |
38
|
|
|
id: "jobCard.status.review", |
39
|
|
|
description: "Text displayed for a Job Status of In Review.", |
40
|
|
|
defaultMessage: "In Review", |
41
|
|
|
}, |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
interface StatusPillProps { |
45
|
|
|
status: JobStatus; |
46
|
|
|
text: string; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
const StatusPill: React.FC<StatusPillProps> = ({ text, status }) => ( |
50
|
|
|
<span |
51
|
|
|
data-c-tag={status === JobStatus.Published ? "go" : "c1"} |
52
|
|
|
data-c-font-size="small" |
53
|
|
|
data-c-radius="pill" |
54
|
|
|
data-c-margin="right(half)" |
55
|
|
|
> |
56
|
|
|
{text} |
57
|
|
|
</span> |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
export interface JobCardProps { |
61
|
|
|
activity: Activity; |
62
|
|
|
applicants: number; |
63
|
|
|
classification: string; |
64
|
|
|
draft: Link; |
65
|
|
|
managerTime: number; |
66
|
|
|
owned: boolean; |
67
|
|
|
preview: Link; |
68
|
|
|
screeningPlan: Link; |
69
|
|
|
summary: Link; |
70
|
|
|
status: JobStatus; |
71
|
|
|
title: string; |
72
|
|
|
userTime: number; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
const JobCard: React.FC<JobCardProps> = ({ |
76
|
|
|
activity, |
77
|
|
|
applicants, |
78
|
|
|
classification, |
79
|
|
|
draft, |
80
|
|
|
managerTime, |
81
|
|
|
owned, |
82
|
|
|
preview, |
83
|
|
|
screeningPlan, |
84
|
|
|
status, |
85
|
|
|
summary, |
86
|
|
|
title, |
87
|
|
|
userTime, |
88
|
|
|
}) => { |
89
|
|
|
const intl = useIntl(); |
90
|
|
|
return ( |
91
|
|
|
<div |
92
|
|
|
data-c-card="" |
93
|
|
|
data-c-background="white(100)" |
94
|
|
|
data-c-radius="rounded" |
95
|
|
|
data-tc-status="in review" |
96
|
|
|
data-c-padding="all(normal)" |
97
|
|
|
data-c-margin="bottom(normal)" |
98
|
|
|
> |
99
|
|
|
<div data-c-grid="gutter middle"> |
100
|
|
|
<div data-c-grid-item="tl(5of10)"> |
101
|
|
|
<h2 data-c-margin="bottom(normal)" data-c-font-size="h3"> |
102
|
|
|
{`${classification} - `} |
103
|
|
|
<span data-c-font-weight="bold" data-c-margin="right(normal)"> |
104
|
|
|
{title} |
105
|
|
|
</span> |
106
|
|
|
<StatusPill |
107
|
|
|
text={intl.formatMessage(statuses[status])} |
108
|
|
|
status={status} |
109
|
|
|
/> |
110
|
|
|
</h2> |
111
|
|
|
|
112
|
|
|
<p data-c-font-size="small" data-c-margin="top(normal)"> |
113
|
|
|
{draft.url.length === 0 ? ( |
114
|
|
|
<a |
115
|
|
|
href={draft.url} |
116
|
|
|
title={draft.title} |
117
|
|
|
data-c-margin="right(half)" |
118
|
|
|
> |
119
|
|
|
{draft.text} |
120
|
|
|
</a> |
121
|
|
|
) : ( |
122
|
|
|
<span data-c-color="gray" data-c-margin="right(half)"> |
123
|
|
|
{draft.text} |
124
|
|
|
</span> |
125
|
|
|
)} |
126
|
|
|
{preview.url !== null ? ( |
127
|
|
|
<a |
128
|
|
|
href={preview.url} |
129
|
|
|
title={preview.title} |
130
|
|
|
data-c-margin="right(half)" |
131
|
|
|
> |
132
|
|
|
{preview.text} |
133
|
|
|
</a> |
134
|
|
|
) : ( |
135
|
|
|
<span data-c-color="gray" data-c-margin="right(half)"> |
136
|
|
|
{preview.text} |
137
|
|
|
</span> |
138
|
|
|
)} |
139
|
|
|
{screeningPlan.url !== null ? ( |
140
|
|
|
<a |
141
|
|
|
href={screeningPlan.url} |
142
|
|
|
title={screeningPlan.title} |
143
|
|
|
data-c-margin="right(half)" |
144
|
|
|
> |
145
|
|
|
{screeningPlan.text} |
146
|
|
|
</a> |
147
|
|
|
) : ( |
148
|
|
|
<span data-c-color="gray" data-c-margin="right(half)"> |
149
|
|
|
{screeningPlan.text} |
150
|
|
|
</span> |
151
|
|
|
)} |
152
|
|
|
<span data-c-color="gray" data-c-margin="right(half)"> |
153
|
|
|
<FormattedMessage |
154
|
|
|
id="jobCard.applicants" |
155
|
|
|
defaultMessage={`{applicants, plural, |
156
|
|
|
=0 {No Applicants} |
157
|
|
|
one {# Applicant} |
158
|
|
|
other {# Applicants} |
159
|
|
|
}`} |
160
|
|
|
description="Text displaying how many applicants have applied to this Job." |
161
|
|
|
values={{ |
162
|
|
|
applicants, |
163
|
|
|
}} |
164
|
|
|
/> |
165
|
|
|
</span> |
166
|
|
|
</p> |
167
|
|
|
</div> |
168
|
|
|
<div data-c-grid-item="tl(3of10)"> |
169
|
|
|
<div data-c-grid="gutter"> |
170
|
|
|
<div data-c-grid-item="base(1of1)"> |
171
|
|
|
<p data-c-font-size="small"> |
172
|
|
|
<FormattedMessage |
173
|
|
|
id="jobCard.managerTime" |
174
|
|
|
defaultMessage={`Time with Manager: {managerTime, plural, |
175
|
|
|
one {# day} |
176
|
|
|
other {# days} |
177
|
|
|
}`} |
178
|
|
|
description="Text displaying how long a job post has been claimed by a manager." |
179
|
|
|
values={{ |
180
|
|
|
managerTime, |
181
|
|
|
}} |
182
|
|
|
/> |
183
|
|
|
</p> |
184
|
|
|
<p data-c-font-size="small" className={owned ? "pulse" : ""}> |
185
|
|
|
<FormattedMessage |
186
|
|
|
id="jobCard.userTime" |
187
|
|
|
defaultMessage={`Time with you: <s>{userTime, plural, |
188
|
|
|
one {# day} |
189
|
|
|
other {# days} |
190
|
|
|
}</s>`} |
191
|
|
|
description="Text displaying how long a job has been claimed by the current user." |
192
|
|
|
values={{ |
193
|
|
|
s: (msg): JSX.Element => <span>{msg}</span>, |
194
|
|
|
userTime, |
195
|
|
|
}} |
196
|
|
|
/> |
197
|
|
|
</p> |
198
|
|
|
{activity.count > 0 && activity.new.url !== null ? ( |
199
|
|
|
<a |
200
|
|
|
href={activity.new.url} |
201
|
|
|
title={activity.new.title} |
202
|
|
|
data-c-font-size="small" |
203
|
|
|
data-c-margin="top(half)" |
204
|
|
|
data-c-color="stop" |
205
|
|
|
> |
206
|
|
|
{`${activity.new.text} (${activity.count})`} |
207
|
|
|
</a> |
208
|
|
|
) : ( |
209
|
|
|
<p |
210
|
|
|
data-c-font-size="small" |
211
|
|
|
data-c-margin="top(half)" |
212
|
|
|
data-c-color="gray" |
213
|
|
|
> |
214
|
|
|
<FormattedMessage |
215
|
|
|
id="jobCard.noActivity" |
216
|
|
|
defaultMessage="No New Activity" |
217
|
|
|
description="Fallback text for no new activity on a Job." |
218
|
|
|
/> |
219
|
|
|
</p> |
220
|
|
|
)} |
221
|
|
|
</div> |
222
|
|
|
</div> |
223
|
|
|
</div> |
224
|
|
|
<div data-c-grid-item="tl(2of10)" data-c-align="base(center)"> |
225
|
|
|
<a |
226
|
|
|
href={summary.url !== null ? summary.url : "#"} |
227
|
|
|
title={summary.title} |
228
|
|
|
data-c-button="solid(c1)" |
229
|
|
|
data-c-radius="rounded" |
230
|
|
|
> |
231
|
|
|
{summary.text} |
232
|
|
|
</a> |
233
|
|
|
</div> |
234
|
|
|
</div> |
235
|
|
|
</div> |
236
|
|
|
); |
237
|
|
|
}; |
238
|
|
|
|
239
|
|
|
export default JobCard; |
240
|
|
|
|