Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6354 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6354 Rev 6355
Línea 1... Línea -...
1
/* eslint-disable array-callback-return */
-
 
2
/* eslint-disable react/prop-types */
-
 
3
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
4
import { axios } from '../../../utils'
2
import { axios } from '../../../utils'
5
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
6
import { useDispatch } from 'react-redux'
4
import { useDispatch } from 'react-redux'
7
import { Button, Modal } from 'react-bootstrap'
5
import { Button, Modal } from 'react-bootstrap'
Línea 24... Línea 22...
24
 
22
 
25
  const handleTagsChange = (tags) => {
23
  const handleTagsChange = (tags) => {
26
    setValue('languages', tags)
24
    setValue('languages', tags)
Línea 27... Línea 25...
27
  }
25
  }
28
 
26
 
29
  const onSubmitHandler = async ({ languages }) => {
27
  const onSubmitHandler = ({ languages }) => {
30
    setModalLoading(true)
28
    setModalLoading(true)
Línea 31... Línea 29...
31
    const formData = new FormData()
29
    const formData = new FormData()
32
    languages.map((language) => formData.append('languages[]', language.value))
30
    languages.map((language) => formData.append('languages[]', language.value))
33
 
31
 
34
    axios
32
    axios
-
 
33
      .post(`/profile/my-profiles/language/${userIdEncrypted}`, formData)
35
      .post(`/profile/my-profiles/language/${userIdEncrypted}`, formData)
34
      .then(({ data: response }) => {
36
      .then((response) => {
35
        const { success, data } = response
37
        const { success, data } = response
36
 
38
        if (!success) {
37
        if (!success) {
39
          const errorMessage = data.languages[0]
38
          const errorMessage = data.languages[0]
Línea 45... Línea 44...
45
        dispatch(
44
        dispatch(
46
          addNotification({ style: 'success', msg: 'Registro actualizado' })
45
          addNotification({ style: 'success', msg: 'Registro actualizado' })
47
        )
46
        )
48
        closeModal()
47
        closeModal()
49
      })
48
      })
-
 
49
      .catch((error) => {
-
 
50
        dispatch(addNotification({ style: 'danger', msg: error }))
-
 
51
        throw new Error(error)
-
 
52
      })
50
    setModalLoading(false)
53
      .finally(() => setModalLoading(false))
51
  }
54
  }
Línea 52... Línea 55...
52
 
55
 
53
  useEffect(() => {
56
  useEffect(() => {
54
    register('languages')
57
    register('languages')