first commit

This commit is contained in:
CHIEFSOFT\ameye
2025-07-21 05:51:52 -04:00
commit 7e28fc8f51
114 changed files with 23749 additions and 0 deletions
+188
View File
@@ -0,0 +1,188 @@
import React from 'react'
import {Link} from 'react-router-dom'
import { useQuery } from "@tanstack/react-query";
import BreadcrumbCom from '../../components/breadcrumb/BreadcrumbCom'
import CustomCounter from '../../components/CustomCounter'
import Icons from '../../components/Icons'
import formatNumber from '../../helpers/formatNumber'
import queryKeys from '../../services/queryKeys'
import { getDashData } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
import RouteLinks from '../../RouteLinks';
export default function HomeCom() {
const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.dashboard,
queryFn: () => getDashData(),
})
const dashData = data?.data // DASHBOARD DATA
// 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>
<div className='flex flex-wrap gap-2 items-end font-bold'>
{/* <p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={dashData?.loans?.value} timeInSeconds='1' /></p> */}
<p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
{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>
<div className='flex flex-wrap gap-2 items-end font-bold'>
<p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
{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'>
<p className='mb-4 text-base sm:text-lg font-bold hover:text-primary'>Request Summary</p>
<div className='grid grid-cols-2 gap-4 font-bold'>
{
Object.values(dashData?.request_summary).map((item, index) => {
return (
<div key={index} className='flex items-center gap-2'>
<div className='min-w-10 min-h-10 bg-white-body dark:bg-black-box dark:shadow-[0_0_0_1px_#f9f9f9] rounded-md flex justify-center items-center'>
<Icons name='sales' />
</div>
<div>
<p className='font-bold text-base'><CustomCounter targetNumber={Object.values(item)[0]} timeInSeconds='1' /></p>
<p className='text-12 text-slate-500'>{Object.keys(item)[0]}</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'>
<div className='flex flex-col gap-1 order-2 xs:order-1'>
<p className='font-bold text-base'>Recent Request</p>
{/* <p className='text-12'>Over 500 members</p> */}
</div>
{/* <div className='order-1 xs:order-2 text-left xs:text-right'>
<button className='font-bold bg-white-aside text-black-body text-12 px-4 py-2 hover:text-primary hover:bg-sky-50 dark:hover:text-white dark:hover:bg-primary dark:text-white-body dark:bg-black-body rounded-md'>+ New Member</button>
</div> */}
</div>
<table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left font-semibold">
<tr>
<th scope="col" className="px-2 py-2">
Request
</th>
<th scope="col" className="px-2">
Account
</th>
<th scope="col" className="px-2">
Activity
</th>
<th scope="col" className="px-2 text-right">
Action
</th>
</tr>
</thead>
<tbody>
{(dashData?.recent_transactions && dashData?.recent_transactions.length > 0) ? dashData?.recent_transactions?.map((item, index) => {
if(index <= 10) {
return (
<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={localImgLoader(`loan_icons/${item?.type}.png`)} alt="Icon" />
<div className="text-left">
<div className="text-base font-semibold">{item?.transaction_id}</div>
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)} {getTimeFromDateString(item?.created_at)}</div>
</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.account_id}</div>
<div className="font-normal text-gray-500">{item?.type}</div>
</div>
</td>
<td className="px-2">
<div className="text-left">
<div className="font-normal text-gray-500">50%</div>
<div className="relative h-[6px] w-full bg-white-body dark:bg-black-body rounded-full overflow-hidden">
<div className={`absolute left-0 h-full w-1/2 bg-emerald-600`}></div>
</div>
</div>
</td>
<td className="px-2 text-right">
<div className='flex items-center justify-end gap-3 md:gap-4'>
{/* <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='edit' />
</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'>
<Link to={RouteLinks.transaction_details_page} state={{transactionID: item?.transaction_id}}>
<Icons name='eye' />
</Link>
</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'>
<Icons name='trash' />
</div> */}
</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>
}
<>
{dashData?.recent_transactions.length > 10 &&
<tr className="py-2 border-t border-dashed text-right text-primary border-slate-300">
<td className="px-3 py-2" colSpan={4}>
<Link to={RouteLinks.transactionsPage} className="flex justify-end items-center">
More ...
</Link>
</td>
</tr>
}
</>
</tbody>
</table>
</div>
</div>
</div>
}
</div>
)
}
+187
View File
@@ -0,0 +1,187 @@
// import {useEffect, useRef} from 'react'
// import ApexCharts from 'apexcharts'
// const Widget1 = ({chartHeight='50px'}) => {
// const chartRef = useRef(null)
// const {mode} = '' // to be replaced by theme mode value later
// useEffect(() => {
// const chart = refreshChart()
// return () => {
// if (chart) {
// chart.destroy()
// }
// }
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [chartRef, mode])
// const refreshChart = () => {
// if (!chartRef.current) {
// return
// }
// const chart = new ApexCharts(chartRef.current, chartOptions(chartHeight))
// if (chart) {
// chart.render()
// }
// return chart
// }
// return (
// <div className='w-full'>
// {/* end::Title */}
// <div
// ref={chartRef}
// className='mixed-widget-13-chart'
// style={{height: chartHeight, minHeight: chartHeight}}
// ></div>
// </div>
// )
// }
// const chartOptions = (chartHeight) => {
// // const labelColor = getCSSVariableValue('--bs-gray-800')
// // const strokeColor = getCSSVariableValue('--bs-gray-300')
// const labelColor = '#e9e9e9'
// const strokeColor = '#e3e3e3'
// // const strokeColor = getCSSVariableValue('--bs-gray-300') as string
// return {
// series: [
// {
// name: 'Loans',
// data: [15, 25, 15, 40, 20, 50],
// },
// ],
// grid: {
// show: false,
// padding: {
// top: 0,
// bottom: 0,
// left: 0,
// right: 0,
// },
// },
// chart: {
// fontFamily: 'inherit',
// type: 'area',
// height: chartHeight,
// toolbar: {
// show: false,
// },
// zoom: {
// enabled: false,
// },
// sparkline: {
// enabled: true,
// },
// },
// plotOptions: {},
// legend: {
// show: false,
// },
// dataLabels: {
// enabled: false,
// },
// fill: {
// type: 'gradient',
// gradient: {
// opacityFrom: 0.4,
// opacityTo: 0,
// stops: [20, 120, 120, 120],
// },
// },
// stroke: {
// curve: 'smooth',
// show: true,
// width: 3,
// colors: ['#FFFFFF'],
// },
// xaxis: {
// categories: ['Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
// axisBorder: {
// show: false,
// },
// axisTicks: {
// show: false,
// },
// labels: {
// show: false,
// style: {
// colors: labelColor,
// fontSize: '12px',
// },
// },
// crosshairs: {
// show: false,
// position: 'front',
// stroke: {
// color: strokeColor,
// width: 1,
// dashArray: 3,
// },
// },
// tooltip: {
// enabled: true,
// formatter: undefined,
// offsetY: 0,
// style: {
// fontSize: '12px',
// },
// },
// },
// yaxis: {
// min: 0,
// max: 60,
// labels: {
// show: false,
// style: {
// colors: labelColor,
// fontSize: '12px',
// },
// },
// },
// states: {
// normal: {
// filter: {
// type: 'none',
// value: 0,
// },
// },
// hover: {
// filter: {
// type: 'none',
// value: 0,
// },
// },
// active: {
// allowMultipleDataPointsSelection: false,
// filter: {
// type: 'none',
// value: 0,
// },
// },
// },
// tooltip: {
// style: {
// fontSize: '12px',
// },
// y: {
// formatter: function (val) {
// return '$' + val + ' thousand'
// },
// },
// },
// colors: ['#ffffff'],
// markers: {
// colors: [labelColor],
// strokeColors: [strokeColor],
// strokeWidth: 3,
// },
// }
// }
// export {Widget1}
+147
View File
@@ -0,0 +1,147 @@
// import {useEffect, useRef} from 'react'
// import ApexCharts from 'apexcharts'
// const Widget2 = ({chartHeight='100px'}) => {
// const chartRef = useRef(null)
// const {mode} = '' // to be replaced by theme mode value later
// useEffect(() => {
// const chart = refreshChart()
// return () => {
// if (chart) {
// chart.destroy()
// }
// }
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [chartRef, mode])
// const refreshChart = () => {
// if (!chartRef.current) {
// return
// }
// const chart = new ApexCharts(chartRef.current, chartOptions(chartHeight))
// if (chart) {
// chart.render()
// }
// return chart
// }
// return (
// <div className='w-full'>
// {/* end::Title */}
// <div
// ref={chartRef}
// className='mixed-widget-13-chart'
// style={{height: chartHeight, minHeight: chartHeight}}
// ></div>
// </div>
// )
// }
// const chartOptions = (chartHeight) => {
// // const labelColor = getCSSVariableValue('--bs-gray-800')
// return {
// series: [
// {
// name: 'Payments',
// data: [1, 2.1, 1, 2.1, 4.1, 6.1, 4.1, 4.1, 2.1, 4.1, 2.1, 3.1, 1, 1, 2.1],
// },
// ],
// chart: {
// fontFamily: 'inherit',
// height: chartHeight,
// type: 'bar',
// toolbar: {
// show: false,
// },
// },
// grid: {
// show: false,
// padding: {
// top: 0,
// bottom: 0,
// left: 0,
// right: 0,
// },
// },
// colors: ['#ffffff'],
// plotOptions: {
// bar: {
// borderRadius: 2.5,
// dataLabels: {
// position: 'top', // top, center, bottom
// },
// columnWidth: '20%',
// },
// },
// dataLabels: {
// enabled: false,
// formatter: function (val) {
// return val + '%'
// },
// offsetY: -20,
// style: {
// fontSize: '12px',
// colors: ['#304758'],
// },
// },
// xaxis: {
// labels: {
// show: false,
// },
// categories: [
// 'Jan',
// 'Feb',
// 'Mar',
// 'Apr',
// 'May',
// 'Jun',
// 'Jul',
// 'Aug',
// 'Sep',
// 'Oct',
// 'Nov',
// 'Dec',
// 'Jan',
// 'Feb',
// 'Mar',
// ],
// position: 'top',
// axisBorder: {
// show: false,
// },
// axisTicks: {
// show: false,
// },
// crosshairs: {
// show: false,
// },
// tooltip: {
// enabled: false,
// },
// },
// yaxis: {
// show: false,
// axisBorder: {
// show: false,
// },
// axisTicks: {
// show: false,
// // background: labelColor,
// },
// labels: {
// show: false,
// formatter: function (val) {
// return val + '%'
// },
// },
// },
// }
// }
// export {Widget2}