transaction change
This commit is contained in:
@@ -1,50 +1,15 @@
|
||||
'use client';
|
||||
import { ef } from '@/lib/helpers/utfNumbers'
|
||||
import {
|
||||
MoneyRecive,
|
||||
MoneySend,
|
||||
Wallet
|
||||
} from 'iconsax-react'
|
||||
import React, { useMemo } from 'react'
|
||||
import { useGetTransactions, useGetUserWallet } from './hooks/useTransactionData';
|
||||
import { Transaction } from './types/Types';
|
||||
import React from 'react'
|
||||
import { useGetTransactions } from './hooks/useTransactionData';
|
||||
import { TransactionsTable } from './components/TransactionsTable';
|
||||
import LoadingOverlay from '@/components/overlays/LoadingOverlay';
|
||||
|
||||
function TransactionsReviewIndex() {
|
||||
const { data: transactionsResponse, isLoading: isLoadingTransactions } = useGetTransactions();
|
||||
const { data: walletResponse, isLoading: isLoadingWallet } = useGetUserWallet();
|
||||
|
||||
const transactions = transactionsResponse?.data || [];
|
||||
const walletAmount = walletResponse?.data?.wallet || 0;
|
||||
|
||||
const stats = useMemo(() => {
|
||||
if (!transactions.length) {
|
||||
return {
|
||||
totalDeposits: 0,
|
||||
totalWithdrawals: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const deposits = transactions
|
||||
.filter((t: Transaction) => t.status === 'SUCCESS' && t.amount > 0)
|
||||
.reduce((sum: number, t: Transaction) => sum + t.amount, 0);
|
||||
|
||||
const withdrawals = transactions
|
||||
.filter((t: Transaction) => t.status === 'SUCCESS' && t.amount < 0)
|
||||
.reduce((sum: number, t: Transaction) => sum + Math.abs(t.amount), 0);
|
||||
|
||||
return {
|
||||
totalDeposits: deposits,
|
||||
totalWithdrawals: withdrawals,
|
||||
};
|
||||
}, [transactions]);
|
||||
|
||||
const formatPrice = (amount: number) => {
|
||||
return ef(amount.toLocaleString('fa-IR'));
|
||||
};
|
||||
|
||||
const isLoading = isLoadingTransactions || isLoadingWallet;
|
||||
const isLoading = isLoadingTransactions;
|
||||
|
||||
return (
|
||||
<section className='flex flex-col h-full pb-10 pt-6 gap-4 relative'>
|
||||
@@ -52,7 +17,7 @@ function TransactionsReviewIndex() {
|
||||
|
||||
<h1 className='font-medium text-base'>لیست تراکنش ها</h1>
|
||||
|
||||
<div className='grid grid-cols-3 gap-2 h-28'>
|
||||
{/* <div className='grid grid-cols-3 gap-2 h-28'>
|
||||
<div className='w-full h-full flex flex-col items-center justify-center p-2.5 text-center bg-container rounded-xl'>
|
||||
<div className='size-8 bg-background rounded-full grid items-center'>
|
||||
<MoneySend
|
||||
@@ -89,7 +54,7 @@ function TransactionsReviewIndex() {
|
||||
{formatPrice(walletAmount)} ریال
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
<div className='w-full h-full bg-container rounded-3xl mt-0'>
|
||||
<TransactionsTable transactions={transactions} />
|
||||
|
||||
Reference in New Issue
Block a user