Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3071 Rev 3694
Línea 1... Línea 1...
1
import React, { useEffect } from 'react'
1
import React, { useEffect } from 'react';
2
import { Place } from '@mui/icons-material'
2
import Place from '@mui/icons-material/Place';
Línea 3... Línea 3...
3
 
3
 
4
import { useLocationAutocomplete } from '@hooks'
4
import { useLocationAutocomplete } from '@hooks';
Línea 5... Línea 5...
5
import Input from './Input'
5
import Input from './Input';
6
 
6
 
7
const UbicationInput = ({
7
const UbicationInput = ({
8
  onGetAddress = () => {},
8
  onGetAddress = () => {},
9
  settedQuery = '',
9
  settedQuery = '',
10
  placeholder = 'Ubicación',
10
  placeholder = 'Ubicación',
11
  onChange = () => {},
11
  onChange = () => {},
12
  error = null
12
  error = null
Línea 13... Línea 13...
13
}) => {
13
}) => {
14
  const { address, error: addressError, ref } = useLocationAutocomplete()
14
  const { address, error: addressError, ref } = useLocationAutocomplete();
15
 
15
 
Línea 16... Línea 16...
16
  useEffect(() => {
16
  useEffect(() => {
17
    onGetAddress(address)
17
    onGetAddress(address);
18
  }, [address])
18
  }, [address]);
19
 
19
 
20
  const handleChangeAddress = (event) => {
20
  const handleChangeAddress = (event) => {
21
    if (!event.target.value) {
21
    if (!event.target.value) {
Línea 22... Línea 22...
22
      const values = {}
22
      const values = {};
23
      Object.keys(address).forEach((key) => (values[key] = ''))
23
      Object.keys(address).forEach((key) => (values[key] = ''));
Línea 24... Línea 24...
24
      onGetAddress(values)
24
      onGetAddress(values);
25
    }
25
    }
26
 
26
 
27
    onChange(event)
27
    onChange(event);
Línea 35... Línea 35...
35
      placeholder={placeholder}
35
      placeholder={placeholder}
36
      defaultValue={settedQuery}
36
      defaultValue={settedQuery}
37
      error={error || addressError}
37
      error={error || addressError}
38
      icon={<Place />}
38
      icon={<Place />}
39
    />
39
    />
40
  )
40
  );
41
}
41
};
Línea 42... Línea 42...
42
 
42