"use client"; import React, { useEffect, useState } from "react"; import Link from "next/link"; import ProfileIcon from "@app/components/ProfileIcon"; import ThemeSwitcher from "@app/components/ThemeSwitcher"; import { useTheme } from "next-themes"; import BrandingLogo from "./BrandingLogo"; import { useEnvContext } from "@app/hooks/useEnvContext"; import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext"; import { ListUserOrgsResponse } from "@server/routers/org"; import { LauncherOrgSelector } from "@app/components/resource-launcher/LauncherOrgSelector"; import { Button } from "@app/components/ui/button"; import { useTranslations } from "next-intl"; type LayoutHeaderProps = { showTopBar: boolean; launcherMode?: boolean; orgId?: string; orgs?: ListUserOrgsResponse["orgs"]; showViewAsAdmin?: boolean; }; export function LayoutHeader({ showTopBar, launcherMode = false, orgId, orgs, showViewAsAdmin = false }: LayoutHeaderProps) { const { theme } = useTheme(); const [path, setPath] = useState(""); const { env } = useEnvContext(); const { isUnlocked } = useLicenseStatusContext(); const t = useTranslations(); const logoWidth = isUnlocked() ? env.branding.logo?.navbar?.width || 98 : 98; const logoHeight = isUnlocked() ? env.branding.logo?.navbar?.height || 32 : 32; useEffect(() => { function getPath() { let lightOrDark = theme; if (theme === "system" || !theme) { lightOrDark = window.matchMedia("(prefers-color-scheme: dark)") .matches ? "dark" : "light"; } if (lightOrDark === "light") { return "/logo/word_mark_black.png"; } return "/logo/word_mark_white.png"; } setPath(getPath()); }, [theme]); return (
{launcherMode ? ( <> {showViewAsAdmin && orgId ? ( ) : null} ) : null}
{showTopBar && (
)}
); } export default LayoutHeader;