Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
5473 stevensc 1
/* eslint-disable react/prop-types */
5489 stevensc 2
import React, { useState, useEffect } from 'react'
3
import { useSelector } from 'react-redux'
4
 
5
import IconButton from '@mui/material/IconButton'
6
import EditIcon from '@mui/icons-material/Edit'
7
import EmptySection from '../../../shared/empty-section/EmptySection'
5473 stevensc 8
import HobbiesModal from './HobbiesModal'
9
 
5489 stevensc 10
const HobbiesAndInterests = ({
11
  hobbiesAndInterest,
12
  hobbiesAndInterestsOptions,
13
  userId,
14
  isEdit,
15
}) => {
5473 stevensc 16
  const [isModalOpen, setIsModalOpen] = useState(false)
5489 stevensc 17
  const [settedHobbiesAndInterest, setSettedHobbiesAndInterest] =
18
    useState(hobbiesAndInterest)
5473 stevensc 19
 
5489 stevensc 20
  const labels = useSelector((state) => state.labels)
21
 
22
  const handleEdit = () => {
23
    setIsModalOpen(true)
24
  }
25
 
26
  useEffect(() => {
27
    setSettedHobbiesAndInterest(hobbiesAndInterest)
28
  }, [hobbiesAndInterest])
29
 
5473 stevensc 30
  return (
31
    <>
5489 stevensc 32
      <div className="profile-attr">
33
        <div className="profile-attr-header">
34
          <h3>{labels.HOBBIES_AND_INTERESTS}</h3>
35
          {isEdit && (
36
            <IconButton onClick={handleEdit}>
37
              <EditIcon />
38
            </IconButton>
39
          )}
40
        </div>
41
        {settedHobbiesAndInterest.length ? (
42
          <ul id="list-skills">
43
            {settedHobbiesAndInterest.map(({ name, value }) => (
44
              <li key={value}>
5473 stevensc 45
                <a href="#" title="">
46
                  {name}
47
                </a>
48
              </li>
5489 stevensc 49
            ))}
50
          </ul>
51
        ) : (
52
          <EmptySection align="left" message={labels.EMPTY} />
53
        )}
5473 stevensc 54
      </div>
55
      <HobbiesModal
56
        show={isModalOpen}
57
        closeModal={() => setIsModalOpen(false)}
5489 stevensc 58
        userIdEncrypted={userId}
5473 stevensc 59
        hobbiesAndInterestsOptions={hobbiesAndInterestsOptions}
5489 stevensc 60
        userHobbiesAndInterests={settedHobbiesAndInterest}
61
        setUserHobbiesAndInterests={(newHobbiesAndInterests) =>
62
          setSettedHobbiesAndInterest(newHobbiesAndInterests)
63
        }
5473 stevensc 64
      />
65
    </>
66
  )
67
}
68
 
69
export default HobbiesAndInterests