forked from caraml-dev/turing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrivateLayout.js
38 lines (37 loc) · 1.17 KB
/
PrivateLayout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from "react";
import {
ApplicationsContext,
ApplicationsContextProvider,
Header,
PrivateRoute,
ProjectsContextProvider,
} from "@caraml-dev/ui-lib";
import urlJoin from "proper-url-join";
import { Outlet, useNavigate } from "react-router-dom";
import { useConfig } from "./config";
import { EnvironmentsContextProvider } from "./providers/environments/context";
import "./PrivateLayout.scss";
export const PrivateLayout = () => {
const navigate = useNavigate();
const { appConfig } = useConfig();
return (
<PrivateRoute>
<ApplicationsContextProvider>
<ProjectsContextProvider>
<EnvironmentsContextProvider>
<ApplicationsContext.Consumer>
{({ currentApp }) => (
<Header
onProjectSelect={pId =>
navigate(urlJoin(currentApp?.homepage, "projects", pId, "routers"))
}
docLinks={appConfig.docsUrl}
/>)}
</ApplicationsContext.Consumer>
<Outlet />
</EnvironmentsContextProvider>
</ProjectsContextProvider>
</ApplicationsContextProvider>
</PrivateRoute>
);
};