adding button on search on masterdata
This commit is contained in:
@ -1,10 +1,24 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { useManageProductsContext } from '../hooks/useManageProductsContext';
|
import { useManageProductsContext } from '../hooks/useManageProductsContext';
|
||||||
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 } = useManageProductsContext();
|
const { handleAddDialog } = useManageProductsContext();
|
||||||
|
const[searchProduct, setSearchProduct] = useState('');
|
||||||
|
|
||||||
|
|
||||||
|
const handleSearch = ()=>{
|
||||||
|
table.getColumn('name')?.setFilterValue(searchProduct);
|
||||||
|
table.setPageIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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,10 +30,16 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Products"
|
placeholder="Search Products"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={ searchProduct}
|
||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => setSearchProduct(event.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
|
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip>
|
||||||
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@ -37,6 +57,7 @@ const ListToolbar = () => {
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 text-[0.8rem]"
|
className="h-7.5 text-[0.8rem]"
|
||||||
onClick={() => handleAddDialog(true)}
|
onClick={() => handleAddDialog(true)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
>
|
>
|
||||||
Add Data
|
Add Data
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -231,7 +231,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
headerClassName: 'w-[100px]',
|
headerClassName: 'w-[100px] text-center',
|
||||||
cellClassName: 'text-center'
|
cellClassName: 'text-center'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,27 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { useManageProfessionContext } from '../hooks/useManageProfessionContext';
|
import { useManageProfessionContext } from '../hooks/useManageProfessionContext';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { set } from 'date-fns';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { reload, table } = useDataGrid();
|
const { reload, table } = useDataGrid();
|
||||||
const { handleAddDialog } = useManageProfessionContext();
|
const { handleAddDialog } = useManageProfessionContext();
|
||||||
|
const [searchProfession, setSearchProfession]= useState('');
|
||||||
|
|
||||||
|
const handleKeyDown = (event: React.KeyboardEvent) =>{
|
||||||
|
if(event.key==='Enter'){
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSearch = () =>{
|
||||||
|
table.getColumn('name')?.setFilterValue(searchProfession);
|
||||||
|
table.setPageIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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,12 +33,18 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Profession"
|
placeholder="Search Profession"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={searchProfession}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
table.getColumn('name')?.setFilterValue(event.target.value)
|
setSearchProfession(event.target.value)
|
||||||
}
|
}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
|
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip>
|
||||||
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@ -102,7 +102,7 @@ const ManageProfessionContextProvider = ({ children }: { children: React.ReactNo
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
headerClassName: 'w-[100px]',
|
headerClassName: 'w-[100px] text-center',
|
||||||
cellClassName: 'text-center'
|
cellClassName: 'text-center'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ const ManageProfessionContextProvider = ({ children }: { children: React.ReactNo
|
|||||||
pagination={{ size: 10 }}
|
pagination={{ size: 10 }}
|
||||||
toolbar={<ListToolbar />}
|
toolbar={<ListToolbar />}
|
||||||
layout={{ card: true }}
|
layout={{ card: true }}
|
||||||
sorting={[{ id: 'id', desc: false }]}
|
sorting={[{ id: 'name', desc: false }]}
|
||||||
serverSide={true}
|
serverSide={true}
|
||||||
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
||||||
getProfessionLists(pageIndex, pageSize, sorting, columnFilters)
|
getProfessionLists(pageIndex, pageSize, sorting, columnFilters)
|
||||||
|
|||||||
@ -1,10 +1,23 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { useManageProviderContext } from '../hooks/useManageProviderContext';
|
import { useManageProviderContext } from '../hooks/useManageProviderContext';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { reload, table } = useDataGrid();
|
const { reload, table } = useDataGrid();
|
||||||
const { handleAddDialog } = useManageProviderContext();
|
const { handleAddDialog } = useManageProviderContext();
|
||||||
|
const [searchProvider, setSearchProvider] = useState('');
|
||||||
|
|
||||||
|
const handleSearch = () =>{
|
||||||
|
table.getColumn('name')?.setFilterValue(searchProvider);
|
||||||
|
table.setPageIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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,12 +29,18 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Provider"
|
placeholder="Search Provider"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={searchProvider}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
table.getColumn('name')?.setFilterValue(event.target.value)
|
setSearchProvider(event.target.value)
|
||||||
}
|
}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
|
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip>
|
||||||
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@ -129,7 +129,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
headerClassName: 'w-[100px]',
|
headerClassName: 'w-[100px] text-center',
|
||||||
cellClassName: 'text-center'
|
cellClassName: 'text-center'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -158,7 +158,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
headerClassName: 'w-[100px]',
|
headerClassName: 'w-[100px] text-center',
|
||||||
cellClassName: 'text-center'
|
cellClassName: 'text-center'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,23 @@
|
|||||||
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useManageRewardContext } from '../hooks/useManageRewardContext';
|
import { useManageRewardContext } from '../hooks/useManageRewardContext';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
const ListToolbar = () => {
|
const ListToolbar = () => {
|
||||||
const { table, reload } = useDataGrid();
|
const { table, reload } = useDataGrid();
|
||||||
const { handleAddDialog } = useManageRewardContext();
|
const { handleAddDialog } = useManageRewardContext();
|
||||||
|
const [searchReward, setSearchReward] = useState('');
|
||||||
|
|
||||||
|
const handleSearch = () =>{
|
||||||
|
table.getColumn('name')?.setFilterValue(searchReward);
|
||||||
|
table.setPageIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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,10 +29,16 @@ const ListToolbar = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search Reward"
|
placeholder="Search Reward"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={searchReward}
|
||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => setSearchReward(event.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<DefaultTooltip title={'Search'} placement={'top'}>
|
||||||
|
<Button variant="outline" className="h-7.5" onClick={handleSearch}>
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -110,7 +110,8 @@ const ManageRewardContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
headerClassName: 'w-[250px]'
|
headerClassName: 'w-[250px] text-center',
|
||||||
|
cellClassName: 'text-center'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -138,7 +139,7 @@ const ManageRewardContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
heaaderClassName: 'w-[100px]',
|
headerClassName: 'w-[100px] text-center',
|
||||||
cellClassName: 'text-center'
|
cellClassName: 'text-center'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user