Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2194 | Rev 3446 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

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