1
|
|
|
import React from "react"; |
2
|
|
|
import { FormattedMessage, useIntl, IntlShape } from "react-intl"; |
3
|
|
|
import { |
4
|
|
|
ExperienceSkill, |
5
|
|
|
BaseExperienceAccordion, |
6
|
|
|
titleBarDateRange, |
7
|
|
|
baseExperienceMessages, |
8
|
|
|
} from "./BaseExperienceAccordion"; |
9
|
|
|
import { Locales, getLocale } from "../../../helpers/localize"; |
10
|
|
|
import { readableDate } from "../../../helpers/dates"; |
11
|
|
|
|
12
|
|
|
interface ExperiencePersonalAccordionProps { |
13
|
|
|
title: string; |
14
|
|
|
description: string; |
15
|
|
|
isShareable: boolean; |
16
|
|
|
startDate: Date; |
17
|
|
|
endDate: Date | null; |
18
|
|
|
isActive: boolean; |
19
|
|
|
relevantSkills: ExperienceSkill[]; |
20
|
|
|
irrelevantSkillCount: number; |
21
|
|
|
isEducationJustification: boolean; |
22
|
|
|
showSkillDetails: boolean; |
23
|
|
|
showButtons: boolean; |
24
|
|
|
handleDelete: () => void; |
25
|
|
|
handleEdit: () => void; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
const experiencePersonalDetails = ({ |
29
|
|
|
locale, |
30
|
|
|
intl, |
31
|
|
|
title, |
32
|
|
|
description, |
33
|
|
|
isShareable, |
34
|
|
|
startDate, |
35
|
|
|
endDate, |
36
|
|
|
isActive, |
37
|
|
|
}: { |
38
|
|
|
locale: Locales; |
39
|
|
|
intl: IntlShape; |
40
|
|
|
title: string; |
41
|
|
|
description: string; |
42
|
|
|
isShareable: boolean; |
43
|
|
|
startDate: Date; |
44
|
|
|
endDate: Date | null; |
45
|
|
|
isActive: boolean; |
46
|
|
|
}): React.ReactElement => { |
47
|
|
|
const notApplicable = ( |
48
|
|
|
<p data-c-color="gray"> |
49
|
|
|
{intl.formatMessage(baseExperienceMessages.notApplicable)} |
50
|
|
|
</p> |
51
|
|
|
); |
52
|
|
|
const endDateOrNa = endDate ? ( |
53
|
|
|
<p>{readableDate(locale, endDate)}</p> |
54
|
|
|
) : ( |
55
|
|
|
notApplicable |
56
|
|
|
); |
57
|
|
|
return ( |
58
|
|
|
<> |
59
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
60
|
|
|
<p data-c-font-weight="bold"> |
61
|
|
|
{intl.formatMessage(baseExperienceMessages.experienceTypeLabel)} |
62
|
|
|
</p> |
63
|
|
|
<p> |
64
|
|
|
<i |
65
|
|
|
className="fas fa-trophy" |
66
|
|
|
data-c-color="c1" |
67
|
|
|
data-c-margin="right(.25)" |
68
|
|
|
/> |
69
|
|
|
<FormattedMessage |
70
|
|
|
id="experiencePersonalAccordion.experienceTypeTitle" |
71
|
|
|
defaultMessage="Personal Experience" |
72
|
|
|
/> |
73
|
|
|
</p> |
74
|
|
|
</div> |
75
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
76
|
|
|
<p data-c-font-weight="bold"> |
77
|
|
|
<FormattedMessage |
78
|
|
|
id="experiencePersonalAccordion.titleLabel" |
79
|
|
|
defaultMessage="Title of Experience:" |
80
|
|
|
/> |
81
|
|
|
{title ? <p>{title}</p> : notApplicable} |
82
|
|
|
</p> |
83
|
|
|
</div> |
84
|
|
|
<div data-c-grid-item="base(1of1)"> |
85
|
|
|
<p data-c-font-weight="bold"> |
86
|
|
|
<FormattedMessage |
87
|
|
|
id="experiencePersonalAccordion.descriptionLabel" |
88
|
|
|
defaultMessage="Description:" |
89
|
|
|
/> |
90
|
|
|
</p> |
91
|
|
|
{description ? <p>{description}</p> : notApplicable} |
92
|
|
|
</div> |
93
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
94
|
|
|
<p data-c-font-weight="bold"> |
95
|
|
|
<FormattedMessage |
96
|
|
|
id="experiencePersonalAccordion.shareableLabel" |
97
|
|
|
defaultMessage="Consent to Share:" |
98
|
|
|
/> |
99
|
|
|
</p> |
100
|
|
|
{isShareable ? ( |
101
|
|
|
<p> |
102
|
|
|
<i |
103
|
|
|
className="fas fa-check-circle" |
104
|
|
|
data-c-color="go" |
105
|
|
|
data-c-margin="right(.25)" |
106
|
|
|
/> |
107
|
|
|
<FormattedMessage |
108
|
|
|
id="experiencePersonalAccordion.isShareable" |
109
|
|
|
defaultMessage="Sharing Approved" |
110
|
|
|
description="Text shown when user has consented to share this experience." |
111
|
|
|
/> |
112
|
|
|
</p> |
113
|
|
|
) : ( |
114
|
|
|
<p> |
115
|
|
|
<i |
116
|
|
|
className="fas fa-check-circle" |
117
|
|
|
data-c-color="stop" |
118
|
|
|
data-c-margin="right(.25)" |
119
|
|
|
/> |
120
|
|
|
<FormattedMessage |
121
|
|
|
id="experiencePersonalAccordion.isNotShareable" |
122
|
|
|
defaultMessage="Sharing Restricted" |
123
|
|
|
description="Text shown when user has NOT consented to share this experience." |
124
|
|
|
/> |
125
|
|
|
</p> |
126
|
|
|
)} |
127
|
|
|
</div> |
128
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
129
|
|
|
<p data-c-font-weight="bold"> |
130
|
|
|
{intl.formatMessage(baseExperienceMessages.startDateLabel)} |
131
|
|
|
</p> |
132
|
|
|
{startDate ? <p>{readableDate(locale, startDate)}</p> : notApplicable} |
133
|
|
|
</div> |
134
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
135
|
|
|
<p data-c-font-weight="bold"> |
136
|
|
|
{intl.formatMessage(baseExperienceMessages.endDateLabel)} |
137
|
|
|
</p> |
138
|
|
|
{isActive ? ( |
139
|
|
|
<p>{intl.formatMessage(baseExperienceMessages.ongoing)}</p> |
140
|
|
|
) : ( |
141
|
|
|
endDateOrNa |
142
|
|
|
)} |
143
|
|
|
</div> |
144
|
|
|
</> |
145
|
|
|
); |
146
|
|
|
}; |
147
|
|
|
|
148
|
|
|
export const ExperiencePersonalAccordion: React.FC<ExperiencePersonalAccordionProps> = ({ |
149
|
|
|
title, |
150
|
|
|
description, |
151
|
|
|
isShareable, |
152
|
|
|
startDate, |
153
|
|
|
endDate, |
154
|
|
|
isActive, |
155
|
|
|
relevantSkills, |
156
|
|
|
irrelevantSkillCount, |
157
|
|
|
isEducationJustification, |
158
|
|
|
showSkillDetails, |
159
|
|
|
showButtons, |
160
|
|
|
handleDelete, |
161
|
|
|
handleEdit, |
162
|
|
|
}) => { |
163
|
|
|
const intl = useIntl(); |
164
|
|
|
const locale = getLocale(intl.locale); |
165
|
|
|
const accordionTitle = ( |
166
|
|
|
<> |
167
|
|
|
<p> |
168
|
|
|
<span data-c-font-weight="bold">{title}</span> |
169
|
|
|
</p> |
170
|
|
|
{titleBarDateRange(startDate, endDate, isActive, locale)} |
171
|
|
|
</> |
172
|
|
|
); |
173
|
|
|
return ( |
174
|
|
|
<BaseExperienceAccordion |
175
|
|
|
title={accordionTitle} |
176
|
|
|
iconClass="fa-trophy" |
177
|
|
|
relevantSkills={relevantSkills} |
178
|
|
|
irrelevantSkillCount={irrelevantSkillCount} |
179
|
|
|
isEducationJustification={isEducationJustification} |
180
|
|
|
details={experiencePersonalDetails({ |
181
|
|
|
locale, |
182
|
|
|
intl, |
183
|
|
|
title, |
184
|
|
|
description, |
185
|
|
|
isShareable, |
186
|
|
|
startDate, |
187
|
|
|
endDate, |
188
|
|
|
isActive, |
189
|
|
|
})} |
190
|
|
|
showSkillDetails={showSkillDetails} |
191
|
|
|
showButtons={showButtons} |
192
|
|
|
handleDelete={handleDelete} |
193
|
|
|
handleEdit={handleEdit} |
194
|
|
|
/> |
195
|
|
|
); |
196
|
|
|
}; |
197
|
|
|
|
198
|
|
|
export default ExperiencePersonalAccordion; |
199
|
|
|
|