1
|
|
|
import React from "react"; |
2
|
|
|
import { useIntl } from "react-intl"; |
3
|
|
|
import { accordionMessages } from "../applicationMessages"; |
4
|
|
|
import { getLocale } from "../../../helpers/localize"; |
5
|
|
|
import { readableDate } from "../../../helpers/dates"; |
6
|
|
|
import { |
7
|
|
|
ExperienceCommunity, |
8
|
|
|
ExperienceSkill, |
9
|
|
|
Skill, |
10
|
|
|
} from "../../../models/types"; |
11
|
|
|
import { |
12
|
|
|
titleBarDateRange, |
13
|
|
|
ApplicationExperienceAccordion, |
14
|
|
|
ProfileExperienceAccordion, |
15
|
|
|
} from "./ExperienceAccordionCommon"; |
16
|
|
|
|
17
|
|
|
const ExperienceCommunityDetails: React.FC<{ |
18
|
|
|
experience: ExperienceCommunity; |
19
|
|
|
}> = ({ experience }) => { |
20
|
|
|
const intl = useIntl(); |
21
|
|
|
const locale = getLocale(intl.locale); |
22
|
|
|
|
23
|
|
|
const { title, group, project } = experience; |
24
|
|
|
const startDate = experience.start_date; |
25
|
|
|
const endDate = experience.end_date; |
26
|
|
|
const isActive = experience.is_active; |
27
|
|
|
|
28
|
|
|
const notApplicable = ( |
29
|
|
|
<p data-c-color="gray"> |
30
|
|
|
{intl.formatMessage(accordionMessages.notApplicable)} |
31
|
|
|
</p> |
32
|
|
|
); |
33
|
|
|
const endDateOrNa = endDate ? ( |
34
|
|
|
<p>{readableDate(locale, endDate)}</p> |
35
|
|
|
) : ( |
36
|
|
|
notApplicable |
37
|
|
|
); |
38
|
|
|
return ( |
39
|
|
|
<div data-c-grid-item="base(1of1)"> |
40
|
|
|
<div data-c-grid="gutter(all, 1)"> |
41
|
|
|
<div data-c-grid-item="base(1of1)"> |
42
|
|
|
<h4 data-c-color="c2" data-c-font-weight="bold"> |
43
|
|
|
{intl.formatMessage(accordionMessages.detailsTitle)} |
44
|
|
|
</h4> |
45
|
|
|
</div> |
46
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
47
|
|
|
<p data-c-font-weight="bold"> |
48
|
|
|
{intl.formatMessage(accordionMessages.experienceTypeLabel)} |
49
|
|
|
</p> |
50
|
|
|
<p> |
51
|
|
|
<i |
52
|
|
|
className="fas fa-people-carry" |
53
|
|
|
data-c-color="c1" |
54
|
|
|
data-c-margin="right(.25)" |
55
|
|
|
/> |
56
|
|
|
{intl.formatMessage(accordionMessages.communityType)} |
57
|
|
|
</p> |
58
|
|
|
</div> |
59
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
60
|
|
|
<p data-c-font-weight="bold"> |
61
|
|
|
{intl.formatMessage(accordionMessages.communityRoleLabel)} |
62
|
|
|
</p> |
63
|
|
|
{title ? <p>{title}</p> : notApplicable} |
64
|
|
|
</div> |
65
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
66
|
|
|
<p data-c-font-weight="bold"> |
67
|
|
|
{intl.formatMessage(accordionMessages.communityOrganizationLabel)} |
68
|
|
|
</p> |
69
|
|
|
{group ? <p>{group}</p> : notApplicable} |
70
|
|
|
</div> |
71
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
72
|
|
|
<p data-c-font-weight="bold"> |
73
|
|
|
{intl.formatMessage(accordionMessages.communityProjectLabel)} |
74
|
|
|
</p> |
75
|
|
|
{project ? <p>{project}</p> : notApplicable} |
76
|
|
|
</div> |
77
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
78
|
|
|
<p data-c-font-weight="bold"> |
79
|
|
|
{intl.formatMessage(accordionMessages.startDateLabel)} |
80
|
|
|
</p> |
81
|
|
|
{startDate ? <p>{readableDate(locale, startDate)}</p> : notApplicable} |
82
|
|
|
</div> |
83
|
|
|
<div data-c-grid-item="base(1of2) tl(1of3)"> |
84
|
|
|
<p data-c-font-weight="bold"> |
85
|
|
|
{intl.formatMessage(accordionMessages.endDateLabel)} |
86
|
|
|
</p> |
87
|
|
|
{isActive ? ( |
88
|
|
|
<p>{intl.formatMessage(accordionMessages.ongoing)}</p> |
89
|
|
|
) : ( |
90
|
|
|
endDateOrNa |
91
|
|
|
)} |
92
|
|
|
</div> |
93
|
|
|
</div> |
94
|
|
|
</div> |
95
|
|
|
); |
96
|
|
|
}; |
97
|
|
|
|
98
|
|
|
interface ProfileCommunityAccordionProps { |
99
|
|
|
experience: ExperienceCommunity; |
100
|
|
|
relevantSkills: ExperienceSkill[]; |
101
|
|
|
skillsById: { [id: number]: Skill }; |
102
|
|
|
handleDelete: () => Promise<void>; |
103
|
|
|
handleEdit: () => void; |
104
|
|
|
handleEditSkill: (experieSkillId: number) => void; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
export const ProfileCommunityAccordion: React.FC<ProfileCommunityAccordionProps> = ({ |
108
|
|
|
experience, |
109
|
|
|
relevantSkills, |
110
|
|
|
skillsById, |
111
|
|
|
handleDelete, |
112
|
|
|
handleEdit, |
113
|
|
|
handleEditSkill, |
114
|
|
|
}) => { |
115
|
|
|
const intl = useIntl(); |
116
|
|
|
const locale = getLocale(intl.locale); |
117
|
|
|
const accordionTitle = intl.formatMessage( |
118
|
|
|
accordionMessages.communityHeading, |
119
|
|
|
{ |
120
|
|
|
title: experience.title, |
121
|
|
|
group: experience.group, |
122
|
|
|
b: (value) => <span data-c-font-weight="bold">{value}</span>, |
123
|
|
|
}, |
124
|
|
|
); |
125
|
|
|
const subtitle = titleBarDateRange( |
126
|
|
|
experience.start_date, |
127
|
|
|
experience.end_date, |
128
|
|
|
experience.is_active, |
129
|
|
|
intl, |
130
|
|
|
locale, |
131
|
|
|
); |
132
|
|
|
return ( |
133
|
|
|
<ProfileExperienceAccordion |
134
|
|
|
title={accordionTitle} |
135
|
|
|
subtitle={subtitle} |
136
|
|
|
iconClass="fa-people-carry" |
137
|
|
|
relevantSkills={relevantSkills} |
138
|
|
|
skillsById={skillsById} |
139
|
|
|
handleDelete={handleDelete} |
140
|
|
|
handleEdit={handleEdit} |
141
|
|
|
handleEditSkill={handleEditSkill} |
142
|
|
|
> |
143
|
|
|
<ExperienceCommunityDetails experience={experience} /> |
144
|
|
|
</ProfileExperienceAccordion> |
145
|
|
|
); |
146
|
|
|
}; |
147
|
|
|
|
148
|
|
|
interface ExperienceCommunityAccordionProps { |
149
|
|
|
experience: ExperienceCommunity; |
150
|
|
|
relevantSkills: ExperienceSkill[]; |
151
|
|
|
skills: Skill[]; |
152
|
|
|
irrelevantSkillCount: number; |
153
|
|
|
showSkillDetails: boolean; |
154
|
|
|
showButtons: boolean; |
155
|
|
|
handleDelete: () => Promise<void>; |
156
|
|
|
handleEdit: () => void; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
export const ExperienceCommunityAccordion: React.FC<ExperienceCommunityAccordionProps> = ({ |
160
|
|
|
experience, |
161
|
|
|
relevantSkills, |
162
|
|
|
skills, |
163
|
|
|
irrelevantSkillCount, |
164
|
|
|
showSkillDetails, |
165
|
|
|
showButtons, |
166
|
|
|
handleDelete, |
167
|
|
|
handleEdit, |
168
|
|
|
}) => { |
169
|
|
|
const intl = useIntl(); |
170
|
|
|
const locale = getLocale(intl.locale); |
171
|
|
|
const accordionTitle = intl.formatMessage( |
172
|
|
|
accordionMessages.communityHeading, |
173
|
|
|
{ |
174
|
|
|
title: experience.title, |
175
|
|
|
group: experience.group, |
176
|
|
|
b: (value) => <span data-c-font-weight="bold">{value}</span>, |
177
|
|
|
}, |
178
|
|
|
); |
179
|
|
|
const subtitle = titleBarDateRange( |
180
|
|
|
experience.start_date, |
181
|
|
|
experience.end_date, |
182
|
|
|
experience.is_active, |
183
|
|
|
intl, |
184
|
|
|
locale, |
185
|
|
|
); |
186
|
|
|
return ( |
187
|
|
|
<ApplicationExperienceAccordion |
188
|
|
|
title={accordionTitle} |
189
|
|
|
subtitle={subtitle} |
190
|
|
|
iconClass="fa-people-carry" |
191
|
|
|
relevantSkills={relevantSkills} |
192
|
|
|
skills={skills} |
193
|
|
|
irrelevantSkillCount={irrelevantSkillCount} |
194
|
|
|
isEducationJustification={experience.is_education_requirement} |
195
|
|
|
showSkillDetails={showSkillDetails} |
196
|
|
|
showButtons={showButtons} |
197
|
|
|
handleDelete={handleDelete} |
198
|
|
|
handleEdit={handleEdit} |
199
|
|
|
> |
200
|
|
|
<ExperienceCommunityDetails experience={experience} /> |
201
|
|
|
</ApplicationExperienceAccordion> |
202
|
|
|
); |
203
|
|
|
}; |
204
|
|
|
|
205
|
|
|
export default ExperienceCommunityAccordion; |
206
|
|
|
|