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 },
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
@@ -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,10 +50,11 @@ export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelec
|
||||
});
|
||||
setSelectedHeader("vehicles");
|
||||
|
||||
setBreadcrumbs([
|
||||
{ link: "/manage/vehicles", label: t("titles.bc.vehicles") },
|
||||
{
|
||||
link: `/manage/vehicles/${vehId}`,
|
||||
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
|
||||
@@ -55,8 +63,9 @@ export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelec
|
||||
} ${(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