import React, { useEffect, useState } from "react"; import Layout from "../Partials/Layout"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import CouponTable from "./CouponTable"; import usersService from "../../services/UsersService"; export default function MyCoupons() { const apiCall = new usersService(); let [couponHistory, setCouponHistory] = useState({ // FOR COUPON HISTORY loading: true, data: [], error: false, }); //FUNCTION TO GET COUPON HISTORY const getCouponHistory = () => { 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 })); }); }; useEffect(() => { getCouponHistory(); }, []); return ( <>
{/* heading */}

Coupons

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