diff --git a/src/components/History/RewardsTable.jsx b/src/components/History/RewardsTable.jsx index 7a65412..edc1b8b 100644 --- a/src/components/History/RewardsTable.jsx +++ b/src/components/History/RewardsTable.jsx @@ -1,34 +1,66 @@ -import React, {useState} from 'react' +import React, {useEffect, useState} from 'react' import Image from '../../assets/images/taskbanners/default.jpg' +import usersService from '../../services/UsersService'; import { handlePagingFunc } from '../../components/Pagination/HandlePagination'; import PaginatedList from '../../components/Pagination/PaginatedList'; +import LoadingSpinner from '../Spinners/LoadingSpinner'; + import { AmountTo2DP } from '../Helpers/PriceFormatter'; -function RewardsTable({reward}) { +function RewardsTable() { + + const apiCall = new usersService() + + let [familyRewardHistory, setFamilyRewardHistory] = useState({ // FOR PURCHASE HISTORY + loading: true, + data: [], + error: false + }) const [currentPage, setCurrentPage] = useState(0); const indexOfFirstItem = Number(currentPage); const indexOfLastItem = Number(indexOfFirstItem)+Number(process.env.REACT_APP_ITEM_PER_PAGE); - const currentReward = reward?.data?.slice(indexOfFirstItem, indexOfLastItem); + const currentReward = familyRewardHistory?.data?.slice(indexOfFirstItem, indexOfLastItem); const handlePagination = (e) => { handlePagingFunc(e,setCurrentPage) } + + //FUNCTION TO GET FAMILY REWARD HISTORY + const getFamilyRewardHistory = ()=>{ + apiCall.getFamilyRewardHx().then((res)=>{ + if(res.data.internal_return < 0){ // success but no data + setFamilyRewardHistory(prev => ({...prev, loading: false})) + return + } + setFamilyRewardHistory(prev => ({...prev, loading: false, data: res.data.result_list})) + }).catch((error)=>{ + setFamilyRewardHistory(prev => ({...prev, loading: false, error: true})) + }) + } + + useEffect(()=>{ + getFamilyRewardHistory() + }, []) + return (
| Title | +Description | Amount | Date | Confirmation |
|---|---|---|---|---|
|
-
-
Title Goes Here-Title Goes Here +Reward to {item.rec_firstname} {item.rec_lastname_}+{item.description} |
@@ -54,7 +86,7 @@ function RewardsTable({reward}) {
||||
Activity Report
*/} - {paymentHistory.loading ? + {/* {paymentHistory.loading ?