Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1627 Rev 1798
Línea 1... Línea 1...
1
import React, { useEffect } from 'react'
1
import React, { useEffect } from 'react'
2
import { InputAdornment, styled } from '@mui/material'
-
 
3
import { Place } from '@mui/icons-material'
2
import { Place } from '@mui/icons-material'
-
 
3
import { InputAdornment, TextField } from '@mui/material'
Línea 4... Línea 4...
4
 
4
 
5
import useLocationAutocomplete from '../../../hooks/useLocationAutocomplete'
-
 
6
 
-
 
7
import InputBase from './InputBase'
-
 
8
import FormErrorFeedback from '../form/FormErrorFeedback'
-
 
9
 
-
 
10
const StyledInput = styled(InputBase)`
-
 
11
  input {
-
 
12
    border: none;
-
 
13
  }
-
 
Línea 14... Línea 5...
14
`
5
import useLocationAutocomplete from '@app/hooks/useLocationAutocomplete'
15
 
6
 
16
const UbicationInput = ({
7
const UbicationInput = ({
17
  onGetAddress = () => {},
8
  onGetAddress = () => {},
18
  settedQuery = '',
9
  settedQuery = '',
-
 
10
  placeholder = 'Ubicación',
19
  placeholder = 'Ubicación',
11
  onChange = () => {},
20
  onChange = () => {}
12
  error = null
Línea 21... Línea 13...
21
}) => {
13
}) => {
22
  const { address, error, ref } = useLocationAutocomplete()
14
  const { address, error: addressError, ref } = useLocationAutocomplete()
23
 
15
 
Línea 24... Línea 16...
24
  useEffect(() => {
16
  useEffect(() => {
25
    onGetAddress(address)
17
    onGetAddress(address)
26
  }, [address])
18
  }, [address])
-
 
19
 
-
 
20
  return (
-
 
21
    <TextField
-
 
22
      type='text'
-
 
23
      inputRef={ref}
-
 
24
      onChange={onChange}
-
 
25
      placeholder={placeholder}
-
 
26
      defaultValue={settedQuery}
27
 
27
      fullWidth
28
  return (
28
      helperText={error || addressError}
29
    <>
29
      error={Boolean(error || addressError)}
30
      <StyledInput
30
      InputProps={{
31
        startAdornment={
31
        startAdornment: (
32
          <InputAdornment position='start'>
-
 
33
            <Place />
-
 
34
          </InputAdornment>
-
 
35
        }
-
 
36
        type='text'
-
 
37
        inputRef={ref}
-
 
38
        onChange={onChange}
32
          <InputAdornment position='start'>
39
        placeholder={placeholder}
-
 
40
        value={settedQuery}
33
            <Place />
41
        fullWidth
34
          </InputAdornment>
42
      />
35
        )
Línea 43... Línea 36...
43
      {error && <FormErrorFeedback>{error}</FormErrorFeedback>}
36
      }}