From 310e3ce7aec17db7d489cd71add73eb54cdb7348 Mon Sep 17 00:00:00 2001
From: unknown <shruthichandran@digitalgreen.org>
Date: Thu, 12 Sep 2024 15:52:27 +0530
Subject: [PATCH] routes fixed

---
 src/features/default/src/Layout/Datahub.js          | 13 ++++++++++++-
 .../default/src/Views/Dashboard/DashboardNew.js     |  7 +++++++
 .../src/Views/GuestUser/TempDaRegistryFile.js       | 13 +++++++++++++
 .../src/Views/Pages/Dashboard/streamlit/index.js    | 10 ++++------
 4 files changed, 36 insertions(+), 7 deletions(-)
 create mode 100644 src/features/default/src/Views/GuestUser/TempDaRegistryFile.js

diff --git a/src/features/default/src/Layout/Datahub.js b/src/features/default/src/Layout/Datahub.js
index 38cd73cc..73867f4d 100644
--- a/src/features/default/src/Layout/Datahub.js
+++ b/src/features/default/src/Layout/Datahub.js
@@ -89,6 +89,7 @@ const EditDataset = lazy(() =>
 const DashboardNew = lazy(() => import("../Views/Dashboard/DashboardNew"));
 const StreamlitFrame = lazy(() => import("../Views/Pages/Dashboard/streamlit"));
 const TempFile = lazy(() => import("../Views/GuestUser/TempFarmerFile"));
+const DaFile = lazy(() => import("../Views/GuestUser/TempDaRegistryFile"));
 const Support = lazy(() => import("../Components/Support_New/Support"));
 const SupportView = lazy(() => import("../Components/Support_New/SupportView"));
 const AskSupport = lazy(() => import("../Components/Support_New/SupportForm"));
@@ -311,7 +312,17 @@ function Datahub(props) {
               <Route
                 exact
                 path="/datahub/dashboards/:name"
-                component={TempFile}
+                render={(props) => {
+                  const { name } = props.match.params;
+
+                  if (name === "farmer_registry_dashboard") {
+                    return <TempFile />;
+                  } else if (name === "da_registry_dashboard") {
+                    return <DaFile />;
+                  } else {
+                    return <NotFound />;
+                  }
+                }}
               />
               {isParticipantsEnabled && (
                 <Route
diff --git a/src/features/default/src/Views/Dashboard/DashboardNew.js b/src/features/default/src/Views/Dashboard/DashboardNew.js
index b707e2d8..2eb8fa57 100644
--- a/src/features/default/src/Views/Dashboard/DashboardNew.js
+++ b/src/features/default/src/Views/Dashboard/DashboardNew.js
@@ -255,6 +255,13 @@ function DashboardNew() {
           : isLoggedInUserParticipant()
           ? `/participant/dashboards/${item}`
           : "/home";
+    } else if (item === "da_registry_dashboard") {
+      path =
+        isLoggedInUserAdmin() || isLoggedInUserCoSteward()
+        ? `/datahub/dashboards/da_registry_dashboard`
+        : isLoggedInUserParticipant()
+        ? `/participant/dashboards/da_registry_dashboard`
+        : "/home";
     } else {
       path =
         isLoggedInUserAdmin() || isLoggedInUserCoSteward()
diff --git a/src/features/default/src/Views/GuestUser/TempDaRegistryFile.js b/src/features/default/src/Views/GuestUser/TempDaRegistryFile.js
new file mode 100644
index 00000000..f74fe3ec
--- /dev/null
+++ b/src/features/default/src/Views/GuestUser/TempDaRegistryFile.js
@@ -0,0 +1,13 @@
+import { FarmStackContext } from "common/components/context/DefaultContext/FarmstackProvider";
+import React, { useContext, useEffect, useRef } from "react";
+import Dashboard from "../../../../../Da_Registry/index";
+
+const TempDaRegistryFile = () => {
+  const { callToast, callLoader } = useContext(FarmStackContext);
+
+  return (
+    <><Dashboard /></>
+  );
+};
+
+export default TempDaRegistryFile;
diff --git a/src/features/default/src/Views/Pages/Dashboard/streamlit/index.js b/src/features/default/src/Views/Pages/Dashboard/streamlit/index.js
index 96690c18..0838652d 100644
--- a/src/features/default/src/Views/Pages/Dashboard/streamlit/index.js
+++ b/src/features/default/src/Views/Pages/Dashboard/streamlit/index.js
@@ -1,7 +1,6 @@
 import { Box, CssBaseline } from "@mui/material";
 import { FarmStackContext } from "common/components/context/DefaultContext/FarmstackProvider";
 import UrlConstant from "common/constants/UrlConstants";
-import Dashboard from "../../../../../../../Da_Registry/index"
 
 import React, { useContext, useEffect, useState } from "react";
 import { useParams } from "react-router-dom";
@@ -30,9 +29,8 @@ const StreamlitFrame = () => {
 
   return (
     <>
-    <Dashboard />
-      {/* <CssBaseline /> */}
-      {/* <Box
+      <CssBaseline /> 
+      <Box
         sx={{
           width: "100vw",
           height: "100vh",
@@ -51,8 +49,8 @@ const StreamlitFrame = () => {
           height="100%"
           frameBorder="0"
           allowFullScreen
-        ></iframe> */}
-      {/* </Box> */}
+        ></iframe> 
+       </Box> 
     </>
   );
 };