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);
}
}