UNPKG

lml-main

Version:

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

46 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_redux_1 = require("react-redux"); const React = require("react"); const cosmo_redux_api_1 = require("@lml/cosmo-redux-api"); const ts_utils_1 = require("@lml/ts-utils"); const cosmoui_1 = require("cosmoui"); const lodash_1 = require("lodash"); class JobStopTimeSlotComponent extends cosmoui_1.StylableComponent { constructor() { super(...arguments); this.delayed = () => this.props.jobDelay && this.props.jobDelay.predictedLabel === '1'; } render() { const postcode = lodash_1.get(this.props.stop, 'location.address.postcode', ''); const status = this.delayed() ? 'delayed' : 'on time'; return (React.createElement("span", { style: { fontWeight: 'bold' } }, React.createElement("span", { id: this.props.id && `${this.props.id}-stop-time`, "data-tooltip": `Job is ${status}`, style: this.styles() }, this.renderTime()), React.createElement("span", { style: { color: cosmoui_1.gray[500] } }, " | ", postcode))); } // todo - needs to be connected to stylable component // just hard coding here due to time pressure styles() { return { cursor: 'pointer', color: this.delayed() ? this.error() : 'inherit', }; } renderTime() { const { stop } = this.props; const earliestTime = lodash_1.get(stop, 'stopTime.earliestTime', null); const latestTime = lodash_1.get(stop, 'stopTime.latestTime', null); if (!earliestTime || !latestTime) { return ''; } return `${ts_utils_1.formatTime(earliestTime)} - ${ts_utils_1.formatTime(latestTime)}`; } } const mapStateToProps = (state, ownProps) => ({ jobDelay: cosmo_redux_api_1.getJobDelay(state, ownProps.refId), }); const mapActionsToProps = {}; exports.JobStopTimeSlot = react_redux_1.connect(mapStateToProps, mapActionsToProps)(JobStopTimeSlotComponent); //# sourceMappingURL=job-stop-timeslot.js.map