import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
import { Storage } from '@ionic/storage';
import {Myservice} from '../../providers/myservice';

@IonicPage()
@Component({
  selector: 'page-catagory_wash',
  templateUrl: 'catagory_wash.html',
})
export class CatagoryWash {

	service_id:any;
	sub_cat:any;
	 toast:any;
	constructor(public navCtrl: NavController, public navParams: NavParams,public storage:Storage, private toastCtrl: ToastController,private myservice: Myservice) {
		this.service_id = this.navParams.get('service_id');
		if(this.service_id)
			this.getSubServices();
		console.log(this.service_id);
	}

	ionViewDidLoad() {
		console.log('ionViewDidLoad CatagoryWash'); 
	}

	back(){
		this.navCtrl.pop();
	}
	
//	issue(id,service){
	//	this.navCtrl.push('DamagephotoPage',{'body_parts':service,'service_id':this.service_id});
	//}
	issue(service){
		this.navCtrl.push('FixpricesPage',{'service':service,'service_id':this.service_id});
	}	
	request(service){
		this.navCtrl.push('RequestPage',{'service':service});
	}	
	request_brk(service){
		this.navCtrl.push('RequestBreak',{'service':service});
	}	
	request_protocol(service){
		this.navCtrl.push('RequestProtocol',{'service':service});
	}
	
	getSubServices(){
		this.myservice.show_loader();
		this.myservice.load_get('getSubServices/id/'+this.service_id).subscribe(data => {
			this.myservice.hide_loader();
			if(data.status == 'success'){
				this.sub_cat = data.result
			}
		});
	}
	tool_tip(msg,evt){
		
		this.closeToast()
		this.presentToast(msg);
		evt.stopPropagation();
	}
	presentToast(msg) {
		
		this.toast = this.toastCtrl.create({
			message: msg,
			duration: 3000,
			 
			position: 'bottom'
		});
		this.toast.present();

		this.toast.onDidDismiss(() => {
			//this.closeToast();
			console.log('Dismissed toast');
		});
		
	}
  
    closeToast() {
		if(this.toast) {
			console.log("hi,close the toast");
			this.toast.dismiss();
		}
	}

}
