2019-07-06 17:40:32 -04:00
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { WidgetApiService } from "../../shared/services/integrations/widget-api.service";
|
|
|
|
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
|
|
|
|
import { ToasterService } from "angular2-toaster";
|
2020-10-23 07:30:20 -04:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2019-07-06 17:40:32 -04:00
|
|
|
|
|
|
|
@Component({
|
2021-09-01 19:29:24 -04:00
|
|
|
selector: "my-terms-widget-wrapper",
|
2019-07-06 17:40:32 -04:00
|
|
|
templateUrl: "terms.component.html",
|
|
|
|
styleUrls: ["terms.component.scss"],
|
|
|
|
})
|
|
|
|
export class TermsWidgetWrapperComponent implements OnInit {
|
|
|
|
public isLoading = true;
|
|
|
|
public html: SafeHtml;
|
|
|
|
|
2021-09-01 19:01:01 -04:00
|
|
|
constructor(
|
|
|
|
private activatedRoute: ActivatedRoute,
|
|
|
|
private sanitizer: DomSanitizer,
|
|
|
|
private toaster: ToasterService,
|
|
|
|
private widgetApi: WidgetApiService,
|
|
|
|
public translate: TranslateService
|
|
|
|
) {
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate = translate;
|
2019-07-06 17:40:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit(): void {
|
|
|
|
const params: any = this.activatedRoute.snapshot.params;
|
|
|
|
|
2021-09-01 19:01:01 -04:00
|
|
|
this.widgetApi
|
|
|
|
.getTerms(params.shortcode, params.lang, params.version)
|
|
|
|
.then((terms) => {
|
|
|
|
this.html = this.sanitizer.bypassSecurityTrustHtml(terms.text);
|
|
|
|
this.isLoading = false;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
this.translate.get("Error loading policy").subscribe((res: string) => {
|
|
|
|
this.toaster.pop("error", res);
|
|
|
|
});
|
|
|
|
});
|
2019-07-06 17:40:32 -04:00
|
|
|
}
|
|
|
|
}
|