From 3bdb0e262694ea5ca7fa40eb3ee0eb4c91575331 Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Tue, 4 Oct 2022 08:14:36 +0000 Subject: [PATCH] [admin] don't auto start search on page load --- components/dashboard/src/admin/ProjectsSearch.tsx | 7 ++++--- components/dashboard/src/admin/TeamsSearch.tsx | 7 ++++--- components/dashboard/src/admin/UserSearch.tsx | 7 ++++--- components/dashboard/src/admin/WorkspacesSearch.tsx | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/components/dashboard/src/admin/ProjectsSearch.tsx b/components/dashboard/src/admin/ProjectsSearch.tsx index 37960e1d990810..bd5d19ca99a84e 100644 --- a/components/dashboard/src/admin/ProjectsSearch.tsx +++ b/components/dashboard/src/admin/ProjectsSearch.tsx @@ -32,9 +32,10 @@ export function ProjectsSearch() { const [currentProjectOwner, setCurrentProjectOwner] = useState(""); const pageLength = 50; const [currentPage, setCurrentPage] = useState(1); - useEffect(() => { + const updateCurrentPage = (page: number) => { + setCurrentPage(page); search(); - }, [currentPage]); + }; useEffect(() => { const projectId = location.pathname.split("/")[3]; @@ -139,7 +140,7 @@ export function ProjectsSearch() { diff --git a/components/dashboard/src/admin/TeamsSearch.tsx b/components/dashboard/src/admin/TeamsSearch.tsx index 33230c5da35521..5924c8b2e32031 100644 --- a/components/dashboard/src/admin/TeamsSearch.tsx +++ b/components/dashboard/src/admin/TeamsSearch.tsx @@ -32,9 +32,10 @@ export function TeamsSearch() { const [searchResult, setSearchResult] = useState>({ total: 0, rows: [] }); const pageLength = 50; const [currentPage, setCurrentPage] = useState(1); - useEffect(() => { + const updateCurrentPage = (page: number) => { + setCurrentPage(page); search(); - }, [currentPage]); + }; useEffect(() => { const teamId = location.pathname.split("/")[3]; @@ -128,7 +129,7 @@ export function TeamsSearch() { diff --git a/components/dashboard/src/admin/UserSearch.tsx b/components/dashboard/src/admin/UserSearch.tsx index 3d3a5f20d6e880..89fd7119ebe6ce 100644 --- a/components/dashboard/src/admin/UserSearch.tsx +++ b/components/dashboard/src/admin/UserSearch.tsx @@ -22,9 +22,10 @@ export default function UserSearch() { const [currentUser, setCurrentUserState] = useState(undefined); const pageLength = 50; const [currentPage, setCurrentPage] = useState(1); - useEffect(() => { + const updateCurrentPage = (page: number) => { + setCurrentPage(page); search(); - }, [currentPage]); + }; useEffect(() => { const userId = location.pathname.split("/")[3]; @@ -111,7 +112,7 @@ export default function UserSearch() { diff --git a/components/dashboard/src/admin/WorkspacesSearch.tsx b/components/dashboard/src/admin/WorkspacesSearch.tsx index 8677c2ebb8a615..9d56c1d3375eb5 100644 --- a/components/dashboard/src/admin/WorkspacesSearch.tsx +++ b/components/dashboard/src/admin/WorkspacesSearch.tsx @@ -47,9 +47,10 @@ export function WorkspaceSearch(props: Props) { const [currentWorkspace, setCurrentWorkspaceState] = useState(undefined); const pageLength = 50; const [currentPage, setCurrentPage] = useState(1); - useEffect(() => { + const updateCurrentPage = (page: number) => { + setCurrentPage(page); search(); - }, [currentPage]); + }; useEffect(() => { const workspaceId = location.pathname.split("/")[3]; @@ -161,7 +162,7 @@ export function WorkspaceSearch(props: Props) {