export default {
    data() {
      return {
        
        fields: {},
        errors: {},
        loaded: true,
        action: '', 
        text: '',
        redirect: ''
      }
    },  
    methods: {  
      //method for deleting admin user used in the views/adminuser.index blade
      deleteItem: function deleteItem(path,id){
       
        var contactpath='/at/contacts/delete/';
        var grouppath='/at/groups/delete/';
        var customeruserDeletepath = '/at/airtimeuser/customeruser_delete/';

        var fpath='';
        var item='';
        if(path=="atcontactdelete"){

          fpath=contactpath;
          item="Contact ";
        }
        else if(path=="atgroupdelete"){
          fpath=grouppath;
          item="Group ";
        }
        else if(path == "customeruserDeletepath")
        {
          fpath=customeruserDeletepath;
          item="User";
        }
       swal({
              title:'Sure to delete?',id,
              text: 'Delete '+item,
              icon: 'warning',
              type: 'warning',
              buttons:{
                confirm: {
                  text : 'Sure',
                  className : 'btn btn-success'
                },
                cancel: {
                  visible: true,
                  className: 'btn btn-info'
                }
              }
            }).then((Delete) => {
              if (Delete) {
                
            axios.get(fpath +id).then(function (response) {
                //this.loaded = true;
                console.log(fpath +id);
                
                swal({
                  title: 'Deleted!',
                  text: item+' has been deleted.',
                  type: 'success',
                  buttons : {
                    confirm: {
                      className : 'btn btn-success'                 
                    }
                  }             
                }).then(function(){
                  window.location.href = '';
                });
              
            })["catch"](function (error) {
                this.loaded = false;
            });
          } else {
                swal.close();
            }
        });
      }
    }
}