Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5473 | Rev 5484 | 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 */
5483 stevensc 2
import React, { useState, useEffect } from 'react'
3
import { useSelector } from 'react-redux'
5473 stevensc 4
 
5483 stevensc 5
import IconButton from '@mui/material/IconButton'
6
import EditIcon from '@mui/icons-material/Edit'
7
import LanguagesModal from './LanguagesModal'
8
import EmptySection from '../../../shared/empty-section/EmptySection'
5473 stevensc 9
 
5483 stevensc 10
const Languages = ({ languages, languagesOptions, userId, isEdit }) => {
11
  const [settedLanguages, setSettedLanguages] = useState(languages)
12
  const [isModalOpen, setIsModalOpen] = useState(false)
13
 
14
  const labels = useSelector((state) => state.labels)
15
 
16
  const handleEdit = () => {
17
    setIsModalOpen(true)
18
  }
19
 
20
  useEffect(() => {
21
    setSettedLanguages(languages)
22
  }, [])
23
 
5473 stevensc 24
  return (
25
    <>
5483 stevensc 26
      <div className="profile-attr">
27
        <div className="profile-attr-header">
28
          <h3>Idiomas</h3>
29
          {isEdit && (
30
            <IconButton onClick={handleEdit}>
31
              <EditIcon />
32
            </IconButton>
33
          )}
34
        </div>
35
        {settedLanguages.length ? (
36
          <ul id="list-languages">
37
            {settedLanguages.map(({ name, value }) => (
38
              <li key={value}>
39
                <a href="#" title="">
40
                  {name}
41
                </a>
42
              </li>
43
            ))}
44
          </ul>
45
        ) : (
46
          <EmptySection align="left" message={labels.EMPTY} />
47
        )}
5473 stevensc 48
      </div>
49
      <LanguagesModal
50
        show={isModalOpen}
51
        closeModal={() => setIsModalOpen(false)}
5483 stevensc 52
        userIdEncrypted={userId}
5473 stevensc 53
        languagesOptions={languagesOptions}
5483 stevensc 54
        userLanguages={settedLanguages}
55
        setLanguages={(newLanguages) => setSettedLanguages(newLanguages)}
5473 stevensc 56
      />
57
    </>
5483 stevensc 58
  )
59
}
5473 stevensc 60
 
5483 stevensc 61
export default Languages