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