Rev 1459 | Rev 1627 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect } from 'react'
import useLocationAutocomplete from '../../../hooks/useLocationAutocomplete'
import InputBase from './InputBase'
import FormErrorFeedback from '../form/FormErrorFeedback'
import { Place } from '@mui/icons-material'
import { InputAdornment } from '@mui/material'
const UbicationInput = ({
onGetAddress = () => {},
settedQuery = '',
placeholder = 'Ubicación',
onChange = () => {}
}) => {
const { address, error, ref } = useLocationAutocomplete()
useEffect(() => {
onGetAddress(address)
}, [address])
return (
<>
<InputBase
startAdornment={
<InputAdornment position='start'>
<Place />
</InputAdornment>
}
type='text'
inputRef={ref}
onChange={onChange}
placeholder={placeholder}
value={settedQuery}
fullWidth
/>
{error && <FormErrorFeedback>{error}</FormErrorFeedback>}
</>
)
}
export default UbicationInput