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