Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6694 Rev 6991
Línea 1... Línea 1...
1
import React, { useRef, useState } from 'react'
1
import React, { useEffect } from 'react'
2
import { useForm } from 'react-hook-form'
2
import { useForm } from 'react-hook-form'
3
import SearchIcon from '@mui/icons-material/Search'
3
import { useHistory } from 'react-router-dom'
Línea 4... Línea 4...
4
 
4
 
Línea 5... Línea 5...
5
import useWindowSize from '../../../../hooks/useWindowSize'
5
import SearchInput from '../../../UI/SearchInput'
6
 
-
 
7
const NavSearch = () => {
6
 
Línea 8... Línea -...
8
  const [showMobileSearch, setShowMobileSearch] = useState(false)
-
 
9
  const searchInput = useRef(null)
7
const NavSearch = () => {
Línea 10... Línea -...
10
 
-
 
11
  const [innerWidth] = useWindowSize()
-
 
12
  const { handleSubmit, register } = useForm()
-
 
13
 
-
 
14
  const toggleSearch = () => {
8
  const history = useHistory()
15
    setShowMobileSearch(!showMobileSearch)
9
 
16
  }
10
  const { handleSubmit, register, setValue } = useForm()
Línea -... Línea 11...
-
 
11
 
-
 
12
  const onSubmit = handleSubmit(({ keyword }) => {
-
 
13
    history.replace(`/search/entity/user?keyword=${keyword}`)
-
 
14
  })
17
 
15
 
18
  const onSubmit = handleSubmit((data) => {
16
  useEffect(() => {
19
    window.location.replace(`/search/entity/user?keyword=${data.keyword}`)
17
    register('keyword', { required: true })
20
  })
-
 
21
 
18
  }, [])
22
  return (
19
 
23
    <form
20
  return (
24
      className="header__search show"
-
 
25
      onClick={innerWidth < 992 && toggleSearch}
-
 
26
      onSubmit={onSubmit}
-
 
27
      ref={searchInput}
21
    <SearchInput
28
    >
22
      forwardedAs="form"
Línea 29... Línea 23...
29
      <SearchIcon />
23
      onSubmit={onSubmit}