vasylmartyniv

Untitled

Jun 8th, 2021 (edited)
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { useDispatch } from 'react-redux';
  3.  
  4. import TransparentDarkBlueButton from '../../src/components/TransparentDarkBlueButton/TransparentDarkBlueButton';
  5.  
  6. import Promotion from '../../src/components/Promotion/Promotion';
  7.  
  8. const ListOfPromitions = ({
  9.   selectedPromotions,
  10.   meta,
  11.   getNextPage,
  12.   renderBottomRight,
  13.   onRemove,
  14.   isRemovable,
  15.   displayExpiresAt,
  16. }) => {
  17.   const dispatch = useDispatch();
  18.  
  19.   const handler = useCallback(
  20.     (data) => {
  21.       dispatch(getNextPage(data, 2));
  22.     },
  23.     [dispatch, meta]
  24.   );
  25.  
  26.   return (
  27.     <>
  28.       {selectedPromotions.map((selectedPromotion) => {
  29.         const { id, promotion, expiresAt } = selectedPromotion;
  30.         return (
  31.           <Promotion
  32.             key={id}
  33.             promotion={promotion}
  34.             expiresAt={expiresAt}
  35.             isRemovable={isRemovable}
  36.             onRemove={() => onRemove(id)}
  37.             displayExpiresAt={displayExpiresAt}
  38.           >
  39.             {renderBottomRight(selectedPromotion)}
  40.           </Promotion>
  41.         );
  42.       })}
  43.       {meta.totalPages > meta.currentPage ? (
  44.         <div
  45.           style={{
  46.             clear: 'both',
  47.             verticalAlign: 'bottom',
  48.             width: '100%',
  49.             textAlign: 'center',
  50.           }}
  51.         >
  52.           <TransparentDarkBlueButton
  53.             onClick={() => handler(meta.currentPage + 1)}
  54.           >
  55.             View More
  56.           </TransparentDarkBlueButton>
  57.         </div>
  58.       ) : null}
  59.     </>
  60.   );
  61. };
  62.  
  63. export default ListOfPromitions;
  64.  
Add Comment
Please, Sign In to add comment