22541 introduce simple route renderer map for static breadcrumb branches
This commit is contained in:
+27
-48
@@ -113,6 +113,26 @@ const Breadcrumbs = (props) => {
|
||||
return staticTextCrumbByPath[path] || null;
|
||||
};
|
||||
|
||||
const getSimpleRouteRenderer = (path) => {
|
||||
const simpleRouteRenderersByPath = {
|
||||
"/myportal": () => renderTextCrumb(t("myportal:page-title")),
|
||||
"/searchresults": () =>
|
||||
renderTextCrumb(t("common:breadcrumb-search-results")),
|
||||
"/advancedsearch": () =>
|
||||
renderTextCrumb(t("common:breadcrumb-advanced-search")),
|
||||
"/addresssearch": () =>
|
||||
renderTextCrumb(t("common:breadcrumb-address-search")),
|
||||
"/contactus": () =>
|
||||
renderTextCrumb(t("common:footer-contact-us-link-label")),
|
||||
"/viewall": () =>
|
||||
renderMyPortalSectionCrumbs(t("common:breadcrumb-your-cases")),
|
||||
"/myportal/dnsapplications": () =>
|
||||
renderMyPortalSectionCrumbs(t("dnsCommon:service-name"))
|
||||
};
|
||||
|
||||
return simpleRouteRenderersByPath[path] || null;
|
||||
};
|
||||
|
||||
const renderMyPortalCrumb = () => (
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link href={myPortalHref} className="govuk-breadcrumbs__link">
|
||||
@@ -208,11 +228,13 @@ const Breadcrumbs = (props) => {
|
||||
t("common:service-name-breadcrumb")
|
||||
)}
|
||||
|
||||
{isPath("/myportal") && (
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("myportal:page-title")}
|
||||
</li>
|
||||
)}
|
||||
{(() => {
|
||||
const renderSimpleRoute =
|
||||
getSimpleRouteRenderer(pathname);
|
||||
return renderSimpleRoute
|
||||
? renderSimpleRoute()
|
||||
: null;
|
||||
})()}
|
||||
{isPath("/myportal/searchresults") && (
|
||||
<>
|
||||
{renderAnchorCrumb(
|
||||
@@ -224,27 +246,6 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/searchresults") && (
|
||||
<>
|
||||
{renderTextCrumb(
|
||||
t("common:breadcrumb-search-results")
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/advancedsearch") && (
|
||||
<>
|
||||
{renderTextCrumb(
|
||||
t("common:breadcrumb-advanced-search")
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/addresssearch") && (
|
||||
<>
|
||||
{renderTextCrumb(
|
||||
t("common:breadcrumb-address-search")
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/myportal/addresssearch") &&
|
||||
renderMyPortalSectionCrumbs(
|
||||
t("common:breadcrumb-address-search")
|
||||
@@ -257,13 +258,6 @@ const Breadcrumbs = (props) => {
|
||||
renderMyPortalSectionCrumbs(
|
||||
t("common:footer-contact-us-link-label")
|
||||
)}
|
||||
{isPath("/contactus") && (
|
||||
<>
|
||||
{renderTextCrumb(
|
||||
t("common:footer-contact-us-link-label")
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/addresssearchresults") && (
|
||||
<>
|
||||
{" "}
|
||||
@@ -384,14 +378,6 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/viewall") && (
|
||||
<>
|
||||
{renderMyPortalCrumb()}
|
||||
{renderTextCrumb(
|
||||
t("common:breadcrumb-your-cases")
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/myportal/viewall") && (
|
||||
<>
|
||||
{renderMyPortalCrumb()}
|
||||
@@ -489,13 +475,6 @@ const Breadcrumbs = (props) => {
|
||||
{renderCaseReferenceCrumb(caseReferenceDisplay)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/myportal/dnsapplications") && (
|
||||
<>
|
||||
{" "}
|
||||
{renderMyPortalCrumb()}
|
||||
{renderTextCrumb(t("dnsCommon:service-name"))}
|
||||
</>
|
||||
)}
|
||||
{isPath("/myportal/dnsdetails") && (
|
||||
<>
|
||||
{renderMyPortalCrumb()}
|
||||
|
||||
Reference in New Issue
Block a user