|
|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
import { CLICKSTREAM_EVENT_NAMES } from '@common/Constants';
|
|
|
|
|
import { getDistanceFromLatLonInKm, isFunction } from '@components/utlis/commonFunctions';
|
|
|
|
|
import { IGeoLocation } from '@interfaces/addressGeolocation.types';
|
|
|
|
|
import { IGeoLocation, IGeolocationCoordinate } from '@interfaces/addressGeolocation.types';
|
|
|
|
|
import { addClickstreamEvent } from '@services/clickstreamEventService';
|
|
|
|
|
import {
|
|
|
|
|
Address,
|
|
|
|
|
@@ -88,13 +88,9 @@ export const sectionListTranformData = (agentList: IReportee[]): ISectionListDat
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getAddressLocation = (addresses: Address[] | undefined) => {
|
|
|
|
|
if (!addresses?.length) return null;
|
|
|
|
|
|
|
|
|
|
for (const address of addresses) {
|
|
|
|
|
if (address?.location?.latitude && address?.location?.longitude) {
|
|
|
|
|
return address.location;
|
|
|
|
|
}
|
|
|
|
|
export const getAddressLocation = (address?: IGeolocationCoordinate) => {
|
|
|
|
|
if(address?.latitude && address?.longitude) {
|
|
|
|
|
return address;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
@@ -108,7 +104,7 @@ export const getNearByCases = (
|
|
|
|
|
let caseIds: Array<string> = [];
|
|
|
|
|
casesList?.forEach((pinnedId) => {
|
|
|
|
|
const caseDetail = caseDetails?.[pinnedId.caseReferenceId];
|
|
|
|
|
const addressLocation = getAddressLocation(caseDetail?.addresses);
|
|
|
|
|
const addressLocation = getAddressLocation(caseDetail?.addressLocation);
|
|
|
|
|
|
|
|
|
|
if (addressLocation) {
|
|
|
|
|
const distanceInKm = getDistanceFromLatLonInKm(addressLocation, deviceGeolocationCoordinate);
|
|
|
|
|
@@ -194,7 +190,7 @@ export const updateNearbyCasesListAndLocation = (
|
|
|
|
|
let caseIdsToDistancesFromCurrentLocationMap: Map<string, number> = new Map();
|
|
|
|
|
allCasesList?.forEach((pinnedId) => {
|
|
|
|
|
const caseDetail = caseDetails?.[pinnedId?.caseReferenceId] || {};
|
|
|
|
|
const addressLocation = getAddressLocation(caseDetail?.addresses);
|
|
|
|
|
const addressLocation = getAddressLocation(caseDetail?.addressLocation);
|
|
|
|
|
if (addressLocation) {
|
|
|
|
|
const distanceInKm = getDistanceFromLatLonInKm(
|
|
|
|
|
addressLocation,
|
|
|
|
|
|