Files
supabase/apps/studio/components/interfaces/Auth/Users/UsersV1/UsersPagination.tsx
Joshen Lim b371266203 Chore/refactor auth users page to use data grid (#29105)
* Convert auth users page to use data grid

* Deprecate old components for auth users

* Remove unused state

* Remove unnecessary file

* Add copy cell value

* Reload -> Refresh

* Fix spelling

* Adjust sizing of search and dropdown

* Add feature flag and reinstate original auth/users UI

* Remove font mono on auth users data grid header and row cells

* Address comments
2024-09-10 11:02:25 +08:00

62 lines
1.8 KiB
TypeScript

import { memo } from 'react'
import { USERS_PAGE_LIMIT } from 'data/auth/users-query'
import { Button } from 'ui'
interface UsersPaginationProps {
total: number
page: number
setPage: (page: number) => void
isFetchingNextPage: boolean
}
export const UsersPagination = ({
total,
page,
setPage,
isFetchingNextPage,
}: UsersPaginationProps) => {
const startRowFromPage = USERS_PAGE_LIMIT * (page - 1) + 1
const fromRow = startRowFromPage > total ? total : startRowFromPage
const endRowFromPage = USERS_PAGE_LIMIT * page
const toRow = endRowFromPage > total ? total : endRowFromPage
const hasPrevious = page > 1
const hasNext = toRow < total
return (
<nav className="flex items-center justify-between overflow-hidden" aria-label="Pagination">
<div className="hidden sm:block">
<p className="text-xs text-foreground-lighter">
Showing
<span className="px-1 font-medium text-foreground-light">{fromRow}</span>
to
<span className="px-1 font-medium text-foreground-light">{toRow}</span>
of
<span className="px-1 font-medium text-foreground-light">{total}</span>
results
</p>
</div>
<div className="flex flex-1 justify-between sm:justify-end">
{hasPrevious && !(isFetchingNextPage && page === 2) && (
<Button type="default" onClick={() => setPage(page - 1)} disabled={isFetchingNextPage}>
Previous
</Button>
)}
{(hasNext || isFetchingNextPage) && (
<Button
type="default"
className="ml-3"
onClick={() => setPage(page + 1)}
disabled={isFetchingNextPage}
loading={isFetchingNextPage}
>
Next
</Button>
)}
</div>
</nav>
)
}