auth-yes/ui/components/AdminLayout.tsx

189 lines
5.6 KiB
TypeScript

export const AdminLayout = ({
children,
title,
currentPath,
}: {
children: any;
title: string;
currentPath: string;
}) => {
const navItems = [
{ label: "← User Dashboard", href: "/dashboard" },
{ label: "Users", href: "/admin/users" },
{ label: "Applications", href: "/admin/apps" },
{ label: "Roles", href: "/admin/roles" },
{ label: "Invite Tokens", href: "/admin/invites" },
{ label: "AAGUID Allow-List", href: "/admin/aaguid" },
{ label: "Audit Logs", href: "/admin/audit-logs" },
];
return (
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{title} - Auth-Yes Admin</title>
<style>
{`
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background: #f4f6f8;
margin: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
.header {
background: #343a40;
color: white;
border-bottom: 1px solid #23272b;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.header h1 {
margin: 0;
font-size: 1.25rem;
color: #ffffff;
}
.nav {
display: flex;
gap: 1.5rem;
}
.nav a {
text-decoration: none;
color: #adb5bd;
font-weight: 500;
padding: 0.5rem 0;
}
.nav a:hover {
color: #ffffff;
}
.nav a.active {
color: #ffffff;
border-bottom: 2px solid #ffffff;
}
.main-content {
flex: 1;
padding: 2rem;
max-width: 1200px;
margin: 0 auto;
width: 100%;
box-sizing: border-box;
}
.card {
background: white;
padding: 1.5rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
margin-bottom: 1.5rem;
border: 1px solid #e9ecef;
}
h2 {
margin-top: 0;
color: #343a40;
font-size: 1.25rem;
border-bottom: 1px solid #e9ecef;
padding-bottom: 0.5rem;
margin-bottom: 1rem;
}
.table-container {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 0.75rem;
text-align: left;
border-bottom: 1px solid #dee2e6;
font-size: 0.9rem;
}
th {
background: #f8f9fa;
font-weight: 600;
color: #495057;
}
.btn-action {
background: #e9ecef;
color: #495057;
border: 1px solid #ced4da;
padding: 0.3rem 0.6rem;
border-radius: 4px;
cursor: pointer;
font-size: 0.8rem;
margin-right: 0.5rem;
}
.btn-action:hover {
background: #dee2e6;
}
.btn-success {
background: #28a745;
color: white;
border: 1px solid #28a745;
}
.btn-success:hover { background: #218838; }
.btn-warning {
background: #ffc107;
color: #212529;
border: 1px solid #ffc107;
}
.btn-warning:hover { background: #e0a800; }
.badge {
display: inline-block;
padding: 0.25em 0.4em;
font-size: 75%;
font-weight: 700;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
}
.badge-active { background-color: #28a745; color: white; }
.badge-pending { background-color: #ffc107; color: #212529; }
.badge-suspended { background-color: #dc3545; color: white; }
pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; font-size: 0.8rem; }
`}
</style>
</head>
<body>
<header class="header">
<div style="display: flex; align-items: center; gap: 2rem;">
<h1>Auth-Yes Admin Console</h1>
<nav class="nav">
{navItems.map((item) => {
const isActive = currentPath === item.href;
return (
<a
href={item.href}
class={isActive ? "active" : ""}
>
{item.label}
</a>
);
})}
</nav>
</div>
<div style="display: flex; align-items: center; gap: 1rem;">
<a
href="/logout"
class="btn-action btn-warning"
style="text-decoration: none; padding: 0.35rem 0.8rem; font-size: 0.85rem; border-radius: 4px;"
>
Logout
</a>
</div>
</header>
<main class="main-content">
{children}
</main>
</body>
</html>
);
};