Harden user management integration
This commit is contained in:
parent
73579d1e79
commit
847f4e9493
18 changed files with 394 additions and 111 deletions
|
|
@ -7,6 +7,7 @@ import { listProjects } from "../utils/api";
|
|||
import type { ProjectDto } from "../types";
|
||||
import { ThemeToggle } from "./ThemeToggle";
|
||||
import { useAuth } from "./AuthProvider";
|
||||
import { getConfigEntry } from "../utils/config-access";
|
||||
|
||||
// Anchors on the project overview page (/projects/[id]).
|
||||
const PROJECT_SECTIONS = [
|
||||
|
|
@ -32,6 +33,7 @@ interface SidebarProps {
|
|||
export function Sidebar({ isCollapsed, onToggleCollapsed }: SidebarProps) {
|
||||
const pathname = usePathname();
|
||||
const { user, isAdmin, logout } = useAuth();
|
||||
const configEntry = getConfigEntry(isAdmin);
|
||||
const projectMatch = pathname?.match(PROJECT_PATH_PATTERN);
|
||||
const activeProjectId = projectMatch ? projectMatch[1] : null;
|
||||
const projectSubPath = projectMatch?.[2] ?? "";
|
||||
|
|
@ -181,18 +183,16 @@ export function Sidebar({ isCollapsed, onToggleCollapsed }: SidebarProps) {
|
|||
</>
|
||||
)}
|
||||
</nav>
|
||||
{isAdmin && (
|
||||
<nav className="sidebar-nav sidebar-nav-bottom">
|
||||
<Link
|
||||
href="/config"
|
||||
className={pathname?.startsWith("/config") ? "sidebar-link active" : "sidebar-link"}
|
||||
title="Config"
|
||||
>
|
||||
<span className="sidebar-icon">⚙</span>
|
||||
<span className="sidebar-label">Config</span>
|
||||
</Link>
|
||||
</nav>
|
||||
)}
|
||||
<nav className="sidebar-nav sidebar-nav-bottom">
|
||||
<Link
|
||||
href={configEntry.href}
|
||||
className={pathname?.startsWith("/config") ? "sidebar-link active" : "sidebar-link"}
|
||||
title={configEntry.label}
|
||||
>
|
||||
<span className="sidebar-icon">⚙</span>
|
||||
<span className="sidebar-label">{configEntry.label}</span>
|
||||
</Link>
|
||||
</nav>
|
||||
<div className="sidebar-footer">
|
||||
{user && !isCollapsed && (
|
||||
<div className="sidebar-identity" title={`Angemeldet als ${user.name}`}>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ import type {
|
|||
CableSizingInput,
|
||||
CableSizingResult,
|
||||
} from "../../cable-sizing/domain/cable-sizing-calculation";
|
||||
import {
|
||||
WRITE_REQUEST_HEADER_NAME,
|
||||
WRITE_REQUEST_HEADER_VALUE,
|
||||
} from "../../shared/constants/request-security";
|
||||
|
||||
export interface CalculateCableSizingResponse {
|
||||
result: CableSizingResult;
|
||||
|
|
@ -17,7 +21,10 @@ export async function calculateCableSizing(
|
|||
): Promise<CalculateCableSizingResponse> {
|
||||
const response = await fetch("/api/cable-sizing/calculate", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
[WRITE_REQUEST_HEADER_NAME]: WRITE_REQUEST_HEADER_VALUE,
|
||||
},
|
||||
body: JSON.stringify(input),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue