import { ApiService } from './../../../../../core/api/api.service';
import {ChangeDetectorRef, Component, Inject, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from "@angular/material/dialog";


@Component({
	selector: 'kt-modal-encuesta',
	templateUrl: './modal-encuesta.component.html',
	styleUrls: ['./modal-encuesta.component.scss']
})
export class ModalEncuestaComponent implements OnInit {

	isLoading: boolean = true;
	data: any = [];
	isCompany = true;

	constructor(private fb: FormBuilder,
				public dialog: MatDialog,
				public dialogRef: MatDialogRef<ModalEncuestaComponent>,
				private api: ApiService,
				private cdr: ChangeDetectorRef,
				@Inject(MAT_DIALOG_DATA) public id: any) {
		this.getQuiz(id);
	}

	ngOnInit() {
	}

	getQuiz(id){

		this.isLoading = true;

		this.api.solicitudesServicioService.getQuiz(id).subscribe(res => {
			this.data = res;
			this.isCompany = res.hasOwnProperty('contacto') && res.hasOwnProperty('empresa');
			this.isLoading = false;
		}, () => {
			this.dialogRef.close();
		});
	}
}
