feature/IO-3255-simplified-parts-management - Checkpoint
This commit is contained in:
@@ -9,7 +9,7 @@ import { createStructuredSelector } from "reselect";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
import { insertAuditTrail } from "../../redux/application/application.actions.js";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { selectIsPartsEntry, selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { selectBodyshop, selectPartsManagementOnly } from "../../redux/user/user.selectors";
|
||||
import AuditTrailMapping from "../../utils/AuditTrailMappings.js";
|
||||
@@ -32,7 +32,8 @@ import "./jobs-detail-header.styles.scss";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
jobRO: selectJobReadOnly,
|
||||
bodyshop: selectBodyshop,
|
||||
partsManagementOnly: selectPartsManagementOnly
|
||||
partsManagementOnly: selectPartsManagementOnly,
|
||||
isPartsEntry: selectIsPartsEntry
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
@@ -53,11 +54,12 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
)
|
||||
});
|
||||
|
||||
export function JobsDetailHeader({ job, bodyshop, disabled, insertAuditTrail, partsManagementOnly }) {
|
||||
export function JobsDetailHeader({ job, bodyshop, disabled, insertAuditTrail, partsManagementOnly, isPartsEntry }) {
|
||||
const { t } = useTranslation();
|
||||
const { notification } = useNotification();
|
||||
const [notesClamped, setNotesClamped] = useState(true);
|
||||
const [updateJob] = useMutation(UPDATE_JOB);
|
||||
const basePath = isPartsEntry ? "/parts" : "/manage";
|
||||
|
||||
const colSpan = {
|
||||
xs: { span: 24 },
|
||||
@@ -107,127 +109,127 @@ export function JobsDetailHeader({ job, bodyshop, disabled, insertAuditTrail, pa
|
||||
return (
|
||||
<>
|
||||
<Row gutter={[16, 16]} style={{ alignItems: "stretch" }}>
|
||||
<Col {...colSpan}>
|
||||
<Card title={"Job Status"} style={{ height: "100%" }}>
|
||||
<div>
|
||||
<DataLabel label={t("jobs.fields.status")}>
|
||||
<Space wrap>
|
||||
{job.status}
|
||||
{job.inproduction && <Tag color="#f50">{t("jobs.labels.inproduction")}</Tag>}
|
||||
{job.suspended && <PauseCircleOutlined style={{ color: "orangered" }} />}
|
||||
{job.iouparent && (
|
||||
<Link to={`/manage/jobs/${job.iouparent}`}>
|
||||
<Tooltip title={t("jobs.labels.iou")}>
|
||||
<BranchesOutlined style={{ color: "orangered" }} />
|
||||
</Tooltip>
|
||||
</Link>
|
||||
)}
|
||||
{job.production_vars && job.production_vars.alert ? (
|
||||
<ExclamationCircleFilled className="production-alert" />
|
||||
) : null}
|
||||
{job.status === bodyshop.md_ro_statuses.default_scheduled && job.scheduled_in ? (
|
||||
<Tag>
|
||||
<Link to={`/manage/schedule?date=${dayjs(job.scheduled_in).format("YYYY-MM-DD")}`}>
|
||||
<DateTimeFormatter>{job.scheduled_in}</DateTimeFormatter>
|
||||
</Link>
|
||||
</Tag>
|
||||
) : null}
|
||||
</Space>
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.comment")} valueStyle={{ overflow: "hidden", textOverflow: "ellipsis" }}>
|
||||
<ProductionListColumnComment record={job} />
|
||||
</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.ponumber")} hideIfNull>
|
||||
{job.po_number}
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.repairtotal")}>
|
||||
<CurrencyFormatter>{job.clm_total}</CurrencyFormatter>
|
||||
<span style={{ margin: "0rem .5rem" }}>/</span>
|
||||
<CurrencyFormatter>{job.owner_owing}</CurrencyFormatter>
|
||||
</DataLabel>
|
||||
|
||||
{!partsManagementOnly && (
|
||||
<>
|
||||
<DataLabel label={t("jobs.fields.alt_transport")}>
|
||||
{job.alt_transport}
|
||||
<JobAltTransportChange job={job} />
|
||||
</DataLabel>
|
||||
{job?.cccontracts?.length > 0 && (
|
||||
<DataLabel label={t("jobs.labels.contracts")}>
|
||||
{job.cccontracts.map((c, index) => (
|
||||
<Space key={c.id} wrap>
|
||||
<Link to={`/manage/courtesycars/contracts/${c.id}`}>
|
||||
{`${c.agreementnumber} - ${c.courtesycar.fleetnumber} ${c.courtesycar.year} ${c.courtesycar.make} ${c.courtesycar.model}`}
|
||||
{index !== job.cccontracts.length - 1 ? "," : null}
|
||||
</Link>
|
||||
</Space>
|
||||
))}
|
||||
</DataLabel>
|
||||
)}
|
||||
<DataLabel label={t("jobs.fields.production_vars.note")}>
|
||||
<ProductionListColumnProductionNote record={job} />
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.estimate_sent_approval")}>
|
||||
<Space>
|
||||
<Checkbox
|
||||
checked={!!job.estimate_sent_approval}
|
||||
onChange={(e) => handleCheckboxChange("estimate_sent_approval", e.target.checked)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{job.estimate_sent_approval && (
|
||||
<span style={{ color: "#888" }}>
|
||||
<DateTimeFormatter>{job.estimate_sent_approval}</DateTimeFormatter>
|
||||
</span>
|
||||
)}
|
||||
</Checkbox>
|
||||
</Space>
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.estimate_approved")}>
|
||||
<Space>
|
||||
<Checkbox
|
||||
checked={!!job.estimate_approved}
|
||||
onChange={(e) => handleCheckboxChange("estimate_approved", e.target.checked)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{job.estimate_approved && (
|
||||
<span style={{ color: "#888" }}>
|
||||
<DateTimeFormatter>{job.estimate_approved}</DateTimeFormatter>
|
||||
</span>
|
||||
)}
|
||||
</Checkbox>
|
||||
</Space>
|
||||
</DataLabel>
|
||||
<Col {...colSpan}>
|
||||
<Card title={"Job Status"} style={{ height: "100%" }}>
|
||||
<div>
|
||||
<DataLabel label={t("jobs.fields.status")}>
|
||||
<Space wrap>
|
||||
{job.special_coverage_policy && (
|
||||
<Tag color="tomato">
|
||||
<Space>
|
||||
<WarningFilled />
|
||||
<span>{t("jobs.labels.specialcoveragepolicy")}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
{job.status}
|
||||
{job.inproduction && <Tag color="#f50">{t("jobs.labels.inproduction")}</Tag>}
|
||||
{job.suspended && <PauseCircleOutlined style={{ color: "orangered" }} />}
|
||||
{job.iouparent && (
|
||||
<Link to={`/manage/jobs/${job.iouparent}`}>
|
||||
<Tooltip title={t("jobs.labels.iou")}>
|
||||
<BranchesOutlined style={{ color: "orangered" }} />
|
||||
</Tooltip>
|
||||
</Link>
|
||||
)}
|
||||
{job.ca_gst_registrant && (
|
||||
<Tag color="geekblue">
|
||||
<Space>
|
||||
<WarningFilled />
|
||||
<span>{t("jobs.fields.ca_gst_registrant")}</span>
|
||||
</Space>
|
||||
{job.production_vars && job.production_vars.alert ? (
|
||||
<ExclamationCircleFilled className="production-alert" />
|
||||
) : null}
|
||||
{job.status === bodyshop.md_ro_statuses.default_scheduled && job.scheduled_in ? (
|
||||
<Tag>
|
||||
<Link to={`/manage/schedule?date=${dayjs(job.scheduled_in).format("YYYY-MM-DD")}`}>
|
||||
<DateTimeFormatter>{job.scheduled_in}</DateTimeFormatter>
|
||||
</Link>
|
||||
</Tag>
|
||||
)}
|
||||
{job.hit_and_run && (
|
||||
<Tag color="green">
|
||||
<Space>
|
||||
<WarningFilled />
|
||||
<span>{t("jobs.fields.hit_and_run")}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
) : null}
|
||||
</Space>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.comment")} valueStyle={{ overflow: "hidden", textOverflow: "ellipsis" }}>
|
||||
<ProductionListColumnComment record={job} />
|
||||
</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.ponumber")} hideIfNull>
|
||||
{job.po_number}
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.repairtotal")}>
|
||||
<CurrencyFormatter>{job.clm_total}</CurrencyFormatter>
|
||||
<span style={{ margin: "0rem .5rem" }}>/</span>
|
||||
<CurrencyFormatter>{job.owner_owing}</CurrencyFormatter>
|
||||
</DataLabel>
|
||||
|
||||
{!partsManagementOnly && (
|
||||
<>
|
||||
<DataLabel label={t("jobs.fields.alt_transport")}>
|
||||
{job.alt_transport}
|
||||
<JobAltTransportChange job={job} />
|
||||
</DataLabel>
|
||||
{job?.cccontracts?.length > 0 && (
|
||||
<DataLabel label={t("jobs.labels.contracts")}>
|
||||
{job.cccontracts.map((c, index) => (
|
||||
<Space key={c.id} wrap>
|
||||
<Link to={`/manage/courtesycars/contracts/${c.id}`}>
|
||||
{`${c.agreementnumber} - ${c.courtesycar.fleetnumber} ${c.courtesycar.year} ${c.courtesycar.make} ${c.courtesycar.model}`}
|
||||
{index !== job.cccontracts.length - 1 ? "," : null}
|
||||
</Link>
|
||||
</Space>
|
||||
))}
|
||||
</DataLabel>
|
||||
)}
|
||||
<DataLabel label={t("jobs.fields.production_vars.note")}>
|
||||
<ProductionListColumnProductionNote record={job} />
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.estimate_sent_approval")}>
|
||||
<Space>
|
||||
<Checkbox
|
||||
checked={!!job.estimate_sent_approval}
|
||||
onChange={(e) => handleCheckboxChange("estimate_sent_approval", e.target.checked)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{job.estimate_sent_approval && (
|
||||
<span style={{ color: "#888" }}>
|
||||
<DateTimeFormatter>{job.estimate_sent_approval}</DateTimeFormatter>
|
||||
</span>
|
||||
)}
|
||||
</Checkbox>
|
||||
</Space>
|
||||
</DataLabel>
|
||||
<DataLabel label={t("jobs.fields.estimate_approved")}>
|
||||
<Space>
|
||||
<Checkbox
|
||||
checked={!!job.estimate_approved}
|
||||
onChange={(e) => handleCheckboxChange("estimate_approved", e.target.checked)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{job.estimate_approved && (
|
||||
<span style={{ color: "#888" }}>
|
||||
<DateTimeFormatter>{job.estimate_approved}</DateTimeFormatter>
|
||||
</span>
|
||||
)}
|
||||
</Checkbox>
|
||||
</Space>
|
||||
</DataLabel>
|
||||
<Space wrap>
|
||||
{job.special_coverage_policy && (
|
||||
<Tag color="tomato">
|
||||
<Space>
|
||||
<WarningFilled />
|
||||
<span>{t("jobs.labels.specialcoveragepolicy")}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
{job.ca_gst_registrant && (
|
||||
<Tag color="geekblue">
|
||||
<Space>
|
||||
<WarningFilled />
|
||||
<span>{t("jobs.fields.ca_gst_registrant")}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
{job.hit_and_run && (
|
||||
<Tag color="green">
|
||||
<Space>
|
||||
<WarningFilled />
|
||||
<span>{t("jobs.fields.hit_and_run")}</span>
|
||||
</Space>
|
||||
</Tag>
|
||||
)}
|
||||
</Space>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col {...colSpan}>
|
||||
@@ -289,7 +291,7 @@ export function JobsDetailHeader({ job, bodyshop, disabled, insertAuditTrail, pa
|
||||
disabled ? (
|
||||
<>{vehicleTitle.length > 0 ? vehicleTitle : t("vehicles.labels.novehinfo")} </>
|
||||
) : (
|
||||
<Link to={job.vehicle && `/manage/vehicles/${job.vehicle.id}`}>
|
||||
<Link to={job.vehicle && `${basePath}/vehicles/${job.vehicle.id}`}>
|
||||
{vehicleTitle.length > 0 ? vehicleTitle : t("vehicles.labels.novehinfo")}
|
||||
</Link>
|
||||
)
|
||||
@@ -344,22 +346,22 @@ export function JobsDetailHeader({ job, bodyshop, disabled, insertAuditTrail, pa
|
||||
</Card>
|
||||
</Col>
|
||||
{!partsManagementOnly && (
|
||||
<Col {...colSpan}>
|
||||
<Card
|
||||
style={{ height: "100%" }}
|
||||
title={<span id="job-employee-assignments-title">{t("jobs.labels.employeeassignments")}</span>}
|
||||
id={"job-employee-assignments"}
|
||||
>
|
||||
<div>
|
||||
<JobEmployeeAssignments job={job} />
|
||||
<Divider style={{ margin: ".5rem" }} />
|
||||
<DataLabel label={t("jobs.labels.labor_hrs")}>
|
||||
{bodyHrs.toFixed(1)} / {refinishHrs.toFixed(1)} / {(bodyHrs + refinishHrs).toFixed(1)}
|
||||
</DataLabel>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
)}
|
||||
<Col {...colSpan}>
|
||||
<Card
|
||||
style={{ height: "100%" }}
|
||||
title={<span id="job-employee-assignments-title">{t("jobs.labels.employeeassignments")}</span>}
|
||||
id={"job-employee-assignments"}
|
||||
>
|
||||
<div>
|
||||
<JobEmployeeAssignments job={job} />
|
||||
<Divider style={{ margin: ".5rem" }} />
|
||||
<DataLabel label={t("jobs.labels.labor_hrs")}>
|
||||
{bodyHrs.toFixed(1)} / {refinishHrs.toFixed(1)} / {(bodyHrs + refinishHrs).toFixed(1)}
|
||||
</DataLabel>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
)}
|
||||
</Row>
|
||||
<PinnedJobNotes job={job} />
|
||||
</>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SettingOutlined, SyncOutlined } from "@ant-design/icons";
|
||||
import { CarOutlined, SettingOutlined, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
||||
import axios from "axios";
|
||||
import _ from "lodash";
|
||||
@@ -16,22 +16,23 @@ import useLocalStorage from "../../utils/useLocalStorage";
|
||||
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
||||
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
|
||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
|
||||
import * as Sentry from "@sentry/react";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
bodyshop: selectBodyshop,
|
||||
isPartsEntry: selectIsPartsEntry
|
||||
});
|
||||
|
||||
export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, jobs, total }) {
|
||||
export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, jobs, total, isPartsEntry }) {
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const [openSearchResults, setOpenSearchResults] = useState([]);
|
||||
const [searchLoading, setSearchLoading] = useState(false);
|
||||
const [filter, setFilter] = useLocalStorage("filter_jobs_all", null);
|
||||
const { page, sortcolumn, sortorder } = search;
|
||||
const history = useNavigate();
|
||||
const basePath = isPartsEntry ? "/parts" : "/manage";
|
||||
|
||||
const { t } = useTranslation();
|
||||
const columns = [
|
||||
@@ -92,7 +93,7 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
|
||||
ellipsis: true,
|
||||
render: (text, record) => {
|
||||
return record.vehicleid ? (
|
||||
<Link to={"/manage/vehicles/" + record.vehicleid}>
|
||||
<Link to={`${basePath}/vehicles/` + record.vehicleid}>
|
||||
{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${record.v_model_desc || ""}`}
|
||||
</Link>
|
||||
) : (
|
||||
@@ -171,7 +172,6 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
|
||||
if (search.search && search.search.trim() !== "") {
|
||||
searchJobs();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
async function searchJobs(value) {
|
||||
@@ -183,7 +183,7 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
|
||||
});
|
||||
setOpenSearchResults(searchData.data.hits.hits.map((s) => s._source));
|
||||
} catch (error) {
|
||||
console.log("Error while fetching search results", error);
|
||||
Sentry.captureMessage(`Error while fetching search results: ${error.message}`, "warning");
|
||||
} finally {
|
||||
setSearchLoading(false);
|
||||
}
|
||||
@@ -193,6 +193,9 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
|
||||
<Card
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button icon={<CarOutlined />} onClick={() => history("/parts/vehicles")}>
|
||||
{t("menus.header.vehicles")}
|
||||
</Button>
|
||||
<RbacWrapper action="shop:config">
|
||||
<Button
|
||||
icon={<SettingOutlined />}
|
||||
@@ -258,4 +261,4 @@ export function SimplifiedPartsJobsListComponent({ bodyshop, refetch, loading, j
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(SimplifiedPartsJobsListComponent);
|
||||
export default connect(mapStateToProps)(SimplifiedPartsJobsListComponent);
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { Button, Col, Descriptions, Popover, Row, Tag } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import VehicleVinDisplay from "../vehicle-vin-display/vehicle-vin-display.component";
|
||||
import { connect } from "react-redux";
|
||||
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
|
||||
export default function VehicleTagPopoverComponent({ job }) {
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
isPartsEntry: selectIsPartsEntry
|
||||
});
|
||||
|
||||
export function VehicleTagPopoverComponent({ job, isPartsEntry }) {
|
||||
const { t } = useTranslation();
|
||||
const basePath = isPartsEntry ? "/parts" : "/manage";
|
||||
if (!job.vehicle) return null;
|
||||
|
||||
const content = (
|
||||
@@ -50,7 +57,7 @@ export default function VehicleTagPopoverComponent({ job }) {
|
||||
</Descriptions>
|
||||
</Col>
|
||||
</Row>
|
||||
<Link to={`/manage/vehicles/${job.vehicle.id}`}>
|
||||
<Link to={`${basePath}/vehicles/${job.vehicle.id}`}>
|
||||
<Button>{t("vehicles.labels.updatevehicle")}</Button>
|
||||
</Link>
|
||||
</div>
|
||||
@@ -60,7 +67,7 @@ export default function VehicleTagPopoverComponent({ job }) {
|
||||
<Popover placement="bottom" content={content}>
|
||||
<Tag color="blue">
|
||||
{job.vehicleid ? (
|
||||
<Link to={`/manage/vehicles/${job.vehicleid}`}>
|
||||
<Link to={`${basePath}/vehicles/${job.vehicleid}`}>
|
||||
{`${job.v_model_yr || ""} ${job.v_color || ""}
|
||||
${job.v_make_desc || ""}
|
||||
${job.v_model_desc || ""} |
|
||||
@@ -78,3 +85,5 @@ export default function VehicleTagPopoverComponent({ job }) {
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(VehicleTagPopoverComponent);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||
import VehicleVinDisplay from "../vehicle-vin-display/vehicle-vin-display.component";
|
||||
import { pageLimit } from "../../utils/config";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
|
||||
export default function VehiclesListComponent({ loading, vehicles, total, refetch }) {
|
||||
export default function VehiclesListComponent({ loading, vehicles, total, refetch, basePath = "/manage" }) {
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const {
|
||||
page
|
||||
@@ -31,7 +31,7 @@ export default function VehiclesListComponent({ loading, vehicles, total, refetc
|
||||
sorter: (a, b) => alphaSort(a.v_vin, b.v_vin),
|
||||
sortOrder: state.sortedInfo.columnKey === "v_vin" && state.sortedInfo.order,
|
||||
render: (text, record) => (
|
||||
<Link to={"/manage/vehicles/" + record.id}>
|
||||
<Link to={`${basePath}/vehicles/${record.id}`}>
|
||||
<VehicleVinDisplay>{record.v_vin || "N/A"}</VehicleVinDisplay>
|
||||
</Link>
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from "react";
|
||||
import VehiclesListComponent from "./vehicles-list.component";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
@@ -6,10 +5,18 @@ import { QUERY_ALL_VEHICLES_PAGINATED } from "../../graphql/vehicles.queries";
|
||||
import queryString from "query-string";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { pageLimit } from "../../utils/config";
|
||||
import { connect } from "react-redux";
|
||||
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
|
||||
export default function VehiclesListContainer() {
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
isPartsEntry: selectIsPartsEntry
|
||||
});
|
||||
|
||||
export function VehiclesListContainer({ isPartsEntry }) {
|
||||
const searchParams = queryString.parse(useLocation().search);
|
||||
const { page, sortcolumn, sortorder, search } = searchParams;
|
||||
const basePath = isPartsEntry ? "/parts" : "/manage";
|
||||
|
||||
const { loading, error, data, refetch } = useQuery(QUERY_ALL_VEHICLES_PAGINATED, {
|
||||
variables: {
|
||||
@@ -33,6 +40,9 @@ export default function VehiclesListContainer() {
|
||||
vehicles={data ? data.search_vehicles : null}
|
||||
total={data ? data.search_vehicles_aggregate.aggregate.count : 0}
|
||||
refetch={refetch}
|
||||
basePath={basePath}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(VehiclesListContainer);
|
||||
|
||||
@@ -29,6 +29,8 @@ const ReportCenterModal = lazy(() => import("../../components/report-center-moda
|
||||
const PrintCenterModalContainer = lazy(
|
||||
() => import("../../components/print-center-modal/print-center-modal.container")
|
||||
);
|
||||
const VehiclesContainer = lazy(() => import("../vehicles/vehicles.page.container.jsx"));
|
||||
const VehiclesDetailContainer = lazy(() => import("../vehicles-detail/vehicles-detail.page.container.jsx"));
|
||||
const { Content } = Layout;
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
@@ -146,6 +148,22 @@ export function SimplifiedPartsPage({ conflict, bodyshop, alerts, setAlerts }) {
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/vehicles"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<VehiclesContainer />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/vehicles/:vehId"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<VehiclesDetailContainer />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/shop/vendors"
|
||||
element={
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useEffect } from "react";
|
||||
import VehicleDetailComponent from "./vehicles-detail.page.component";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { useParams } from "react-router-dom";
|
||||
@@ -11,6 +11,12 @@ import { connect } from "react-redux";
|
||||
import { CreateRecentItem } from "../../utils/create-recent-item";
|
||||
import NotFound from "../../components/not-found/not-found.component";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import { selectIsPartsEntry } from "../../redux/application/application.selectors";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
isPartsEntry: selectIsPartsEntry
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
@@ -18,9 +24,10 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
setSelectedHeader: (key) => dispatch(setSelectedHeader(key))
|
||||
});
|
||||
|
||||
export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelectedHeader }) {
|
||||
export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelectedHeader, isPartsEntry }) {
|
||||
const { vehId } = useParams();
|
||||
const { t } = useTranslation();
|
||||
const basePath = isPartsEntry ? "/parts" : "/manage";
|
||||
|
||||
const { loading, data, error, refetch } = useQuery(QUERY_VEHICLE_BY_ID, {
|
||||
variables: { id: vehId },
|
||||
@@ -43,20 +50,22 @@ export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelec
|
||||
});
|
||||
setSelectedHeader("vehicles");
|
||||
|
||||
setBreadcrumbs([
|
||||
{ link: "/manage/vehicles", label: t("titles.bc.vehicles") },
|
||||
{
|
||||
link: `/manage/vehicles/${vehId}`,
|
||||
label: t("titles.bc.vehicle-details", {
|
||||
vehicle:
|
||||
data && data.vehicles_by_pk
|
||||
? `${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_yr) || ""} ${
|
||||
(data.vehicles_by_pk && data.vehicles_by_pk.v_make_desc) || ""
|
||||
} ${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_desc) || ""}`
|
||||
: ""
|
||||
})
|
||||
}
|
||||
]);
|
||||
const crumbs = [];
|
||||
if (isPartsEntry) crumbs.push({ link: "/parts/", label: t("titles.bc.jobs") });
|
||||
crumbs.push({ link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") });
|
||||
crumbs.push({
|
||||
link: `${basePath}/vehicles/${vehId}`,
|
||||
label: t("titles.bc.vehicle-details", {
|
||||
vehicle:
|
||||
data && data.vehicles_by_pk
|
||||
? `${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_yr) || ""} ${
|
||||
(data.vehicles_by_pk && data.vehicles_by_pk.v_make_desc) || ""
|
||||
} ${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_desc) || ""}`
|
||||
: ""
|
||||
})
|
||||
});
|
||||
|
||||
setBreadcrumbs(crumbs);
|
||||
|
||||
if (data && data.vehicles_by_pk)
|
||||
addRecentItem(
|
||||
@@ -66,10 +75,10 @@ export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelec
|
||||
`${data.vehicles_by_pk.v_vin || "N/A"} | ${
|
||||
data.vehicles_by_pk.v_model_yr || ""
|
||||
} ${data.vehicles_by_pk.v_make_desc || ""} ${data.vehicles_by_pk.v_model_desc || ""}`.trim(),
|
||||
`/manage/vehicles/${vehId}`
|
||||
`${basePath}/vehicles/${vehId}`
|
||||
)
|
||||
);
|
||||
}, [t, data, setBreadcrumbs, vehId, addRecentItem, setSelectedHeader]);
|
||||
}, [t, data, setBreadcrumbs, vehId, addRecentItem, setSelectedHeader, basePath, isPartsEntry]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
@@ -77,4 +86,4 @@ export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelec
|
||||
return <VehicleDetailComponent vehicle={data.vehicles_by_pk} refetch={refetch} />;
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatchToProps)(VehicleDetailContainer);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(VehicleDetailContainer);
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useEffect } from "react";
|
||||
import VehiclesPageComponent from "./vehicles.page.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
|
||||
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectIsPartsEntry } from "../../redux/application/application.selectors.js";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
isPartsEntry: selectIsPartsEntry
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
setSelectedHeader: (key) => dispatch(setSelectedHeader(key))
|
||||
});
|
||||
|
||||
export function VehiclesPageContainer({ setBreadcrumbs, setSelectedHeader }) {
|
||||
export function VehiclesPageContainer({ setBreadcrumbs, setSelectedHeader, isPartsEntry }) {
|
||||
const { t } = useTranslation();
|
||||
const basePath = isPartsEntry ? "/parts" : "/manage";
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.vehicles", {
|
||||
@@ -22,10 +29,18 @@ export function VehiclesPageContainer({ setBreadcrumbs, setSelectedHeader }) {
|
||||
})
|
||||
});
|
||||
setSelectedHeader("vehicles");
|
||||
setBreadcrumbs([{ link: "/manage/vehicles", label: t("titles.bc.vehicles") }]);
|
||||
}, [t, setBreadcrumbs, setSelectedHeader]);
|
||||
|
||||
if (isPartsEntry) {
|
||||
setBreadcrumbs([
|
||||
{ link: "/parts/", label: t("titles.bc.jobs") },
|
||||
{ link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") }
|
||||
]);
|
||||
} else {
|
||||
setBreadcrumbs([{ link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") }]);
|
||||
}
|
||||
}, [t, setBreadcrumbs, setSelectedHeader, basePath, isPartsEntry]);
|
||||
|
||||
return <VehiclesPageComponent />;
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatchToProps)(VehiclesPageContainer);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(VehiclesPageContainer);
|
||||
|
||||
Reference in New Issue
Block a user