add button search for searching

This commit is contained in:
Raja Oktafrianto
2025-04-16 14:53:40 +07:00
parent d281ff0a9f
commit 2f81da93a9
3 changed files with 72 additions and 28 deletions

View File

@ -1,10 +1,22 @@
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
import { useManageNotificationContext } from '../hooks/useManageNotificationContext';
import { Button } from '@/components/ui/button';
import React, { useState } from 'react';
const ListToolBar = () => {
const { table, reload } = useDataGrid();
const { handleAddDialog } = useManageNotificationContext();
const [searchValue, setSearchValue] = useState('');
const handleKeydown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
handleSearch();
}
};
const handleSearch = () => {
table.getColumn('content')?.setFilterValue(searchValue);
};
return (
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
@ -16,21 +28,20 @@ const ListToolBar = () => {
<input
type="text"
placeholder="Search users"
value={(table.getColumn('content')?.getFilterValue() as string) ?? ''}
onChange={(event) => table.getColumn('content')?.setFilterValue(event.target.value)}
value={searchValue}
onChange={(event) => setSearchValue(event.target.value)}
onKeyDown={handleKeydown}
/>
</label>
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
<DefaultTooltip title={'Search'} placement={'top'}>
<Button
variant="outline"
className="h-7.5 disabled:bg-gray-400"
// disabled={isLoading}
// onClick={handleFilterData}
onClick={handleSearch}
>
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
{/* <KeenIcon icon="filter" /> */}
{/* </Button>
</DefaultTooltip> */}
<KeenIcon icon="magnifier" />
</Button>
</DefaultTooltip>
</div>
<div className="flex gap-3 items-center">
<Button