From 60ed9e7bcf6229b10c2030eb209faa7aaadd9655 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Mon, 8 Apr 2024 14:51:14 +0100 Subject: [PATCH] changed history page tab style --- src/components/History/RewardsTable.jsx | 10 ++--- src/components/History/index.jsx | 37 +++++++++++++------ .../WalletComponent/RecentActivityTable.jsx | 2 +- src/components/Partials/RightSideBar.jsx | 4 +- src/components/customTabs/TabButton.jsx | 26 +++++++++++++ 5 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 src/components/customTabs/TabButton.jsx diff --git a/src/components/History/RewardsTable.jsx b/src/components/History/RewardsTable.jsx index c67901d..16bc7b3 100644 --- a/src/components/History/RewardsTable.jsx +++ b/src/components/History/RewardsTable.jsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react' +import React, {memo, useCallback, useEffect, useState} from 'react' import Image from '../../assets/images/taskbanners/default.jpg' import usersService from '../../services/UsersService'; @@ -9,8 +9,8 @@ import LoadingSpinner from '../Spinners/LoadingSpinner'; import { AmountTo2DP } from '../Helpers/PriceFormatter'; -function RewardsTable() { +export const RewardsTable = memo(() => { const apiCall = new usersService() let [familyRewardHistory, setFamilyRewardHistory] = useState({ // FOR PURCHASE HISTORY @@ -30,7 +30,7 @@ function RewardsTable() { //FUNCTION TO GET FAMILY REWARD HISTORY - const getFamilyRewardHistory = ()=>{ + const getFamilyRewardHistory = useCallback(()=>{ apiCall.getFamilyRewardHx().then((res)=>{ if(res.data.internal_return < 0){ // success but no data setFamilyRewardHistory(prev => ({...prev, loading: false})) @@ -40,7 +40,7 @@ function RewardsTable() { }).catch((error)=>{ setFamilyRewardHistory(prev => ({...prev, loading: false, error: true})) }) - } + },[]) useEffect(()=>{ getFamilyRewardHistory() @@ -99,5 +99,5 @@ function RewardsTable() { ) } - +) export default RewardsTable \ No newline at end of file diff --git a/src/components/History/index.jsx b/src/components/History/index.jsx index b1c446a..48c8336 100644 --- a/src/components/History/index.jsx +++ b/src/components/History/index.jsx @@ -13,11 +13,15 @@ import LoadingSpinner from "../Spinners/LoadingSpinner"; import RewardsTable from "./RewardsTable"; import JobsCompleted from "./JobsCompleted"; +import TabButton from "../customTabs/TabButton"; + export default function History() { const apiCall = new usersService() let [tab, setTab] = useState("purchases"); //STATE FOR SWITCHING BETWEEN TABS + const [selectedTab, setSelectedTab] = useState("purchases"); + const tabs = ["purchases", "recent activity", "rewards", 'jobs completed'] //STATE FOR SWITCHING BETWEEN TABS let [paymentHistory, setPaymentHistory] = useState({ // FOR PAYMENT HISTORY loading: true, @@ -222,7 +226,18 @@ export default function History() { {/* */}
{/* switch button */} -
+
+ {tabs.map((item) => ( + + ))} +
+ {/* switch button */} + {/*
-
+
*/} {/* END OF switch button */} -
+
{/* PURCHASE SECTION */} - {tab == 'purchases' && -
+ {selectedTab == 'purchases' && +
{/*

Purchases

*/} {purchaseHistory.loading ? @@ -276,8 +291,8 @@ export default function History() { {/* END OF PURCHASE SECTION */} {/* RECENT ACTIVITY SECTION */} - {tab == 'recent' && -
+ {selectedTab == 'recent activity' && +
{/*

Recent Activity

*/} {/*

Activity Report

*/} {paymentHistory.loading ? @@ -290,16 +305,16 @@ export default function History() { {/* END OF RECENT ACTIVITY SECTION */} {/* REWARD SECTION */} - {tab == 'reward' && -
+ {selectedTab == 'rewards' && +
} {/* END OF REWARD SECTION */} {/* JOBS COMPLETED SECTION */} - {tab == 'jobs_completed' && -
+ {selectedTab == 'jobs completed' && +
} diff --git a/src/components/MyWallet/WalletComponent/RecentActivityTable.jsx b/src/components/MyWallet/WalletComponent/RecentActivityTable.jsx index 9c847f7..c1fa34d 100644 --- a/src/components/MyWallet/WalletComponent/RecentActivityTable.jsx +++ b/src/components/MyWallet/WalletComponent/RecentActivityTable.jsx @@ -24,7 +24,7 @@ function RecentActivityTable({ payment }) { Date - Trx. + Trx. Amnt./Fee Status diff --git a/src/components/Partials/RightSideBar.jsx b/src/components/Partials/RightSideBar.jsx index 576fbf2..268b10b 100644 --- a/src/components/Partials/RightSideBar.jsx +++ b/src/components/Partials/RightSideBar.jsx @@ -40,7 +40,7 @@ export default function RightSideBar({ myJobList }) { return ( <>
-
+
{/* heading */}

@@ -280,7 +280,7 @@ export default function RightSideBar({ myJobList }) { {/*JOB LINKS*/} {userDetails?.account_type !== "FAMILY" && myJobList?.data?.result_list?.length > 0 && ( -
+
{/* heading */}

diff --git a/src/components/customTabs/TabButton.jsx b/src/components/customTabs/TabButton.jsx new file mode 100644 index 0000000..611cf72 --- /dev/null +++ b/src/components/customTabs/TabButton.jsx @@ -0,0 +1,26 @@ +import React from 'react' + +export default function TabButton({ item='', selectedTab='', setSelectedTab=()=>{} }) { + return ( + + ) +} +