diff --git a/src/components/MyCoupons/CouponTable.jsx b/src/components/MyCoupons/CouponTable.jsx new file mode 100644 index 0000000..2394eb3 --- /dev/null +++ b/src/components/MyCoupons/CouponTable.jsx @@ -0,0 +1,67 @@ +import React, {useState} from 'react' + +//import PaginatedList from '../../Pagination/PaginatedList' +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 ? + ( + + + + + + ) + : + + + + + + } +
DateDescriptionAmountActive
{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 \ No newline at end of file diff --git a/src/components/MyCoupons/MyCoupons.jsx b/src/components/MyCoupons/MyCoupons.jsx index 10903b0..ae836bb 100644 --- a/src/components/MyCoupons/MyCoupons.jsx +++ b/src/components/MyCoupons/MyCoupons.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react' import Layout from "../Partials/Layout"; import LoadingSpinner from "../Spinners/LoadingSpinner"; -import CouponTable from "../MyWallet/WalletComponent/CouponTable"; +import CouponTable from "./CouponTable"; import usersService from '../../services/UsersService' export default function MyCoupons() { @@ -33,10 +33,24 @@ export default function MyCoupons() { <>
-
+ {/* heading */} +
+
+

+ + Coupons + +

+
+ +
+ +
+
+
{/* COUPON SECTION */} -
+

Coupons

{couponHistory.loading ?