import { Injectable } from '@angular/core';
import { AuthServiceService } from './auth-service.service';
import { HttpClient } from '@angular/common/http';
import { NgxSpinnerService } from 'ngx-spinner';
import { ToastrService } from 'ngx-toastr';

@Injectable({
  providedIn: 'root'
})
export class TabsService {

  constructor(private http: HttpClient, 
    private spinner: NgxSpinnerService, 
    private toastr: ToastrService, 
    private authService: AuthServiceService) { }

  //get hospitals list 
  getTabsList(pageId: number, currentPage: number, dataTableNumber: number){
    this.spinner.show();
    console.log(this.authService.pathApi +'/page_list/' + pageId + '/' + currentPage + '/' + dataTableNumber + '/all');
    return this.http.get(this.authService.pathApi +'/page_list/' + pageId + '/' + currentPage + '/' + dataTableNumber + '/all');
  }

   //get data data from searchBar 
   getDataUSerSearchBar(data, pageId, pagenationNumber, dataTableNumber) {
    console.log('url', this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataTableNumber + '/all/' + data);
     return this.http.get(this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataTableNumber + '/all/' + data);
  }

   //delete event 
   deleteTab(tabsIds) {
    console.log(tabsIds);
    return this.http.post(this.authService.pathApi + '/delete_tabs' , {'tabs_id' : tabsIds});
  };

    //addEvent
    addTab(dataTab) {
      return this.http.post(this.authService.pathApi + '/add_tab' , dataTab);
    }
  
    //edit event
    editEvent( dataTabEdit,EditTabId){
      const editData = dataTabEdit;
      editData.id = EditTabId;
      console.log(editData);
      return this.http.post(this.authService.pathApi + '/edit_tab', editData);
    }

    //get tab data
    getTabData(tabId: number) {
      return this.http.get(this.authService.pathApi + '/get_tab/' + tabId);
    }
  
}
