lml-main
Version:
This is now a mono repository published into many standalone packages.
46 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const cosmo_redux_api_1 = require("@lml/cosmo-redux-api");
const flags_1 = require("./flags");
exports.courierDirections = (state, courier) => {
const location = cosmo_redux_api_1.getLocationByObjectId(state, courier.refId);
return {
id: courier.refId,
title: '',
waypoints: [location.position],
};
};
exports.getCourierMarker = (state, refId) => {
const courier = cosmo_redux_api_1.getCourierById(state, refId);
if (!courier || !courier.refId)
return null;
const location = cosmo_redux_api_1.getLocationByObjectId(state, courier.refId);
// make sure the model is valid before we add it in
const latitude = lodash_1.get(location, 'position.coordinates.latitude', null);
const longitude = lodash_1.get(location, 'position.coordinates.longitude', null);
if (!latitude || !longitude) {
console.warn('LOCATION DOES NOT HAVE CORRECT LAT LONG', location);
return null;
}
const locationTitle = courier
? `${courier.firstName} ${courier.lastName} - ${courier.assignment.callsign}`
: '';
return {
id: location.objectId,
title: locationTitle,
label: courier.assignment.callsign,
position: {
type: 'point',
coordinates: { latitude, longitude },
},
};
};
exports.getCourierMarkers = (state, refIds) => refIds
.map((id) => exports.getCourierMarker(state, id))
.filter(Boolean);
exports.getActiveCourierMarker = (state) => {
const id = flags_1.getActiveCourierId(state);
return id ? exports.getCourierMarker(state, id) : null;
};
//# sourceMappingURL=locations.js.map