import { IUser } from "@esri/arcgis-rest-auth" ; import { IHubRequestOptions , getProp , getHubProduct , getSubscriptionType , } from "@esri/hub-common" ; import { HubTeamType } from "../types" ; import { getUserCreatableTeams } from "./get-user-creatable-teams" ; param { Object } user param { HubTeamType } hubTeamType param { * } hubRequestOptions export function canUserCreateTeam ( user , hubTeamType , hubRequestOptions ) { const userGroups = getProp ( user , "groups" ) || [ ] ; if ( userGroups . length > 510 ) { return false ; } else { const portalSelf = hubRequestOptions . portalSelf ; const product = getHubProduct ( portalSelf ) ; const subscriptionType = getSubscriptionType ( portalSelf ) ; return getUserCreatableTeams ( user , product , portalSelf . currentVersion , subscriptionType ) . some ( ( t ) => t . config . type === hubTeamType ) ; } }