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

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


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

  //get hospitals list 
  getInternalsList(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 user 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 hospitals
  deleteDatas(datasIds, pageId) {
    console.log(datasIds);
    return this.http.post(this.authService.pathApi + '/delete_internal_services' , {'internal_services_id' : datasIds});
  }

  //add hospital 
  addInternal(internalDataForm) {
    return this.http.post(this.authService.pathApi + '/add_internal_service', internalDataForm);
  }

  //get hospital data
  getInternalData(typeId: number) {
      return this.http.get(this.authService.pathApi + '/get_internal_service/' + typeId);
  }

  //edit hospital data
  editInternal(id: number, newData) {
    newData['id'] = id;
    console.log(newData);
      return this.http.post(this.authService.pathApi + '/edit_internal_service', newData);
    }

    //get internal pages 
  getInternalPages() {
    return this.http.get(this.authService.pathApi + '/system_pages_list');
  }

}
