import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams,ViewController  } from 'ionic-angular';
import { DoctorService } from '../../services/doctor.service';

@Component({
  selector: 'page-user-info',
  templateUrl: 'user-info.html',
})
export class UserInfoPage {
  load:any;
  idUser:any;
  star:any;
  numService:any;
  registro:any;
  mobile:any;
  coments:any;
  constructor(public navCtrl: NavController, 
    public navParams: NavParams, 
    private docService: DoctorService,
    public viewCtrl:ViewController) {
    this.idUser = this.navParams.get('id');
    this.loadUserInfo();
  }


  dismiss() {
    this.viewCtrl.dismiss();
  }
  loadUserInfo(){
    this.load=true;
    let param = this.idUser;
    this.docService.getRating(param).subscribe((data)=>{
      this.load = false;
      console.log(data)
      if(data["res"]=="OK"){
        this.numService = data["services"];
        this.registro = data["oldest"];
        this.coments = data["comments"];
        if(data["stars"]==null){
          this.star = 0;
        }else{
          this.star = data["stars"]
        }

       
      }
    })
  }

}
