diff --git a/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx b/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx index c8e624dd0..a4416d7c8 100644 --- a/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx +++ b/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx @@ -164,9 +164,10 @@ function ProfessionTab() { const locale = i18n.language as "en" | "am"; const { handleError } = useErrorHandler(); const { data: deptRes } = useGetOrganizationsQuery(); - const { pageIndex, setPageIndex, setQ, skip, take } = useServerTable({ - pageSize: 10, - }); + const { pageIndex, setPageIndex, setQ, pageSize, setPageSize, skip, take } = + useServerTable({ + pageSize: 10, + }); const { data: profRes, isLoading, @@ -371,7 +372,8 @@ function ProfessionTab() { itemCount={totalCount} pageIndex={pageIndex} onPageChange={setPageIndex} - pageSize={10} + pageSize={pageSize} + onPageSizeChange={setPageSize} refresh={refetch} onSearchChange={setQ} isLoading={isFetching} diff --git a/libs/ui/src/lib/data/AdvancedTable.md b/libs/ui/src/lib/data/AdvancedTable.md index 74bcd0512..7b760324f 100644 --- a/libs/ui/src/lib/data/AdvancedTable.md +++ b/libs/ui/src/lib/data/AdvancedTable.md @@ -56,6 +56,8 @@ Copy `AdvancedTable.tsx` and `useServerTable.ts` into the new project (e.g. `src | `pageIndex` | `number` | yes | 0-based current page. | | `onPageChange` | `(pageIndex: number) => void` | yes | | | `pageSize` | `number` | no | Default `10`. Pagination only renders when `itemCount > pageSize`. | +| `onPageSizeChange` | `(pageSize: number) => void` | no | Shows a page-size ` when given; called with the chosen size. */ + onPageSizeChange?: (pageSize: number) => void; + /** Options for the page-size select. Default [10, 20, 50, 100]. */ + pageSizeOptions?: number[]; refresh?: () => void; /** Server-side search — debounced internally. Omit to hide the search box. */ onSearchChange?: (q: string) => void; @@ -67,6 +72,8 @@ export function AdvancedTable({ pageIndex, onPageChange, pageSize = 10, + onPageSizeChange, + pageSizeOptions = [10, 20, 50, 100], refresh, isLoading = false, emptyText, @@ -213,16 +220,28 @@ export function AdvancedTable({ - {itemCount > pageSize && ( + {(itemCount > pageSize || onPageSizeChange) && ( - onPageChange(page - 1)} - size="sm" - siblings={0} - boundaries={1} - /> + {onPageSizeChange && ( +