Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1814 | Rev 1849 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1814 Rev 1847
Línea 1... Línea 1...
1
import React, { useState, useEffect } from 'react'
1
import React from 'react'
2
import { useParams } from 'react-router-dom'
2
import { useParams } from 'react-router-dom'
3
import { useSelector } from 'react-redux'
-
 
4
import { getBackendVars } from '../../services/backendVars'
-
 
5
import { Container, Grid } from '@mui/material'
3
import { Container, Grid } from '@mui/material'
Línea 6... Línea -...
6
 
-
 
7
import ProfileCard from '../../components/linkedin/profile/ProfileCard'
-
 
8
import ProfileWidget from '../../components/linkedin/profile/ProfileWidget'
-
 
9
import ExperienceCard from '../../components/linkedin/profile/cards/ExperienceCard'
-
 
10
import EducationCard from '../../components/linkedin/profile/cards/EducationCard'
-
 
11
import EmptySection from '../../components/UI/EmptySection'
4
 
12
import TagsList from '../../components/UI/TagsList'
5
import useFetch from '@app/hooks/useFetch'
13
 
-
 
14
import EducationModal from '../../components/educations/EducationModal'
6
 
15
import SkillsModal from '../../components/skills/SkillsModal'
-
 
16
import LanguagesModal from '../../components/languages/LanguagesModal'
-
 
17
import AptitudesModal from '../../components/aptitudes/AptitudesModal'
7
import ProfileCard from '@app/components/profile/ProfileCard'
18
import HobbiesModal from '../../components/hobbies-and-interests/HobbiesModal'
8
import ExperiencesCard from '@app/components/profile/experiences/ExperiencesCard'
Línea 19... Línea 9...
19
import LocationModal from '../../components/location/LocationModal'
9
import EducationsCard from '@app/components/profile/educations/EducationsCard'
Línea 20... Línea 10...
20
 
10
 
21
import '../../styles/profile/profile.scss'
-
 
22
 
-
 
23
const View = () => {
-
 
24
  const [profile, setProfile] = useState({})
-
 
25
  const [experiences, setExperiences] = useState([])
-
 
26
  const [educations, setEducations] = useState([])
-
 
27
  const [languages, setLanguages] = useState([])
-
 
28
  const [skills, setSkills] = useState([])
-
 
29
  const [aptitudes, setAptitudes] = useState([])
-
 
30
  const [hobbiesAndInterests, setHobbiesAndInterests] = useState([])
-
 
31
  const [address, setAddress] = useState('')
-
 
32
  const [modalShow, setModalShow] = useState(null)
-
 
33
  const [settedDescription, setSettedDescription] = useState('')
-
 
34
  const [postUrl, setPostUrl] = useState('')
11
import '../../styles/profile/profile.scss'
-
 
12
 
Línea 35... Línea -...
35
  const [isEdit, setIsEdit] = useState(false)
-
 
36
  const labels = useSelector(({ intl }) => intl.labels)
-
 
37
  const { uuid } = useParams()
-
 
38
 
-
 
39
  const handleEdit = (modalName, url, description) => {
-
 
40
    setModalShow(modalName)
-
 
41
    setPostUrl(url)
-
 
42
    setSettedDescription(description)
-
 
43
  }
-
 
44
 
-
 
45
  const handleAdd = (modalName, url) => {
-
 
46
    setModalShow(modalName)
-
 
47
    setPostUrl(url)
-
 
48
  }
-
 
49
 
-
 
50
  const closeModal = () => {
-
 
51
    setSettedDescription('')
-
 
52
    setPostUrl('')
-
 
53
    setIsEdit(false)
-
 
54
    setModalShow(null)
-
 
55
  }
-
 
56
 
-
 
57
  const renderModal = {
-
 
58
    Educación: (
-
 
59
      <EducationModal
-
 
60
        show={modalShow === 'Educación'}
-
 
61
        postUrl={postUrl}
-
 
62
        closeModal={closeModal}
-
 
63
        setEducations={(newEducations) => setEducations(newEducations)}
-
 
64
        settedDescription={settedDescription}
-
 
65
      />
-
 
66
    ),
-
 
67
    Habilidades: (
-
 
68
      <SkillsModal
-
 
69
        show={modalShow === 'Habilidades'}
-
 
70
        userSkills={skills}
-
 
71
        userId={profile?.user_profile_uuid}
-
 
72
        onClose={closeModal}
-
 
73
        onComplete={(newSkills) => setSkills(newSkills)}
-
 
74
      />
-
 
75
    ),
-
 
76
    Idiomas: (
-
 
77
      <LanguagesModal
-
 
78
        show={modalShow === 'Idiomas'}
-
 
79
        userId={profile?.user_profile_uuid}
-
 
80
        userLanguages={languages}
-
 
81
        onClose={closeModal}
-
 
82
        onComplete={(newLanguages) => setLanguages(newLanguages)}
-
 
83
      />
-
 
84
    ),
-
 
85
    Aptitudes: (
-
 
86
      <AptitudesModal
-
 
87
        show={modalShow === 'Aptitudes'}
-
 
88
        userId={profile?.user_profile_uuid}
-
 
89
        userAptitudes={aptitudes}
-
 
90
        onClose={closeModal}
-
 
91
        onComplete={(newAptitudes) => setAptitudes(newAptitudes)}
-
 
92
      />
-
 
93
    ),
-
 
94
    'Hobbies e Intereses': (
-
 
95
      <HobbiesModal
-
 
96
        onClose={closeModal}
-
 
97
        show={modalShow === 'Hobbies e Intereses'}
-
 
98
        userId={profile?.user_profile_uuid}
-
 
99
        userHobbies={hobbiesAndInterests}
-
 
100
        onComplete={(newHobbiesAndInterests) =>
-
 
101
          setHobbiesAndInterests(newHobbiesAndInterests)
-
 
102
        }
-
 
103
      />
-
 
104
    ),
-
 
105
    Ubicación: (
-
 
106
      <LocationModal
-
 
107
        show={modalShow === 'Ubicación'}
-
 
108
        onClose={() => setModalShow(null)}
-
 
109
        onComplete={(newAddress) => setAddress(newAddress)}
-
 
110
        id={profile?.user_profile_uuid}
-
 
111
      />
-
 
112
    )
-
 
113
  }
-
 
114
 
13
const View = () => {
115
  useEffect(() => {
14
  const { uuid } = useParams()
116
    getBackendVars(`/profile/my-profiles/edit/${uuid}`)
15
  const { data: profile } = useFetch(`/profile/my-profiles/edit/${uuid}`)
117
      .then((vars) => {
16
 
118
        const {
17
  /*  const {
119
          user_experiences,
18
    user_experiences,
120
          user_educations,
19
    user_educations,
121
          user_hobbies_and_interests,
20
    user_hobbies_and_interests,
122
          user_skills,
21
    user_skills,
123
          user_aptitudes,
-
 
124
          user_languages,
-
 
125
          formatted_address,
-
 
126
          ...profileInfo
-
 
127
        } = vars
-
 
128
 
-
 
129
        const attrAdapter = (attr) => {
-
 
130
          return Object.entries(attr).map(([key, value]) => {
-
 
131
            return { name: value, value: key }
-
 
132
          })
-
 
133
        }
-
 
134
 
-
 
135
        setExperiences(user_experiences)
-
 
136
        setEducations(user_educations)
-
 
137
        setAddress(formatted_address)
-
 
138
        setProfile(profileInfo)
-
 
139
        setHobbiesAndInterests(attrAdapter(user_hobbies_and_interests))
-
 
140
        setSkills(attrAdapter(user_skills))
-
 
141
        setAptitudes(attrAdapter(user_aptitudes))
-
 
142
        setLanguages(attrAdapter(user_languages))
-
 
143
      })
-
 
Línea 144... Línea 22...
144
      .catch((err) => {
22
    user_aptitudes,
145
        console.log(`Error: ${err}`)
-
 
146
      })
23
    user_languages,
147
  }, [])
24
    formatted_address
148
 
-
 
149
  return (
25
  } = profile */
150
    <>
-
 
151
      <Container as='main' sx={{ p: 0 }}>
-
 
152
        <Grid container spacing={2}>
-
 
153
          <Grid item xs={12} display='flex' direction='column' gap={2}>
-
 
154
            <ProfileCard
26
 
155
              {...profile}
-
 
156
              sizes={{
-
 
157
                image: profile.image_size_profile,
-
 
158
                cover: profile.image_size_cover
27
  return (
159
              }}
-
 
160
              uuid={profile.user_uuid}
-
 
161
              image={profile.image}
-
 
162
              cover={profile.cover}
-
 
163
            />
-
 
164
 
-
 
165
            <ExperienceCard experiences={experiences} uuid={uuid} />
-
 
166
 
-
 
167
            <ProfileWidget
28
    <Container as='main' sx={{ p: 0 }}>
168
              title={labels.education}
-
 
169
              onEdit={() => setIsEdit(!isEdit)}
-
 
170
              onAdd={handleAdd}
-
 
171
              addUrl={`/profile/my-profiles/education/${profile?.user_profile_uuid}/operation/add`}
29
      <Grid container spacing={2}>
172
            >
-
 
173
              {educations.length ? (
-
 
174
                educations.map((education, index) => (
30
        <Grid
175
                  <EducationCard
31
          item
176
                    key={index}
32
          xs={12}
177
                    isEdit={isEdit}
-
 
178
                    onEdit={handleEdit}
-
 
179
                    education={education}
33
          sx={{
180
                  />
34
            display: 'flex',
181
                ))
-
 
182
              ) : (
35
            flexDirection: 'column',
183
                <EmptySection align='left' message={labels.empty} />
-
 
184
              )}
-
 
185
            </ProfileWidget>
36
            gap: 1
186
 
-
 
187
            <ProfileWidget
37
          }}
188
              title={labels.location}
38
        >
189
              onEdit={() => setModalShow('Ubicación')}
39
          <ProfileCard
190
              justEdit
40
            {...profile}
191
            >
-
 
192
              <div className='card__items'>
41
            sizes={{
193
                <p>{address}</p>
42
              image: profile.image_size_profile,
194
              </div>
-
 
195
            </ProfileWidget>
-
 
196
 
43
              cover: profile.image_size_cover
197
            <ProfileWidget
-
 
198
              title={labels.languages}
-
 
199
              onEdit={() => setModalShow('Idiomas')}
44
            }}
200
              justEdit
45
            uuid={profile.user_uuid}
201
            >
46
            image={profile.image}
202
              <TagsList tags={languages} />
-
 
203
            </ProfileWidget>
47
            cover={profile.cover}
204
 
48
          />
205
            <ProfileWidget
-
 
206
              title={labels.skills}
-
 
207
              onEdit={() => setModalShow('Habilidades')}
-
 
208
              justEdit
-
 
209
            >
-
 
210
              <TagsList tags={skills} />
-
 
211
            </ProfileWidget>
-
 
212
 
49
 
213
            <ProfileWidget
-
 
214
              title={labels.aptitudes}
-
 
215
              onEdit={() => setModalShow('Aptitudes')}
50
          <ExperiencesCard
216
              justEdit
51
            experiences={profile.user_experiences}
217
            >
52
            uuid={uuid}
218
              <TagsList tags={aptitudes} />
-
 
219
            </ProfileWidget>
53
            edit
220
 
54
          />
221
            <ProfileWidget
-
 
222
              title={labels.hobbies_and_interests}
-
 
223
              onEdit={() => setModalShow('Hobbies e Intereses')}
55
 
224
              justEdit
56
          <EducationsCard
225
            >
57
            educations={profile.user_educations}
226
              <TagsList tags={hobbiesAndInterests} />
-
 
227
            </ProfileWidget>
58
            uuid={uuid}
228
          </Grid>
59
            edit
229
        </Grid>
60
          />
Línea 230... Línea 61...
230
      </Container>
61
        </Grid>