Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3692 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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