-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLayout.tsx
More file actions
65 lines (61 loc) · 2.06 KB
/
Layout.tsx
File metadata and controls
65 lines (61 loc) · 2.06 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
59
60
61
62
63
64
65
import { NavLink, Outlet, useNavigate } from "react-router-dom";
import { useAuth } from "../auth";
const navItems: { to: string; label: string; end?: boolean }[] = [
{ to: "/", label: "Overview", end: true },
{ to: "/dynamo", label: "DynamoDB" },
{ to: "/sqs", label: "SQS" },
{ to: "/s3", label: "S3" },
{ to: "/keyviz", label: "Key Visualizer" },
];
export function Layout() {
const { session, logout } = useAuth();
const navigate = useNavigate();
const onSignOut = async () => {
await logout();
navigate("/login", { replace: true });
};
return (
<div className="min-h-screen flex flex-col">
<header className="border-b border-border bg-surface-2">
<div className="mx-auto max-w-6xl px-4 py-3 flex items-center gap-6">
<div className="font-semibold text-lg">elastickv admin</div>
<nav className="flex gap-1 text-sm">
{navItems.map((item) => (
<NavLink
key={item.to}
to={item.to}
end={item.end}
className={({ isActive }) =>
`px-3 py-1.5 rounded-md transition-colors ${
isActive
? "bg-accent text-white"
: "text-muted hover:text-ink hover:bg-surface"
}`
}
>
{item.label}
</NavLink>
))}
</nav>
<div className="ml-auto flex items-center gap-3 text-sm">
{session && (
<>
<span className={session.role === "full" ? "pill-accent" : "pill-muted"}>
{session.role === "full" ? "full access" : "read only"}
</span>
<button type="button" className="btn-secondary" onClick={onSignOut}>
Sign out
</button>
</>
)}
</div>
</div>
</header>
<main className="flex-1">
<div className="mx-auto max-w-6xl px-4 py-6">
<Outlet />
</div>
</main>
</div>
);
}