You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LoadMore.tsx 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Button } from '@mui/material';
  2. import CircularProgress from '@mui/material/CircularProgress';
  3. import { useTranslation } from 'next-i18next';
  4. import Image from 'next/image';
  5. const LoadMore = ({ fetchNextPage, isFetchingNextPage, hasNextPage }) => {
  6. const { t } = useTranslation('products');
  7. return (
  8. <Button
  9. onClick={fetchNextPage}
  10. startIcon={
  11. !isFetchingNextPage && (
  12. <Image
  13. src="/images/arrow.svg"
  14. alt="arrow down"
  15. width={29}
  16. height={29}
  17. />
  18. )
  19. }
  20. sx={{
  21. backgroundColor: 'primary.main',
  22. height: 50,
  23. width: 150,
  24. color: 'white',
  25. ':hover': {
  26. bgcolor: 'primary.main',
  27. color: 'white',
  28. },
  29. }}
  30. >
  31. {isFetchingNextPage && (
  32. <CircularProgress
  33. style={{
  34. color: '#fff',
  35. width: '29px',
  36. height: '29px',
  37. marginRight: '20px',
  38. }}
  39. />
  40. )}
  41. {isFetchingNextPage
  42. ? t('products:loading')
  43. : hasNextPage
  44. ? t('products:more')
  45. : t('products:end')}
  46. </Button>
  47. );
  48. };
  49. export default LoadMore;