Skip to content

Commit be138e9

Browse files
committed
chore: clean up
1 parent 7de59be commit be138e9

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,18 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
7676
enabled: isOrg ? canReadAPIKeys : true,
7777
});
7878

79-
const { startingRow, endingRow, invalidateAll } = useAPIKeysPagination({
79+
const { invalidateAll } = useAPIKeysPagination({
8080
query,
8181
page,
8282
pageCount,
83-
itemCount,
8483
isFetching,
85-
perPage: perPage ?? 5,
8684
subject,
8785
fetchPage,
8886
});
8987

88+
const startingRow = itemCount > 0 ? Math.max(0, (page - 1) * (perPage ?? 5)) + 1 : 0;
89+
const endingRow = Math.min(page * (perPage ?? 5), itemCount);
90+
9091
const handlePageChange = (newPage: number) => {
9192
fetchPage(newPage);
9293
};

packages/clerk-js/src/ui/components/ApiKeys/utils.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { useCallback, useEffect, useMemo, useRef } from 'react';
1+
import { useCallback, useEffect, useRef } from 'react';
22
import { useSWRConfig } from 'swr';
33

44
type UseApiKeysPaginationParams = {
55
query: string;
66
page: number;
77
pageCount: number;
8-
itemCount: number;
98
isFetching: boolean;
10-
perPage: number;
119
subject: string;
1210
fetchPage: (page: number) => void;
1311
};
@@ -16,16 +14,13 @@ type UseApiKeysPaginationParams = {
1614
* Hook that manages pagination logic for API keys:
1715
* - Resets to page 1 when query changes
1816
* - Adjusts page when current page exceeds available pages (e.g., after deletion)
19-
* - Calculates row information for pagination display
2017
* - Provides cache invalidation function for mutations
2118
*/
2219
export const useAPIKeysPagination = ({
2320
query,
2421
page,
2522
pageCount,
26-
itemCount,
2723
isFetching,
28-
perPage,
2924
subject,
3025
fetchPage,
3126
}: UseApiKeysPaginationParams) => {
@@ -60,21 +55,7 @@ export const useAPIKeysPagination = ({
6055
}
6156
}, [pageCount, page, isFetching, fetchPage]);
6257

63-
// Calculate row info for pagination display
64-
const startingRow = useMemo(() => {
65-
if (itemCount === 0) {
66-
return 0;
67-
}
68-
return (page - 1) * perPage + 1;
69-
}, [itemCount, page, perPage]);
70-
71-
const endingRow = useMemo(() => {
72-
return Math.min(page * perPage, itemCount);
73-
}, [page, perPage, itemCount]);
74-
7558
return {
76-
startingRow,
77-
endingRow,
7859
invalidateAll,
7960
};
8061
};

0 commit comments

Comments
 (0)