import React, {useState} from 'react' import PaginatedList from '../../Pagination/PaginatedList' import { handlePagingFunc } from '../../Pagination/HandlePagination'; function CouponTable({coupon}) { const [currentPage, setCurrentPage] = useState(0); const indexOfFirstItem = Number(currentPage); const indexOfLastItem = Number(indexOfFirstItem)+Number(process.env.REACT_APP_ITEM_PER_PAGE); const currentCoupon = coupon?.data?.slice(indexOfFirstItem, indexOfLastItem); const handlePagination = (e) => { handlePagingFunc(e,setCurrentPage) } return (
{coupon.data.length ? ( {currentCoupon.map((item, index) => ( ))} ) : coupon.error ? ( ) : }
Date Description Amount Active
{item.added} {item.code} {item.amount} {item.status}
Opps! an error occurred. Please try again!
No Purchase History Found!
{/* PAGINATION BUTTON */} = coupon?.data?.length ? true : false} data={coupon?.data} start={indexOfFirstItem} stop={indexOfLastItem} /> {/* END OF PAGINATION BUTTON */}
) } export default CouponTable