Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3047 Rev 3432
Línea 1... Línea 1...
1
import React, { useState, useEffect } from 'react'
1
import React, { useState, useEffect } from "react";
2
import { useSelector, useDispatch } from 'react-redux'
2
import { useSelector, useDispatch } 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 { axios } from '@utils'
6
import { axios } from "@utils";
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 AptitudesModal from './AptitudesModal'
11
import AptitudesModal from "./AptitudesModal";
Línea 12... Línea 12...
12
 
12
 
13
const AptitudesCard = ({
13
const AptitudesCard = ({
14
  aptitudes: defaultAptitudes = [],
14
  aptitudes: defaultAptitudes = [],
15
  uuid = '',
15
  uuid = "",
16
  edit = false
16
  edit = false,
17
}) => {
17
}) => {
18
  const [aptitudes, setAptitudes] = useState([])
18
  const [aptitudes, setAptitudes] = useState([]);
19
  const [showModal, setShowModal] = useState(false)
19
  const [showModal, setShowModal] = useState(false);
20
  const labels = useSelector(({ intl }) => intl.labels)
20
  const labels = useSelector(({ intl }) => intl.labels);
Línea 21... Línea 21...
21
  const dispatch = useDispatch()
21
  const dispatch = useDispatch();
Línea 22... Línea 22...
22
 
22
 
23
  const toggleModal = () => setShowModal(!showModal)
23
  const toggleModal = () => setShowModal(!showModal);
24
 
24
 
Línea 25... Línea 25...
25
  const handleEditAptitudes = ({ aptitudes }) => {
25
  const handleEditAptitudes = ({ aptitudes }) => {
26
    const formData = new FormData()
26
    const formData = new FormData();
27
    aptitudes.map((aptitude) => formData.append('aptitudes[]', aptitude.value))
27
    aptitudes.map((aptitude) => formData.append("aptitudes[]", aptitude.value));
28
 
28
 
Línea 29... Línea 29...
29
    axios
29
    axios
30
      .post(`/profile/my-profiles/aptitude/${uuid}`, formData)
30
      .post(`/profile/my-profiles/aptitude/${uuid}`, formData)
31
      .then(({ data: response }) => {
31
      .then((response) => {
32
        const { data, success } = response
32
        const { data, success } = response.data;
33
 
33
 
Línea 34... Línea 34...
34
        if (!success) {
34
        if (!success) {
35
          const errorMessage =
35
          const errorMessage =
36
            typeof data === 'string' ? data : data.aptitudes[0]
36
            typeof data === "string" ? data : data.aptitudes[0];
37
          throw new Error(errorMessage)
37
          throw new Error(errorMessage);
38
        }
38
        }
39
 
39
 
40
        setAptitudes(aptitudes)
40
        setAptitudes(aptitudes);
Línea 41... Línea 41...
41
        toggleModal()
41
        toggleModal();
42
      })
42
      })
43
      .catch((err) => {
43
      .catch((err) => {
Línea 44... Línea 44...
44
        dispatch(addNotification({ style: 'danger', msg: err.message }))
44
        dispatch(addNotification({ style: "danger", msg: err.message }));
45
      })
45
      });
46
  }
46
  };
47
 
47
 
Línea 73... Línea 73...
73
        onClose={toggleModal}
73
        onClose={toggleModal}
74
        onConfirm={handleEditAptitudes}
74
        onConfirm={handleEditAptitudes}
75
        aptitudes={aptitudes}
75
        aptitudes={aptitudes}
76
      />
76
      />
77
    </>
77
    </>
78
  )
78
  );
79
}
79
};
Línea 80... Línea 80...
80
 
80