feature/IO-3255-simplified-parts-management - Fix Breadcrumbs

This commit is contained in:
Dave
2025-08-22 11:03:34 -04:00
parent 364813193f
commit 9860447e42
7 changed files with 36 additions and 25 deletions

View File

@@ -22,9 +22,9 @@ export function BreadCrumbs({ breadcrumbs, bodyshop, isPartsEntry }) {
} = useSplitTreatments({ } = useSplitTreatments({
attributes: {}, attributes: {},
names: ["OpenSearch"], names: ["OpenSearch"],
splitKey: bodyshop && bodyshop.imexshopid splitKey: bodyshop?.imexshopid
}); });
// TODO - Client Update - Technically key is not doing anything here
return ( return (
<Row className="breadcrumb-container"> <Row className="breadcrumb-container">
<Col xs={24} sm={24} md={16}> <Col xs={24} sm={24} md={16}>
@@ -35,7 +35,7 @@ export function BreadCrumbs({ breadcrumbs, bodyshop, isPartsEntry }) {
key: "home", key: "home",
title: ( title: (
<Link to={isPartsEntry ? `/parts/` : `/manage/`}> <Link to={isPartsEntry ? `/parts/` : `/manage/`}>
<HomeFilled /> {(bodyshop && bodyshop.shopname && `(${bodyshop.shopname})`) || ""} <HomeFilled /> {(bodyshop?.shopname && `(${bodyshop.shopname})`) || ""}
</Link> </Link>
) )
}, },

View File

@@ -34,7 +34,7 @@ export function PartsSettingsPage({ setSelectedHeader, setBreadcrumbs }) {
setBreadcrumbs([ setBreadcrumbs([
{ {
link: "/parts", link: "/parts",
label: t("titles.bc.parts") label: "Parts"
}, },
{ {
link: "/parts/settings", link: "/parts/settings",

View File

@@ -60,19 +60,19 @@ function SimplifiedPartsJobsDetailContainer({ setBreadcrumbs, addRecentItem, set
imex: "$t(titles.imexonline)", imex: "$t(titles.imexonline)",
rome: "$t(titles.romeonline)" rome: "$t(titles.romeonline)"
}), }),
ro_number: (data.jobs_by_pk && data.jobs_by_pk.ro_number) || t("general.labels.na") ro_number: data.jobs_by_pk?.ro_number || t("general.labels.na")
}); });
setBreadcrumbs([ setBreadcrumbs([
{ link: "/parts/", label: t("titles.bc.jobs") }, { link: "/parts", label: "Parts" },
{ {
link: `/parts/jobs/${jobId}`, link: `/parts/jobs/${jobId}`,
label: t("titles.bc.jobs-detail", { label: t("titles.bc.jobs-detail", {
number: (data && data.jobs_by_pk && data.jobs_by_pk.ro_number) || t("general.labels.na") number: (data?.jobs_by_pk && data.jobs_by_pk.ro_number) || t("general.labels.na")
}) })
} }
]); ]);
if (data && data.jobs_by_pk) { if (data?.jobs_by_pk) {
setJobReadOnly(IsJobReadOnly(data.jobs_by_pk)); setJobReadOnly(IsJobReadOnly(data.jobs_by_pk));
addRecentItem( addRecentItem(

View File

@@ -22,7 +22,7 @@ export function SimplifiedPartsJobsPage({ setBreadcrumbs, setSelectedHeader }) {
}) })
}); });
setSelectedHeader("parts-queue"); setSelectedHeader("parts-queue");
setBreadcrumbs([{ link: "/parts", label: t("titles.bc.simplified-parts-jobs") }]); setBreadcrumbs([{ link: "/parts", label: "Parts" }]);
}, [setBreadcrumbs, t, setSelectedHeader]); }, [setBreadcrumbs, t, setSelectedHeader]);
return ( return (

View File

@@ -3,7 +3,7 @@ import { FloatButton, Layout, Spin } from "antd";
import { lazy, Suspense, useEffect } from "react"; import { lazy, Suspense, useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Route, Routes } from "react-router-dom"; import { Navigate, Route, Routes, useLocation } from "react-router-dom";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import BreadCrumbs from "../../components/breadcrumbs/breadcrumbs.component.jsx"; import BreadCrumbs from "../../components/breadcrumbs/breadcrumbs.component.jsx";
import ConflictComponent from "../../components/conflict/conflict.component.jsx"; import ConflictComponent from "../../components/conflict/conflict.component.jsx";
@@ -39,6 +39,15 @@ const mapStateToProps = createStructuredSelector({
export function SimplifiedPartsPage({ conflict, bodyshop }) { export function SimplifiedPartsPage({ conflict, bodyshop }) {
const { t } = useTranslation(); const { t } = useTranslation();
// Redirector to strip '/parts/jobs' from path for non-detail routes
function JobsStripRedirect() {
// lazy import to avoid top-level import churn
const location = useLocation();
const { pathname, search, hash } = location;
const target = pathname.replace("/parts/jobs", "/parts") + (search || "") + (hash || "");
return <Navigate to={target} replace />;
}
// Centralized alerts handling (fetch + dedupe + notifications) // Centralized alerts handling (fetch + dedupe + notifications)
useAlertsNotifications(); useAlertsNotifications();
@@ -67,6 +76,10 @@ export function SimplifiedPartsPage({ conflict, bodyshop }) {
<EmailOverlayContainer /> <EmailOverlayContainer />
<PrintCenterModalContainer /> <PrintCenterModalContainer />
<Routes> <Routes>
{/* Redirect legacy or relative routes that include '/jobs' segment */}
<Route path="jobs" element={<JobsStripRedirect />} />
<Route path="jobs/*" element={<JobsStripRedirect />} />
<Route <Route
path="/" path="/"
element={ element={

View File

@@ -42,33 +42,31 @@ export function VehicleDetailContainer({ setBreadcrumbs, addRecentItem, setSelec
imex: "$t(titles.imexonline)", imex: "$t(titles.imexonline)",
rome: "$t(titles.romeonline)" rome: "$t(titles.romeonline)"
}), }),
vehicle: vehicle: data?.vehicles_by_pk
data && data.vehicles_by_pk ? `${data.vehicles_by_pk?.v_model_yr || ""} ${
? `${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_yr) || ""} ${ data.vehicles_by_pk?.v_make_desc || ""
(data.vehicles_by_pk && data.vehicles_by_pk.v_make_desc) || "" } ${data.vehicles_by_pk?.v_model_desc || ""}`
} ${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_desc) || ""}` : ""
: ""
}); });
setSelectedHeader("vehicles"); setSelectedHeader("vehicles");
const crumbs = []; const crumbs = [];
if (isPartsEntry) crumbs.push({ link: "/parts/", label: t("titles.bc.jobs") }); if (isPartsEntry) crumbs.push({ link: "/parts", label: "Parts" });
crumbs.push({ link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") }); crumbs.push({ link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") });
crumbs.push({ crumbs.push({
link: `${basePath}/vehicles/${vehId}`, link: `${basePath}/vehicles/${vehId}`,
label: t("titles.bc.vehicle-details", { label: t("titles.bc.vehicle-details", {
vehicle: vehicle: data?.vehicles_by_pk
data && data.vehicles_by_pk ? `${data.vehicles_by_pk?.v_model_yr || ""} ${
? `${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_yr) || ""} ${ data.vehicles_by_pk?.v_make_desc || ""
(data.vehicles_by_pk && data.vehicles_by_pk.v_make_desc) || "" } ${data.vehicles_by_pk?.v_model_desc || ""}`
} ${(data.vehicles_by_pk && data.vehicles_by_pk.v_model_desc) || ""}` : ""
: ""
}) })
}); });
setBreadcrumbs(crumbs); setBreadcrumbs(crumbs);
if (data && data.vehicles_by_pk) if (data?.vehicles_by_pk)
addRecentItem( addRecentItem(
CreateRecentItem( CreateRecentItem(
vehId, vehId,

View File

@@ -33,7 +33,7 @@ export function VehiclesPageContainer({ setBreadcrumbs, setSelectedHeader, isPar
if (isPartsEntry) { if (isPartsEntry) {
setBreadcrumbs([ setBreadcrumbs([
{ link: "/parts/", label: t("titles.bc.jobs") }, { link: "/parts", label: "Parts" },
{ link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") } { link: `${basePath}/vehicles`, label: t("titles.bc.vehicles") }
]); ]);
} else { } else {