28 lines
710 B
TypeScript
28 lines
710 B
TypeScript
import { Directive, OnInit, TemplateRef, ViewContainerRef } from "@angular/core";
|
|
|
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
|
|
|
/**
|
|
* Hides the element if the user has premium.
|
|
*/
|
|
@Directive({
|
|
selector: "[appNotPremium]",
|
|
})
|
|
export class NotPremiumDirective implements OnInit {
|
|
constructor(
|
|
private templateRef: TemplateRef<any>,
|
|
private viewContainer: ViewContainerRef,
|
|
private stateService: StateService
|
|
) {}
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
const premium = await this.stateService.getCanAccessPremium();
|
|
|
|
if (premium) {
|
|
this.viewContainer.clear();
|
|
} else {
|
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
}
|
|
}
|
|
}
|