import { Menu } from "react-native-paper";

interface ItemsPerPageMenuProps {
  menuVisible: boolean;
  menuAnchor: { x: number; y: number };
  onDismiss: () => void;
  onItemsPerPageChange: (value: number) => void;
  totalItems: number;
  itemsPerPageMenuOptions: number[];
}

export const ItemsPerPageMenu = ({
  menuVisible,
  menuAnchor,
  onDismiss,
  onItemsPerPageChange,
  itemsPerPageMenuOptions,
}: ItemsPerPageMenuProps) => {
  return (
    <Menu visible={menuVisible} onDismiss={onDismiss} anchor={menuAnchor}>
      {itemsPerPageMenuOptions.map((option) => (
        <Menu.Item
          key={option}
          onPress={() => {
            onItemsPerPageChange(option);
            onDismiss();
          }}
          title={`${option} per page`}
        />
      ))}
    </Menu>
  );
};
