Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3047 Rev 3640
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react';
2
import { useDispatch, useSelector } from 'react-redux'
2
import { useDispatch, useSelector } from 'react-redux';
3
import { IconButton } from '@mui/material'
3
import { IconButton } from '@mui/material';
4
import { Edit } from '@mui/icons-material'
4
import { Edit } from '@mui/icons-material';
5
 
5
 
6
import { updateSkills } from '@services/profile/profiles'
6
import { updateSkills } from '@services/profile/profiles';
7
import { addNotification } from '@store/notification/notification.actions'
7
import { addNotification } from '@store/notification/notification.actions';
8
 
8
 
9
import Widget from '@components/UI/Widget'
9
import Widget from '@components/UI/Widget';
10
import TagsList from '@components/UI/TagsList'
10
import TagsList from '@components/UI/TagsList';
11
import SkillsModal from './SkillsModal'
11
import SkillsModal from './SkillsModal';
12
 
12
 
13
const SkillsCard = ({
-
 
14
  skills: defaultSkills = [],
13
const SkillsCard = ({ skills: defaultSkills = [], uuid = '', edit = false }) => {
15
  uuid = '',
-
 
16
  edit = false
-
 
17
}) => {
-
 
18
  const [skills, setSkills] = useState([])
14
  const [skills, setSkills] = useState([]);
19
  const [showModal, setShowModal] = useState(false)
15
  const [showModal, setShowModal] = useState(false);
20
  const labels = useSelector(({ intl }) => intl.labels)
16
  const labels = useSelector(({ intl }) => intl.labels);
21
  const dispatch = useDispatch()
17
  const dispatch = useDispatch();
Línea 22... Línea 18...
22
 
18
 
Línea 23... Línea 19...
23
  const toggleModal = () => setShowModal(!showModal)
19
  const toggleModal = () => setShowModal(!showModal);
24
 
20
 
25
  const handleEditSkills = ({ skills }) => {
21
  const handleEditSkills = ({ skills }) => {
26
    updateSkills(uuid, skills)
22
    updateSkills(uuid, skills)
27
      .then((skills) => {
23
      .then((skills) => {
28
        setSkills(skills)
24
        setSkills(skills);
29
        toggleModal()
25
        toggleModal();
30
      })
26
      })
31
      .catch((error) => {
27
      .catch((error) => {
32
        dispatch(addNotification({ style: 'danger', msg: error.message }))
28
        dispatch(addNotification({ style: 'danger', msg: error.message }));
Línea 33... Línea 29...
33
      })
29
      });
34
  }
30
  };
35
 
31
 
Línea 36... Línea 32...
36
  useEffect(() => {
32
  useEffect(() => {
37
    setSkills(defaultSkills)
33
    setSkills(defaultSkills);
38
  }, [defaultSkills])
34
  }, [defaultSkills]);
39
 
35
 
40
  return (
36
  return (
41
    <>
37
    <>
42
      <Widget>
38
      <Widget>
43
        <Widget.Header
39
        <Widget.Header
44
          title={labels.skills}
40
          title={labels.skills}
45
          renderAction={() => {
41
          renderAction={() => {
46
            if (!edit) return
42
            if (!edit) return;
47
            return (
43
            return (
48
              <IconButton onClick={toggleModal}>
44
              <IconButton onClick={toggleModal}>
49
                <Edit />
45
                <Edit />
Línea 50... Línea 46...
50
              </IconButton>
46
              </IconButton>
51
            )
47
            );
Línea 62... Línea 58...
62
        onClose={toggleModal}
58
        onClose={toggleModal}
63
        onConfirm={handleEditSkills}
59
        onConfirm={handleEditSkills}
64
        skills={skills}
60
        skills={skills}
65
      />
61
      />
66
    </>
62
    </>
67
  )
63
  );
68
}
64
};
Línea 69... Línea 65...
69
 
65