diff --git a/pwa/app/components/bar-chart/chart.jsx b/pwa/app/components/bar-chart/chart.jsx
index 9028d212ab871bac130c8204807aac0de4cc48d9..e8721f1f425552a3f7070de89ed55339407c68c5 100644
--- a/pwa/app/components/bar-chart/chart.jsx
+++ b/pwa/app/components/bar-chart/chart.jsx
@@ -1,7 +1,9 @@
import React, { useEffect, useRef } from 'react';
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faSpinner } from "@fortawesome/free-solid-svg-icons";
import * as d3 from 'd3';
-const BarChart = ({ data }) => {
+const BarChart = ({ data}) => {
const d3Chart = useRef();
const drawChart = () => {
@@ -81,7 +83,7 @@ const BarChart = ({ data }) => {
}, [data]);
return (
-
+
);
diff --git a/pwa/app/components/line_chart.jsx b/pwa/app/components/line_chart.jsx
index 83a95c8ea45ef1ef26d74f468a9f10e795e3ff71..c32bd660d8efa418b28bef0192b622a6f3f70045 100644
--- a/pwa/app/components/line_chart.jsx
+++ b/pwa/app/components/line_chart.jsx
@@ -5,6 +5,7 @@ import * as d3 from "d3";
function LineChart({ data }) {
const chartRef = useRef(null);
+ const isLoading = data.length === 0;
const width = 940;
const height = 400;
@@ -13,8 +14,6 @@ function LineChart({ data }) {
const marginBottom = 30;
const marginLeft = 60;
- const isLoading = data.length === 0;
-
useEffect(() => {
const x = d3.scaleTime()
diff --git a/pwa/app/page.jsx b/pwa/app/page.jsx
index ef8ac7594b254578a04b77896d0fe59bad75c540..e61855e7c2a3a6b46139de665b89cbdd7249b47c 100644
--- a/pwa/app/page.jsx
+++ b/pwa/app/page.jsx
@@ -9,13 +9,14 @@ import DateInput from "./components/date-input";
import DataForm from "./components/bar-chart/form";
import BarChart from "./components/bar-chart/chart";
import Line_Chart from "./components/line_chart.jsx";
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faSpinner } from "@fortawesome/free-solid-svg-icons";
export default function Page() {
const [donutValues, setDonutValues] = useState([]);
const [chartData, setChartData] = useState([]);
const [lineData, setLineData] = useState([]);
const [isLoading, setIsLoading] = useState(false);
- const Loader = () =>
Loading...
;
const handleFormSubmit = async (formData) => {
setIsLoading(true);
@@ -23,6 +24,7 @@ export default function Page() {
setChartData(data);
setIsLoading(false);
};
+
const loadInitialBarChartData = async () => {
setIsLoading(true);
try {
@@ -70,9 +72,12 @@ export default function Page() {
Nombre des ventes par période
- {isLoading && }
-
+ {isLoading? (
+
+ ) : (
+
+ )}
Répartition des ventes par régions
diff --git a/pwa/app/style/style.css b/pwa/app/style/style.css
index f16df6e796c9e2ca5eb4106c19b714c9d0d6cbca..2e1b648bd0d72c7bd9ddc0274311bc072a6fda53 100644
--- a/pwa/app/style/style.css
+++ b/pwa/app/style/style.css
@@ -3,14 +3,16 @@
border: 1px solid #ddd;
border-radius: 8px;
padding: 20px;
- margin: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
+ width: auto;
+ margin-bottom: 20px;
}
.card-container {
display: flex;
- justify-content: center;
- flex-wrap: wrap;
+ flex-direction: column;
+ align-items: center;
+ width: auto;
}
.chart-container {
@@ -41,3 +43,7 @@
.form-container button:hover {
background-color: #45a049;
}
+
+.spinner{
+ margin: 50%;
+}