lml-main
Version:
This is now a mono repository published into many standalone packages.
43 lines • 2.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const react_redux_1 = require("react-redux");
const cosmoui_1 = require("cosmoui");
const ts_utils_1 = require("@lml/ts-utils");
const selectors_1 = require("../../../couriers/selectors");
const actions_1 = require("../../../couriers/actions");
class CourierActionBoxComponent extends React.Component {
constructor() {
super(...arguments);
this.showCourierDetails = ts_utils_1.mkNonPropagatingClick(() => {
this.props.showCourierDetails(this.props.courier.refId);
});
this.showCourierChangeFrequencyModal = ts_utils_1.mkNonPropagatingClick(() => {
this.props.showCourierChangeFrequencyModal(this.props.courier);
});
this.expandOrCollapse = ts_utils_1.mkNonPropagatingClick(() => this.props.expanded
? this.props.unsetExpandedCourier(this.props.courier.refId)
: this.props.setExpandedCourier(this.props.courier.refId));
this.expandIcon = () => this.props.expanded ? 'CollapseVertical' : 'ExpandVertical';
this.expandTooltip = () => `${(this.props.expanded ? 'Collapse' : 'Expand')} courier card`;
}
render() {
const { courier, active, expanded, showCourierDetails, } = this.props;
return (React.createElement(cosmoui_1.ActionBox, { hidden: !active },
React.createElement(cosmoui_1.ActionNode, { id: "expand-courier-button", className: "expand", icon: this.expandIcon(), tooltip: this.expandTooltip(), onClick: this.expandOrCollapse }),
React.createElement(cosmoui_1.ActionNode, { id: "show-courier-details-modal-button", className: "info", icon: "Info", tooltip: "Courier details", onClick: this.showCourierDetails }),
React.createElement(cosmoui_1.ActionNode, { id: "show-courier-change-frequency-modal-button", className: "frequency", icon: "FrequencyLight", tooltip: "Change courier frequency", onClick: this.showCourierChangeFrequencyModal })));
}
}
const mapStateToProps = (state, ownProps) => ({
active: selectors_1.courierIsActive(state, ownProps.courier.refId),
expanded: selectors_1.courierIsExpanded(state, ownProps.courier.refId),
});
const mapActionsToProps = {
showCourierDetails: actions_1.showCourierDetails,
showCourierChangeFrequencyModal: actions_1.showCourierChangeFrequencyModal,
setExpandedCourier: actions_1.setExpandedCourier,
unsetExpandedCourier: actions_1.unsetExpandedCourier,
};
exports.CourierActionBox = react_redux_1.connect(mapStateToProps, mapActionsToProps)(CourierActionBoxComponent);
//# sourceMappingURL=courier-action-box.js.map