import { Command } from "cmdk"; // hooks import Link from "next/link"; import { useRouter } from "next/router"; // constants import { EUserWorkspaceRoles, WORKSPACE_SETTINGS_LINKS } from "constants/workspace"; import { useUser } from "hooks/store"; 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}
) )} ); };