loan info API added
This commit is contained in:
@@ -3,7 +3,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { IoIosArrowForward } from "react-icons/io";
|
||||
|
||||
import { getOffers, loanSelect } from '../../../services/siteServices'
|
||||
import { getLoanInfo, loanSelect } from '../../../services/siteServices'
|
||||
import queryKeys from '../../../services/queryKeys'
|
||||
|
||||
export default function LoanInfoList({step, handleStep, screens}) {
|
||||
@@ -12,10 +12,10 @@ export default function LoanInfoList({step, handleStep, screens}) {
|
||||
|
||||
const {data, isFetching, isError, error} = useQuery({
|
||||
queryKey: queryKeys.offers,
|
||||
queryFn: () => getOffers()
|
||||
queryFn: () => getLoanInfo()
|
||||
})
|
||||
|
||||
// const list = data?.data?.product_data?.offers // OFFERS LIST
|
||||
const loanInfoList = data?.data // LOAN INFO LIST
|
||||
|
||||
const selectedLoan = useMutation({
|
||||
mutationFn: (details) => {
|
||||
@@ -55,7 +55,7 @@ export default function LoanInfoList({step, handleStep, screens}) {
|
||||
:
|
||||
<>
|
||||
<p className='text-center text-base md:text-xl'>Loan to repay</p>
|
||||
{offers.map(item => {
|
||||
{loanInfoList.map(item => {
|
||||
let isDisabled = item.active == '0' ? true : false
|
||||
return (
|
||||
<button
|
||||
@@ -93,9 +93,4 @@ export default function LoanInfoList({step, handleStep, screens}) {
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const offers = [ // remove later
|
||||
{cid: '1', amount: 50000, description: 'Total amount to replay N50,000'},
|
||||
{cid: '2', amount: 25000, description: 'Total amount to replay N25,000'}
|
||||
]
|
||||
}
|
||||
@@ -54,7 +54,7 @@ export default function PinRepayment({step, handleStep, screens}) {
|
||||
{!isSuccess ?
|
||||
<div className='mt-3 flex flex-col gap-4'>
|
||||
<div className='text-input font-semibold w-full flex flex-col gap-4 justify-center items-center'>
|
||||
<p className='text-center text-base md:text-xl'>{`Your loan amount due is ₦${step.details.selectedAmount}`}</p>
|
||||
<p className='text-center text-base md:text-xl'>{`Your loan amount due is ${step.details.selectedAmount}`}</p>
|
||||
<Label name='Enter your 4 Digit pin' htmlfor='pin' />
|
||||
<InputText id='pin' name='pin' type='text' value={pin} handleChange={handlePinChange} />
|
||||
{/* <button onClick={()=>{proceed.mutate()}} disabled={proceed.isPending} className='p-3 bg-purple-800 text-base sm:text-xl text-white font-bold rounded'>{proceed.isPending ? 'loading...' : 'Continue'}</button> */}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { IoIosArrowForward } from "react-icons/io";
|
||||
|
||||
import { getOffers, loanSelect } from '../../../services/siteServices'
|
||||
import { getLoanInfo, loanSelect } from '../../../services/siteServices'
|
||||
import queryKeys from '../../../services/queryKeys'
|
||||
|
||||
export default function RepayLoanList({step, handleStep, screens}) {
|
||||
@@ -12,10 +12,10 @@ export default function RepayLoanList({step, handleStep, screens}) {
|
||||
|
||||
const {data, isFetching, isError, error} = useQuery({
|
||||
queryKey: queryKeys.offers,
|
||||
queryFn: () => getOffers()
|
||||
queryFn: () => getLoanInfo()
|
||||
})
|
||||
|
||||
// const list = data?.data?.product_data?.offers // OFFERS LIST
|
||||
const loanInfoList = data?.data // LOAN INFO LIST
|
||||
|
||||
const selectedLoan = useMutation({
|
||||
mutationFn: (details) => {
|
||||
@@ -55,15 +55,16 @@ export default function RepayLoanList({step, handleStep, screens}) {
|
||||
:
|
||||
<>
|
||||
<p className='text-center text-base md:text-xl'>Select Loan to repay</p>
|
||||
{offers.map(item => {
|
||||
{loanInfoList.map(item => {
|
||||
let isDisabled = item.active == '0' ? true : false
|
||||
let amount = item?.description.split(' ')[item?.description.split(' ').length -1] //remove later
|
||||
return (
|
||||
<button
|
||||
key={item?.cid}
|
||||
disabled={isDisabled || selectedLoan.isPending}
|
||||
// value={item.loan}
|
||||
// onClick={()=>selectedLoan.mutate(item)}
|
||||
onClick={()=>handleClick(item?.amount)}
|
||||
onClick={()=>handleClick(amount)}
|
||||
className={`w-full flex gap-2 justify-between items-center p-2 bg-purple-800 ${selectedLoan.isPending && 'bg-purple-800/50'} text-base sm:text-xl text-white font-bold rounded ${isDisabled && 'opacity-50'}`}
|
||||
>
|
||||
{item?.description}
|
||||
@@ -92,9 +93,4 @@ export default function RepayLoanList({step, handleStep, screens}) {
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const offers = [ // remove later
|
||||
{cid: '1', amount: 50000, description: 'Total amount to replay N50,000'},
|
||||
{cid: '2', amount: 25000, description: 'Total amount to replay N25,000'}
|
||||
]
|
||||
}
|
||||
@@ -98,4 +98,10 @@ export const getProducts = (reqData) => {
|
||||
export const getOffers = (reqData) => {
|
||||
const postData = { ...reqData }
|
||||
return getAuxEnd(`/salary/loanoffers`, postData)
|
||||
}
|
||||
|
||||
// FUNCTION TO GET LOAN INFO
|
||||
export const getLoanInfo = (reqData) => {
|
||||
const postData = { ...reqData }
|
||||
return getAuxEnd(`/loan/info`, postData)
|
||||
}
|
||||
Reference in New Issue
Block a user