Skip to content

Commit

Permalink
[admin] don't auto start search on page load
Browse files Browse the repository at this point in the history
  • Loading branch information
svenefftinge committed Oct 4, 2022
1 parent 83cb1c7 commit 3bdb0e2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
7 changes: 4 additions & 3 deletions components/dashboard/src/admin/ProjectsSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ export function ProjectsSearch() {
const [currentProjectOwner, setCurrentProjectOwner] = useState<string | undefined>("");
const pageLength = 50;
const [currentPage, setCurrentPage] = useState(1);
useEffect(() => {
const updateCurrentPage = (page: number) => {
setCurrentPage(page);
search();
}, [currentPage]);
};

useEffect(() => {
const projectId = location.pathname.split("/")[3];
Expand Down Expand Up @@ -139,7 +140,7 @@ export function ProjectsSearch() {
</div>
<Pagination
currentPage={currentPage}
setPage={setCurrentPage}
setPage={updateCurrentPage}
totalNumberOfPages={Math.ceil(searchResult.total / pageLength)}
/>
</>
Expand Down
7 changes: 4 additions & 3 deletions components/dashboard/src/admin/TeamsSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ export function TeamsSearch() {
const [searchResult, setSearchResult] = useState<AdminGetListResult<Team>>({ 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];
Expand Down Expand Up @@ -128,7 +129,7 @@ export function TeamsSearch() {
</div>
<Pagination
currentPage={currentPage}
setPage={setCurrentPage}
setPage={updateCurrentPage}
totalNumberOfPages={Math.ceil(searchResult.total / pageLength)}
/>
</>
Expand Down
7 changes: 4 additions & 3 deletions components/dashboard/src/admin/UserSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ export default function UserSearch() {
const [currentUser, setCurrentUserState] = useState<User | undefined>(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];
Expand Down Expand Up @@ -111,7 +112,7 @@ export default function UserSearch() {
</div>
<Pagination
currentPage={currentPage}
setPage={setCurrentPage}
setPage={updateCurrentPage}
totalNumberOfPages={Math.ceil(searchResult.total / pageLength)}
/>
</PageWithAdminSubMenu>
Expand Down
7 changes: 4 additions & 3 deletions components/dashboard/src/admin/WorkspacesSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ export function WorkspaceSearch(props: Props) {
const [currentWorkspace, setCurrentWorkspaceState] = useState<WorkspaceAndInstance | undefined>(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];
Expand Down Expand Up @@ -161,7 +162,7 @@ export function WorkspaceSearch(props: Props) {
</div>
<Pagination
currentPage={currentPage}
setPage={setCurrentPage}
setPage={updateCurrentPage}
totalNumberOfPages={Math.ceil(searchResult.total / pageLength)}
/>
</>
Expand Down

0 comments on commit 3bdb0e2

Please sign in to comment.