From 2f81da93a998c25d6f2c47ef3c5230c78d8f7d22 Mon Sep 17 00:00:00 2001 From: Raja Oktafrianto Date: Wed, 16 Apr 2025 14:53:40 +0700 Subject: [PATCH] add button search for searching --- src/pages/notification/blocks/ListToolbar.tsx | 29 +++++++++---- .../manage-position/blocks/ListToolBar.tsx | 42 +++++++++++++++---- .../user/manage-user/blocks/ListToolBar.tsx | 29 ++++++++----- 3 files changed, 72 insertions(+), 28 deletions(-) diff --git a/src/pages/notification/blocks/ListToolbar.tsx b/src/pages/notification/blocks/ListToolbar.tsx index 5ca290f..2f4c918 100644 --- a/src/pages/notification/blocks/ListToolbar.tsx +++ b/src/pages/notification/blocks/ListToolbar.tsx @@ -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 (
@@ -16,21 +28,20 @@ const ListToolBar = () => { table.getColumn('content')?.setFilterValue(event.target.value)} + value={searchValue} + onChange={(event) => setSearchValue(event.target.value)} + onKeyDown={handleKeydown} /> - {/* + - */} + + +
+ +
- */} +