lml-main
Version:
This is now a mono repository published into many standalone packages.
47 lines • 2.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const cosmo_ui_auth_1 = require("@lml/cosmo-ui-auth");
const cosmoui_1 = require("cosmoui");
const modals_1 = require("../../../couriers/actions/modals");
const react_redux_1 = require("react-redux");
const actions_1 = require("../../../jobs/actions");
class JobButtonBarComponent extends React.Component {
constructor() {
super(...arguments);
this.openModal = () => {
const { job } = this.props;
if (!job.currentAllocation) {
throw new Error('Cannot set courier action for a live job');
}
modals_1.showCourierActionModal(job.refId);
};
this.showEditJobModal = () => this.props.showEditJobModal(this.props.job.refId);
}
render() {
const { job } = this.props;
if (!job)
return null;
return (React.createElement(cosmoui_1.ButtonBar, null,
React.createElement(cosmoui_1.Button, { id: `btn-job-detail-modify`, onClick: this.showEditJobModal }, "MODIFY"),
React.createElement(cosmoui_1.Button, { id: `btn-job-detail-accept`, disabled: this.disabled(), onClick: this.openModal }, "ACCEPT"),
React.createElement(cosmoui_1.Button, { id: `btn-job-detail-arr-collection`, disabled: this.disabled(), onClick: this.openModal }, "ARR.COLLECTION"),
React.createElement(cosmoui_1.Button, { id: `btn-job-detail-collected`, disabled: this.disabled(), onClick: this.openModal }, "COLLECTED"),
React.createElement(cosmoui_1.Button, { id: `btn-job-detail-delivery`, disabled: this.disabled(), onClick: this.openModal }, "ARR.DELIVERY"),
React.createElement(cosmoui_1.Button, { id: `btn-job-detail-delivered`, disabled: this.disabled(), onClick: this.openModal }, "DELIVERED")));
}
disabled() {
const { job } = this.props;
return !job.currentAllocation || !job.currentAllocation.courier;
}
}
exports.JobButtonBarComponent = JobButtonBarComponent;
const mapStateToProps = (state, ownProps) => ({
username: cosmo_ui_auth_1.getUsername(state),
});
const mapActionsToProps = {
showEditJobModal: actions_1.showEditJobModal,
showCourierActionModal: modals_1.showCourierActionModal,
};
exports.JobButtonBar = react_redux_1.connect(mapStateToProps, mapActionsToProps)(JobButtonBarComponent);
//# sourceMappingURL=job-button-bar.js.map