Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5085 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5085 Rev 5087
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React from 'react'
2
import React from 'react'
3
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
Línea 4... Línea 4...
4
 
4
 
5
export default function SearchList({
-
 
6
    title,
-
 
7
    fetchCallback,
-
 
8
    addTitle = '',
-
 
9
    addCallback = ''
-
 
10
}) {
5
const SearchList = ({ onChange = () => null }) => {
Línea 11... Línea 6...
11
    const { register, getValues } = useForm()
6
  const { register, getValues } = useForm()
12
 
7
 
13
    const handleSearch = () => {
8
  const handleSearch = () => {
14
        const searchValue = getValues('search')
9
    const searchValue = getValues('search')
Línea 15... Línea 10...
15
        if (fetchCallback) setTimeout(() => fetchCallback(searchValue), [500])
10
    if (onChange) setTimeout(() => onChange(searchValue), [500])
16
    }
-
 
17
 
-
 
18
    return (
-
 
19
        <>
-
 
20
            {!!title &&
-
 
21
                <div className="company-title">
-
 
22
                    <div className="section_admin_title_buttons" style={!addTitle ? { width: '100%' } : {}}>
-
 
23
                        <h1
-
 
24
                            className="title"
-
 
25
                            style={!addTitle ? { flex: '1', textAlign: 'center' } : {}}
-
 
26
                        >{title}</h1>
-
 
27
                        {(!!addTitle && !!addCallback) &&
-
 
28
                            <h2 className="title" onClick={addCallback}>
-
 
29
                                {addTitle}
-
 
30
                            </h2>
-
 
31
                        }
-
 
32
                    </div>
11
  }
33
                </div>
12
 
34
            }
13
  return (
35
            <div className="search-box">
14
    <div className="search-box">
36
                <input
15
      <input
37
                    type="text"
16
        type="text"
38
                    name="search"
17
        name="search"
39
                    className="form-control"
18
        className="form-control"
40
                    ref={register}
19
        ref={register}
41
                    onKeyUp={handleSearch}
20
        onKeyUp={handleSearch}
42
                />
21
      />
43
                <button className='btn btn-search'>
-
 
44
                    {LABELS.SEARCH}
22
      <button className='btn btn-search'>
45
                </button>
23
        {LABELS.SEARCH}
46
            </div>
24
      </button>
-
 
25
    </div>
-
 
26
  )