
import { Component, ViewChild, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';

@Component({
    selector: 'claims',
    template: `    <claims-admin fetchBy="Context" [fetchId]=communityPid [isConnect]="true" [claimsInfoURL]=claimsInfoURL [externalPortalUrl]="externalPortalUrl">
    </claims-admin>`,
})

export class ClaimsComponent implements OnInit {

    communityPid:string;
    claimsInfoURL:string;
    externalPortalUrl:string ="";

    ngOnInit() {

            this.route.queryParams.subscribe(params => {
              this.communityPid = params['communityId'];

             });
             this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
                    this.claimsInfoURL = data.envSpecific.claimsInformationLink;
                    console.log(this.claimsInfoURL);
                    this.externalPortalUrl = "https://"+(data.envSpecific.environment =='beta'?'beta.':'')+((this.communityPid == "openaire")?"explore":this.communityPid)+".openaire.eu"
            });
    }

    constructor(private route: ActivatedRoute) {}

}
