Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5891 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5891 stevensc 1
import React, { useState } from 'react'
5868 stevensc 2
import EmptySection from '../../../../../shared/empty-section/EmptySection'
3
import EducationCard from '../../../../pages/view/templates/linkedin/components/cards/EducationCard'
4
import ExperienceCard from '../../../../pages/view/templates/linkedin/components/cards/ExperienceCard'
5
import ItemsList from '../../../../pages/view/templates/linkedin/components/cards/ItemsList'
6
import ProfileCard from '../../../../pages/view/templates/linkedin/components/ProfileCard'
7
import ProfileWidget from '../../../../pages/view/templates/linkedin/components/ProfileWidget'
8
import AptitudesModal from '../../../../components/aptitudes/AptitudesModal'
9
import EducationModal from '../../../../components/educations/EducationModal'
10
import ExperienceModal from '../../../../components/experiences/ExperienceModal'
11
import HobbiesModal from '../../../../components/hobbies-and-interests/HobbiesModal'
12
import LanguagesModal from '../../../../components/languages/LanguagesModal'
13
import LocationModal from '../../../../components/location/LocationModal'
14
import SkillsModal from '../../../../components/skills/SkillsModal'
5473 stevensc 15
 
16
const EditView = (userInfo) => {
17
  const {
5872 stevensc 18
    experiences: userExperiences,
5865 stevensc 19
    educations: userEducations,
20
    languages: userLanguages,
21
    skills: userSkills,
22
    aptitudes: userAptitudes,
23
    hobbiesAndInterests: userHobbiesAndInterests,
5473 stevensc 24
    months,
5865 stevensc 25
    options,
26
    formatted_address,
5473 stevensc 27
  } = userInfo
28
 
29
  const [experiences, setExperiences] = useState(userExperiences)
30
  const [educations, setEducations] = useState(userEducations)
5891 stevensc 31
  const [languages, setLanguages] = useState(userLanguages)
32
  const [skills, setSkills] = useState(userSkills)
33
  const [aptitudes, setAptitudes] = useState(userAptitudes)
34
  const [hobbiesAndInterests, setHobbiesAndInterests] = useState(
35
    userHobbiesAndInterests
36
  )
5473 stevensc 37
  const [address, setAddress] = useState(formatted_address)
38
 
39
  const [modalShow, setModalShow] = useState(null)
40
  const [settedDescription, setSettedDescription] = useState('')
41
  const [postUrl, setPostUrl] = useState('')
42
  const [isEdit, setIsEdit] = useState(false)
43
 
44
  const handleEdit = (modalName, url, description) => {
45
    setModalShow(modalName)
46
    setPostUrl(url)
47
    setSettedDescription(description)
48
  }
49
 
50
  const handleAdd = (modalName, url) => {
51
    setModalShow(modalName)
52
    setPostUrl(url)
53
  }
54
 
55
  const closeModal = () => {
56
    setSettedDescription('')
57
    setPostUrl('')
58
    setIsEdit(false)
59
    setModalShow(null)
60
  }
61
 
62
  const renderModal = {
5865 stevensc 63
    Experiencia: (
64
      <ExperienceModal
65
        companySizesOptions={options.companySizes}
66
        industriesOptions={options.industries}
67
        months={months}
68
        setUserExperiences={(newExperiences) => setExperiences(newExperiences)}
69
        show={modalShow === 'Experiencia'}
70
        postUrl={postUrl}
71
        closeModal={closeModal}
72
        settedDescription={settedDescription}
73
      />
74
    ),
75
    Educación: (
76
      <EducationModal
77
        closeModal={closeModal}
78
        postUrl={postUrl}
79
        setEducations={(newEducations) => setEducations(newEducations)}
80
        show={modalShow === 'Educación'}
81
        settedDescription={settedDescription}
82
        degreesOptions={options.degrees}
83
      />
84
    ),
85
    Habilidades: (
86
      <SkillsModal
87
        closeModal={closeModal}
88
        setSkills={(newSkills) => setSkills(newSkills)}
89
        show={modalShow === 'Habilidades'}
5891 stevensc 90
        skillsOptions={options.skills}
5952 stevensc 91
        userIdEncrypted={userInfo.profileId}
5865 stevensc 92
        userSkillsArray={skills}
93
      />
94
    ),
95
    Idiomas: (
96
      <LanguagesModal
97
        show={modalShow === 'Idiomas'}
98
        closeModal={closeModal}
5952 stevensc 99
        userIdEncrypted={userInfo.profileId}
5891 stevensc 100
        languagesOptions={options.languages}
5865 stevensc 101
        userLanguages={languages}
102
        setLanguages={(newLanguages) => setLanguages(newLanguages)}
103
      />
104
    ),
105
    Aptitudes: (
106
      <AptitudesModal
107
        show={modalShow === 'Aptitudes'}
108
        closeModal={closeModal}
5952 stevensc 109
        userIdEncrypted={userInfo.profileId}
5891 stevensc 110
        aptitudesOptions={options.aptitudes}
5865 stevensc 111
        userAptitudes={aptitudes}
112
        setAptitudes={(newAptitudes) => setAptitudes(newAptitudes)}
113
      />
114
    ),
115
    'Hobbies e Intereses': (
116
      <HobbiesModal
117
        show={modalShow === 'Hobbies e Intereses'}
118
        closeModal={closeModal}
5952 stevensc 119
        userIdEncrypted={userInfo.profileId}
5891 stevensc 120
        hobbiesAndInterestsOptions={options.hobbiesAndInterests}
5865 stevensc 121
        userHobbiesAndInterests={hobbiesAndInterests}
122
        setUserHobbiesAndInterests={(newHobbiesAndInterests) =>
123
          setHobbiesAndInterests(newHobbiesAndInterests)
124
        }
125
      />
126
    ),
127
    Ubicación: (
128
      <LocationModal
129
        isModalOpen={modalShow === 'Ubicación'}
130
        closeModal={() => setModalShow(null)}
131
        setSettedAddress={(newAddress) => setAddress(newAddress)}
5952 stevensc 132
        userIdEncrypted={userInfo.profileId}
5865 stevensc 133
      />
134
    ),
5473 stevensc 135
  }
136
 
5891 stevensc 137
  return (
138
    <main className="w-100">
139
      <div className="container">
140
        <div className="main d-flex flex-column" style={{ gap: '.5rem' }}>
141
          <ProfileCard
142
            {...{
143
              ...userInfo,
144
              formatted_address: address,
145
            }}
146
          />
147
          <ProfileWidget
148
            title="Experiencia"
149
            onEdit={() => setIsEdit(!isEdit)}
150
            onAdd={handleAdd}
5952 stevensc 151
            addUrl={`/profile/my-profiles/experience/${userInfo.profileId}/operation/add`}
5891 stevensc 152
          >
153
            {experiences.map((experience, index) => {
154
              return (
155
                <ExperienceCard
156
                  key={index}
157
                  experience={experience}
158
                  months={userInfo.months}
159
                  isEdit={isEdit}
160
                  onEdit={handleEdit}
161
                  setExperiences={(newExperiences) =>
162
                    setExperiences(newExperiences)
163
                  }
164
                />
165
              )
166
            })}
167
          </ProfileWidget>
168
          <ProfileWidget
169
            title="Educación"
170
            onEdit={() => setIsEdit(!isEdit)}
171
            onAdd={handleAdd}
5952 stevensc 172
            addUrl={`/profile/my-profiles/education/${userInfo.profileId}/operation/add`}
5891 stevensc 173
          >
174
            {educations.map((education, index) => {
175
              return (
176
                <EducationCard
177
                  key={index}
178
                  education={education}
179
                  isEdit={isEdit}
180
                  onEdit={handleEdit}
181
                  setEducations={(newEducations) =>
182
                    setEducations(newEducations)
183
                  }
184
                />
185
              )
186
            })}
187
          </ProfileWidget>
188
          <ProfileWidget
189
            title="Ubicación"
190
            onEdit={() => setModalShow('Ubicación')}
191
            justEdit
192
          >
193
            <div className="card__items">
194
              <p>{address}</p>
195
            </div>
196
          </ProfileWidget>
197
          <ProfileWidget
198
            title="Idiomas"
199
            onEdit={() => setModalShow('Idiomas')}
200
            justEdit
201
          >
202
            {!languages.length ? (
203
              <EmptySection align="left" message="Sin información" />
204
            ) : (
205
              <ItemsList value={languages} />
206
            )}
207
          </ProfileWidget>
208
          <ProfileWidget
209
            title="Habilidades"
210
            onEdit={() => setModalShow('Habilidades')}
211
            justEdit
212
          >
213
            {!skills.length ? (
214
              <EmptySection align="left" message="Sin información" />
215
            ) : (
216
              <ItemsList value={skills} />
217
            )}
218
          </ProfileWidget>
219
          <ProfileWidget
220
            title="Aptitudes"
221
            onEdit={() => setModalShow('Aptitudes')}
222
            justEdit
223
          >
224
            {!aptitudes.length ? (
225
              <EmptySection align="left" message="Sin información" />
226
            ) : (
227
              <ItemsList value={aptitudes} />
228
            )}
229
          </ProfileWidget>
230
          <ProfileWidget
231
            title="Pasatiempos e intereses"
232
            onEdit={() => setModalShow('Hobbies e Intereses')}
233
            justEdit
234
          >
235
            {!hobbiesAndInterests.length ? (
236
              <EmptySection align="left" message="Sin información" />
237
            ) : (
238
              <ItemsList value={hobbiesAndInterests} />
239
            )}
240
          </ProfileWidget>
241
          {renderModal[modalShow]}
242
        </div>
243
      </div>
244
    </main>
245
  )
5473 stevensc 246
}
247
 
248
export default EditView