Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6753 Rev 6781
Línea 7... Línea 7...
7
 
7
 
8
import Spinner from '../UI/Spinner'
8
import Spinner from '../UI/Spinner'
9
import UbicationInput from '../../../shared/ubication-input/UbicationInput'
9
import UbicationInput from '../../../shared/ubication-input/UbicationInput'
Línea 10... Línea 10...
10
import FormErrorFeedback from '../UI/FormErrorFeedback'
10
import FormErrorFeedback from '../UI/FormErrorFeedback'
11
 
-
 
12
const LocationModal = ({
-
 
13
  closeModal,
-
 
14
  isModalOpen,
-
 
15
  userIdEncrypted,
-
 
16
  setSettedAddress,
11
 
17
}) => {
12
const LocationModal = ({ onClose, show, id, onComplete }) => {
18
  const [modalLoading, setModalLoading] = useState(false)
13
  const [modalLoading, setModalLoading] = useState(false)
Línea 19... Línea 14...
19
  const labels = useSelector(({ intl }) => intl.labels)
14
  const labels = useSelector(({ intl }) => intl.labels)
Línea 44... Línea 39...
44
  ])
39
  ])
Línea 45... Línea 40...
45
 
40
 
46
  const handleModalOpen = (event) => {
41
  const handleModalOpen = (event) => {
47
    event && event.preventDefault()
42
    event && event.preventDefault()
48
    Object.keys(getValues()).map(([key]) => setValue(key, ''))
43
    Object.keys(getValues()).map(([key]) => setValue(key, ''))
49
    closeModal()
44
    onClose()
Línea 50... Línea 45...
50
  }
45
  }
51
 
46
 
52
  const getAddressHandler = (addresObject) => {
47
  const getAddressHandler = (addresObject) => {
Línea 101... Línea 96...
101
    const formData = new FormData()
96
    const formData = new FormData()
102
    Object.entries(data).map(([key, value]) => {
97
    Object.entries(data).map(([key, value]) => {
103
      formData.append(key, value)
98
      formData.append(key, value)
104
    })
99
    })
105
    await axios
100
    await axios
106
      .post(`/profile/my-profiles/location/${userIdEncrypted}`, formData)
101
      .post(`/profile/my-profiles/location/${id}`, formData)
107
      .then((response) => {
102
      .then((response) => {
108
        const resData = response.data
103
        const resData = response.data
109
        if (resData.success) {
104
        if (resData.success) {
110
          setSettedAddress(resData.data.formatted_address)
105
          onComplete(resData.data.formatted_address)
111
          handleModalOpen()
106
          handleModalOpen()
112
        } else {
107
        } else {
113
          const resError = resData.data
108
          const resError = resData.data
114
          if (resError.constructor.name === 'Object') {
109
          if (resError.constructor.name === 'Object') {
115
            Object.entries(resError).map(([key, value]) => {
110
            Object.entries(resError).map(([key, value]) => {
Línea 136... Línea 131...
136
      required: 'por favor seleccione una ubicación correcta',
131
      required: 'por favor seleccione una ubicación correcta',
137
    })
132
    })
138
  }, [])
133
  }, [])
Línea 139... Línea 134...
139
 
134
 
140
  return (
135
  return (
141
    <Modal show={isModalOpen} onHide={handleModalOpen}>
136
    <Modal show={show} onHide={handleModalOpen}>
142
      <Modal.Header closeButton>
137
      <Modal.Header closeButton>
143
        <Modal.Title>{labels.location}</Modal.Title>
138
        <Modal.Title>{labels.location}</Modal.Title>
144
      </Modal.Header>
139
      </Modal.Header>
145
      <form onSubmit={handleSubmit(onSubmitHandler)}>
140
      <form onSubmit={handleSubmit(onSubmitHandler)}>