lml-main
Version:
This is now a mono repository published into many standalone packages.
64 lines • 3.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const react_redux_1 = require("react-redux");
const ts_utils_1 = require("@lml/ts-utils");
const cosmo_redux_api_1 = require("@lml/cosmo-redux-api");
const lodash_1 = require("lodash");
const components_1 = require("../../../common/components");
const selectors_1 = require("../../../jobs/selectors");
const actions_1 = require("../../../jobs/actions");
class JobRowComponent extends React.Component {
constructor() {
super(...arguments);
this.renderCollection = (job) => {
const stop = selectors_1.getCollectionStop(job);
return this.renderAddress(lodash_1.get(job, 'pickupBy', ''), lodash_1.get(stop, 'location.address.postcode', ''), lodash_1.get(stop, 'location.address.streets', []).join(', '), 'job-table-collect');
};
this.renderDelivery = (job) => {
const stop = selectors_1.getDeliveryStop(job);
return this.renderAddress(lodash_1.get(job, 'completeBy', ''), lodash_1.get(stop, 'location.address.postcode', ''), lodash_1.get(stop, 'location.address.streets', []).join(', '), 'job-table-deliver');
};
this.renderAddress = (time, postcode, address, id) => (React.createElement("td", { style: this.cellStyles() },
React.createElement("strong", null,
React.createElement("span", { id: `${id}-time-${this.props.job.refId}` }, ts_utils_1.formatTime(time)),
React.createElement("span", null, " - "),
React.createElement("span", { id: `${id}-postcode-${this.props.job.refId}` }, postcode),
React.createElement("span", null, " | ")),
React.createElement("span", { id: `${id}-address-${this.props.job.refId}` }, address)));
this.showJobDetails = (refId) => () => this.props.showJobDetails(refId);
this.rowStyles = () => ({
cursor: 'pointer',
});
this.cellStyles = () => ({
verticalAlign: 'middle',
borderLeft: 'none',
borderRight: 'none',
});
}
render() {
const { job, jobStatus } = this.props;
if (!job || !jobStatus)
return null;
return (React.createElement("tr", { style: this.rowStyles(), onClick: this.showJobDetails(job.refId) },
React.createElement("td", { style: this.cellStyles() },
React.createElement(components_1.AvatarIcon, { avatarName: lodash_1.get(job, 'label.label', ''), id: `job-table-label-${job.refId}` })),
React.createElement("td", { style: this.cellStyles(), id: `job-table-date-${job.refId}` }, ts_utils_1.formatDate(lodash_1.get(job, 'createdAt', ''))),
React.createElement("td", { style: this.cellStyles(), id: `job-table-number-${job.refId}` }, lodash_1.get(job, 'jobNumber', '')),
React.createElement("td", { style: this.cellStyles(), id: `job-table-customer-${job.refId}` }, lodash_1.get(job, 'customer.name', '')),
this.renderCollection(job),
this.renderDelivery(job),
React.createElement("td", { style: this.cellStyles() },
React.createElement("strong", { id: `job-table-status-${job.refId}` }, lodash_1.capitalize(lodash_1.get(jobStatus, 'status', ''))))));
}
}
const mapStateToProps = (state, ownProps) => ({
job: cosmo_redux_api_1.getJobById(state, ownProps.refId),
jobStatus: cosmo_redux_api_1.getJobStatusById(state, ownProps.refId),
});
const mapDispatchToProps = {
showJobDetails: actions_1.showJobDetails,
};
exports.JobRow = react_redux_1.connect(mapStateToProps, mapDispatchToProps)(JobRowComponent);
//22762821
//# sourceMappingURL=job-row.js.map