import {Component, OnInit} from '@angular/core'; import {FieldType} from '@ngx-formly/material'; import {AllService} from '../../../all.service'; import {ActivatedRoute} from '@angular/router'; import {faCheck} from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'jhi-step-finalisation-mdr', templateUrl: './step-finalisation-mdr.component.html', styleUrls: ['./step-finalisation-mdr.component.scss'] }) export class StepFinalisationMdrComponent extends FieldType implements OnInit { isForever = false; environnementName = 'magnolia'; email = 'resiliation@magnolia.fr'; constructor(public allService: AllService, private route: ActivatedRoute) { super(); } ngOnInit(): void { const productcollectionid = this.route.snapshot.paramMap.get('productcollectionid') ? this.route.snapshot.paramMap.get('productcollectionid') : ''; this.isForever = productcollectionid === 'foreverC1'; this.environnementName = this.getPlatformFromUrl(); if (this.environnementName === 'simulassur') { this.email = 'resiliation@simulassur.fr'; } // Tell to Zuko that's the form is completed this.allService.getStepsSubjectAsObserVable().subscribe((data) => { if (data && data.step && data.step.fields && data.step.fields[0].fieldGroup[0].type === 'stepFinalisationMdr') { this.allService['trackingService'].submitForm(); } }); } getPlatformFromUrl(): string { const hostname = window && window.location && window.location.hostname; const hostInformation = hostname.split('.'); if (/^.*localhost.*/.test(hostname)) { return 'magnolia'; } else if (hostInformation.includes('magnolia')) { return 'magnolia'; } else if (hostInformation.includes('fluo')) { return 'fluo'; } else { return 'simulassur'; } } }