From 3034886eef14053a3d4dc8dd0213999d10fc79a6 Mon Sep 17 00:00:00 2001 From: Raja Oktafrianto Date: Thu, 17 Apr 2025 11:14:53 +0700 Subject: [PATCH] update search --- src/pages/notification/blocks/ListToolbar.tsx | 23 ++++--------------- .../manage-position/blocks/ListToolBar.tsx | 20 ++++------------ .../user/manage-user/blocks/ListToolBar.tsx | 23 +++++-------------- 3 files changed, 15 insertions(+), 51 deletions(-) diff --git a/src/pages/notification/blocks/ListToolbar.tsx b/src/pages/notification/blocks/ListToolbar.tsx index 2f4c918..823454b 100644 --- a/src/pages/notification/blocks/ListToolbar.tsx +++ b/src/pages/notification/blocks/ListToolbar.tsx @@ -1,22 +1,10 @@ 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 (
@@ -27,13 +15,12 @@ const ListToolBar = () => { setSearchValue(event.target.value)} - onKeyDown={handleKeydown} + placeholder="Search notifications" + value={table.getColumn(`content`)?.getFilterValue() as string} + onChange={(event) => table.getColumn('content')?.setFilterValue(event.target.value)} /> - + {/* - + */}
- + */}
diff --git a/src/pages/settings/user/manage-user/blocks/ListToolBar.tsx b/src/pages/settings/user/manage-user/blocks/ListToolBar.tsx index daa8cec..a884d14 100644 --- a/src/pages/settings/user/manage-user/blocks/ListToolBar.tsx +++ b/src/pages/settings/user/manage-user/blocks/ListToolBar.tsx @@ -1,22 +1,10 @@ import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components'; import { useUserContext } from '../hooks'; import { Button } from '@/components/ui/button'; -import React, { useState } from 'react'; const ListToolBar = () => { const { table, reload } = useDataGrid(); 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 (
@@ -28,12 +16,13 @@ const ListToolBar = () => { setSearchValue(event.target.value)} - onKeyDown={handleKeyDown} + value={table.getColumn(`username`)?.getFilterValue() as string} + onChange={(event) => + table.getColumn('username')?.setFilterValue(event.target.value) + } /> - + {/* - + */}