From 1598fa93b602374dd18b4cf2c1f20977e364b99f Mon Sep 17 00:00:00 2001 From: bcjang Date: Mon, 14 Apr 2025 12:15:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=A1=B0=ED=9A=8C=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=8B=9C=20=EC=9E=90=EB=8F=99=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=95=88=EB=90=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../searchBar/BusinessLogSearchBar.js | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/components/ServiceManage/searchBar/BusinessLogSearchBar.js b/src/components/ServiceManage/searchBar/BusinessLogSearchBar.js index f453349..14fa4f7 100644 --- a/src/components/ServiceManage/searchBar/BusinessLogSearchBar.js +++ b/src/components/ServiceManage/searchBar/BusinessLogSearchBar.js @@ -35,12 +35,12 @@ export const useBusinessLogSearch = (token, initialPageSize, setAlertMsg) => { const [data, setData] = useState(null); useEffect(() => { - // fetchData(searchParams); // 컴포넌트 마운트 시 초기 데이터 로드 - const initialLoad = async () => { - await fetchData(searchParams); - }; + //초기 데이터 로드 안함 + // const initialLoad = async () => { + // await fetchData(searchParams); + // }; - initialLoad(); + // initialLoad(); }, [token]); const fetchData = useCallback(async (params) => { @@ -74,14 +74,18 @@ export const useBusinessLogSearch = (token, initialPageSize, setAlertMsg) => { })); }, []); - const handleSearch = useCallback(async (newParams = {}) => { + const handleSearch = useCallback(async (newParams = {}, executeSearch = true) => { const updatedParams = { ...searchParams, ...newParams, page_no: newParams.page_no || 1 // Reset to first page on new search }; updateSearchParams(updatedParams); - return await fetchData(updatedParams); + + if (executeSearch) { + return await fetchData(updatedParams); + } + return null; }, [searchParams, fetchData]); const handleReset = useCallback(async () => { @@ -105,15 +109,15 @@ export const useBusinessLogSearch = (token, initialPageSize, setAlertMsg) => { }, [initialPageSize, fetchData]); const handlePageChange = useCallback(async (newPage) => { - return await handleSearch({ page_no: newPage }); + return await handleSearch({ page_no: newPage }, true); }, [handleSearch]); const handlePageSizeChange = useCallback(async (newSize) => { - return await handleSearch({ page_size: newSize, page_no: 1 }); + return await handleSearch({ page_size: newSize, page_no: 1 }, true); }, [handleSearch]); const handleOrderByChange = useCallback(async (newOrder) => { - return await handleSearch({ order_by: newOrder }); + return await handleSearch({ order_by: newOrder }, true); }, [handleSearch]); return { @@ -133,13 +137,13 @@ const BusinessLogSearchBar = ({ searchParams, onSearch, onReset }) => { const handleSubmit = event => { event.preventDefault(); - onSearch(searchParams); + onSearch(searchParams, true); }; const searchList = [ <> - onSearch({search_type: e.target.value })}> + onSearch({search_type: e.target.value }, false)}> {userSearchType2.map((data, index) => ( , @@ -185,7 +189,7 @@ const BusinessLogSearchBar = ({ searchParams, onSearch, onReset }) => { placeholder='트랜잭션 ID 입력' value={searchParams.tran_id} width="300px" - onChange={e => onSearch({ tran_id: e.target.value })} + onChange={e => onSearch({ tran_id: e.target.value }, false)} /> , <> @@ -200,7 +204,7 @@ const BusinessLogSearchBar = ({ searchParams, onSearch, onReset }) => { ]; const filterComponent = ( - onSearch({filters: e.target.value })} /> + onSearch({filters: e.target.value }, false)} /> ); return ;