-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.tsx
More file actions
58 lines (50 loc) · 1.51 KB
/
Copy pathindex.tsx
File metadata and controls
58 lines (50 loc) · 1.51 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { useRouterState } from "@tanstack/react-router";
import { useCurrentUserRole } from "@flow/stores";
import { Role } from "@flow/types";
import { BottomSection, TopSection } from "./components";
export const routeOptions = [
"projects",
"deployments",
"general",
"integrations",
"members",
"runnning",
"queued",
"completed",
"new",
"all",
];
export type RouteOption = (typeof routeOptions)[number];
const LeftPanel: React.FC = () => {
const {
location: { pathname },
} = useRouterState();
const route: RouteOption = getRoute(pathname);
const [currentUserRole] = useCurrentUserRole();
return (
<div className="m-2 flex w-[260px] flex-col justify-between gap-[8px] rounded-xl border bg-secondary px-2 shadow-md shadow-secondary backdrop-blur-xs">
<div className="flex flex-1 flex-col">
<TopSection route={route} />
{currentUserRole !== Role.Reader && <BottomSection route={route} />}
</div>
</div>
);
};
export default LeftPanel;
const getRoute = (pathname: string): RouteOption => {
return pathname.includes("deployments")
? "deployments"
: pathname.includes("general")
? "general"
: pathname.includes("integrations")
? "integrations"
: pathname.includes("members")
? "members"
: pathname.includes("jobs")
? "jobs"
: pathname.includes("triggers")
? "triggers"
: pathname.includes("assets")
? "assets"
: "projects";
};