Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
          isEdit
60
        />
61
        <section className="feed-section">
62
          <Overview overview={profile?.overview} isEdit />
63
          <Experiences experiences={profile?.user_experiences} />
64
          <Educations educations={profile?.user_educations} />
65
          <Location address={profile?.formatted_address} />
66
          <Languages languages={profile?.user_languages} />
67
          <Skills skills={profile?.user_skills} />
68
          <Aptitudes aptitudes={profile?.user_aptitudes} />
69
          <HobbiesAndInterests
70
            hobbiesAndInterest={profile?.user_hobbies_and_interests}
71
          />
72
        </section>
73
        <SuggestWidget
74
          url={`/helpers/people-viewed-profile/${profile?.user_profile_id}`}
75
          btnLabelAccept={labels.view_profile}
76
          title={labels.who_has_seen_this_profile}
77
        />
78
      </main>
79
    </>
80
  )
81
}
82
 
83
export default ProfileView