| 5871 |
stevensc |
1 |
import React, { useEffect, useState } from 'react'
|
| 5868 |
stevensc |
2 |
import EmptySection from '../../../../../shared/empty-section/EmptySection'
|
|
|
3 |
import EducationCard from '../../../../pages/view/templates/linkedin/components/cards/EducationCard'
|
|
|
4 |
import ExperienceCard from '../../../../pages/view/templates/linkedin/components/cards/ExperienceCard'
|
|
|
5 |
import ItemsList from '../../../../pages/view/templates/linkedin/components/cards/ItemsList'
|
|
|
6 |
import ProfileCard from '../../../../pages/view/templates/linkedin/components/ProfileCard'
|
|
|
7 |
import ProfileWidget from '../../../../pages/view/templates/linkedin/components/ProfileWidget'
|
|
|
8 |
import AptitudesModal from '../../../../components/aptitudes/AptitudesModal'
|
|
|
9 |
import EducationModal from '../../../../components/educations/EducationModal'
|
|
|
10 |
import ExperienceModal from '../../../../components/experiences/ExperienceModal'
|
|
|
11 |
import HobbiesModal from '../../../../components/hobbies-and-interests/HobbiesModal'
|
|
|
12 |
import LanguagesModal from '../../../../components/languages/LanguagesModal'
|
|
|
13 |
import LocationModal from '../../../../components/location/LocationModal'
|
|
|
14 |
import SkillsModal from '../../../../components/skills/SkillsModal'
|
| 5473 |
stevensc |
15 |
|
|
|
16 |
const EditView = (userInfo) => {
|
|
|
17 |
const {
|
| 5872 |
stevensc |
18 |
experiences: userExperiences,
|
| 5865 |
stevensc |
19 |
educations: userEducations,
|
|
|
20 |
languages: userLanguages,
|
|
|
21 |
skills: userSkills,
|
|
|
22 |
aptitudes: userAptitudes,
|
|
|
23 |
hobbiesAndInterests: userHobbiesAndInterests,
|
| 5473 |
stevensc |
24 |
months,
|
| 5865 |
stevensc |
25 |
options,
|
|
|
26 |
formatted_address,
|
| 5473 |
stevensc |
27 |
} = userInfo
|
|
|
28 |
|
|
|
29 |
const [experiences, setExperiences] = useState(userExperiences)
|
|
|
30 |
const [educations, setEducations] = useState(userEducations)
|
| 5871 |
stevensc |
31 |
const [languages, setLanguages] = useState([])
|
|
|
32 |
const [skills, setSkills] = useState([])
|
|
|
33 |
const [aptitudes, setAptitudes] = useState([])
|
|
|
34 |
const [hobbiesAndInterests, setHobbiesAndInterests] = useState([])
|
| 5473 |
stevensc |
35 |
const [address, setAddress] = useState(formatted_address)
|
|
|
36 |
|
|
|
37 |
const [modalShow, setModalShow] = useState(null)
|
|
|
38 |
const [settedDescription, setSettedDescription] = useState('')
|
|
|
39 |
const [postUrl, setPostUrl] = useState('')
|
|
|
40 |
const [isEdit, setIsEdit] = useState(false)
|
|
|
41 |
|
|
|
42 |
const handleEdit = (modalName, url, description) => {
|
|
|
43 |
setModalShow(modalName)
|
|
|
44 |
setPostUrl(url)
|
|
|
45 |
setSettedDescription(description)
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
const handleAdd = (modalName, url) => {
|
|
|
49 |
setModalShow(modalName)
|
|
|
50 |
setPostUrl(url)
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
const closeModal = () => {
|
|
|
54 |
setSettedDescription('')
|
|
|
55 |
setPostUrl('')
|
|
|
56 |
setIsEdit(false)
|
|
|
57 |
setModalShow(null)
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
const renderModal = {
|
| 5865 |
stevensc |
61 |
Experiencia: (
|
|
|
62 |
<ExperienceModal
|
|
|
63 |
companySizesOptions={options.companySizes}
|
|
|
64 |
industriesOptions={options.industries}
|
|
|
65 |
months={months}
|
|
|
66 |
setUserExperiences={(newExperiences) => setExperiences(newExperiences)}
|
|
|
67 |
show={modalShow === 'Experiencia'}
|
|
|
68 |
postUrl={postUrl}
|
|
|
69 |
closeModal={closeModal}
|
|
|
70 |
settedDescription={settedDescription}
|
|
|
71 |
/>
|
|
|
72 |
),
|
|
|
73 |
Educación: (
|
|
|
74 |
<EducationModal
|
|
|
75 |
closeModal={closeModal}
|
|
|
76 |
postUrl={postUrl}
|
|
|
77 |
setEducations={(newEducations) => setEducations(newEducations)}
|
|
|
78 |
show={modalShow === 'Educación'}
|
|
|
79 |
settedDescription={settedDescription}
|
|
|
80 |
degreesOptions={options.degrees}
|
|
|
81 |
/>
|
|
|
82 |
),
|
|
|
83 |
Habilidades: (
|
|
|
84 |
<SkillsModal
|
|
|
85 |
closeModal={closeModal}
|
|
|
86 |
setSkills={(newSkills) => setSkills(newSkills)}
|
|
|
87 |
show={modalShow === 'Habilidades'}
|
| 5871 |
stevensc |
88 |
skillsOptions={Object.entries(options.skills).map(([key, value]) => ({
|
|
|
89 |
value: key,
|
|
|
90 |
name: value,
|
|
|
91 |
}))}
|
| 5865 |
stevensc |
92 |
userIdEncrypted={userInfo.userProfileIdEncrypted}
|
|
|
93 |
userSkillsArray={skills}
|
|
|
94 |
/>
|
|
|
95 |
),
|
|
|
96 |
Idiomas: (
|
|
|
97 |
<LanguagesModal
|
|
|
98 |
show={modalShow === 'Idiomas'}
|
|
|
99 |
closeModal={closeModal}
|
|
|
100 |
userIdEncrypted={userInfo.userProfileIdEncrypted}
|
| 5871 |
stevensc |
101 |
languagesOptions={Object.entries(options.languages).map(
|
|
|
102 |
([key, value]) => ({ value: key, name: value })
|
|
|
103 |
)}
|
| 5865 |
stevensc |
104 |
userLanguages={languages}
|
|
|
105 |
setLanguages={(newLanguages) => setLanguages(newLanguages)}
|
|
|
106 |
/>
|
|
|
107 |
),
|
|
|
108 |
Aptitudes: (
|
|
|
109 |
<AptitudesModal
|
|
|
110 |
show={modalShow === 'Aptitudes'}
|
|
|
111 |
closeModal={closeModal}
|
|
|
112 |
userIdEncrypted={userInfo.userProfileIdEncrypted}
|
| 5871 |
stevensc |
113 |
aptitudesOptions={Object.entries(options.aptitudes).map(
|
|
|
114 |
([key, value]) => ({ value: key, name: value })
|
|
|
115 |
)}
|
| 5865 |
stevensc |
116 |
userAptitudes={aptitudes}
|
|
|
117 |
setAptitudes={(newAptitudes) => setAptitudes(newAptitudes)}
|
|
|
118 |
/>
|
|
|
119 |
),
|
|
|
120 |
'Hobbies e Intereses': (
|
|
|
121 |
<HobbiesModal
|
|
|
122 |
show={modalShow === 'Hobbies e Intereses'}
|
|
|
123 |
closeModal={closeModal}
|
|
|
124 |
userIdEncrypted={userInfo.userProfileIdEncrypted}
|
| 5871 |
stevensc |
125 |
hobbiesAndInterestsOptions={Object.entries(
|
|
|
126 |
options.hobbiesAndInterests
|
|
|
127 |
).map(([key, value]) => ({ value: key, name: value }))}
|
| 5865 |
stevensc |
128 |
userHobbiesAndInterests={hobbiesAndInterests}
|
|
|
129 |
setUserHobbiesAndInterests={(newHobbiesAndInterests) =>
|
|
|
130 |
setHobbiesAndInterests(newHobbiesAndInterests)
|
|
|
131 |
}
|
|
|
132 |
/>
|
|
|
133 |
),
|
|
|
134 |
Ubicación: (
|
|
|
135 |
<LocationModal
|
|
|
136 |
isModalOpen={modalShow === 'Ubicación'}
|
|
|
137 |
closeModal={() => setModalShow(null)}
|
|
|
138 |
setSettedAddress={(newAddress) => setAddress(newAddress)}
|
|
|
139 |
userIdEncrypted={userInfo.userProfileIdEncrypted}
|
|
|
140 |
/>
|
|
|
141 |
),
|
| 5473 |
stevensc |
142 |
}
|
|
|
143 |
|
| 5871 |
stevensc |
144 |
useEffect(() => {
|
|
|
145 |
const adapters = [
|
|
|
146 |
{
|
|
|
147 |
value: userSkills,
|
|
|
148 |
setter: setSkills,
|
|
|
149 |
},
|
|
|
150 |
{
|
|
|
151 |
value: userLanguages,
|
|
|
152 |
setter: setLanguages,
|
|
|
153 |
},
|
|
|
154 |
{
|
|
|
155 |
value: userAptitudes,
|
|
|
156 |
setter: setAptitudes,
|
|
|
157 |
},
|
|
|
158 |
{
|
|
|
159 |
value: userHobbiesAndInterests,
|
|
|
160 |
setter: setHobbiesAndInterests,
|
|
|
161 |
},
|
|
|
162 |
]
|
|
|
163 |
|
|
|
164 |
adapters.map((adapter) => {
|
|
|
165 |
const value = Object.entries(adapter.value).map(([key, value]) => ({
|
|
|
166 |
value: key,
|
|
|
167 |
name: value,
|
|
|
168 |
}))
|
|
|
169 |
adapter.setter(value)
|
|
|
170 |
})
|
|
|
171 |
}, [])
|
|
|
172 |
|
|
|
173 |
return (
|
|
|
174 |
<main className="w-100">
|
|
|
175 |
<div className="container">
|
|
|
176 |
<div className="main d-flex flex-column" style={{ gap: '.5rem' }}>
|
| 5873 |
stevensc |
177 |
<ProfileCard
|
|
|
178 |
{...{
|
|
|
179 |
...userInfo,
|
|
|
180 |
formatted_address: address,
|
| 5875 |
stevensc |
181 |
userIdEncrypted: userInfo.profileId,
|
| 5873 |
stevensc |
182 |
}}
|
|
|
183 |
/>
|
| 5871 |
stevensc |
184 |
<ProfileWidget
|
|
|
185 |
title="Experiencia"
|
|
|
186 |
onEdit={() => setIsEdit(!isEdit)}
|
|
|
187 |
onAdd={handleAdd}
|
|
|
188 |
addUrl={`/profile/my-profiles/experience/${userInfo.userProfileIdEncrypted}/operation/add`}
|
|
|
189 |
>
|
|
|
190 |
{experiences.map((experience, index) => {
|
|
|
191 |
return (
|
|
|
192 |
<ExperienceCard
|
|
|
193 |
key={index}
|
|
|
194 |
experience={experience}
|
|
|
195 |
months={userInfo.months}
|
|
|
196 |
isEdit={isEdit}
|
|
|
197 |
onEdit={handleEdit}
|
|
|
198 |
setExperiences={(newExperiences) =>
|
|
|
199 |
setExperiences(newExperiences)
|
|
|
200 |
}
|
|
|
201 |
/>
|
|
|
202 |
)
|
|
|
203 |
})}
|
|
|
204 |
</ProfileWidget>
|
|
|
205 |
<ProfileWidget
|
|
|
206 |
title="Educación"
|
|
|
207 |
onEdit={() => setIsEdit(!isEdit)}
|
|
|
208 |
onAdd={handleAdd}
|
|
|
209 |
addUrl={`/profile/my-profiles/education/${userInfo.userProfileIdEncrypted}/operation/add`}
|
|
|
210 |
>
|
|
|
211 |
{educations.map((education, index) => {
|
|
|
212 |
return (
|
|
|
213 |
<EducationCard
|
|
|
214 |
key={index}
|
|
|
215 |
education={education}
|
|
|
216 |
isEdit={isEdit}
|
|
|
217 |
onEdit={handleEdit}
|
|
|
218 |
setEducations={(newEducations) =>
|
|
|
219 |
setEducations(newEducations)
|
|
|
220 |
}
|
|
|
221 |
/>
|
|
|
222 |
)
|
|
|
223 |
})}
|
|
|
224 |
</ProfileWidget>
|
|
|
225 |
<ProfileWidget
|
|
|
226 |
title="Ubicación"
|
|
|
227 |
onEdit={() => setModalShow('Ubicación')}
|
|
|
228 |
justEdit
|
|
|
229 |
>
|
|
|
230 |
<div className="card__items">
|
|
|
231 |
<p>{address}</p>
|
|
|
232 |
</div>
|
|
|
233 |
</ProfileWidget>
|
|
|
234 |
<ProfileWidget
|
|
|
235 |
title="Idiomas"
|
|
|
236 |
onEdit={() => setModalShow('Idiomas')}
|
|
|
237 |
justEdit
|
|
|
238 |
>
|
|
|
239 |
{!languages.length ? (
|
|
|
240 |
<EmptySection align="left" message="Sin información" />
|
|
|
241 |
) : (
|
|
|
242 |
<ItemsList value={languages} />
|
|
|
243 |
)}
|
|
|
244 |
</ProfileWidget>
|
|
|
245 |
<ProfileWidget
|
|
|
246 |
title="Habilidades"
|
|
|
247 |
onEdit={() => setModalShow('Habilidades')}
|
|
|
248 |
justEdit
|
|
|
249 |
>
|
|
|
250 |
{!skills.length ? (
|
|
|
251 |
<EmptySection align="left" message="Sin información" />
|
|
|
252 |
) : (
|
|
|
253 |
<ItemsList value={skills} />
|
|
|
254 |
)}
|
|
|
255 |
</ProfileWidget>
|
|
|
256 |
<ProfileWidget
|
|
|
257 |
title="Aptitudes"
|
|
|
258 |
onEdit={() => setModalShow('Aptitudes')}
|
|
|
259 |
justEdit
|
|
|
260 |
>
|
|
|
261 |
{!aptitudes.length ? (
|
|
|
262 |
<EmptySection align="left" message="Sin información" />
|
|
|
263 |
) : (
|
|
|
264 |
<ItemsList value={aptitudes} />
|
|
|
265 |
)}
|
|
|
266 |
</ProfileWidget>
|
|
|
267 |
<ProfileWidget
|
|
|
268 |
title="Pasatiempos e intereses"
|
|
|
269 |
onEdit={() => setModalShow('Hobbies e Intereses')}
|
|
|
270 |
justEdit
|
|
|
271 |
>
|
|
|
272 |
{!hobbiesAndInterests.length ? (
|
|
|
273 |
<EmptySection align="left" message="Sin información" />
|
|
|
274 |
) : (
|
|
|
275 |
<ItemsList value={hobbiesAndInterests} />
|
|
|
276 |
)}
|
|
|
277 |
</ProfileWidget>
|
|
|
278 |
{renderModal[modalShow]}
|
|
|
279 |
</div>
|
|
|
280 |
</div>
|
|
|
281 |
</main>
|
|
|
282 |
)
|
| 5473 |
stevensc |
283 |
}
|
|
|
284 |
|
|
|
285 |
export default EditView
|