Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3040 Rev 3047
Línea 2... Línea 2...
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'
Línea 5... Línea 5...
5
 
5
 
6
import { updateSkills } from '@services/profile/profiles'
6
import { updateSkills } from '@services/profile/profiles'
Línea 7... Línea 7...
7
import { addNotification } from '@app/redux/notification/notification.actions'
7
import { addNotification } from '@store/notification/notification.actions'
8
 
8
 
9
import TagsList from '@app/components/UI/TagsList'
9
import Widget from '@components/UI/Widget'
Línea 10... Línea 10...
10
import ProfileWidget from '../ProfileWidget'
10
import TagsList from '@components/UI/TagsList'
11
import SkillsModal from './SkillsModal'
11
import SkillsModal from './SkillsModal'
12
 
12
 
Línea 22... Línea 22...
22
 
22
 
Línea 23... Línea 23...
23
  const toggleModal = () => setShowModal(!showModal)
23
  const toggleModal = () => setShowModal(!showModal)
24
 
24
 
25
  const handleEditSkills = ({ skills }) => {
25
  const handleEditSkills = ({ skills }) => {
26
    updateSkills(uuid, skills)
-
 
27
      .then(({ data: response }) => {
-
 
28
        const { data, success } = response
-
 
29
        if (!success) {
-
 
30
          const errorMessage = typeof data === 'string' ? data : data.skills[0]
-
 
31
          throw new Error(errorMessage)
-
 
32
        }
-
 
33
 
26
    updateSkills(uuid, skills)
-
 
27
      .then((skills) => {
34
        toggleModal()
28
        setSkills(skills)
35
        setSkills(skills)
29
        toggleModal()
36
      })
30
      })
37
      .catch((error) => {
31
      .catch((error) => {
38
        dispatch(addNotification({ style: 'danger', msg: error.message }))
32
        dispatch(addNotification({ style: 'danger', msg: error.message }))
Línea 43... Línea 37...
43
    setSkills(defaultSkills)
37
    setSkills(defaultSkills)
44
  }, [defaultSkills])
38
  }, [defaultSkills])
Línea 45... Línea 39...
45
 
39
 
46
  return (
40
  return (
47
    <>
41
    <>
-
 
42
      <Widget>
48
      <ProfileWidget
43
        <Widget.Header
49
        title={labels.skills}
44
          title={labels.skills}
-
 
45
          renderAction={() => {
50
        action={
46
            if (!edit) return
51
          edit && (
47
            return (
52
            <IconButton onClick={toggleModal}>
48
              <IconButton onClick={toggleModal}>
53
              <Edit />
49
                <Edit />
54
            </IconButton>
50
              </IconButton>
55
          )
51
            )
56
        }
52
          }}
-
 
53
        />
-
 
54
 
57
      >
55
        <Widget.Body>
-
 
56
          <TagsList tags={skills} />
58
        <TagsList tags={skills} />
57
        </Widget.Body>
Línea 59... Línea 58...
59
      </ProfileWidget>
58
      </Widget>
60
 
59
 
61
      <SkillsModal
60
      <SkillsModal
62
        show={showModal}
61
        show={showModal}