import { useTranslation } from "react-i18next"; import { Check, ChevronDown } from "lucide-react"; import { LuLayers } from "react-icons/lu"; import { cn } from "@/lib/utils"; import { getProfileColor } from "@/utils/profileColors"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; type ProfileSectionDropdownProps = { allProfileNames: string[]; profileFriendlyNames: Map; editingProfile: string | null; hasProfileData: (profileName: string) => boolean; onSelectProfile: (profileName: string | null) => void; /** When true, show only an icon as the trigger (for mobile) */ iconOnly?: boolean; }; export function ProfileSectionDropdown({ allProfileNames, profileFriendlyNames, editingProfile, hasProfileData, onSelectProfile, iconOnly = false, }: ProfileSectionDropdownProps) { const { t } = useTranslation(["views/settings"]); const activeColor = editingProfile ? getProfileColor(editingProfile, allProfileNames) : null; const editingFriendlyName = editingProfile ? (profileFriendlyNames.get(editingProfile) ?? editingProfile) : null; return ( {iconOnly ? ( ) : ( )} onSelectProfile(null)}>
{editingProfile === null && ( )} {t("profiles.baseConfig", { ns: "views/settings" })}
{allProfileNames.length > 0 && } {allProfileNames.map((profile) => { const color = getProfileColor(profile, allProfileNames); const hasData = hasProfileData(profile); const isActive = editingProfile === profile; return ( onSelectProfile(profile)} >
{isActive && } {profileFriendlyNames.get(profile) ?? profile}
{!hasData && ( {t("profiles.noOverrides", { ns: "views/settings" })} )}
); })}
); }