login endpoint added
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from 'react'
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import BreadcrumbCom from '../../components/breadcrumb/BreadcrumbCom'
|
||||
import CustomCounter from '../../components/CustomCounter'
|
||||
import Icons from '../../components/Icons'
|
||||
@@ -6,27 +7,50 @@ import TableWrapper from '../../components/tableWrapper/TableWrapper'
|
||||
import Avatar from '../../assets/user_avatar.jpg'
|
||||
import { Widget1 } from './Widget1'
|
||||
import { Widget2 } from './Widget2'
|
||||
import formatNumber from '../../helpers/formatNumber'
|
||||
|
||||
import queryKeys from '../../services/queryKeys'
|
||||
import { getDashData } from '../../services/siteServices'
|
||||
|
||||
export default function HomeCom() {
|
||||
|
||||
const {data, isFetching, isError, error} = useQuery({
|
||||
queryKey: queryKeys.dashboard,
|
||||
queryFn: () => getDashData()
|
||||
})
|
||||
|
||||
const dashData = data?.data // APPLY LOAN LIST
|
||||
|
||||
// console.log('dashData', dashData)
|
||||
// loans, payments, recent_transactions [], request_summary
|
||||
|
||||
|
||||
return (
|
||||
<div className='w-full flex flex-col gap-8'>
|
||||
<BreadcrumbCom title='Dashboard' paths={['Home', 'Dashboard']} />
|
||||
|
||||
{(isFetching || isError) ?
|
||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
{isError ? <p className='text-red-500'>{error.message}</p> : <p className='text-slate-800'>Loading...</p>}
|
||||
</div>
|
||||
:
|
||||
<div className='grid grid-cols-1 gap-8'>
|
||||
<div className='w-full grid grid-cols-1 xl:grid-cols-3 gap-8'>
|
||||
<div className='box min-h-[230] justify-between bg-[#F7D9E3] dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
<p className='text-base sm:text-lg font-bold hover:text-primary'>Loans</p>
|
||||
<Widget1 />
|
||||
<div className='flex gap-2 items-end font-bold'>
|
||||
<p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>$</span><CustomCounter targetNumber='47' timeInSeconds='1' /></p>
|
||||
<p className='sm:text-[13.9px]'>This week</p>
|
||||
{/* <p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={formatNumber(dashData?.loans?.value)} timeInSeconds='1' /></p> */}
|
||||
<p className='text-base sm:text-lg'><span className='text-sm'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={formatNumber(dashData?.loans?.value)} timeInSeconds='1' /></p>
|
||||
<p className='sm:text-[13.9px]'>{dashData?.loans?.text}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className='box min-h-[230] justify-between bg-[#CBF0F5] dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
<p className='text-base sm:text-lg font-bold hover:text-primary'>Payments</p>
|
||||
{/* <Widget2 /> */}
|
||||
<div className='flex gap-2 items-end font-bold'>
|
||||
<p className='text-3xl sm:text-[39px]'><CustomCounter targetNumber='500' timeInSeconds='1' /></p>
|
||||
<p className='sm:text-[13.9px]'>This week</p>
|
||||
<p className='text-sm sm:text-base'><span className='text-sm'>{dashData?.payments?.currency_text}</span><CustomCounter targetNumber={formatNumber(dashData?.payments?.value)} timeInSeconds='1' /></p>
|
||||
<p className='sm:text-[13.9px]'>{dashData?.payments?.text}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className='box min-h-[230] justify-between bg-[#CBD4F4] dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
@@ -37,8 +61,8 @@ export default function HomeCom() {
|
||||
<Icons name='sales' />
|
||||
</div>
|
||||
<div>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber='50' timeInSeconds='1' />K</p>
|
||||
<p className='text-12 text-slate-500'>Sales</p>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber={formatNumber(dashData?.request_summary?.eligibility_check?.Eligibility)} timeInSeconds='1' />K</p>
|
||||
<p className='text-12 text-slate-500'>Eligibility</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
@@ -46,8 +70,8 @@ export default function HomeCom() {
|
||||
<Icons name='sales' />
|
||||
</div>
|
||||
<div>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber='50' timeInSeconds='1' />K</p>
|
||||
<p className='text-12 text-slate-500'>Revenue</p>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber={formatNumber(dashData?.request_summary?.provide_loan?.Loans)} timeInSeconds='1' />K</p>
|
||||
<p className='text-12 text-slate-500'>Loans</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
@@ -55,8 +79,8 @@ export default function HomeCom() {
|
||||
<Icons name='sales' />
|
||||
</div>
|
||||
<div>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber='265' timeInSeconds='1' />K</p>
|
||||
<p className='text-12 text-slate-500'>Tickets</p>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber={formatNumber(dashData?.request_summary?.repayment?.Repayments)} timeInSeconds='1' />K</p>
|
||||
<p className='text-12 text-slate-500'>Repayments</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
@@ -64,13 +88,14 @@ export default function HomeCom() {
|
||||
<Icons name='sales' />
|
||||
</div>
|
||||
<div>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber='5' timeInSeconds='1' />M</p>
|
||||
<p className='text-12 text-slate-500'>Tasks</p>
|
||||
<p className='font-bold text-base'>$<CustomCounter targetNumber={formatNumber(dashData?.request_summary?.select_offer?.Offers)} timeInSeconds='1' />M</p>
|
||||
<p className='text-12 text-slate-500'>Offers</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='w-full'>
|
||||
<div className='box gap-8 bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
<div className='grid grid-cols-1 xs:grid-cols-2 gap-4'>
|
||||
@@ -83,7 +108,7 @@ export default function HomeCom() {
|
||||
</div> */}
|
||||
</div>
|
||||
|
||||
<TableWrapper data={[1,2,3,4,5]} itemsPerPage={15}>
|
||||
<TableWrapper data={dashData?.recent_transactions} itemsPerPage={15}>
|
||||
{({ data }) => (
|
||||
<>
|
||||
<table className="py-2 w-full text-sm">
|
||||
@@ -104,21 +129,21 @@ export default function HomeCom() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.map(item => (
|
||||
<tr className="py-2 border-t border-dashed border-slate-300">
|
||||
{(data && data.length > 0) ? data?.map((item, index) => (
|
||||
<tr key={item?.id} className="py-2 border-t border-dashed border-slate-300">
|
||||
<td className="px-2 py-2">
|
||||
<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" />
|
||||
<div className="text-left">
|
||||
<div className="text-base font-semibold">John Dummy</div>
|
||||
<div className="font-normal text-gray-500">HTML, JS, ReactJS</div>
|
||||
<div className="text-base font-semibold">{item?.account_id}</div>
|
||||
<div className="font-normal text-gray-500">{item?.channel}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-2">
|
||||
<div className="text-left">
|
||||
<div className="text-base font-semibold">chiefSoft</div>
|
||||
<div className="font-normal text-gray-500">Web, UI/UX Design</div>
|
||||
<div className="text-base font-semibold">{item?.transaction_id}</div>
|
||||
<div className="font-normal text-gray-500">{item?.type}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-2">
|
||||
@@ -143,7 +168,16 @@ export default function HomeCom() {
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
))
|
||||
:
|
||||
<tr className="py-2 border-t border-dashed border-slate-300">
|
||||
<td className="px-3 py-2" colSpan={4}>
|
||||
<div className="flex justify-center items-center">
|
||||
No Record Found
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</>
|
||||
@@ -152,6 +186,7 @@ export default function HomeCom() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user