From 35259e9cdd034f14099bf93a61245883a31478d0 Mon Sep 17 00:00:00 2001 From: Jason Chuang Date: Tue, 14 Apr 2026 22:09:44 +0800 Subject: [PATCH] fix audit log search and export criteria bug --- src/pages/AuditLog/AuditLogSearchForm.js | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/pages/AuditLog/AuditLogSearchForm.js b/src/pages/AuditLog/AuditLogSearchForm.js index 27fa580..ddb2437 100644 --- a/src/pages/AuditLog/AuditLogSearchForm.js +++ b/src/pages/AuditLog/AuditLogSearchForm.js @@ -43,7 +43,7 @@ const AuditLogSearchForm = ({ applySearch, searchCriteria, onGridReady}) => { const marginBottom = 2.5; - const { reset, register, handleSubmit } = useForm() + const { reset, register, handleSubmit, getValues } = useForm() React.useEffect(() => { setFromDateValue(minDate); @@ -53,21 +53,26 @@ const AuditLogSearchForm = ({ applySearch, searchCriteria, onGridReady}) => { setToDateValue(maxDate); }, [maxDate]); - const onSubmit = (data) => { + /** Same filter fields as the list API; must reflect current form/UI state (not parent `searchCriteria`). */ + const getCurrentFilterParams = () => { let sentDateFrom = ""; let sentDateTo = ""; - if (fromDateValue != "dd / mm / yyyy" && toDateValue != "dd / mm / yyyy") { - sentDateFrom = DateUtils.dateValue(fromDateValue) - sentDateTo = DateUtils.dateValue(toDateValue) + sentDateFrom = DateUtils.dateValue(fromDateValue); + sentDateTo = DateUtils.dateValue(toDateValue); } - - const temp = { - username: data.userName, + return { + username: getValues("userName"), modifiedTo: sentDateTo, modifiedFrom: sentDateFrom, - start:0, - limit:10 + }; + }; + + const onSubmit = () => { + const temp = { + ...getCurrentFilterParams(), + start: 0, + limit: 10, }; applySearch(temp); }; @@ -81,7 +86,7 @@ const AuditLogSearchForm = ({ applySearch, searchCriteria, onGridReady}) => { setOnDownload(true) HttpUtils.fileDownload({ url: UrlUtils.AUDIT_LOG_EXPORT, - params: searchCriteria, + params: getCurrentFilterParams(), onResponse:()=>{ setOnDownload(false) },