add button search for searching
This commit is contained in:
@ -1,10 +1,22 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { useManageNotificationContext } from '../hooks/useManageNotificationContext';
|
import { useManageNotificationContext } from '../hooks/useManageNotificationContext';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
const ListToolBar = () => {
|
const ListToolBar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog } = useManageNotificationContext();
|
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 (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
@ -16,21 +28,20 @@ const ListToolBar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search users"
|
placeholder="Search users"
|
||||||
value={(table.getColumn('content')?.getFilterValue() as string) ?? ''}
|
value={searchValue}
|
||||||
onChange={(event) => table.getColumn('content')?.setFilterValue(event.target.value)}
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
|
onKeyDown={handleKeydown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
onClick={handleSearch}
|
||||||
// onClick={handleFilterData}
|
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
<KeenIcon icon="magnifier" />
|
||||||
{/* <KeenIcon icon="filter" /> */}
|
</Button>
|
||||||
{/* </Button>
|
</DefaultTooltip>
|
||||||
</DefaultTooltip> */}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -1,24 +1,48 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { useManagePositionContext } from '../hooks';
|
import { useManagePositionContext } from '../hooks';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
const ListToolBar = () => {
|
const ListToolBar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog } = useManagePositionContext();
|
const { handleAddDialog } = useManagePositionContext();
|
||||||
|
const [searchValue, setSearchValue] = useState('');
|
||||||
|
|
||||||
|
const handleSearch = () => {
|
||||||
|
table.getColumn('name')?.setFilterValue(searchValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
<div className="flex flex-wrap gap-2 lg:gap-5 w-full">
|
<div className="flex flex-wrap gap-2 lg:gap-5 w-full">
|
||||||
<div className="flex justify-between w-full items-center">
|
<div className="flex justify-between w-full items-center">
|
||||||
<label className="input input-sm w-1/6">
|
<div className="flex w-[50%] gap-3 items-center">
|
||||||
<KeenIcon icon="magnifier" />
|
<label className="input input-sm w-1/3">
|
||||||
<input
|
<KeenIcon icon="magnifier" />
|
||||||
type="text"
|
<input
|
||||||
placeholder="Search roles"
|
type="text"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
placeholder="Search roles"
|
||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
value={searchValue}
|
||||||
/>
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
</label>
|
onKeyDown={handleKeyDown}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
|
onClick={handleSearch}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -1,10 +1,22 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { useUserContext } from '../hooks';
|
import { useUserContext } from '../hooks';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
const ListToolBar = () => {
|
const ListToolBar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog } = useUserContext();
|
const { handleAddDialog } = useUserContext();
|
||||||
|
const [searchValue, setSearchValue] = useState('');
|
||||||
|
|
||||||
|
const handleSearch = () => {
|
||||||
|
table.getColumn('username')?.setFilterValue(searchValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
@ -16,23 +28,20 @@ const ListToolBar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Username"
|
placeholder="Search Username"
|
||||||
value={(table.getColumn('username')?.getFilterValue() as string) ?? ''}
|
value={searchValue}
|
||||||
onChange={(event) =>
|
onChange={(event) => setSearchValue(event.target.value)}
|
||||||
table.getColumn('username')?.setFilterValue(event.target.value)
|
onKeyDown={handleKeyDown}
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
onClick={handleSearch}
|
||||||
// onClick={handleFilterData}
|
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
<KeenIcon icon="magnifier" />
|
||||||
{/* <KeenIcon icon="filter" />
|
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip> */}
|
</DefaultTooltip>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user