Loan details updates
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import {useQuery} from "@tanstack/react-query";
|
||||||
|
|
||||||
import Icons from '../Icons'
|
import Icons from '../Icons'
|
||||||
|
|
||||||
import Avatar from '../../assets/user_avatar.jpg'
|
import Avatar from '../../assets/user_avatar.jpg'
|
||||||
import queryKeys from '../../services/queryKeys'
|
import queryKeys from '../../services/queryKeys'
|
||||||
import { getLoans } from '../../services/siteServices'
|
import {getLoans} from '../../services/siteServices'
|
||||||
import getDateFromDateString from '../../helpers/GetDateFromDateString';
|
import getDateFromDateString from '../../helpers/GetDateFromDateString';
|
||||||
import formatNumber from '../../helpers/formatNumber'
|
import formatNumber from '../../helpers/formatNumber'
|
||||||
|
|
||||||
export default function LoanDetails({transactionID}) {
|
export default function LoanDetails({transactionID}) {
|
||||||
|
|
||||||
const {data:allLoans, isFetching, isError, error} = useQuery({
|
const {data: allLoans, isFetching, isError, error} = useQuery({
|
||||||
queryKey: queryKeys.loans,
|
queryKey: queryKeys.loans,
|
||||||
queryFn: () => getLoans({transaction_id: transactionID})
|
queryFn: () => getLoans({transaction_id: transactionID})
|
||||||
})
|
})
|
||||||
@@ -21,98 +21,122 @@ export default function LoanDetails({transactionID}) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isFetching ?
|
{isFetching ?
|
||||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||||
<p className='pb-4 font-bold text-base'>Loans</p>
|
<p className='pb-4 font-bold text-base'>Loans</p>
|
||||||
<p className='text-slate-800'>Loading...</p>
|
<p className='text-slate-800'>Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
: isError ?
|
: isError ?
|
||||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||||
<p className='pb-4 font-bold text-base'>Loans</p>
|
<p className='pb-4 font-bold text-base'>Loans</p>
|
||||||
<p className='text-red-500'>{error.message}</p>
|
<p className='text-red-500'>{error.message}</p>
|
||||||
</div>
|
</div>
|
||||||
: (loans && loans.length > 0) ?
|
: (loans && loans.length > 0) ?
|
||||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||||
<p className='pb-4 font-bold text-base'>Loans</p>
|
<p className='pb-4 font-bold text-base'>Loans</p>
|
||||||
<table className="table-auto py-2 w-full text-sm">
|
<table className="table-auto py-2 w-full text-sm">
|
||||||
<thead className="py-2 text-sm text-slate-500 text-left">
|
<thead className="py-2 text-sm text-slate-500 text-left">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" className="px-2 py-2">
|
<th scope="col" className="px-2 py-2">
|
||||||
Name
|
Name
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-2 text-right">
|
<th scope="col" className="px-2 text-right">
|
||||||
Loan/Eligible Amount
|
Loan/Eligible Amount
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-2 text-right">
|
<th scope="col" className="px-2 text-right">
|
||||||
Product/Tenor
|
Product/Tenor
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-2 text-right">
|
<th scope="col" className="px-2 text-right">
|
||||||
Repay/Install Amount.
|
Repay/Install Amount.
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-2 text-right">
|
<th scope="col" className="px-2 text-right">
|
||||||
Added/Due
|
Added/Due
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-2 text-right">
|
<th scope="col" className="px-2 text-right">
|
||||||
Action
|
Action
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{loans?.map((item, index) => (
|
{loans?.map((item, index) => (
|
||||||
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
|
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
|
||||||
<td className="px-2 py-2">
|
<td className="px-2 py-2">
|
||||||
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
|
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
|
||||||
<img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese image" />
|
<img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese image"/>
|
||||||
<div className="text-left">
|
<div className="text-left">
|
||||||
<div className="text-base font-semibold">{item?.account_id || ''}</div>
|
<div
|
||||||
<div className="font-normal text-gray-500">{item?.id} : {item?.transaction_id}</div>
|
className="text-base font-semibold">{item?.account_id || ''}</div>
|
||||||
<div className="font-semibold text-red-500">ORIGIN : {item?.original_transaction}</div>
|
<div
|
||||||
<div className="font-bold text-blue-500">OFFER : {item?.offer_id}</div>
|
className="font-normal text-gray-500">{item?.id} : {item?.transaction_id}</div>
|
||||||
</div>
|
<div className="font-semibold text-red-500">ORIGIN
|
||||||
</div>
|
: {item?.original_transaction}</div>
|
||||||
</td>
|
<div className="font-bold text-blue-500">OFFER
|
||||||
<td className="px-2">
|
: {item?.offer_id}</div>
|
||||||
<div className="text-right">
|
</div>
|
||||||
{/* <div className="text-base font-semibold">{formatNumber(item?.initial_loan_amount)}</div> */}
|
</div>
|
||||||
<div className="font-normal text-gray-500">{formatNumber(item?.initial_loan_amount)}</div>
|
</td>
|
||||||
<div className="font-semibold text-red-500">{formatNumber(item?.eligible_amount)}</div>
|
<td className="px-2">
|
||||||
|
<div className="text-right">
|
||||||
|
{/* <div className="text-base font-semibold">{formatNumber(item?.initial_loan_amount)}</div> */}
|
||||||
|
<div
|
||||||
|
className="font-normal text-gray-500">{formatNumber(item?.initial_loan_amount)}</div>
|
||||||
|
<div
|
||||||
|
className="font-semibold text-red-500">{formatNumber(item?.eligible_amount)}</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-2">
|
<td className="px-2">
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
<div className="font-normal text-gray-500">{formatNumber(item?.product_id)}</div>
|
<div
|
||||||
<div className="font-normal text-gray-500">{item?.tenor} days</div>
|
className="font-normal text-gray-500">{formatNumber(item?.product_id)}</div>
|
||||||
</div>
|
<div className="font-normal text-gray-500">{item?.tenor} days</div>
|
||||||
</td>
|
</div>
|
||||||
<td className="px-2">
|
</td>
|
||||||
<div className="text-right">
|
<td className="px-2">
|
||||||
<div className="font-normal text-gray-500">{formatNumber(item?.repayment_amount)}</div>
|
<div className="text-right">
|
||||||
<div className="font-normal text-gray-500">{formatNumber(item?.installment_amount)}</div>
|
<div
|
||||||
</div>
|
className="font-normal text-gray-500">{formatNumber(item?.repayment_amount)}</div>
|
||||||
</td>
|
<div
|
||||||
<td className="px-2">
|
className="font-normal text-gray-500">{formatNumber(item?.installment_amount)}</div>
|
||||||
<div className="text-right">
|
</div>
|
||||||
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)}</div>
|
</td>
|
||||||
<div className="font-semibold text-red-500">{getDateFromDateString(item?.due_date)}</div>
|
<td className="px-2">
|
||||||
</div>
|
<div className="text-right">
|
||||||
</td>
|
<div
|
||||||
<td className="px-2 text-right">
|
className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)}</div>
|
||||||
<div className='flex items-center justify-end gap-3 md:gap-4'>
|
<div
|
||||||
<div className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
|
className="font-semibold text-red-500">{getDateFromDateString(item?.due_date)}</div>
|
||||||
<Icons name='eye' />
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</div>
|
<td className="px-2 text-right">
|
||||||
</td>
|
<div className='flex items-center justify-end gap-3 md:gap-4'>
|
||||||
</tr>
|
<div
|
||||||
))
|
className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
|
||||||
}
|
<Icons name='eye'/>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
</div>
|
||||||
</div>
|
</td>
|
||||||
:
|
</tr>
|
||||||
null
|
))
|
||||||
}
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div>
|
||||||
|
<p className='pb-4 font-bold text-base'>Loans Disbursement Details</p>
|
||||||
|
<div className="font-bold text-blue-500">Disburse Date : {item?.disburseDate}</div>
|
||||||
|
<div className="font-bold text-gray-500">Disburse Description
|
||||||
|
: {item?.disburseDescription}</div>
|
||||||
|
<div className="font-bold text-red-500">Disburse Result : {item?.disburseResult}</div>
|
||||||
|
<div><br/></div>
|
||||||
|
<div className="font-bold text-blue-500">Disburse Verify DAte: {item?.disburseVerify}</div>
|
||||||
|
<div className="font-bold text-gray-500">Verify Description
|
||||||
|
: {item?.verifyDescription}</div>
|
||||||
|
<div className="font-bold text-red-500">Verify Result : {item?.verifyResult}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user