import { Injectable } from '@angular/core';
import { map } from 'rxjs';
import { HttpRequestService } from 'src/app/services/resources/http-request.service';

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

  private _url:string;

  constructor( private _httpRequestService: HttpRequestService ) {
    this._url = 'modulo';
  }

  // Obtener Módulos
  public getModules(){
    return this._httpRequestService.getQuery(`${this._url}/consulta`).pipe(map((data:any) => data));
  }

  // Obtener Módulos Disponibles
  public getModuleAviable(){
    return this._httpRequestService.getQuery(`${this._url}/consulta-disponibles`).pipe(map((data:any) => data));
  }

  // Registro de Módulos
  public registerModule(data: any){
    return this._httpRequestService.postQuery(`${this._url}/registra`, data).pipe(map((data:any) => data));
  }

  // Modificar Módulos
  public updateModules(data: any) {
    return this._httpRequestService.postQuery(`${this._url}/modifica`, data).pipe(map((data:any) => data));
  }

  // Eliminar Módulos
  public deleteModule(codigo: any){
    return this._httpRequestService.postQuery(`${this._url}/elimina`, codigo).pipe(map((data:any) => data));
  }

}
