Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2309 | Rev 3517 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React from 'react'
import { useForm } from "react-hook-form"

export default function SearchList({ title, fetchCallback, addTitle = '', addCallback = '' }) {
    const { register, getValues } = useForm();
    const handleSearch = () => {
        const searchValue = getValues("search");
        if (fetchCallback) {
            setTimeout(() => {
                fetchCallback(searchValue);
            }, [500])
        }
    };
    return (
        <>
            {
                !!title && (
                    <div className="company-title">
                        <div
                            className="section_admin_title_buttons"
                            style={!addTitle ? { width: '100%' } : {}}
                        >
                            <h1
                                className="title"
                                style={!addTitle ? { flex: '1', textAlign: 'center' } : {}}
                            >{title}</h1>
                            {
                                (!!addTitle && !!addCallback)
                                &&
                                <h2 className="title" onClick={addCallback}>
                                    {addTitle}
                                </h2>
                            }
                        </div>
                    </div>
                )
            }
            <div className="company-title">
                <div className="search-box border-gray border-radius">
                    <div className="form-group">
                        <input
                            type="text"
                            name="search"
                            id="search"
                            className="form-control"
                            placeholder="Buscar"
                            ref={register}
                            onKeyUp={handleSearch}
                        />
                    </div>
                </div>
            </div>
        </>
    )
}