mirror of
https://github.com/fleetdm/fleet
synced 2026-05-14 20:48:35 +00:00
* all login methods no longer use redux * removed redux from registration * redirect user from registration * removed redux from sso invite * removed redundant component * refactored user settings page * removed redux from logout * cleaned up unused redux calls * lint fixes * removed test * removed old config interface * fixed registration bug * team permission fix * removed remaining redux references from pages - #4436 * better way to set config
38 lines
897 B
TypeScript
38 lines
897 B
TypeScript
import React, { useState } from "react";
|
|
import { useDebouncedCallback } from "use-debounce";
|
|
// @ts-ignore
|
|
import InputField from "../InputField";
|
|
|
|
const baseClass = "search-field";
|
|
|
|
export interface ISearchFieldProps {
|
|
placeholder: string;
|
|
onChange: (value: string) => void;
|
|
}
|
|
|
|
const SearchField = ({
|
|
placeholder,
|
|
onChange,
|
|
}: ISearchFieldProps): JSX.Element => {
|
|
const [searchQueryInput, setSearchQueryInput] = useState("");
|
|
|
|
const debouncedOnChange = useDebouncedCallback((newValue: string) => {
|
|
onChange(newValue);
|
|
}, 500);
|
|
|
|
const onInputChange = (newValue: string): void => {
|
|
setSearchQueryInput(newValue);
|
|
debouncedOnChange(newValue);
|
|
};
|
|
|
|
return (
|
|
<InputField
|
|
placeholder={placeholder}
|
|
value={searchQueryInput}
|
|
inputWrapperClass={`${baseClass}__input-wrapper`}
|
|
onChange={onInputChange}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default SearchField;
|