Show only business org create form if provider (#1104)

* Show only business org create form if provider

* Show only business-level orgs to add to providers

* business name was previously removed
This commit is contained in:
Matt Gibson 2021-08-03 12:42:02 -04:00 committed by GitHub
parent f6df9983a3
commit a23c2523d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -17,7 +17,10 @@ import { ProviderService } from '../services/provider.service';
import { Organization } from 'jslib-common/models/domain/organization';
import { Provider } from 'jslib-common/models/domain/provider';
import { ApiService } from 'jslib-common/abstractions';
import { PlanType } from 'jslib-common/enums/planType';
const DisallowedPlanTypes = [PlanType.Free, PlanType.FamiliesAnnually2019, PlanType.FamiliesAnnually];
@Component({
selector: 'provider-add-organization',
@ -35,7 +38,8 @@ export class AddOrganizationComponent implements OnInit {
constructor(private userService: UserService, private providerService: ProviderService,
private toasterService: ToasterService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private validationService: ValidationService) { }
private platformUtilsService: PlatformUtilsService, private validationService: ValidationService,
private apiService: ApiService) { }
async ngOnInit() {
await this.load();
@ -48,7 +52,12 @@ export class AddOrganizationComponent implements OnInit {
this.provider = await this.userService.getProvider(this.providerId);
this.organizations = (await this.userService.getAllOrganizations()).filter(p => p.providerId == null);
const candidateOrgs = (await this.userService.getAllOrganizations()).filter(o => o.providerId == null);
const allowedOrgsIds = await Promise.all(candidateOrgs.map(o => this.apiService.getOrganization(o.id))).then(orgs =>
orgs.filter(o => !DisallowedPlanTypes.includes(o.planType))
.map(o => o.id));
this.organizations = candidateOrgs.filter(o => allowedOrgsIds.includes(o.id));
this.loading = false;
}