import { Button, Container, Grid } from '@mui/material';
import CircularProgress from '@mui/material/CircularProgress';
import { Box } from '@mui/system';
import Image from 'next/image';
import ProductCard from '../product-card/ProductCard';
const ProductsGrid = ({
allProducts,
hasNextPage,
fetchNextPage,
isFetchingNextPage,
}) => {
const dataToDisplay = allProducts.pages.map((page) =>
page.product.map((item) => (
))
);
return (
{dataToDisplay}
{hasNextPage && (
)
}
sx={{
backgroundColor: 'primary.main',
height: 50,
width: 150,
color: 'white',
':hover': {
bgcolor: 'primary.main', // theme.palette.primary.main
color: 'white',
},
}}
>
{isFetchingNextPage && (
)}
{isFetchingNextPage
? 'Loading...'
: hasNextPage
? 'Load More'
: 'Nothing more to load'}
)}
);
};
export default ProductsGrid;