6830 |
stevensc |
1 |
import React, { useState, useEffect } from 'react'
|
|
|
2 |
import { useParams } from 'react-router-dom'
|
|
|
3 |
import { useSelector } from 'react-redux'
|
|
|
4 |
import { getBackendVars } from '../../services/backendVars'
|
|
|
5 |
import ProfileCard from '../../components/linkedin/profile/ProfileCard'
|
|
|
6 |
import ProfileWidget from '../../components/linkedin/profile/ProfileWidget'
|
|
|
7 |
import ExperienceCard from '../../components/linkedin/profile/cards/ExperienceCard'
|
|
|
8 |
import EducationCard from '../../components/linkedin/profile/cards/EducationCard'
|
|
|
9 |
import EmptySection from '../../components/UI/EmptySection'
|
|
|
10 |
import ItemsList from '../../components/linkedin/profile/cards/ItemsList'
|
|
|
11 |
import SuggestionWidget from '../../components/widgets/default/SuggestWidget'
|
|
|
12 |
import '../../styles/profile/profile.scss'
|
|
|
13 |
|
|
|
14 |
const DEFAULT_VARS = {
|
|
|
15 |
user_experiences: [],
|
|
|
16 |
user_educations: [],
|
|
|
17 |
user_hobbies_and_interests: [],
|
|
|
18 |
user_skills: [],
|
|
|
19 |
user_aptitudes: [],
|
|
|
20 |
user_languages: [],
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
const View = () => {
|
|
|
24 |
const [profile, setProfile] = useState(DEFAULT_VARS)
|
|
|
25 |
const labels = useSelector(({ intl }) => intl.labels)
|
|
|
26 |
const { uuid } = useParams()
|
|
|
27 |
|
|
|
28 |
useEffect(() => {
|
|
|
29 |
getBackendVars(`/profile/view/${uuid}`)
|
|
|
30 |
.then((vars) => {
|
|
|
31 |
const adapters = [
|
|
|
32 |
'user_hobbies_and_interests',
|
|
|
33 |
'user_skills',
|
|
|
34 |
'user_aptitudes',
|
|
|
35 |
'user_languages',
|
|
|
36 |
]
|
|
|
37 |
|
|
|
38 |
adapters.forEach((adapter) => {
|
|
|
39 |
vars[adapter] = Object.entries(vars[adapter]).map(([key, value]) => {
|
|
|
40 |
return { name: value, value: key }
|
|
|
41 |
})
|
|
|
42 |
})
|
|
|
43 |
|
|
|
44 |
setProfile(vars)
|
|
|
45 |
})
|
|
|
46 |
.catch((err) => {
|
|
|
47 |
console.log(`Error: ${err}`)
|
|
|
48 |
throw new Error(err)
|
|
|
49 |
})
|
6974 |
stevensc |
50 |
}, [uuid])
|
6830 |
stevensc |
51 |
|
|
|
52 |
return (
|
|
|
53 |
<main className="w-100">
|
|
|
54 |
<div className="container profile__layout">
|
|
|
55 |
<div className="main d-flex flex-column" style={{ gap: '.5rem' }}>
|
|
|
56 |
<ProfileCard {...profile} />
|
|
|
57 |
<ProfileWidget title={labels.experience}>
|
|
|
58 |
{!profile.user_experiences.length ? (
|
|
|
59 |
<EmptySection align="left" message={labels.empty} />
|
|
|
60 |
) : (
|
|
|
61 |
profile.user_experiences.map((experience, index) => {
|
|
|
62 |
return <ExperienceCard key={index} experience={experience} />
|
|
|
63 |
})
|
|
|
64 |
)}
|
|
|
65 |
</ProfileWidget>
|
|
|
66 |
<ProfileWidget title={labels.education}>
|
|
|
67 |
{!profile.user_educations.length ? (
|
|
|
68 |
<EmptySection align="left" message={labels.empty} />
|
|
|
69 |
) : (
|
|
|
70 |
profile.user_educations.map((education, index) => {
|
|
|
71 |
return <EducationCard key={index} education={education} />
|
|
|
72 |
})
|
|
|
73 |
)}
|
|
|
74 |
</ProfileWidget>
|
|
|
75 |
<ProfileWidget title={labels.languages}>
|
|
|
76 |
{!profile.user_languages.length ? (
|
|
|
77 |
<EmptySection align="left" message={labels.empty} />
|
|
|
78 |
) : (
|
|
|
79 |
<ItemsList value={profile.user_languages} />
|
|
|
80 |
)}
|
|
|
81 |
</ProfileWidget>
|
|
|
82 |
<ProfileWidget title={labels.skills}>
|
|
|
83 |
{!profile.user_skills.length ? (
|
|
|
84 |
<EmptySection align="left" message={labels.empty} />
|
|
|
85 |
) : (
|
|
|
86 |
<ItemsList value={profile.user_skills} />
|
|
|
87 |
)}
|
|
|
88 |
</ProfileWidget>
|
|
|
89 |
<ProfileWidget title={labels.aptitudes}>
|
|
|
90 |
{!profile.user_aptitudes.length ? (
|
|
|
91 |
<EmptySection align="left" message={labels.empty} />
|
|
|
92 |
) : (
|
|
|
93 |
<ItemsList value={profile.user_aptitudes} />
|
|
|
94 |
)}
|
|
|
95 |
</ProfileWidget>
|
|
|
96 |
<ProfileWidget title={labels.hobbies_and_interests}>
|
|
|
97 |
{!profile.user_hobbies_and_interests.length ? (
|
|
|
98 |
<EmptySection align="left" message={labels.empty} />
|
|
|
99 |
) : (
|
|
|
100 |
<ItemsList value={profile.user_hobbies_and_interests} />
|
|
|
101 |
)}
|
|
|
102 |
</ProfileWidget>
|
|
|
103 |
</div>
|
|
|
104 |
<div className="aside">
|
|
|
105 |
<SuggestionWidget
|
|
|
106 |
url={`/helpers/people-viewed-profile/${profile.user_profile_id}`}
|
|
|
107 |
title={labels.who_has_seen_this_profile}
|
|
|
108 |
/>
|
|
|
109 |
</div>
|
|
|
110 |
</div>
|
|
|
111 |
</main>
|
|
|
112 |
)
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
export default View
|