-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.tsx
44 lines (36 loc) · 1.55 KB
/
index.tsx
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
39
40
41
42
43
44
import "./react-selenium-prep";
import "@skbkontur/react-selenium-testing";
import React from "react";
import ReactDom from "react-dom";
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
import { DbViewerApplication, DbViewerApi, NullCustomRenderer } from "./src";
import { DbViewerApiFake } from "./stories/Api/DbViewerApiFake";
import "./index.css";
const dbViewerApiPrefix = "/db-viewer/";
export const dbViewerApi = process.env.API === "fake" ? new DbViewerApiFake() : new DbViewerApi(dbViewerApiPrefix);
const AdminToolsEntryPoint = () => (
<BrowserRouter>
<Routes>
<Route
path="/BusinessObjects/*"
element={
<DbViewerApplication
identifierKeywords={["Cql", "StorageElement"]}
customRenderer={new NullCustomRenderer()}
useErrorHandlingContainer
isSuperUser={localStorage.getItem("isSuperUser") === "true"}
dbViewerApi={dbViewerApi}
/>
}
/>
<Route path="/" element={<Navigate to="/BusinessObjects" replace />} />
<Route path="/Admin" element={<AdminRedirect />} />
</Routes>
</BrowserRouter>
);
function AdminRedirect(): React.ReactElement {
document.cookie = "isSuperUser=true";
localStorage.setItem("isSuperUser", "true");
return <Navigate to="/BusinessObjects" replace />;
}
ReactDom.render(<AdminToolsEntryPoint />, document.getElementById("content"));