UNPKG

lml-main

Version:

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

64 lines 4.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const react_redux_1 = require("react-redux"); const cosmo_redux_api_1 = require("@lml/cosmo-redux-api"); const cosmoui_1 = require("cosmoui"); const modals_1 = require("../../../allocation/actions/modals"); const modals_2 = require("../../../couriers/actions/modals"); const actions_1 = require("../../../booking/actions"); const actions_2 = require("../../../jobs/actions"); const selectors_1 = require("../../selectors"); const styles = require('./job-detail.scss'); class JobActionButtonsComponent extends React.Component { constructor() { super(...arguments); this.renderDeallocateButton = () => { // you must have a jobStatus to render this button const { jobStatus } = this.props; if (!jobStatus) { console.error(`JobStatus not found: ${this.props.job.refId}`); return null; } return !(jobStatus.status === 'live' || jobStatus.status === 'completed') ? (React.createElement(cosmoui_1.Icon, { icon: "Unallocate", id: "btn-job-detail-deallocate", className: styles.actionIcon, size: 24, tooltip: "Deallocate job", onClick: this.showDeallocationModal })) : null; }; this.showCloneJobModal = () => this.props.showCloneJobModal(this.props.job.refId); this.showEditJobModal = () => this.props.showEditJobModal(this.props.job.refId); this.showCancelJobModal = () => this.props.showCancelJobModal(this.props.job.refId); this.showDeallocationModal = () => this.props.showDeallocationModal(this.props.job); this.showChangeJobStatusModal = () => this.props.showCourierActionModal(this.props.job.refId); this.showReturnToDepotModal = () => this.props.showReturnToDepotModal(this.props.job.refId); } render() { const { jobStatus } = this.props; if (!jobStatus) { return null; } return (React.createElement(cosmoui_1.Row, { className: styles.actions }, React.createElement(cosmoui_1.Icon, { icon: "EditJob", id: "btn-job-detail-edit", className: styles.actionIcon, size: 24, tooltip: "Edit job", onClick: this.showEditJobModal }), React.createElement(cosmoui_1.Icon, { icon: "DuplicateJob", id: "btn-job-detail-clone", className: styles.actionIcon, size: 24, tooltip: "Clone job", onClick: this.showCloneJobModal }), selectors_1.isJobCurrentlyProcessed(jobStatus) ? (React.createElement(cosmoui_1.Icon, { icon: "Return", id: "btn-job-detail-return-to-depot", className: styles.actionIcon, size: 24, tooltip: "Return to depot", onClick: this.showReturnToDepotModal })) : null, selectors_1.isJobCurrentlyProcessed(jobStatus) ? (React.createElement(cosmoui_1.Icon, { icon: "JobStatus", id: "btn-job-status-update", className: styles.actionIcon, size: 24, tooltip: "Change job status", onClick: this.showChangeJobStatusModal })) : null, React.createElement(cosmoui_1.Divider, { vertical: true }), React.createElement(cosmoui_1.Icon, { icon: "Delete", id: "btn-job-detail-cancel", className: styles.actionIcon, size: 24, tooltip: "Cancel job", onClick: this.showCancelJobModal }), this.renderDeallocateButton())); } } JobActionButtonsComponent.defaultProps = { jobStatus: {}, }; const mapStateToProps = (state, ownProps) => ({ jobStatus: cosmo_redux_api_1.getJobStatusById(state, ownProps.job.refId), }); const mapDispatchToProps = { showCloneJobModal: actions_2.showCloneJobModal, showEditJobModal: actions_2.showEditJobModal, showCancelJobModal: actions_2.showCancelJobModal, showDeallocationModal: modals_1.showDeallocationModal, showCourierActionModal: modals_2.showCourierActionModal, showReturnToDepotModal: actions_1.showReturnToDepotModal, }; exports.JobActionButtons = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(JobActionButtonsComponent); //# sourceMappingURL=job-action-buttons.js.map