148 lines
5.0 KiB
JavaScript
148 lines
5.0 KiB
JavaScript
import { Card, Col, Row, Tag } from "antd";
|
|
import React, { useMemo } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { connect } from "react-redux";
|
|
import { Link } from "react-router-dom";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
|
import ChatOpenButton from "../chat-open-button/chat-open-button.component";
|
|
import DataLabel from "../data-label/data-label.component";
|
|
import JobEmployeeAssignments from "../job-employee-assignments/job-employee-assignments.container";
|
|
import ProductionListColumnProductionNote from "../production-list-columns/production-list-columns.productionnote.component";
|
|
import "./jobs-detail-header.styles.scss";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
jobRO: selectJobReadOnly,
|
|
bodyshop: selectBodyshop,
|
|
});
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
setPrintCenterContext: (context) =>
|
|
dispatch(setModalContext({ context: context, modal: "printCenter" })),
|
|
});
|
|
|
|
const colSpan = {
|
|
xs: {
|
|
span: 24,
|
|
},
|
|
sm: {
|
|
span: 24,
|
|
},
|
|
md: {
|
|
span: 12,
|
|
},
|
|
lg: {
|
|
span: 6,
|
|
},
|
|
xl: {
|
|
span: 6,
|
|
},
|
|
};
|
|
|
|
export function JobsDetailHeader({ job, bodyshop }) {
|
|
const { t } = useTranslation();
|
|
|
|
const jobInPostProduction = useMemo(() => {
|
|
return bodyshop.md_ro_statuses.post_production_statuses.includes(
|
|
job.status
|
|
);
|
|
}, [job.status, bodyshop.md_ro_statuses.post_production_statuses]);
|
|
|
|
return (
|
|
<Row gutter={[16, 16]} style={{ alignItems: "stretch" }}>
|
|
<Col {...colSpan}>
|
|
<Card title={"Job Status"} style={{ height: "100%" }}>
|
|
<div>
|
|
<DataLabel label={t("jobs.fields.status")}>
|
|
{job.status}
|
|
{job.inproduction && (
|
|
<span style={{ marginLeft: ".5rem" }}>
|
|
<Tag color="#f50" key="production">
|
|
{t("jobs.labels.inproduction")}
|
|
</Tag>
|
|
</span>
|
|
)}
|
|
</DataLabel>
|
|
<DataLabel label={t("jobs.fields.ins_co_nm_short")}>
|
|
{job.ins_co_nm}
|
|
</DataLabel>
|
|
<DataLabel label={t("jobs.fields.clm_no")}>{job.clm_no}</DataLabel>
|
|
<DataLabel label={t("jobs.fields.repairtotal")}>
|
|
<CurrencyFormatter>{job.clm_total}</CurrencyFormatter>
|
|
<span style={{ margin: "0rem .5rem" }}>/</span>
|
|
<CurrencyFormatter>{job.owner_owing}</CurrencyFormatter>
|
|
</DataLabel>
|
|
{(job.inproduction || jobInPostProduction) && (
|
|
<DataLabel label={t("jobs.fields.production_vars.note")}>
|
|
<ProductionListColumnProductionNote record={job} />
|
|
</DataLabel>
|
|
)}
|
|
</div>
|
|
</Card>
|
|
</Col>
|
|
<Col {...colSpan}>
|
|
<Link to={`/manage/owners/${job.owner.id}`}>
|
|
<Card
|
|
className="ant-card-grid-hoverable"
|
|
style={{ height: "100%" }}
|
|
title={`${job.ownr_fn || ""} ${job.ownr_ln || ""} ${
|
|
job.ownr_co_nm || ""
|
|
}`}
|
|
>
|
|
<div>
|
|
<DataLabel key="2" label={t("jobs.fields.ownr_ph1")}>
|
|
<ChatOpenButton>{job.ownr_ph1 || ""}</ChatOpenButton>
|
|
</DataLabel>
|
|
<DataLabel key="3" label={t("owners.fields.address")}>
|
|
{`${job.ownr_addr1 || ""} ${job.ownr_addr2 || ""} ${
|
|
job.ownr_city || ""
|
|
} ${job.ownr_st || ""} ${job.ownr_zip || ""}`}
|
|
</DataLabel>
|
|
<DataLabel key="4" label={t("owners.fields.ownr_ea")}>
|
|
{job.ownr_ea || ""}
|
|
</DataLabel>
|
|
</div>
|
|
</Card>
|
|
</Link>
|
|
</Col>
|
|
<Col {...colSpan}>
|
|
<Link to={job.vehicle && `/manage/vehicles/${job.vehicle.id}`}>
|
|
<Card
|
|
className="ant-card-grid-hoverable"
|
|
style={{ height: "100%" }}
|
|
title={`${job.v_model_yr || ""} ${job.v_color || ""}
|
|
${job.v_make_desc || ""}
|
|
${job.v_model_desc || ""}`}
|
|
>
|
|
<div>
|
|
<DataLabel key="2" label={t("vehicles.fields.plate_no")}>
|
|
{`${job.plate_no || t("general.labels.na")} (${`${
|
|
job.plate_st || t("general.labels.na")
|
|
}`})`}
|
|
</DataLabel>
|
|
<DataLabel key="4" label={t("vehicles.fields.v_vin")}>
|
|
{`${job.v_vin || t("general.labels.na")}`}
|
|
</DataLabel>
|
|
</div>
|
|
</Card>
|
|
</Link>
|
|
</Col>
|
|
<Col {...colSpan}>
|
|
<Card
|
|
style={{ height: "100%" }}
|
|
title={t("jobs.labels.employeeassignments")}
|
|
>
|
|
<div>
|
|
<JobEmployeeAssignments job={job} />
|
|
</div>
|
|
</Card>
|
|
</Col>
|
|
</Row>
|
|
);
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(JobsDetailHeader);
|