diff --git a/src/components/CurveFit.js b/src/components/CurveFit.js index 0395374..9b335a5 100644 --- a/src/components/CurveFit.js +++ b/src/components/CurveFit.js @@ -8,11 +8,12 @@ import ImageDownloader from './ImageDownloader'; function CurveFit({ show }) { const [showCardInfo, setShowCardInfo] = useState(false); const [svgData, setSvgData] = useState(null); + const [loading, setLoading] = useState(true); const fetchSvg = () => { axios({ method: 'get', - url: "https://asia-south1-hpos-qa.cloudfunctions.net/curvefit", + url: "https://asia-south1-hpos-af3cc.cloudfunctions.net/crdboxplot", data: { "_id": "id", "underMedication": false, @@ -28,29 +29,37 @@ function CurveFit({ show }) { }) .then(response => response.data) .then((data) => { - // setMessage(`${id} is being created`); - // setSvgData(data?.plot?.replace('\"', '').replace('\n', '').replace('"', "'")); + setSvgData(data?.plot?.replace('\"', '').replace('\n', '').replace('"', "'")); + setLoading(false); // Set loading to false once data is fetched }) .catch((err) => { console.log(err); - // setMessage(`error: ${err?.message}`); + setLoading(false); // Set loading to false in case of an error }); } useEffect(() => { if (!svgData) { - // fetchSvg(); + fetchSvg(); } }, []); return (
-

Curve Fit

- {/* ; */} - - +

Plots

+ + {loading ? ( +
+ {/* Add your spinner component here or use a simple text */} +

Loading...

+
+ ) : ( + + )} + {/* */}
); } -export default CurveFit; \ No newline at end of file + +export default CurveFit; diff --git a/src/routes/appRoutes.js b/src/routes/appRoutes.js index 361d464..e506f8e 100644 --- a/src/routes/appRoutes.js +++ b/src/routes/appRoutes.js @@ -114,15 +114,15 @@ const appRoutes = [ icon: } }, - // { - // path: "/curvefit", - // element: , - // state: "curvefit", - // sidebarProps: { - // displayText: "Linear Fit", - // icon: - // } - // }, + { + path: "/plots", + element: , + state: "plots", + sidebarProps: { + displayText: "Plots", + icon: + } + }, { path: "/chat", element: ,