import React, { useCallback, useEffect, useMemo, useState } from "react"; import Layout from "../Partials/Layout"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import CouponTable from "./CouponTable"; import usersService from "../../services/UsersService"; import { useSelector } from "react-redux"; export default function MyCoupons() { const apiCall = useMemo(() => new usersService(), []); const {couponTable, walletTable} = useSelector(state => state.tableReload) let [couponHistory, setCouponHistory] = useState({ // FOR COUPON HISTORY loading: true, data: [], error: false, }); //FUNCTION TO GET COUPON HISTORY const getCouponHistory = useCallback(() => { apiCall .getCouponPending() .then((res) => { if (res.data.internal_return < 0) { // success but no data setCouponHistory((prev) => ({ ...prev, loading: false })); return; } setCouponHistory((prev) => ({ ...prev, loading: false, data: res.data.result_list, })); }) .catch((error) => { setCouponHistory((prev) => ({ ...prev, loading: false, error: true })); }); }, [apiCall]); useEffect(() => { getCouponHistory(); }, [couponTable, walletTable]); return ( <>
{/* heading */}

Coupons

{/* COUPON SECTION */}
{couponHistory.loading ? (
) : ( )}
{/* END OF COUPON SECTION */}
); }