6830 |
stevensc |
1 |
import React, { useEffect, useState } from 'react'
|
|
|
2 |
import { useParams } from 'react-router-dom'
|
|
|
3 |
import { useSelector } from 'react-redux'
|
|
|
4 |
import { getBackendVars } from '../../services/backendVars'
|
|
|
5 |
|
|
|
6 |
import ProfileInfo from '../../components/ProfileInfo'
|
|
|
7 |
import Cover from '../../components/cover/Cover'
|
|
|
8 |
import Skills from '../../components/skills/Skills'
|
|
|
9 |
import Location from '../../components/location/Location'
|
|
|
10 |
import Overview from '../../components/overview/Overview'
|
|
|
11 |
import Aptitudes from '../../components/aptitudes/Aptitudes'
|
|
|
12 |
import Languages from '../../components/languages/Languages'
|
|
|
13 |
import Educations from '../../components/educations/Educations'
|
|
|
14 |
import Experiences from '../../components/experiences/Experiences'
|
|
|
15 |
import SuggestWidget from '../../components/widgets/default/SuggestWidget'
|
|
|
16 |
import HobbiesAndInterests from '../../components/hobbies-and-interests/HobbiesAndInterests'
|
|
|
17 |
|
|
|
18 |
const ProfileView = () => {
|
|
|
19 |
const [profile, setProfile] = useState(null)
|
|
|
20 |
const labels = useSelector(({ intl }) => intl.labels)
|
|
|
21 |
const { uuid } = useParams()
|
|
|
22 |
|
|
|
23 |
useEffect(() => {
|
|
|
24 |
getBackendVars(`/profile/view/${uuid}`)
|
|
|
25 |
.then((vars) => {
|
|
|
26 |
const adapters = [
|
|
|
27 |
'user_hobbies_and_interests',
|
|
|
28 |
'user_skills',
|
|
|
29 |
'user_aptitudes',
|
|
|
30 |
'user_languages',
|
|
|
31 |
]
|
|
|
32 |
|
|
|
33 |
adapters.forEach((adapter) => {
|
|
|
34 |
vars[adapter] = Object.entries(vars[adapter]).map(([key, value]) => {
|
|
|
35 |
return { name: value, value: key }
|
|
|
36 |
})
|
|
|
37 |
})
|
|
|
38 |
|
|
|
39 |
setProfile(vars)
|
|
|
40 |
})
|
|
|
41 |
.catch((err) => {
|
|
|
42 |
console.log(`Error: ${err}`)
|
|
|
43 |
throw new Error(err)
|
|
|
44 |
})
|
|
|
45 |
}, [])
|
|
|
46 |
|
|
|
47 |
return (
|
|
|
48 |
<>
|
|
|
49 |
<Cover cover={profile?.cover} />
|
|
|
50 |
<main className="main-section-data container px-0">
|
|
|
51 |
<ProfileInfo
|
|
|
52 |
{...profile}
|
|
|
53 |
fullName={profile?.full_name}
|
|
|
54 |
linkInmail={profile?.link_inmail}
|
|
|
55 |
showContact={profile?.show_contact}
|
|
|
56 |
id={profile?.user_uuid}
|
|
|
57 |
cancelUrl={profile?.link_cancel}
|
|
|
58 |
connectUrl={profile?.link_request}
|
|
|
59 |
/>
|
|
|
60 |
<section className="feed-section">
|
|
|
61 |
<Overview overview={profile?.overview} />
|
|
|
62 |
<Experiences experiences={profile?.user_experiences} />
|
|
|
63 |
<Educations educations={profile?.user_educations} />
|
|
|
64 |
<Location address={profile?.formatted_address} />
|
|
|
65 |
<Languages languages={profile?.user_languages} />
|
|
|
66 |
<Skills skills={profile?.user_skills} />
|
|
|
67 |
<Aptitudes aptitudes={profile?.user_aptitudes} />
|
|
|
68 |
<HobbiesAndInterests
|
|
|
69 |
hobbiesAndInterest={profile?.user_hobbies_and_interests}
|
|
|
70 |
/>
|
|
|
71 |
</section>
|
|
|
72 |
<SuggestWidget
|
|
|
73 |
url={`/helpers/people-viewed-profile/${profile?.user_profile_id}`}
|
|
|
74 |
btnLabelAccept={labels.view_profile}
|
|
|
75 |
title={labels.who_has_seen_this_profile}
|
|
|
76 |
/>
|
|
|
77 |
</main>
|
|
|
78 |
</>
|
|
|
79 |
)
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
export default ProfileView
|