diff --git a/src/pages/notification/blocks/AddDialog.tsx b/src/pages/notification/blocks/AddDialog.tsx index 2b5778e..29063ea 100644 --- a/src/pages/notification/blocks/AddDialog.tsx +++ b/src/pages/notification/blocks/AddDialog.tsx @@ -65,15 +65,15 @@ const AddDialog = () => { const doCreateNotification = async (e: React.FormEvent) => { e.preventDefault(); - const payload = { - ...formField, - subject: - formField.subject.trim() === '' && formField.via === 'sms' - ? 'SMS Notification' - : formField.subject - }; + // const payload = { + // ...formField, + // subject: + // formField.subject.trim() === '' && formField.via === 'sms' + // ? 'SMS Notification' + // : formField.subject + // }; - const response = await PostData(`${API_URL_NOTIFICATION}/send`, payload); + const response = await PostData(`${API_URL_NOTIFICATION}/send`, formField); // console.log('send response :', response); if (response?.status) { diff --git a/src/pages/notification/blocks/ListToolbar.tsx b/src/pages/notification/blocks/ListToolbar.tsx index 823454b..4406253 100644 --- a/src/pages/notification/blocks/ListToolbar.tsx +++ b/src/pages/notification/blocks/ListToolbar.tsx @@ -1,10 +1,34 @@ import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components'; import { useManageNotificationContext } from '../hooks/useManageNotificationContext'; import { Button } from '@/components/ui/button'; +import { useEffect, useState } from 'react'; const ListToolBar = () => { const { table, reload } = useDataGrid(); const { handleAddDialog } = useManageNotificationContext(); + const [searchValue, setSearchValue] = useState( + (table.getColumn('content')?.getFilterValue() as string) ?? '' + ); + + const handleKeyDown = (event: React.KeyboardEvent) => { + if (event.key === 'Enter') { + handleSearch(); + } + }; + + const handleSearch = () => { + table.getColumn('content')?.setFilterValue(searchValue); + table.setPageIndex(0); + }; + + useEffect(() => { + const timer = setTimeout(() => { + table.getColumn('content')?.setFilterValue(searchValue); + table.setPageIndex(0); + }, 200); + + return () => clearTimeout(timer); + }, [searchValue, table]); return (
@@ -16,8 +40,8 @@ const ListToolBar = () => { table.getColumn('content')?.setFilterValue(event.target.value)} + value={searchValue} + onChange={(event) => setSearchValue(event.target.value)} /> {/* diff --git a/src/pages/settings/user/manage-position/blocks/ListToolBar.tsx b/src/pages/settings/user/manage-position/blocks/ListToolBar.tsx index 156a507..3ee35a7 100644 --- a/src/pages/settings/user/manage-position/blocks/ListToolBar.tsx +++ b/src/pages/settings/user/manage-position/blocks/ListToolBar.tsx @@ -1,11 +1,33 @@ import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components'; import { useManagePositionContext } from '../hooks'; import { Button } from '@/components/ui/button'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; const ListToolBar = () => { const { table, reload } = useDataGrid(); const { handleAddDialog } = useManagePositionContext(); + const [searchValue, setSearchValue] = useState( + (table.getColumn('name')?.getFilterValue() as string) ?? '' + ); + + const handleKeyDown = (event: React.KeyboardEvent) => { + if (event.key === 'Enter') { + handleSearch(); + } + }; + + const handleSearch = () => { + table.getColumn('username')?.setFilterValue(searchValue); + table.setPageIndex(0); + }; + + useEffect(() => { + const timer = setTimeout(() => { + table.getColumn('username')?.setFilterValue(searchValue); + table.setPageIndex(0); + }, 200); + return () => clearTimeout(timer); + }, [searchValue, table]); return (
@@ -17,8 +39,8 @@ const ListToolBar = () => { table.getColumn('name')?.setFilterValue(event.target.value)} + value={searchValue} + onChange={(event) => setSearchValue(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 a884d14..ae55333 100644 --- a/src/pages/settings/user/manage-user/blocks/ListToolBar.tsx +++ b/src/pages/settings/user/manage-user/blocks/ListToolBar.tsx @@ -1,10 +1,33 @@ import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components'; import { useUserContext } from '../hooks'; import { Button } from '@/components/ui/button'; +import { useEffect, useState } from 'react'; const ListToolBar = () => { const { table, reload } = useDataGrid(); const { handleAddDialog } = useUserContext(); + const [searchValue, setSearchValue] = useState( + (table.getColumn('username')?.getFilterValue() as string) ?? '' + ); + + const handleKeyDown = (event: React.KeyboardEvent) => { + if (event.key === 'Enter') { + handleSearch(); + } + }; + + const handleSearch = () => { + table.getColumn('username')?.setFilterValue(searchValue); + table.setPageIndex(0); + }; + + useEffect(() => { + const timer = setTimeout(() => { + table.getColumn('username')?.setFilterValue(searchValue); + table.setPageIndex(0); + }, 200); + return () => clearTimeout(timer); + }, [searchValue, table]); return (
@@ -16,10 +39,8 @@ const ListToolBar = () => { - table.getColumn('username')?.setFilterValue(event.target.value) - } + value={searchValue} + onChange={(event) => setSearchValue(event.target.value)} /> {/*