lml-main
Version:
This is now a mono repository published into many standalone packages.
43 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const react_redux_1 = require("react-redux");
const lodash_1 = require("lodash");
const cosmo_redux_api_1 = require("@lml/cosmo-redux-api");
const abstract_field_1 = require("./abstract-field");
const cosmoui_1 = require("cosmoui");
const actions_1 = require("../../../../allocation/actions");
const styles = require('./job-fields.scss');
class SmartFieldComponent extends abstract_field_1.AbstractJobField {
constructor() {
super(...arguments);
this.onClick = (courierRefId) => () => {
// console.log('CLICKED ON SMART MATCH', courierRefId)
this.props.allocate('ACTUAL', this.props.job.refId, courierRefId);
};
}
render() {
const { job, matches, allocate, callsigns } = this.props;
//still need to render an empty version due to the widths issue
if (!matches || !matches.length) {
return (React.createElement("div", { className: styles.smartField }));
}
return (React.createElement(cosmoui_1.Row, { className: styles.smartField },
React.createElement("div", null, matches.length),
React.createElement(cosmoui_1.Dropdown, { name: `smartRecommendation${job.jobNumber}`, position: "right", width: 60, icon: React.createElement(cosmoui_1.Icon, { icon: "Down", className: styles.iconGray, size: 10 }) }, matches.map((refId) => {
const callsign = lodash_1.get(callsigns, `${refId}`, 'ERR');
return (React.createElement(cosmoui_1.DropdownItem, { active: false, onClick: this.onClick(refId), key: refId }, callsign.slice(0, 4)));
}))));
}
}
exports.SmartFieldComponent = SmartFieldComponent;
const mapStateToProps = (state, ownProps) => {
const matches = cosmo_redux_api_1.getJobSmartMatches(state, ownProps.job.refId);
const callsigns = matches ? cosmo_redux_api_1.getIdToCallsignMap(state, matches) : null;
return { matches, callsigns };
};
const mapDispatchToProps = {
allocate: actions_1.allocate,
};
exports.SmartField = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(SmartFieldComponent);
//# sourceMappingURL=smart-field.js.map