/** * Copyright (c) 2026-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { observer } from 'mobx-react-lite'; import { useCallback } from 'react'; import { Box, MenuItem, Pagination, Select, Typography, type SelectChangeEvent, } from '@mui/material'; export const PaginationControls = observer( (props: { totalItems: number; itemsPerPage: number; page: number; onPageChange: (page: number) => void; onItemsPerPageChange: (itemsPerPage: number) => void; disabled?: boolean; pageSizeOptions?: number[] | undefined; }) => { const { totalItems, itemsPerPage, page, onPageChange, onItemsPerPageChange, disabled = false, pageSizeOptions = [12, 24, 36, 48], } = props; const totalPages = Math.ceil(totalItems / itemsPerPage); const handlePageChange = useCallback( (_: unknown, newPage: number) => { onPageChange(newPage); }, [onPageChange], ); const handleItemsPerPageChange = useCallback( (event: SelectChangeEvent) => { onItemsPerPageChange(Number(event.target.value)); }, [onItemsPerPageChange], ); if (totalItems === 0) { return null; } return ( Items per page: Showing {(page - 1) * itemsPerPage + 1} to{' '} {Math.min(page * itemsPerPage, totalItems)} of{' '} {totalItems} results {totalPages > 1 && ( )} ); }, );