import React, {Children, cloneElement, isValidElement} from "react";
import PaginationProps from "./Pagination.types";
import PaginationItem from "../PaginationItem";
export const Pagination = ({
children,
previous,
next,
landmarkLabel,
currentPageNumber,
classes,
}: PaginationProps) => {
const arrayChildren: any = Children.toArray(children);
if (arrayChildren?.length < 1) {
return null;
}
const blockLevel = arrayChildren?.length < 1 && (previous || next);
const finalArray: any = [];
arrayChildren.forEach((child: any, index: number) => {
//first page
if (index === 0) {
finalArray.push(child);
}
//previous page
else if (index === currentPageNumber-2) {
finalArray.push(child);
}
//current page
else if (index === currentPageNumber-1) {
finalArray.push(child);
}
//next page
else if (index === currentPageNumber) {
finalArray.push(child);
}
// last page
else if (arrayChildren.length -1 === index) {
finalArray.push(child)
}
})
// ellipsis after first page
if (currentPageNumber > 3) {
finalArray.splice(1, 0, )
}
// ellipsis before last page
if (currentPageNumber < (arrayChildren?.length - 2)) {
finalArray.splice((finalArray?.length - 1), 0, )
}
const nextArrow = (
);
return (
<>
>
);
};
export default Pagination;