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

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

  private _url: string;

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

  public registerData(data: any) {
    return this._httpRequestService.postQueryQA(`${this._url}/registra-form`, data).pipe(map((data:any) => data));
  }

  public updateData(data: any) {
    return this._httpRequestService.postQueryQA(`${this._url}/modifica-form`, data).pipe(map((data:any) => data));
  }

  public generateMenu(data: any) {
    return this._httpRequestService.getQueryQA(`${this._url}/generate-menu/${data}`).pipe(map((data:any) => data));
  }

  public generateTable(data: any) {
    return this._httpRequestService.postQueryQA(`${this._url}/generate-table`, data).pipe(map((data:any) => data));
  }

  public generateForm(id_form: string) {
    return this._httpRequestService.getQueryQA(`${this._url}/generate-form/${id_form}`).pipe(map((data:any) => data));
  }

  public generateFormEdit(id_form: string, data_table: any) {
    return this._httpRequestService.postQueryQA(`${this._url}/consulta-info/${id_form}`, data_table).pipe(map((data:any) => data));
  }

}
