UNPKG

lml-main

Version:

This is now a mono repository published into many standalone packages.

35 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const react_redux_1 = require("react-redux"); const lodash_1 = require("lodash"); const cosmoui_1 = require("cosmoui"); const cosmo_redux_api_1 = require("@lml/cosmo-redux-api"); const constants_1 = require("../../constants"); const selectors_1 = require("../../selectors"); class JobMapComponent extends React.Component { constructor() { super(...arguments); this.getDirections = () => { const { job } = this.props; const collectionCoords = lodash_1.get(selectors_1.getCollectionStop(job), 'location.position.coordinates'); const deliveryCoords = lodash_1.get(selectors_1.getDeliveryStop(job), 'location.position.coordinates'); if (collectionCoords && deliveryCoords) { const origin = { latitude: collectionCoords[1], longitude: collectionCoords[0] }; const destination = { latitude: deliveryCoords[1], longitude: deliveryCoords[0] }; return { origin, destination, waypoints: [] }; } return undefined; }; } render() { const directions = this.getDirections(); return (React.createElement(cosmoui_1.Map, { id: constants_1.JOB_DETAILS_MAP_KEY, directions: directions, style: { width: '400px', height: '300px' } })); } } const mapStateToProps = (state, props) => ({ job: cosmo_redux_api_1.getJobById(state, props.refId), }); const mapDispatchToProps = {}; exports.JobMap = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(JobMapComponent); //# sourceMappingURL=job-map.js.map