import { HttpClient } from '@angular/common/http'; import { AuthServiceService } from './auth-service.service'; import { Injectable } from '@angular/core'; import { NgxSpinnerService } from 'ngx-spinner'; import { ToastrService } from 'ngx-toastr'; @Injectable({ providedIn: 'root' }) export class HospitalService { constructor(private authService: AuthServiceService, private http: HttpClient, private spinner: NgxSpinnerService, private toastr: ToastrService) { } //get hospitals list getHospitalsList(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) { if(pageId == 6){ console.log(datasIds); return this.http.post(this.authService.pathApi + '/delete_hospitals_centers' , {'hospitals_centers_id' : datasIds}); } else if(pageId == 10) { this.spinner.show(); console.log(datasIds); return this.http.post(this.authService.pathApi + '/delete_managements' , {'managements_id' : datasIds}); } } //add hospital addHospital(hospitalDataForm, pageName) { if(pageName == 'hospital'){ return this.http.post(this.authService.pathApi + '/add_hospitals_centers', hospitalDataForm); } else if(pageName == 'management'){ return this.http.post(this.authService.pathApi + '/add_management', hospitalDataForm); } } //get hospital data getHospitalData(typeId: number, typeEditPage: string) { if(typeEditPage == 'edithos') { return this.http.get(this.authService.pathApi + '/get_hospitals_centers/' + typeId); } else if(typeEditPage == 'editman') { return this.http.get(this.authService.pathApi + '/get_management/' + typeId); } } //edit hospital data editHospital(id: number, newData, typePage:string) { newData['id'] = id; console.log(newData); if(typePage == 'hospital') { return this.http.post(this.authService.pathApi + '/edit_hospitals_centers', newData); } else if (typePage == 'management') { return this.http.post(this.authService.pathApi + '/edit_management', newData); } } }