Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2298 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1587 steven 1
import React from 'react'
2
import { useForm } from "react-hook-form"
3
 
4
export default function SearchList({title, fetchCallback, addTitle='', addCallback=''}) {
5
    const { register, getValues } = useForm();
6
    const handleSearch = () => {
7
        const searchValue = getValues("search");
8
        if(fetchCallback){
9
            setTimeout(() => {
10
                fetchCallback(searchValue);
11
            }, [500])
12
        }
13
    };
14
    return (
15
        <>
16
            {
17
                !!title && (
18
                    <div className="company-title">
19
                        <div className="section_admin_title_buttons">
20
                            <div style={{ float: "left" }}>
21
                                <h1 className="title"> {title} </h1>
22
                            </div>
23
                            {
24
                                !!addTitle && !!addCallback && (
25
                                    <div style={{ float: "right" }}>
26
                                        <button
27
                                            type="button"
28
                                            className="btn btn-primary btn-add"
29
                                            onClick={(e) => {
30
                                                e.preventDefault();
31
                                                addCallback();
32
                                            }}
33
                                        >
34
                                            {addTitle}
35
                                        </button>
36
                                    </div>
37
                                )
38
                            }
39
                        </div>
40
                    </div>
41
                )
42
            }
43
 
44
            <div className="company-title">
45
                <div className="section_admin_title_buttons">
46
                    <div className="form-group">
47
                        <input
48
                            type="text"
49
                            name="search"
50
                            id="search"
51
                            className="form-control"
52
                            placeholder="Buscar"
53
                            ref={register}
54
                            onKeyUp={handleSearch}
55
                        />
56
                    </div>
57
                </div>
58
            </div>
59
        </>
60
    )
61
}