import { Link } from 'react-router-dom' import { Menu, useMenuState, MenuItem, MenuButton, MenuStateReturn, } from 'reakit' import classNames from 'classnames' import IconCheck from '~/icons/compiled/Check' import { useOrgSwitcher } from '~/utils/useOrgSwitcher' import Transition from '../Transition' import { dropdownMenuClassNames } from '~/components/DropdownMenu' import { NAV_ITEM_HEIGHT } from '.' import IconCaretDown from '~/icons/compiled/CaretDown' import React from 'react' function MenuHeader({ label }) { return (

{label}

) } function MenuListItem({ onClick, label, isActive, ...menu }: MenuStateReturn & { onClick?: (event: React.MouseEvent) => void label: string isActive?: boolean }) { return ( {isActive && ( )} {label} ) } export default function OrgSwitcher() { const switcherState = useOrgSwitcher() const { me, organization: currentOrg, setOrg } = switcherState const menu = useMenuState({ animated: 250, gutter: -4 }) const otherOrgs = me?.userOrganizationAccess.filter( access => access.organizationId !== currentOrg.id ) ?? [] return (
{currentOrg.name}
{otherOrgs.length > 0 && (
{otherOrgs.map(({ organization }) => (
{ if (e.metaKey || e.ctrlKey) { window.open( `/dashboard/${organization.slug}/actions` ) menu.hide() } else { setOrg(organization) } }} label={organization.name} isActive={currentOrg.id === organization.id} />
))}
)} Create organization...
) }