1
|
|
|
import React from "react"; |
2
|
|
|
import { useIntl, IntlShape } from "react-intl"; |
3
|
|
|
import { |
4
|
|
|
BaseExperienceAccordion, |
5
|
|
|
titleBarDateRange, |
6
|
|
|
} from "./BaseExperienceAccordion"; |
7
|
|
|
import { accordionMessages } from "../applicationMessages"; |
8
|
|
|
import { Locales, getLocale } from "../../../helpers/localize"; |
9
|
|
|
import { readableDate } from "../../../helpers/dates"; |
10
|
|
|
import { ExperienceSkill, Skill } from "../../../models/types"; |
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
|
|
|
skills: Skill[]; |
21
|
|
|
irrelevantSkillCount: number; |
22
|
|
|
isEducationJustification: boolean; |
23
|
|
|
showSkillDetails: boolean; |
24
|
|
|
showButtons: boolean; |
25
|
|
|
handleDelete: () => Promise<void>; |
26
|
|
|
handleEdit: () => void; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
const experiencePersonalDetails = ({ |
30
|
|
|
locale, |
31
|
|
|
intl, |
32
|
|
|
title, |
33
|
|
|
description, |
34
|
|
|
isShareable, |
35
|
|
|
startDate, |
36
|
|
|
endDate, |
37
|
|
|
isActive, |
38
|
|
|
}: { |
39
|
|
|
locale: Locales; |
40
|
|
|
intl: IntlShape; |
41
|
|
|
title: string; |
42
|
|
|
description: string; |
43
|
|
|
isShareable: boolean; |
44
|
|
|
startDate: Date; |
45
|
|
|
endDate: Date | null; |
46
|
|
|
isActive: boolean; |
47
|
|
|
}): React.ReactElement => { |
48
|
|
|
const notApplicable = ( |
49
|
|
|
<p data-c-color="gray"> |
50
|
|
|
{intl.formatMessage(accordionMessages.notApplicable)} |
51
|
|
|
</p> |
52
|
|
|
); |
53
|
|
|
const endDateOrNa = endDate ? ( |
54
|
|
|
<p>{readableDate(locale, endDate)}</p> |
55
|
|
|
) : ( |
56
|
|
|
notApplicable |
57
|
|
|
); |
58
|
|
|
return ( |
59
|
|
|
<> |
60
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
61
|
|
|
<p data-c-font-weight="bold"> |
62
|
|
|
{intl.formatMessage(accordionMessages.experienceTypeLabel)} |
63
|
|
|
</p> |
64
|
|
|
<p> |
65
|
|
|
<i |
66
|
|
|
className="fas fa-trophy" |
67
|
|
|
data-c-color="c1" |
68
|
|
|
data-c-margin="right(.25)" |
69
|
|
|
/> |
70
|
|
|
{intl.formatMessage(accordionMessages.personalType)} |
71
|
|
|
</p> |
72
|
|
|
</div> |
73
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
74
|
|
|
<p data-c-font-weight="bold"> |
75
|
|
|
{intl.formatMessage(accordionMessages.personalTitleLabel)} |
76
|
|
|
</p> |
77
|
|
|
{title ? <p>{title}</p> : notApplicable} |
78
|
|
|
</div> |
79
|
|
|
<div data-c-grid-item="base(1of1)"> |
80
|
|
|
<p data-c-font-weight="bold"> |
81
|
|
|
{intl.formatMessage(accordionMessages.personalDescriptionLabel)} |
82
|
|
|
</p> |
83
|
|
|
{description ? <p>{description}</p> : notApplicable} |
84
|
|
|
</div> |
85
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
86
|
|
|
<p data-c-font-weight="bold"> |
87
|
|
|
{intl.formatMessage(accordionMessages.personalShareLabel)} |
88
|
|
|
</p> |
89
|
|
|
{isShareable ? ( |
90
|
|
|
<p> |
91
|
|
|
<i |
92
|
|
|
className="fas fa-check-circle" |
93
|
|
|
data-c-color="go" |
94
|
|
|
data-c-margin="right(.25)" |
95
|
|
|
/> |
96
|
|
|
{intl.formatMessage(accordionMessages.personalShareAllowed)} |
97
|
|
|
</p> |
98
|
|
|
) : ( |
99
|
|
|
<p> |
100
|
|
|
<i |
101
|
|
|
className="fas fa-check-circle" |
102
|
|
|
data-c-color="stop" |
103
|
|
|
data-c-margin="right(.25)" |
104
|
|
|
/> |
105
|
|
|
{intl.formatMessage(accordionMessages.personalShareDenied)} |
106
|
|
|
</p> |
107
|
|
|
)} |
108
|
|
|
</div> |
109
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
110
|
|
|
<p data-c-font-weight="bold"> |
111
|
|
|
{intl.formatMessage(accordionMessages.startDateLabel)} |
112
|
|
|
</p> |
113
|
|
|
{startDate ? <p>{readableDate(locale, startDate)}</p> : notApplicable} |
114
|
|
|
</div> |
115
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
116
|
|
|
<p data-c-font-weight="bold"> |
117
|
|
|
{intl.formatMessage(accordionMessages.endDateLabel)} |
118
|
|
|
</p> |
119
|
|
|
{isActive ? ( |
120
|
|
|
<p>{intl.formatMessage(accordionMessages.ongoing)}</p> |
121
|
|
|
) : ( |
122
|
|
|
endDateOrNa |
123
|
|
|
)} |
124
|
|
|
</div> |
125
|
|
|
</> |
126
|
|
|
); |
127
|
|
|
}; |
128
|
|
|
|
129
|
|
|
export const ExperiencePersonalAccordion: React.FC<ExperiencePersonalAccordionProps> = ({ |
130
|
|
|
title, |
131
|
|
|
description, |
132
|
|
|
isShareable, |
133
|
|
|
startDate, |
134
|
|
|
endDate, |
135
|
|
|
isActive, |
136
|
|
|
relevantSkills, |
137
|
|
|
skills, |
138
|
|
|
irrelevantSkillCount, |
139
|
|
|
isEducationJustification, |
140
|
|
|
showSkillDetails, |
141
|
|
|
showButtons, |
142
|
|
|
handleDelete, |
143
|
|
|
handleEdit, |
144
|
|
|
}) => { |
145
|
|
|
const intl = useIntl(); |
146
|
|
|
const locale = getLocale(intl.locale); |
147
|
|
|
const accordionTitle = ( |
148
|
|
|
<> |
149
|
|
|
<p> |
150
|
|
|
<span data-c-font-weight="bold">{title}</span> |
151
|
|
|
</p> |
152
|
|
|
{titleBarDateRange(startDate, endDate, isActive, intl, locale)} |
153
|
|
|
</> |
154
|
|
|
); |
155
|
|
|
return ( |
156
|
|
|
<BaseExperienceAccordion |
157
|
|
|
title={accordionTitle} |
158
|
|
|
iconClass="fa-mountain" |
159
|
|
|
relevantSkills={relevantSkills} |
160
|
|
|
skills={skills} |
161
|
|
|
irrelevantSkillCount={irrelevantSkillCount} |
162
|
|
|
isEducationJustification={isEducationJustification} |
163
|
|
|
details={experiencePersonalDetails({ |
164
|
|
|
locale, |
165
|
|
|
intl, |
166
|
|
|
title, |
167
|
|
|
description, |
168
|
|
|
isShareable, |
169
|
|
|
startDate, |
170
|
|
|
endDate, |
171
|
|
|
isActive, |
172
|
|
|
})} |
173
|
|
|
showSkillDetails={showSkillDetails} |
174
|
|
|
showButtons={showButtons} |
175
|
|
|
handleDelete={handleDelete} |
176
|
|
|
handleEdit={handleEdit} |
177
|
|
|
/> |
178
|
|
|
); |
179
|
|
|
}; |
180
|
|
|
|
181
|
|
|
export default ExperiencePersonalAccordion; |
182
|
|
|
|