diff --git a/openubl/ui/client/src/app/context/ProjectContext.tsx b/openubl/ui/client/src/app/context/ProjectContext.tsx new file mode 100644 index 00000000..6457d97c --- /dev/null +++ b/openubl/ui/client/src/app/context/ProjectContext.tsx @@ -0,0 +1,35 @@ +import React, { createContext, useContext, useState } from "react"; + +interface IProjectContext { + projectId?: number | string; + setProjectId: (projectId: number | string) => void; +} + +const ProjectContext = createContext({ + projectId: undefined, + setProjectId: () => undefined, +}); + +interface IProjectContextProviderProps { + children: React.ReactNode; +} + +export const ProjectContextProvider: React.FC = ({ + children, +}: IProjectContextProviderProps) => { + const [projectid, setProjectId] = useState(); + + return ( + setProjectId(key), + }} + > + {children} + + ); +}; + +export const useProjectContext = (): IProjectContext => + useContext(ProjectContext); diff --git a/openubl/ui/client/src/app/layout/sidebar.tsx b/openubl/ui/client/src/app/layout/sidebar.tsx index 42741632..1e3c52b0 100644 --- a/openubl/ui/client/src/app/layout/sidebar.tsx +++ b/openubl/ui/client/src/app/layout/sidebar.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { NavLink, useParams } from "react-router-dom"; +import { NavLink, useMatch } from "react-router-dom"; import { Nav, @@ -11,17 +11,21 @@ import { import { css } from "@patternfly/react-styles"; import { LayoutTheme } from "./layout-constants"; +import { useFetchProjectById } from "@app/queries/projects"; const LINK_CLASS = "pf-v5-c-nav__link"; const ACTIVE_LINK_CLASS = "pf-m-current"; export const SidebarApp: React.FC = () => { - const params = useParams(); -console.log(params); + const routeParams = useMatch("/projects/:projectId/*"); + + let projectId = routeParams?.params.projectId; + let { project } = useFetchProjectById(projectId || ""); + const renderPageNav = () => { return (