Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4675 Rev 6551
Línea 1... Línea -...
1
/* eslint-disable react/prop-types */
-
 
2
import React from "react";
-
 
3
import { useState, useEffect, useRef } from "react";
1
import React, { useState, useEffect, useRef } from 'react'
4
import FormErrorFeedback from "../form-error-feedback/FormErrorFeedback";
2
import FormErrorFeedback from '../form-error-feedback/FormErrorFeedback'
Línea -... Línea 3...
-
 
3
 
-
 
4
const UbicationInput = ({
-
 
5
  onGetAddress,
5
 
6
  settedQuery,
-
 
7
  placeholder = 'Ubicación',
6
const UbicationInput = ({ onGetAddress, settedQuery, placeholder = 'Ubicación' }) => {
8
}) => {
7
  const [addresObject, setAddressObject] = useState({});
9
  const [addresObject, setAddressObject] = useState({})
8
  const [query, setQuery] = useState("");
10
  const [query, setQuery] = useState('')
9
  const [error, setError] = useState("");
11
  const [error, setError] = useState('')
Línea 10... Línea 12...
10
  const autoCompleteRef = useRef(null);
12
  const autoCompleteRef = useRef(null)
11
 
13
 
12
  useEffect(() => {
14
  useEffect(() => {
Línea 13... Línea 15...
13
    handleScriptLoad(setQuery, autoCompleteRef, setAddressObject, setError);
15
    handleScriptLoad(setQuery, autoCompleteRef, setAddressObject, setError)
14
  }, []);
16
  }, [])
15
 
17
 
Línea 16... Línea 18...
16
  useEffect(() => {
18
  useEffect(() => {
17
    onGetAddress(addresObject, query);
19
    onGetAddress(addresObject, query)
18
  }, [addresObject]);
20
  }, [addresObject])
19
 
21
 
Línea 25... Línea 27...
25
        name="location_search"
27
        name="location_search"
26
        className="form-control"
28
        className="form-control"
27
        placeholder={placeholder}
29
        placeholder={placeholder}
28
        ref={autoCompleteRef}
30
        ref={autoCompleteRef}
29
        onChange={(event) => {
31
        onChange={(event) => {
30
          setAddressObject({});
32
          setAddressObject({})
31
          setQuery(event.target.value);
33
          setQuery(event.target.value)
32
        }}
34
        }}
33
        value={settedQuery ? settedQuery : query}
35
        value={settedQuery || query}
34
      />
36
      />
35
      {error && <FormErrorFeedback>{error}</FormErrorFeedback>}
37
      {error && <FormErrorFeedback>{error}</FormErrorFeedback>}
36
    </React.Fragment>
38
    </React.Fragment>
37
  );
39
  )
38
};
40
}
Línea 39... Línea 41...
39
 
41