import { Component, forwardRef, OnInit, ViewChild, ElementRef } from '@angular/core';
import * as moment from 'moment';
import { HyperService } from '../../core/services/http.service';
import { Router } from "@angular/router";
import { LocalStorage } from '../../core/services/local_storage.service';
import{EnquirypopupComponent} from '../../leadmodule/enquirypopup/enquirypopup.component';

@Component({
  selector: 'app-status-popup',
  templateUrl: './status-popup.component.html',
  styleUrls: ['./status-popup.component.scss']
})
export class StatusPopupComponent implements OnInit {
  
  confirm_modal_visible: boolean = false;
  confirm_logout_visible: boolean = false;
  screen_callback: any;
  success_modal_visible: boolean = false;
  displaytext:any;
  message:any;
  btn_label: any;
  remark;
  dsedata: any;
  constructor(private server: HyperService, private router: Router) { }

  ngOnInit() {
  }
  public showconfirmModal(url: string = "", data: any, list:any,callBack: any = null) {
    console.log(list);
    this.dsedata = list;
    this.btn_label =data;
    this.screen_callback = callBack;
    this.confirm_modal_visible = true;
  }
  onType(type,data:any) {
    console.log(data);
    if (type == 1) {
      let senddata = {};
      senddata = {
        "userid" : this.dsedata.userid,
        "status" : this.btn_label == 1 ? 2 : 1,
        "remark" : this.remark
      }
      
      this.server.post("manager/userstatusupdate",senddata)
        .then((data) => {
          if (data.status == 200 && data.result.response == 'success') {
            this.screen_callback(true);
            this.confirm_modal_visible = false;
            this.remark = '';
          } else if (data.result.status == 401 && data.result.response == 'failed') {
            this.router.navigateByUrl('');
          }
        });
    } else {
      this.confirm_modal_visible = false;
    }

  }
  onCloseModal() {
    this.success_modal_visible = false;
    this.message='close';
  }

}
