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

@Injectable({
  providedIn: 'root'
})

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

      //get externals list 
  getFooterList(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 data 
  deleteFooter(footersId) {
    console.log(footersId);
    return this.http.post(this.authService.pathApi + '/delete_footers' , {'footers_id' : footersId});
  };

  //add external 
  addFooter(dataExternals) {
    console.log(dataExternals);
    return this.http.post(this.authService.pathApi + '/add_footer', dataExternals);
  }

  //get external data
  getFooterData(externalId: number) {
    return this.http.get(this.authService.pathApi + '/get_footer/' + externalId);
  };

  //edit extrnal
  editFooter( dataRoleEdit,EditRoleId){
    const editData = dataRoleEdit;
    editData.id = EditRoleId;
    console.log(editData);
    return this.http.post(this.authService.pathApi + '/edit_footer', editData);
  }

}
