HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/services/address.service.ts
import { Injectable } from "@angular/core";
import { UtilsService } from "./utils.service";
import { ApiService } from "./api.service";

@Injectable({
  providedIn: "root",
})
export class AddressService {
  _allCitiesService: any = [];
  _allDepartments: any = [];
  _pointCoverage: any;
  _coords: any;
  _addressUser: any;
  _address_id: any;
  constructor(public api: ApiService, public utilsService: UtilsService) { }

  async getAllCitiesService() {
    let seq = this.api.getFree("address/allCitiesService");
    (await seq).subscribe(
      (res: any) => {
        if (res.status == "success") {
          this._allCitiesService = res.citiesService;
          this._pointCoverage = res.pointCoverage.point_coverage;
        }
      },
      (err) => {
        console.error("Error provider address getAllCitiesService", err);
      }
    );
  }

  async getAllDepartments() {
    return new Promise(async (resolve, reject) => {
      (await this.api.getFree("address/allDepartments")).subscribe(
        (res: any) => {
          if (res.status == "success") {
            this._allDepartments = res.departments;
          }
          resolve(res);
        },
        (err) => {
          console.error("Error provider address getAllDepartments", err);
          reject(err);
        }
      );
    });
  }

  getAllCities(department_id) {
    return this.api.getFree("address/allCities/" + department_id);
  }
  //Prueba
  getAllCitiesAdvisor(department_id) {
    return this.api.getFree("address/allCities/" + department_id);
  }

  addAddressUser(addressInfo: any, token_access) {
    return this.api.post("address/add", addressInfo, token_access);
  }

  deleteAddress(address_id, token_access) {
    let info = {
      address_id: address_id,
    };
    return this.api.post("address/delete", info, token_access);
  }

  updateLocationAddress(address_id, dataLocation, token_access) {
    let info = {
      address_id: address_id,
      lat: dataLocation.lat,
      lng: dataLocation.lng,
    };
    return this.api.put("address/updateLocation", info, token_access);
  }

  saveCoveragePending(info, token_access) {
    return this.api.post("address/saveCoveragePending", info, token_access);
  }

  addresToLatLong(address: string, token_access) {
    return this.api.get("address/geocode/" + encodeURIComponent(address), token_access);
  }
}