Compare commits

..

2 Commits

Author SHA1 Message Date
victorAnumudu e4526652d3 Merge master into session-implement 2023-11-01 20:27:35 +01:00
victorAnumudu 79325450f3 session logout implemented 2023-11-01 18:04:47 +01:00
8 changed files with 107 additions and 64 deletions
+11
View File
@@ -17,6 +17,10 @@ import { updateUserDetails } from "../../../store/UserDetails";
import ReCAPTCHA from "react-google-recaptcha"; import ReCAPTCHA from "react-google-recaptcha";
export default function Login() { export default function Login() {
const queryParams = new URLSearchParams(location?.search);
const sessionExpired = queryParams.get("sessionExpired")
const dispatch = useDispatch(); const dispatch = useDispatch();
const { state } = useLocation(); const { state } = useLocation();
@@ -255,6 +259,13 @@ export default function Login() {
</Link> </Link>
</span> </span>
</div> </div>
{/* SHOWS THIS IF USER SESSION HAS EXPIRED */}
{sessionExpired == 'true' &&
<div className="w-full p-1">
<p className="text-red-500 text-sm text-center">Your session expired and will need to login again</p>
</div>
}
{/* switch login component */} {/* switch login component */}
<div className="ml-7 flex justify-start items-center gap-3"> <div className="ml-7 flex justify-start items-center gap-3">
+2 -2
View File
@@ -5,7 +5,7 @@ import React, {
useMemo, useMemo,
useState, useState,
} from "react"; } from "react";
import SiteService from "../../services/SiteService"; import usersService from "../../services/UsersService";
import InputCom from "../Helpers/Inputs/InputCom"; import InputCom from "../Helpers/Inputs/InputCom";
import ModalCom from "../Helpers/ModalCom"; import ModalCom from "../Helpers/ModalCom";
import Layout from "../Partials/Layout"; import Layout from "../Partials/Layout";
@@ -27,7 +27,7 @@ export default function FamilyAcc() {
last_name: "", last_name: "",
}); });
const apiCall = useMemo(() => new SiteService(), []); const apiCall = useMemo(() => new usersService(), []);
const popUpHandler = () => { const popUpHandler = () => {
setPopUp((prev) => !prev); setPopUp((prev) => !prev);
+20 -9
View File
@@ -50,7 +50,7 @@ function RewardsTable() {
<div className='flex flex-col justify-between min-h-[500px]'> <div className='flex flex-col justify-between min-h-[500px]'>
{familyRewardHistory.loading ? {familyRewardHistory.loading ?
<LoadingSpinner size='16' color='sky-blue' height='h-[500px]' /> <LoadingSpinner size='16' color='sky-blue' height='h-[500px]' />
: familyRewardHistory.data.length ? :
<table className="wallet-activity w-full table-auto border-collapse text-left"> <table className="wallet-activity w-full table-auto border-collapse text-left">
<thead className='border-b-2'> <thead className='border-b-2'>
<tr className='text-slate-600'> <tr className='text-slate-600'>
@@ -60,6 +60,8 @@ function RewardsTable() {
<th className="p-2">Confirmation</th> <th className="p-2">Confirmation</th>
</tr> </tr>
</thead> </thead>
{familyRewardHistory.data.length ?
(
<tbody> <tbody>
{currentReward.map((item, index) => { {currentReward.map((item, index) => {
let date = new Date(item.added).toLocaleDateString() let date = new Date(item.added).toLocaleDateString()
@@ -82,15 +84,24 @@ function RewardsTable() {
} }
)} )}
</tbody> </tbody>
)
:
familyRewardHistory.error ?
(
<tbody>
<tr className='text-slate-500'>
<td className="p-2" colSpan={4}>Opps! an error occurred. Please try again!</td>
</tr>
</tbody>
)
:
<tbody>
<tr className='text-slate-500'>
<td className="p-2" colSpan={4}>No Rewards History Found!</td>
</tr>
</tbody>
}
</table> </table>
:familyRewardHistory.error ?
<div className="p-2 text-slate-500 flex flex-col grow justify-center items-center">
<span>Opps! an error occurred. Please try again!</span>
</div>
:
<div className="p-2 text-slate-500 flex flex-col grow justify-center items-center">
<span>No Rewards History Found!</span>
</div>
} }
{/* PAGINATION BUTTON */} {/* PAGINATION BUTTON */}
+4 -4
View File
@@ -255,9 +255,9 @@ export default function History() {
{/* PURCHASE SECTION */} {/* PURCHASE SECTION */}
{tab == 'purchases' && {tab == 'purchases' &&
<div className="wallet w-full border-t"> <div className="wallet w-full border-t">
{/* <h1 className="p-2 text-xl font-bold text-dark-gray dark:text-white tracking-wide">Purchases</h1> */} <h1 className="p-2 text-xl font-bold text-dark-gray dark:text-white tracking-wide">Purchases</h1>
{purchaseHistory.loading ? {purchaseHistory.loading ?
<LoadingSpinner size='16' color='sky-blue' height='h-[500px]' /> <LoadingSpinner size='16' color='sky-blue' />
: :
<PurchasesTable purchase={purchaseHistory} /> <PurchasesTable purchase={purchaseHistory} />
} }
@@ -268,10 +268,10 @@ export default function History() {
{/* RECENT ACTIVITY SECTION */} {/* RECENT ACTIVITY SECTION */}
{tab == 'recent' && {tab == 'recent' &&
<div className="wallet w-full border-t"> <div className="wallet w-full border-t">
{/* <h1 className="p-2 text-xl font-bold text-dark-gray dark:text-white tracking-wide">Recent Activity</h1> */} <h1 className="p-2 text-xl font-bold text-dark-gray dark:text-white tracking-wide">Recent Activity</h1>
{/* <p className='text-base text-slate-500 dark:text-white'>Activity Report</p> */} {/* <p className='text-base text-slate-500 dark:text-white'>Activity Report</p> */}
{paymentHistory.loading ? {paymentHistory.loading ?
<LoadingSpinner size='16' color='sky-blue' height='h-[500px]' /> <LoadingSpinner size='16' color='sky-blue' />
: :
<RecentActivityTable payment={paymentHistory} /> <RecentActivityTable payment={paymentHistory} />
} }
@@ -16,36 +16,45 @@ function PurchasesTable({purchase}) {
return ( return (
<div className='flex flex-col justify-between min-h-[500px]'> <div className='flex flex-col justify-between min-h-[500px]'>
<table className="wallet-activity w-full table-auto border-collapse text-left">
<thead className='border-b-2'>
<tr className='text-slate-600'>
<th className="p-2">Trx.</th>
<th className="p-2">Amount</th>
<th className="p-2">Fee</th>
</tr>
</thead>
{purchase.data.length ? {purchase.data.length ?
<table className="wallet-activity w-full table-auto border-collapse text-left"> (
<thead className='border-b-2'> <tbody>
<tr className='text-slate-600'> {currentPurchase.map((item, index) => (
<th className="p-2">Trx.</th> <tr key={index} className='text-slate-500'>
<th className="p-2">Amount</th> <td className="p-2">{item.added_date}<br />
<th className="p-2">Fee</th> <b>{item.confirmation} </b>
</tr> </td>
</thead> <td className="p-2">{item.amount}</td>
<tbody> <td className="p-2">{item.fee}</td>
{currentPurchase.map((item, index) => ( </tr>
<tr key={index} className='text-slate-500'> ))}
<td className="p-2">{item.added_date}<br /> </tbody>
<b>{item.confirmation} </b> )
</td>
<td className="p-2">{item.amount}</td>
<td className="p-2">{item.fee}</td>
</tr>
))}
</tbody>
</table>
:purchase.error ?
<div className="p-2 text-slate-500 flex flex-col grow justify-center items-center">
<span>Opps! an error occurred. Please try again!</span>
</div>
: :
<div className="p-2 text-slate-500 flex flex-col grow justify-center items-center"> purchase.error ?
<span>No Purchase History Found!</span> (
</div> <tbody>
<tr className='text-slate-500'>
<td className="p-2" colSpan={4}>Opps! an error occurred. Please try again!</td>
</tr>
</tbody>
)
:
<tbody>
<tr className='text-slate-500'>
<td className="p-2" colSpan={4}>No Purchase History Found!</td>
</tr>
</tbody>
} }
</table>
{/* PAGINATION BUTTON */} {/* PAGINATION BUTTON */}
<PaginatedList onClick={handlePagination} prev={currentPage == 0 ? true : false} next={currentPage+Number(process.env.REACT_APP_ITEM_PER_PAGE) >= purchase?.data?.length ? true : false} data={purchase?.data} start={indexOfFirstItem} stop={indexOfLastItem} /> <PaginatedList onClick={handlePagination} prev={currentPage == 0 ? true : false} next={currentPage+Number(process.env.REACT_APP_ITEM_PER_PAGE) >= purchase?.data?.length ? true : false} data={purchase?.data} start={indexOfFirstItem} stop={indexOfLastItem} />
@@ -19,16 +19,16 @@ function RecentActivityTable({ payment }) {
return ( return (
<div className="flex flex-col justify-between min-h-[500px]"> <div className="flex flex-col justify-between min-h-[500px]">
{payment?.data?.length > 0 ? <table className="wallet-activity w-full table-auto border-collapse text-left">
<table className="wallet-activity w-full table-auto border-collapse text-left"> <thead className="border-b-2">
<thead className="border-b-2"> <tr className="text-slate-600">
<tr className="text-slate-600"> <th className="p-2">Date</th>
<th className="p-2">Date</th> <th className="p-4">Trx.</th>
<th className="p-4">Trx.</th> <th className="p-2">Amnt./Fee</th>
<th className="p-2">Amnt./Fee</th> <th className="p-2">Status</th>
<th className="p-2">Status</th> </tr>
</tr> </thead>
</thead> {payment?.data?.length > 0 ? (
<tbody> <tbody>
{currentActivity.map((item, index) => ( {currentActivity.map((item, index) => (
<tr key={index} className="text-slate-500"> <tr key={index} className="text-slate-500">
@@ -46,16 +46,24 @@ function RecentActivityTable({ payment }) {
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> ) : payment?.error ? (
:payment.error ? <tbody>
<div className="p-2 text-slate-500 flex flex-col grow justify-center items-center"> <tr className="text-slate-500">
<span>Opps! an error occurred. Please try again!</span> <td className="p-2" colSpan={4}>
</div> Opps! an error occurred. Please try again!
: </td>
<div className="p-2 text-slate-500 flex flex-col grow justify-center items-center"> </tr>
<span>No Payment History Found!</span> </tbody>
</div> ) : (
} <tbody>
<tr className="text-slate-500">
<td className="p-2" colSpan={4}>
No Payment History Found!
</td>
</tr>
</tbody>
)}
</table>
{/* PAGINATION BUTTON */} {/* PAGINATION BUTTON */}
<PaginatedList <PaginatedList
+2 -2
View File
@@ -1,7 +1,7 @@
import { Field, Form, Formik } from "formik"; import { Field, Form, Formik } from "formik";
import React, { useCallback, useEffect, useMemo, useState } from "react"; import React, { useCallback, useEffect, useMemo, useState } from "react";
import * as Yup from "yup"; import * as Yup from "yup";
import SiteService from "../../services/SiteService"; import usersService from "../../services/UsersService";
import InputCom from "../Helpers/Inputs/InputCom/index"; import InputCom from "../Helpers/Inputs/InputCom/index";
import ModalCom from "../Helpers/ModalCom"; import ModalCom from "../Helpers/ModalCom";
import LoadingSpinner from "../Spinners/LoadingSpinner"; import LoadingSpinner from "../Spinners/LoadingSpinner";
@@ -36,7 +36,7 @@ const dispatch = useDispatch()
}, },
}); });
const apiCall = useMemo(() => new SiteService(), []); const apiCall = useMemo(() => new usersService(), []);
// member listing // member listing
const memberList = useCallback(async () => { const memberList = useCallback(async () => {
+4
View File
@@ -1237,6 +1237,10 @@ class usersService {
console.log(response); console.log(response);
// res = response; // res = response;
console.log("~~~~~~~ Toks2 POST ~~~~~~~~"); console.log("~~~~~~~ Toks2 POST ~~~~~~~~");
if(response.data.internal_return == '-9999'){
localStorage.clear()
window.location.href=`/login?sessionExpired=true`
}
return response; return response;
}) })
.catch((error) => { .catch((error) => {