lml-main
Version:
This is now a mono repository published into many standalone packages.
44 lines • 1.99 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 cosmoui_1 = require("cosmoui");
const components_1 = require("../../../common/components");
const actions_1 = require("../../../allocation/actions");
const styles = require('./courier-card.scss');
class CourierAllocationIconComponent extends cosmoui_1.HoverableComponent {
constructor() {
super(...arguments);
this.containerStyles = () => ({ borderColor: this.bgColor() });
this.onClick = (e) => {
const { allocate, canAllocate, courier } = this.props;
if (canAllocate) {
allocate('ACTUAL', undefined, courier.refId);
}
};
}
render() {
//console.log('RENDER COURIER ALLOCATION ICON', this)
const { courier } = this.props;
const avatarName = lodash_1.get(courier, 'label.label', '');
return (React.createElement("div", { id: `courier-allocation-icon-${courier.refId}`, "data-tooltip": "Allocate", "data-tooltip-at": "bottom", className: styles.avatarIcon, style: this.containerStyles(), onClick: this.onClick, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave },
React.createElement(components_1.AvatarIcon, { avatarName: avatarName, fill: this.bgColor(), color: this.fgColor() })));
}
bgColor() {
return this.state.hover
? this.props.canAllocate ? this.primary() : this.error()
: 'transparent';
}
fgColor() {
return this.state.hover
? 'white'
: 'inherit';
}
}
const mapStateToProps = (state, ownProps) => ({});
const mapDispatchToProps = {
allocate: actions_1.allocate,
};
exports.CourierAllocationIcon = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(CourierAllocationIconComponent);
//# sourceMappingURL=courier-allocation-icon.js.map