1
|
|
|
import React, { ReactElement } from "react"; |
2
|
|
|
import { FormattedMessage } from "react-intl"; |
3
|
|
|
import { Skill } from "../../../models/types"; |
4
|
|
|
|
5
|
|
|
interface ExperienceSkill { |
6
|
|
|
id: number; |
7
|
|
|
name: string; |
8
|
|
|
claim: string; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
interface BaseExperienceAccordionProps { |
12
|
|
|
iconClass: string; |
13
|
|
|
title: Element | string; |
14
|
|
|
relevantSkills: ExperienceSkill[]; |
15
|
|
|
irrelevantSkillCount: number; |
16
|
|
|
isEducationJustification: boolean; |
17
|
|
|
details: Element; |
18
|
|
|
showSkillDetails: boolean; |
19
|
|
|
showButtons: boolean; |
20
|
|
|
handleDelete: () => void; |
21
|
|
|
handleEdit: () => void; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
export const BaseExperienceAccordion: React.FC<BaseExperienceAccordionProps> = ({ |
25
|
|
|
iconClass, |
26
|
|
|
title, |
27
|
|
|
relevantSkills, |
28
|
|
|
irrelevantSkillCount, |
29
|
|
|
isEducationJustification, |
30
|
|
|
details, |
31
|
|
|
showSkillDetails, |
32
|
|
|
showButtons, |
33
|
|
|
handleDelete, |
34
|
|
|
handleEdit, |
35
|
|
|
}) => { |
36
|
|
|
const relevantSkillCount = relevantSkills.length; |
37
|
|
|
return ( |
38
|
|
|
<div |
39
|
|
|
data-c-accordion |
40
|
|
|
data-c-background="white(100)" |
41
|
|
|
data-c-card |
42
|
|
|
data-c-margin="bottom(.5)" |
43
|
|
|
> |
44
|
|
|
<button |
45
|
|
|
tabIndex={0} |
46
|
|
|
aria-expanded="false" |
47
|
|
|
data-c-accordion-trigger |
48
|
|
|
type="button" |
49
|
|
|
> |
50
|
|
|
<div data-c-grid=""> |
51
|
|
|
<div data-c-grid-item="base(1of4) tl(1of6) equal-col"> |
52
|
|
|
<div className="experience-type-indicator"> |
53
|
|
|
<i |
54
|
|
|
className={`fas ${iconClass}`} |
55
|
|
|
data-c-color="c1" |
56
|
|
|
data-c-font-size="h4" |
57
|
|
|
></i> |
58
|
|
|
</div> |
59
|
|
|
</div> |
60
|
|
|
<div data-c-grid-item="base(3of4) tl(5of6)"> |
61
|
|
|
<div data-c-padding="all(1)"> |
62
|
|
|
<div data-c-grid="middle"> |
63
|
|
|
<div data-c-grid-item="tl(3of4)">{title}</div> |
64
|
|
|
<div |
65
|
|
|
data-c-grid-item="tl(1of4)" |
66
|
|
|
data-c-align="base(left) tl(right)" |
67
|
|
|
> |
68
|
|
|
<FormattedMessage |
69
|
|
|
id="baseExperienceAccordion.skillCount" |
70
|
|
|
defaultMessage="{skillCount, plural, =0 {No related skills} one {# related skill} other {# related skills}} {isEducationJustification, select, true {/ Education Requirement} false {}}" |
71
|
|
|
description="Displays the number of required skills this relates to, and whether it's used to meed education requirements." |
72
|
|
|
values={{ |
73
|
|
|
skillCount: relevantSkillCount, |
74
|
|
|
isEducationJustification, |
75
|
|
|
}} |
76
|
|
|
/> |
77
|
|
|
</div> |
78
|
|
|
</div> |
79
|
|
|
</div> |
80
|
|
|
</div> |
81
|
|
|
</div> |
82
|
|
|
<span data-c-visibility="invisible"> |
83
|
|
|
<FormattedMessage |
84
|
|
|
id="baseExperienceAccordion.clickToView" |
85
|
|
|
defaultMessage="Click to view." |
86
|
|
|
description="Instructions for interacting with accordion, for accessibility devices." |
87
|
|
|
/> |
88
|
|
|
</span> |
89
|
|
|
<i |
90
|
|
|
aria-hidden="true" |
91
|
|
|
className="fas fa-angle-down" |
92
|
|
|
data-c-accordion-add |
93
|
|
|
data-c-colour="black" |
94
|
|
|
></i> |
95
|
|
|
<i |
96
|
|
|
aria-hidden="true" |
97
|
|
|
className="fas fa-angle-up" |
98
|
|
|
data-c-accordion-remove |
99
|
|
|
data-c-colour="black" |
100
|
|
|
></i> |
101
|
|
|
</button> |
102
|
|
|
<div |
103
|
|
|
aria-hidden="true" |
104
|
|
|
data-c-accordion-content |
105
|
|
|
data-c-background="gray(10)" |
106
|
|
|
data-c-padding="bottom(2)" |
107
|
|
|
> |
108
|
|
|
<hr data-c-hr="thin(gray)" data-c-margin="bottom(2)" /> |
109
|
|
|
<div data-c-padding="lr(2)"> |
110
|
|
|
<div data-c-grid="gutter(all, 1)"> |
111
|
|
|
<div data-c-grid-item="base(1of1)"> |
112
|
|
|
<div data-c-grid="gutter(all, 1)"> |
113
|
|
|
<div data-c-grid-item="base(1of1)"> |
114
|
|
|
<h4 data-c-color="c2" data-c-font-weight="bold"> |
115
|
|
|
<FormattedMessage |
116
|
|
|
id="baseExperienceAccordion.detailsTitle" |
117
|
|
|
defaultMessage="Details of this Experience" |
118
|
|
|
description="Subtitle of the details section." |
119
|
|
|
/> |
120
|
|
|
</h4> |
121
|
|
|
</div> |
122
|
|
|
{details} |
123
|
|
|
</div> |
124
|
|
|
</div> |
125
|
|
|
<div data-c-grid-item="base(1of1)"> |
126
|
|
|
<h4 |
127
|
|
|
data-c-color="c2" |
128
|
|
|
data-c-font-weight="bold" |
129
|
|
|
data-c-margin="top(1) bottom(.5)" |
130
|
|
|
> |
131
|
|
|
<FormattedMessage |
132
|
|
|
id="baseExperienceAccordion.skillsTitle" |
133
|
|
|
defaultMessage="Skills for this Job" |
134
|
|
|
description="Subtitle of the skills section." |
135
|
|
|
/> |
136
|
|
|
</h4> |
137
|
|
|
<div data-c-grid="gutter(all, 1)"> |
138
|
|
|
{showSkillDetails ? ( |
139
|
|
|
relevantSkills.map(skill => ( |
140
|
|
|
<div key={skill.id} data-c-grid-item="base(1of1)"> |
141
|
|
|
<p> |
142
|
|
|
<span |
143
|
|
|
data-c-tag="c1" |
144
|
|
|
data-c-radius="pill" |
145
|
|
|
data-c-font-size="small" |
146
|
|
|
> |
147
|
|
|
{skill.name} |
148
|
|
|
</span> |
149
|
|
|
</p> |
150
|
|
|
<p data-c-font-style="italic" data-c-margin="top(.5)"> |
151
|
|
|
{skill.claim} |
152
|
|
|
</p> |
153
|
|
|
</div> |
154
|
|
|
)) |
155
|
|
|
) : ( |
156
|
|
|
<div data-c-grid-item="base(1of1)"> |
157
|
|
|
{relevantSkills.map(skill => ( |
158
|
|
|
<span |
159
|
|
|
key={skill.id} |
160
|
|
|
data-c-tag="c1" |
161
|
|
|
data-c-radius="pill" |
162
|
|
|
data-c-font-size="small" |
163
|
|
|
> |
164
|
|
|
{skill.name} |
165
|
|
|
</span> |
166
|
|
|
))} |
167
|
|
|
</div> |
168
|
|
|
)} |
169
|
|
|
{irrelevantSkillCount > 0 && ( |
170
|
|
|
<div data-c-grid-item="base(1of1)"> |
171
|
|
|
<p |
172
|
|
|
data-c-font-size="small" |
173
|
|
|
data-c-color="gray" |
174
|
|
|
data-c-margin="bottom(1)" |
175
|
|
|
> |
176
|
|
|
<FormattedMessage |
177
|
|
|
id="baseExperienceAccordion.irrelevantSkillCount" |
178
|
|
|
defaultMessage="There {skillCount, plural, one {is <b>#</b> other unrelated skill} other {are <b>#</b> other unrelated skills}} attached to this experience. You can see {skillCount, plural, one {it} other {them}} on your profile." |
179
|
|
|
description="Say how many skills unrelated to this job are associated with this experience." |
180
|
|
|
values={{ |
181
|
|
|
skillCount: irrelevantSkillCount, |
182
|
|
|
b: (...chunks) => ( |
183
|
|
|
<span data-c-font-weight="bold">{chunks}</span> |
184
|
|
|
), |
185
|
|
|
}} |
186
|
|
|
/> |
187
|
|
|
</p> |
188
|
|
|
</div> |
189
|
|
|
)} |
190
|
|
|
{irrelevantSkillCount === 0 && relevantSkillCount === 0 && ( |
191
|
|
|
<div data-c-grid-item="base(1of1)"> |
192
|
|
|
<p data-c-color="gray" data-c-margin="bottom(1)"> |
193
|
|
|
<FormattedMessage |
194
|
|
|
id="baseExperienceAccordion.noSkills" |
195
|
|
|
defaultMessage="You don't have any skills attached to this experience." |
196
|
|
|
description="Message to show if experience has no associated skills at all." |
197
|
|
|
/> |
198
|
|
|
</p> |
199
|
|
|
</div> |
200
|
|
|
)} |
201
|
|
|
</div> |
202
|
|
|
</div> |
203
|
|
|
{isEducationJustification && ( |
204
|
|
|
<div data-c-grid-item="base(1of1)"> |
205
|
|
|
<h4 |
206
|
|
|
data-c-color="c2" |
207
|
|
|
data-c-font-weight="bold" |
208
|
|
|
data-c-margin="bottom(.5)" |
209
|
|
|
> |
210
|
|
|
<i |
211
|
|
|
className="fas fa-check-circle" |
212
|
|
|
data-c-margin="right(.25)" |
213
|
|
|
data-c-color="go" |
214
|
|
|
></i> |
215
|
|
|
<FormattedMessage |
216
|
|
|
id="baseExperienceAccordion.educationRequirement" |
217
|
|
|
defaultMessage="Education Requirement" |
218
|
|
|
/> |
219
|
|
|
</h4> |
220
|
|
|
<p data-c-margin="bottom(1)"> |
221
|
|
|
<FormattedMessage |
222
|
|
|
id="baseExperienceAccordion.educationRequirmentDescription" |
223
|
|
|
defaultMessage="You've selected this experience as an indicator of how you meet the education requirements for this job." |
224
|
|
|
description="Explanation of what it means that this experience meets an education requirement." |
225
|
|
|
/> |
226
|
|
|
</p> |
227
|
|
|
</div> |
228
|
|
|
)} |
229
|
|
|
</div> |
230
|
|
|
</div> |
231
|
|
|
{showButtons && ( |
232
|
|
|
<div data-c-padding="top(1) lr(2)"> |
233
|
|
|
<div data-c-grid="gutter(all, 1) middle"> |
234
|
|
|
<div |
235
|
|
|
data-c-grid-item="tp(1of2)" |
236
|
|
|
data-c-align="base(center) tp(left)" |
237
|
|
|
> |
238
|
|
|
<button |
239
|
|
|
data-c-button="outline(c1)" |
240
|
|
|
data-c-radius="rounded" |
241
|
|
|
type="button" |
242
|
|
|
onClick={handleDelete} |
243
|
|
|
> |
244
|
|
|
<FormattedMessage |
245
|
|
|
id="baseExperienceAccordion.deleteButton" |
246
|
|
|
defaultMessage="Delete Experience" |
247
|
|
|
/> |
248
|
|
|
</button> |
249
|
|
|
</div> |
250
|
|
|
<div |
251
|
|
|
data-c-grid-item="tp(1of2)" |
252
|
|
|
data-c-align="base(center) tp(right)" |
253
|
|
|
> |
254
|
|
|
<button |
255
|
|
|
data-c-button="solid(c1)" |
256
|
|
|
data-c-radius="rounded" |
257
|
|
|
type="button" |
258
|
|
|
onClick={handleEdit} |
259
|
|
|
> |
260
|
|
|
<FormattedMessage |
261
|
|
|
id="baseExperienceAccordion.editButton" |
262
|
|
|
defaultMessage="Edit Experience" |
263
|
|
|
/> |
264
|
|
|
</button> |
265
|
|
|
</div> |
266
|
|
|
</div> |
267
|
|
|
</div> |
268
|
|
|
)} |
269
|
|
|
</div> |
270
|
|
|
</div> |
271
|
|
|
); |
272
|
|
|
}; |
273
|
|
|
|