import { Inject, Component, OnInit, ViewEncapsulation} from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';

import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';

@Component({
	selector: 'app-cancel',
	templateUrl: './cancel.component.html',
	styleUrls: ['./cancel.component.css']
})

export class CancelComponent {
	title: string;
	msg1: string;
	msg2: string;
	// -------------------------------------
    //
    // Language Support
    //
    vE = {
    	cancelTitle : '',
    	cancelConfirmBtn : '',
    	cancelDismissBtn : ''
    }
    //
    // ------------------------------------------------------------
	constructor(
		private languageService : LanguageService,
		private dialogRef: MatDialogRef<CancelComponent>,
		@Inject(MAT_DIALOG_DATA) public data: { title: string, msg1: string, msg2: string;}
	) {
		this.title = data.title;
		this.msg1 = data.msg1;
		this.msg2 = data.msg2;
	}

	ngOnInit() {
        this.chgUILanguage();
	}

	confirm() {
		this.dialogRef.close(true);
	}

	close() {
		this.dialogRef.close(false);
	}

	chgUILanguage(){
        console.log('CANCEL.chgUILanguage Called ');
 		this.languageService.getViewElements('cancel').subscribe(
				response => { 
					console.log('Received >> ', response );
					console.log('Language Code : ', response.language);
					console.log('Component Name : ',response.component);
					console.log('Language data : ',response.data);

			        this.vE.cancelTitle = response.data.cancel_title;
			    	this.vE.cancelConfirmBtn = response.data.cancel_confirm_btn;
			    	this.vE.cancelDismissBtn = response.data.cancel_dismiss_btn;
			    },
				error  => { console.log('Error >> ',error); }
			);
	}

}
