import { useRouter } from "next/router"; import { Command } from "cmdk"; // hooks import { useUser } from "hooks/store"; import Link from "next/link"; // constants import { EUserWorkspaceRoles, WORKSPACE_SETTINGS_LINKS } from "constants/workspace"; type Props = { closePalette: () => void; }; export const CommandPaletteWorkspaceSettingsActions: React.FC = (props) => { const { closePalette } = props; // router const router = useRouter(); const { workspaceSlug } = router.query; // mobx store const { membership: { currentWorkspaceRole }, } = useUser(); // derived values const workspaceMemberInfo = currentWorkspaceRole || EUserWorkspaceRoles.GUEST; const redirect = (path: string) => { closePalette(); router.push(path); }; return ( <> {WORKSPACE_SETTINGS_LINKS.map( (setting) => workspaceMemberInfo >= setting.access && ( redirect(`/${workspaceSlug}${setting.href}`)} className="focus:outline-none" >
{setting.label}
) )} ); };