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

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

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

export class ItemDeleteComponent implements OnInit{
	item: Item;
    //
    // Language Support
    //
    vE = {
    	itemdelDelItem : '',
    	itemdelConfirmDel : '',
    	itemdelCloseBtn : '',
    	itemdelDeleteBtn : ''
    }
    //
    // ------------------------------------------------------------
	constructor(
		private languageService : LanguageService,
		private dialogRef: MatDialogRef<ItemDeleteComponent>,
		@Inject(MAT_DIALOG_DATA) public data: Item
	) {
		this.item = data;
	}

	ngOnInit() {
        this.chgUILanguage();
	}

	save() {
		this.dialogRef.close(this.item._id);
	}

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

	chgUILanguage(){
        console.log('ITEMDEL.chgUILanguage Called ');
 		this.languageService.getViewElements('itemdel').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.itemdelDelItem = response.data.itemdel_del_item;
			        this.vE.itemdelConfirmDel = response.data.itemdel_confirm_del;
			    	this.vE.itemdelCloseBtn = response.data.itemdel_close_btn;
			    	this.vE.itemdelDeleteBtn = response.data.itemdel_delete_btn;
			    },
				error  => { console.log('Error >> ',error); }
			);
	}

}
