Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6828 Rev 6829
Línea 1... Línea 1...
1
import React, { useState, useEffect } from 'react'
1
import React, { useState, useEffect } from 'react'
2
import { axios } from '../../utils'
2
import { axios } from '../../utils'
3
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
4
import { useParams } from 'react-router-dom'
4
import { useLocation, useParams } from 'react-router-dom'
5
import { useDispatch, useSelector } from 'react-redux'
5
import { useDispatch, useSelector } from 'react-redux'
6
import { Button, Modal } from 'react-bootstrap'
6
import { Button, Modal } from 'react-bootstrap'
7
import { addNotification } from '../../redux/notification/notification.actions'
7
import { addNotification } from '../../redux/notification/notification.actions'
Línea 8... Línea 8...
8
 
8
 
Línea 11... Línea 11...
11
import FormErrorFeedback from '../UI/FormErrorFeedback'
11
import FormErrorFeedback from '../UI/FormErrorFeedback'
Línea 12... Línea 12...
12
 
12
 
13
const CoverModal = ({ isOpen, sizes, onClose, onComplete }) => {
13
const CoverModal = ({ isOpen, sizes, onClose, onComplete }) => {
14
  const [loading, setLoading] = useState(false)
14
  const [loading, setLoading] = useState(false)
-
 
15
  const { uuid } = useParams()
15
  const { uuid } = useParams()
16
  const { pathname } = useLocation()
16
  const labels = useSelector(({ intl }) => intl.labels)
17
  const labels = useSelector(({ intl }) => intl.labels)
Línea 17... Línea 18...
17
  const dispatch = useDispatch()
18
  const dispatch = useDispatch()
18
 
19
 
19
  const typesUrl = {
20
  const typesUrl = {
20
    user: `/profile/my-profiles/cover/${uuid}/operation/upload`,
21
    profile: `/profile/my-profiles/cover/${uuid}/operation/upload`,
21
    company: `/my-company/${uuid}/profile/cover/upload`,
22
    company: `/my-company/${uuid}/profile/cover/upload`,
Línea 22... Línea 23...
22
    group: `/group/my-groups/cover/${uuid}/operation/upload`,
23
    group: `/group/my-groups/cover/${uuid}/operation/upload`,
Línea 33... Línea 34...
33
  const onSubmitHandler = ({ cover }) => {
34
  const onSubmitHandler = ({ cover }) => {
34
    setLoading(true)
35
    setLoading(true)
Línea 35... Línea 36...
35
 
36
 
36
    const formData = new FormData()
37
    const formData = new FormData()
37
    formData.append('cover', cover)
38
    formData.append('cover', cover)
38
    const type = window.location.pathname.split('/')[1]
-
 
39
 
-
 
Línea 40... Línea 39...
40
    console.log(type)
39
    const type = pathname.split('/')[1]
41
 
40
 
42
    axios
41
    axios
43
      .post(typesUrl.user, formData)
42
      .post(typesUrl[type], formData)
Línea 44... Línea 43...
44
      .then(({ data: response }) => {
43
      .then(({ data: response }) => {
45
        const { data, success } = response
44
        const { data, success } = response