Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
3446 stevensc 1
import React, { useEffect, useState } from 'react';
2
import { useParams } from 'react-router-dom';
3
import { useDispatch, useSelector } from 'react-redux';
4
import { getBackendVars } from '../../services/backendVars';
5 stevensc 5
 
3446 stevensc 6
import ProfileInfo from '../../components/ProfileInfo';
7
import Cover from '../../components/UI/cover/Cover';
8
import Skills from '../../components/profile/skills/SkillsCard';
9
import Location from '../../components/location/Location';
10
import Overview from '../../components/overview/Overview';
11
import Aptitudes from '../../components/profile/aptitudes/AptitudesCard';
12
import Languages from '../../components/profile/languages/LanguagesCard';
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/profile/hobbies/HobbiesCard.jsx';
17
import { addNotification } from '@app/redux/notification/notification.actions';
5 stevensc 18
 
19
const ProfileView = () => {
3446 stevensc 20
  const [profile, setProfile] = useState(null);
21
  const labels = useSelector(({ intl }) => intl.labels);
22
  const { uuid } = useParams();
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'
3446 stevensc 33
        ];
5 stevensc 34
 
35
        adapters.forEach((adapter) => {
36
          vars[adapter] = Object.entries(vars[adapter]).map(([key, value]) => {
3446 stevensc 37
            return { name: value, value: key };
38
          });
39
        });
5 stevensc 40
 
3446 stevensc 41
        setProfile(vars);
5 stevensc 42
      })
2194 stevensc 43
      .catch((error) => {
3446 stevensc 44
        dispatch(addNotification({ style: 'danger', msg: error.message }));
45
      });
46
  }, []);
5 stevensc 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} />
3446 stevensc 70
          <HobbiesAndInterests hobbiesAndInterest={profile?.user_hobbies_and_interests} />
5 stevensc 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
    </>
3446 stevensc 79
  );
80
};
5 stevensc 81
 
3446 stevensc 82
export default ProfileView;