import { DashboardLayout } from "@edr/ui-common";
import { Box } from "@mantine/core";
import { useLocation, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type { ReactNode } from "react";
import { useAuth } from "@/auth/AuthContext";
import { setLanguage } from "@/i18n";
import { FINANCE_NAV, findActive, visibleNav } from "@/shared/nav/nav-model";
import { localized } from "@/shared/lib/localizedName";
import {
CommandPalette,
openCommandPalette,
} from "@/shared/components/CommandPalette";
const LANGUAGES = [
{ code: "en", label: "English" },
{ code: "am", label: "አማርኛ" },
];
/** The shortcut is only discoverable if something on screen names it. */
function SearchPill() {
return (
);
}
export function AppShell({ children }: { children: ReactNode }) {
const navigate = useNavigate();
const location = useLocation();
const { user, logout, can } = useAuth();
const { i18n } = useTranslation();
const items = visibleNav(FINANCE_NAV, can);
const { group, entry } = findActive(FINANCE_NAV, location.pathname);
const name = localized(user?.name, "en") || user?.username || "";
const breadcrumb = entry ? (
{group ? (
<>
{group.label}
/
>
) : null}
{entry.label}
) : (
EDR Finance
);
return (
<>
navigate(href)}
userName={name}
userEmail={user?.email}
userInitials={name.slice(0, 2).toUpperCase()}
onLogout={logout}
enableThemeToggle
breadcrumb={breadcrumb}
headerLeft={}
languages={LANGUAGES}
language={i18n.language}
onLanguageChange={(code) => setLanguage(code as "en" | "am")}
// No notification source exists in this app yet.
showNotifications={false}
// finance-web has no profile screen — an entry that 404s is worse than
// no entry.
showProfileLink={false}
responsiveSidebar
sidebarPersistKey="finance-nav-expanded"
>
{/* `main` in ui-common has zero padding by design — its other ~94
consumers pad themselves — so the gutter belongs here. */}
{children}
>
);
}