diff --git a/src/components/Charts/HorizontalBarChart.jsx b/src/components/Charts/HorizontalBarChart.jsx index 5a02c98f..5aec5e12 100644 --- a/src/components/Charts/HorizontalBarChart.jsx +++ b/src/components/Charts/HorizontalBarChart.jsx @@ -1,6 +1,7 @@ import React from "react"; import ReactApexChart from "react-apexcharts"; import PropTypes from "prop-types"; +import { SpinnerLoader } from "../common/Loader"; const HorizontalBarChart = ({ seriesData = [], @@ -23,7 +24,12 @@ const HorizontalBarChart = ({ if (loading) { return (
- Loading chart... +
+ +
{/* Replace this with a skeleton or spinner if you prefer */}
); diff --git a/src/components/Charts/LineChart.jsx b/src/components/Charts/LineChart.jsx index 6eb4840c..be8b5ebe 100644 --- a/src/components/Charts/LineChart.jsx +++ b/src/components/Charts/LineChart.jsx @@ -1,6 +1,7 @@ import React from "react"; import ReactApexChart from "react-apexcharts"; import PropTypes from "prop-types"; +import { SpinnerLoader } from "../common/Loader"; const LineChart = ({ seriesData = [], @@ -9,24 +10,28 @@ const LineChart = ({ loading = false, lineChartCategoriesDates = [], }) => { - const hasValidData = - Array.isArray(seriesData) && - seriesData.length > 0 && - Array.isArray(categories) && - categories.length > 0; + const hasValidData = + Array.isArray(seriesData) && + seriesData.length > 0 && + Array.isArray(categories) && + categories.length > 0; - if (loading) { - return ( -
-
- Loading chart... -
- ); - } + if (loading) { + return ( +
+
+ +
+
+ ); + } - if (!hasValidData) { - return
No data to display
; - } + if (!hasValidData) { + return
No data to display
; + } const chartOptions = { chart: { @@ -129,16 +134,16 @@ const LineChart = ({ }; LineChart.propTypes = { - seriesData: PropTypes.arrayOf( - PropTypes.shape({ - name: PropTypes.string.isRequired, - data: PropTypes.arrayOf(PropTypes.number).isRequired - }) - ), - categories: PropTypes.arrayOf(PropTypes.string), - colors: PropTypes.arrayOf(PropTypes.string), - title: PropTypes.string, - loading: PropTypes.bool + seriesData: PropTypes.arrayOf( + PropTypes.shape({ + name: PropTypes.string.isRequired, + data: PropTypes.arrayOf(PropTypes.number).isRequired + }) + ), + categories: PropTypes.arrayOf(PropTypes.string), + colors: PropTypes.arrayOf(PropTypes.string), + title: PropTypes.string, + loading: PropTypes.bool }; export default LineChart; diff --git a/src/components/Dashboard/ExpenseAnalysis.jsx b/src/components/Dashboard/ExpenseAnalysis.jsx index f398e8b5..ae7c9f37 100644 --- a/src/components/Dashboard/ExpenseAnalysis.jsx +++ b/src/components/Dashboard/ExpenseAnalysis.jsx @@ -6,6 +6,7 @@ import { DateRangePicker1 } from "../common/DateRangePicker"; import { FormProvider, useForm } from "react-hook-form"; import { formatCurrency, localToUtc } from "../../utils/appUtils"; import { useProjectName } from "../../hooks/useProjects"; +import { SpinnerLoader } from "../common/Loader"; const ExpenseAnalysis = () => { const projectId = useSelectedProject(); @@ -78,86 +79,92 @@ const ExpenseAnalysis = () => { return ( <> - -
-
-
Expense Breakdown
- {/*

Category Wise Expense Breakdown

*/} -

{projectName}

-
-
- - - -
+
+
+
Expense Breakdown
+ {/*

Category Wise Expense Breakdown

*/} +

{projectName}

- {/* Card body */} -
- {isLoading && ( -
- Loading... +
+ + + +
+
+ + {/* Card body */} +
+ {isLoading && ( +
+ +
+ )} + + {!isLoading && report.length === 0 && ( +
+ No data found +
+ )} + + + {!isLoading && report.length > 0 && ( + <> + {isFetching && ( +
+ Loading... +
+ )} + +
+
- )} - {!isLoading && report.length === 0 && ( -
No data found
- )} - - {!isLoading && report.length > 0 && ( - <> - {isFetching && ( -
- Loading... -
- )} - -
- -
- -
-
- {report.map((item, idx) => ( -
-
- - - -
-
- {item.projectName} - - {formatCurrency(item.totalApprovedAmount)} - -
+
+
+ {report.map((item, idx) => ( +
+
+ + +
- ))} -
+
+ {item.projectName} + + {formatCurrency(item.totalApprovedAmount)} + +
+
+ ))}
- - )} -
- +
+ + )} +
+ {/* Header */} diff --git a/src/components/common/Loader.jsx b/src/components/common/Loader.jsx index 07078edb..6727117f 100644 --- a/src/components/common/Loader.jsx +++ b/src/components/common/Loader.jsx @@ -19,3 +19,13 @@ const Loader = () => { export default Loader; +export const SpinnerLoader = () => { + return ( +
+
+ Loading... +
+

Loading data...

+
+ ) +} \ No newline at end of file