Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4669 | Rev 4675 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
import React from "react";
2
import { useState, useEffect, useRef } from "react";
3
const UbicationInput = (props) => {
4
  const [query, setQuery] = useState("");
5
  const [addresObject, setAddressObject] = useState({});
6
  const autoCompleteRef = useRef(null);
7
  const [error, setError] = useState("");
8
 
1819 steven 9
  const { onGetAddress, settedQuery, placeholder = 'Ubicación' } = props;
1 www 10
 
11
  useEffect(() => {
4664 stevensc 12
    handleScriptLoad(setQuery, autoCompleteRef, setAddressObject, setError);
4671 stevensc 13
  }, [settedQuery]);
4664 stevensc 14
 
15
  useEffect(() => {
1 www 16
    onGetAddress(addresObject, query);
4664 stevensc 17
  }, [addresObject, query]);
1 www 18
 
19
  return (
20
    <React.Fragment>
21
      <input
22
        type="text"
23
        id="location_search"
24
        name="location_search"
25
        className="form-control"
1819 steven 26
        placeholder={placeholder}
1 www 27
        ref={autoCompleteRef}
28
        onChange={(event) => {
29
          setAddressObject({});
30
          setQuery(event.target.value);
31
        }}
32
        value={settedQuery ? settedQuery : query}
33
      />
34
      {/* {error && <FormErrorFeedback>{error}</FormErrorFeedback>} */}
35
    </React.Fragment>
36
  );
37
};
38
 
39
export default UbicationInput;