From c8d3e60c918dc593fe8333de36ca3cb6b503ddc6 Mon Sep 17 00:00:00 2001 From: balanza Date: Mon, 2 Sep 2024 23:16:04 +0800 Subject: [PATCH] refactor --- .../pages/ActivityLogPage/ActivityLogPage.jsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx b/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx index 9e6114d9c9..c6b0bbbc54 100644 --- a/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx +++ b/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx @@ -65,8 +65,7 @@ function ActivityLogPage() { const [searchParams, setSearchParams] = useSearchParams( resetPaginationToSearchParams(defaultItemsPerPage)() ); - const [activityLog, setActivityLog] = useState([]); - const [activityLogMetadata, setActivityLogMetadata] = useState({}); + const [activityLogResponse, setActivityLogResponse] = useState({ data: [] }); const [isLoading, setLoading] = useState(true); const [activityLogDetailModalOpen, setActivityLogDetailModalOpen] = @@ -80,11 +79,10 @@ function ActivityLogPage() { setLoading(true); const params = searchParamsToAPIParams(searchParams); getActivityLog(params) - .then(({ data: { data = [], ...metadata } = {} }) => { - setActivityLog(data); - setActivityLogMetadata(metadata); + .then(({ data }) => { + setActivityLogResponse(data); }) - .catch(() => setActivityLog([])) + .catch(() => setActivityLogResponse({ data: [] })) .finally(() => { setLoading(false); }); @@ -109,7 +107,7 @@ function ActivityLogPage() { setActivityLogDetailModalOpen(true)} onCloseActivityLogEntryDetails={() => @@ -117,8 +115,8 @@ function ActivityLogPage() { } />