From f947821afa2b09c31e23624d3080f3aa7b550512 Mon Sep 17 00:00:00 2001 From: robbond Date: Wed, 11 Mar 2026 10:40:48 +0000 Subject: [PATCH] adjusted logic to cater for viewl all path and dnsapplications --- components/breadcrumbs.js | 471 ++++++++++++++----------------------- components/case/summary.js | 23 +- i18n.js | 16 +- 3 files changed, 210 insertions(+), 300 deletions(-) diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index b96c0cf5..94dffcc5 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -13,24 +13,40 @@ import { setRepresentationSubmit } from "../store/currentView/action"; const Breadcrumbs = (props) => { - const { currentView, setCurrentSection, setRepresentationSubmit } = props; + const { + currentView, + setCurrentSection, + setRepresentationSubmit, + appealType, + showQuestionnaireSection, + setShowQuestionnaireSection + } = props; const router = useRouter(); let { t } = useTranslation(); const { data: session } = useSession(); + const nestedProps = props?.props || {}; + const nestedSearchString = nestedProps?.search?.searchString || ""; + const nestedCurrentReference = + nestedProps?.currentView?.caseReference?.currentReference || ""; + + const isWelsh = router.locale === "cy"; + const localisedPath = (englishPath, welshSuffixPath) => + isWelsh ? `/${router.locale}${welshSuffixPath}` : englishPath; + const currentReference = - props?.props?.currentView?.caseReference?.currentReference || ""; + currentView?.caseReference?.currentReference || nestedCurrentReference; const fallbackSearchTitle = - props?.props?.searchResultsObj?.searchResultsObj?.value?.[0]?.title || - ""; + props?.searchResultsObj?.searchResultsObj?.value?.[0]?.title || ""; const caseReferenceDisplay = currentReference || fallbackSearchTitle; - const myPortalHref = - router.locale != "en" ? "/" + router.locale + "/fymhorth" : "/myportal"; - const cyMyPortalHref = - router.locale == "cy" ? "/" + router.locale + "/fymhorth" : "/myportal"; + const myPortalHref = localisedPath("/myportal", "/fymhorth"); + const cyMyPortalHref = myPortalHref; + const pathname = router.pathname; + const isPath = (path) => pathname === path; const caseReference = currentView?.caseReference || {}; + const currentViewState = currentView?.currentView || {}; const repDetails = caseReference?.repDetails; const hasRepDetails = Object.prototype.hasOwnProperty.call( caseReference, @@ -38,22 +54,46 @@ const Breadcrumbs = (props) => { ); const qcount = - caseReference.appealType == 846040000 || - caseReference.appealType == 846040001 || - caseReference.appealType == 846040025 || - caseReference.appealType == 846040004 || - caseReference.appealType == 846040018 || - caseReference.appealType == 846040003 || - caseReference.appealType == 846040009 || - caseReference.appealType == 846040008 + caseReference.appealType === 846040000 || + caseReference.appealType === 846040001 || + caseReference.appealType === 846040025 || + caseReference.appealType === 846040004 || + caseReference.appealType === 846040018 || + caseReference.appealType === 846040003 || + caseReference.appealType === 846040009 || + caseReference.appealType === 846040008 ? 7 - : caseReference.appealType == 846040005 || - caseReference.appealType == 846040006 || - caseReference.appealType == 846040007 + : caseReference.appealType === 846040005 || + caseReference.appealType === 846040006 || + caseReference.appealType === 846040007 ? 9 : ""; const { va, adv, ads, key } = router.query; + const isAdv = adv === "true"; + const isAds = ads === "true"; + + const hideServiceNamePaths = [ + "/myportal/[appealtypes]", + "/newappeal", + "/newappeal/[appealtypes]", + "/myportal/representation" + ]; + const shouldShowServiceName = !hideServiceNamePaths.includes(pathname); + + const getViewAllLabel = (viewKey) => { + const labelsByKey = { + awaitingSubmissionDetails: t( + "myportal:awatitingsubmission-card-title" + ), + watchedCases: t("myportal:watchedcases-card-title"), + myCases: t("myportal:mycases-card-title"), + myRepresentations: t("myportal:myrepresentations-card-title"), + mySubmittedReps: "Submitted representations" + }; + + return labelsByKey[viewKey] || null; + }; const breadcrumbHref = (() => { if (va === "true") { @@ -65,6 +105,12 @@ const Breadcrumbs = (props) => { const base = session ? "/myportal" : ""; + if (!va && !adv && !ads) { + return { + pathname: "/myportal" + }; + } + if (adv === "true") { return { pathname: `${base}/advancedsearchresults`, @@ -87,35 +133,17 @@ const Breadcrumbs = (props) => { const breadcrumbLabel = (() => { if (va === "true") { - if (key === "awaitingSubmissionDetails") - return t("myportal:awatitingsubmission-card-title"); + return getViewAllLabel(key); } - if (key === "watchedCases") - return t("myportal:watchedcases-card-title"); - if (key === "myCases") return t("myportal:mycases-card-title"); + const keyedLabel = getViewAllLabel(key); + if (keyedLabel) return keyedLabel; - if (key === "myRepresentations") - return t("myportal:myrepresentations-card-title"); - - if (key === "awaitingSubmissionDetails") - return t("myportal:awatitingsubmission-card-title"); - - if (key === "watchedCases") - return t("myportal:watchedcases-card-title"); - - if (key === "myCases") return t("myportal:mycases-card-title"); - - if (key === "myRepresentations") - return t("myportal:myrepresentations-card-title"); - - if (key === "mySubmittedReps") return "Submitted representations"; - - if (adv === "true") { + if (isAdv) { return t("common:breadcrumb-advanced-search-results"); } - if (ads === "true") { + if (isAds) { return t("common:breadcrumb-address-search-results"); } @@ -130,26 +158,23 @@ const Breadcrumbs = (props) => { >
    - {router.pathname != "/myportal/[appealtypes]" && - router.pathname != "/newappeal" && - router.pathname != "/newappeal/[appealtypes]" && - router.pathname != "/myportal/representation" && ( -
  1. - - {t("common:service-name-breadcrumb")} - -
  2. - )} + {shouldShowServiceName && ( +
  3. + + {t("common:service-name-breadcrumb")} + +
  4. + )} - {router.pathname == "/myportal" && ( + {isPath("/myportal") && (
  5. {t("myportal:page-title")}
  6. )} - {router.pathname == "/myportal/searchresults" && ( + {isPath("/myportal/searchresults") && ( <>
  7. {
  8. )} - {router.pathname == "/searchresults" && ( + {isPath("/searchresults") && ( <>
  9. {t("common:breadcrumb-search-results")}
  10. )} - {router.pathname == "/advancedsearch" && ( + {isPath("/advancedsearch") && ( <>
  11. {t("common:breadcrumb-advanced-search")}
  12. )} - {router.pathname == "/addresssearch" && ( + {isPath("/addresssearch") && ( <>
  13. {t("common:breadcrumb-address-search")}
  14. )} - {router.pathname == "/myportal/addresssearch" && ( + {isPath("/myportal/addresssearch") && ( <>
  15. {
  16. )} - {router.pathname == "/myportal/advancedsearch" && ( + {isPath("/myportal/advancedsearch") && ( <>
  17. {
  18. )} - {router.pathname == "/myportal/contactus" && ( + {isPath("/myportal/contactus") && ( <>
  19. {
  20. )} - {router.pathname == "/addresssearchresults" && ( + {isPath("/contactus") && ( + <> +
  21. + {t("common:footer-contact-us-link-label")} +
  22. + + )} + {isPath("/addresssearchresults") && ( <> {" "}
  23. {
  24. )} - {router.pathname == "/advancedsearchresults" && ( + {isPath("/advancedsearchresults") && ( <> {" "}
  25. {
  26. )} - {router.pathname == - "/myportal/advancedsearchresults" && ( + {isPath("/myportal/advancedsearchresults") && ( <>
  27. {
  28. {
  29. )} - {router.pathname == - "/myportal/addresssearchresults" && ( + {isPath("/myportal/addresssearchresults") && ( <>
  30. {
  31. {
  32. )} - {router.pathname == "/newappeal" && ( + {isPath("/newappeal") && <>} + {isPath("/newappeal/[appealtypes]") && ( <> - {/*
  33. - - {t("newappeal:parent-page-title")} - -
  34. -
  35. - {t("newappeal:page-title")} -
  36. */} - - )} - {router.pathname == "/newappeal/[appealtypes]" && ( - <> - {/*
  37. - - {t("newappeal:parent-page-title")} - -
  38. -
  39. - {t("newappeal:page-title")} -
  40. */} - - {props.appealType.currentSection > 1 && - (props.appealType.currentSection == 9999 ? ( + {appealType.currentSection > 1 && + (appealType.currentSection === 9999 ? (
  41. { href="#" onClick={() => setCurrentSection( - props.appealType - .currentSection - 1 + appealType.currentSection - + 1 ) } > @@ -410,30 +402,10 @@ const Breadcrumbs = (props) => { ))} )} - {router.pathname == "/myportal/[appealtypes]" && ( + {isPath("/myportal/[appealtypes]") && ( <> - {/*
  42. - - {t("newappeal:parent-page-title")} - -
  43. -
  44. - {t("newappeal:page-title")} -
  45. -
  46. - {t("common:back-link")} {props.formTitle} -
  47. */} - {props.appealType.currentSection > 1 && - (props.appealType.currentSection == 9999 ? ( + {appealType.currentSection > 1 && + (appealType.currentSection === 9999 ? (
  48. { href="#" onClick={() => setCurrentSection( - props.appealType - .currentSection - + appealType.currentSection - 1 ) } @@ -465,7 +436,7 @@ const Breadcrumbs = (props) => { ))} )} - {router.pathname == "/newappeal/selectappeal" && ( + {isPath("/newappeal/selectappeal") && ( <>
  49. {
  50. )} - {router.pathname == "/viewall" && ( + {isPath("/viewall") && ( <>
  51. {
  52. )} - {router.pathname == "/myportal/viewall" && ( + {isPath("/myportal/viewall") && ( <>
  53. {
  54. - {(currentView.currentView.viewKey || - router.query.key) == - "awaitingSubmissionDetails" && - t( - "myportal:awatitingsubmission-card-title" - )} - {(currentView.currentView.viewKey || - router.query.key) == "watchedCases" && - t("myportal:watchedcases-card-title")} - {(currentView.currentView.viewKey || - router.query.key) == "myCases" && - t("myportal:mycases-card-title")} - {(currentView.currentView.viewKey || - router.query.key) == - "myRepresentations" && - t( - "myportal:myrepresentations-card-title" - )} - {(currentView.currentView.viewKey || - router.query.key) == - "mySubmittedReps" && - "Submitted representations"} + {getViewAllLabel( + currentViewState.viewKey || + router.query.key + )}
  55. )} - {router.pathname == "/myportal/case" && ( + {isPath("/myportal/case") && ( <>
  56. {
  57. )} - {router.pathname == "/case/[ticketnumber]" && ( + {isPath("/case/[ticketnumber]") && ( <>
  58. - {router.query.ads == "true" - ? t( - "common:breadcrumb-addresssearch-results" - ) - : t( - "common:breadcrumb-search-results" - )} + {breadcrumbLabel}
  59. @@ -592,12 +539,12 @@ const Breadcrumbs = (props) => {
  60. )} - {router.pathname == "/case/id/[incident]" && ( + {isPath("/case/id/[incident]") && ( <>
  61. {
  62. @@ -634,7 +579,7 @@ const Breadcrumbs = (props) => {
  63. )} - {router.pathname == "/myportal/case/id/[incident]" && ( + {isPath("/myportal/case/id/[incident]") && ( <> {" "}
  64. @@ -648,7 +593,7 @@ const Breadcrumbs = (props) => {
  65. {
  66. { // spinnerState(); @@ -689,7 +632,7 @@ const Breadcrumbs = (props) => {
  67. )} - {router.pathname == "/myportal/case/[ticketnumber]" && ( + {isPath("/myportal/case/[ticketnumber]") && ( <>
  68. {
  69. )} - {router.pathname == "/myportal/dnsapplications" && ( + {isPath("/myportal/dnsapplications") && ( <> {" "}
  70. @@ -729,7 +672,7 @@ const Breadcrumbs = (props) => {
  71. )} - {router.pathname == "/myportal/dnsdetails" && ( + {isPath("/myportal/dnsdetails") && ( <>
  72. {
  73. )} - {router.pathname == - "/myportal/dns/[developmentName]" && ( + {isPath("/myportal/dns/[developmentName]") && ( <>
  74. {
  75. )} - {router.pathname == "/case" && ( + {isPath("/case") && ( <>
  76. - {/* {session != null && ( -
  77. - - {t("common:breadcrumb-my-portal")} - -
  78. - )} -
  79. - - { - props.props.currentView - .caseReference.currentReference - } - -
  80. -
  81. - {t( - "myrepresentations:make-a-representation-for-label" - )}{" "} - { - props.props.currentView.caseReference - .currentReference - } -
  82. */} - - {props.currentView.representationSubmit == - true && - props.currentView - .representationSubmitConfirmation != + {currentView.representationSubmit === true && + currentView.representationSubmitConfirmation !== true && (
  83. {
  84. )} - {props.currentView.representationSubmit != - true && + {currentView.representationSubmit !== true && hasRepDetails && - repDetails?.representationType != + repDetails?.representationType !== "Questionnaire" && (
  85. {
  86. )} - {props.currentView.representationSubmit != - true && + {currentView.representationSubmit !== true && hasRepDetails && - repDetails?.representationType == + repDetails?.representationType === "Questionnaire" && - props.showQuestionnaireSection > 1 && ( + showQuestionnaireSection > 1 && (
  87. { - props.setShowQuestionnaireSection( - props.showQuestionnaireSection - + setShowQuestionnaireSection( + showQuestionnaireSection - 1 ); setRepresentationSubmit( @@ -927,7 +817,7 @@ const Breadcrumbs = (props) => { )} )} - {router.pathname == "/account/personaldetails" && ( + {isPath("/account/personaldetails") && ( <>
  88. {
  89. )} - {router.pathname == "/account/register" && ( + {isPath("/account/register") && ( <>
  90. {t("account:register-new-account-heading")}
  91. )} - {router.pathname == "/account/changepassword" && ( + {isPath("/account/changepassword") && ( <>
  92. {
  93. )} - {router.pathname == "/dns" && ( + {isPath("/dns") && ( <>
  94. {t("dnsCommon:service-name")} @@ -972,19 +862,19 @@ const Breadcrumbs = (props) => { )} - {router.pathname == "/dnsapplications" && ( + {isPath("/dnsapplications") && ( <>
  95. {t("dnsCommon:service-name")}
  96. )} - {router.pathname == "/dnsdetails" && ( + {isPath("/dnsdetails") && ( <>
  97. {
  98. )} - {router.pathname == "/dns/[developmentName]" && ( + {isPath("/dns/[developmentName]") && ( <>
  99. {
  100. )} - {router.pathname == "/dns/application-process" && ( + {isPath("/dns/application-process") && ( <>
  101. Guidance
  102. )} - {router.pathname == "/dns/help" && ( + {isPath("/dns/help") && ( <>
  103. Help
  104. )} - {router.pathname == "/dns/contact-us" && ( + {isPath("/dns/contact-us") && ( <>
  105. {t("common:footer-contact-us-link-label")}
  106. )} - {router.pathname == "/dns/applications" && ( + {isPath("/dns/applications") && ( <>
  107. {t("dnsApplications:page-title")}
  108. )} - {router.pathname == "/dns/application-view" && ( + {isPath("/dns/application-view") && ( <>
  109. {
  110. )} - {router.pathname == "/help/cookies" && ( + {isPath("/help/cookies") && ( <>
  111. {t("cookies:cookie-breadcrumb")}
  112. )} - {router.pathname == "/privacy" && ( + {isPath("/privacy") && ( <>
  113. {t("common:footer-privacy-link-label")}
  114. )} - {router.pathname == "/accessibility" && ( + {isPath("/accessibility") && ( <>
  115. {t( @@ -1094,28 +984,28 @@ const Breadcrumbs = (props) => {
  116. )} - {router.pathname == "/details-about-cookies" && ( + {isPath("/details-about-cookies") && ( <>
  117. {t("cookies:cookie-policy-title-heading")}
  118. )} - {router.pathname == "/auth/signin" && ( + {isPath("/auth/signin") && ( <>
  119. {t("auth:auth-page-title")}
  120. )} - {router.pathname == "/auth/verify-request" && ( + {isPath("/auth/verify-request") && ( <>
  121. {t("auth:auth-check-email-page-title")}
  122. )} - {router.pathname == "/auth/error" && ( + {isPath("/auth/error") && ( <>
  123. {t("auth:auth-error-signin-error-title")} @@ -1129,11 +1019,12 @@ const Breadcrumbs = (props) => { ); }; -const mapStateToProps = (state) => { - return { - ...state - }; -}; +const mapStateToProps = (state) => ({ + currentView: state.currentView, + appealType: state.appealType, + searchResultsObj: state.searchResultsObj, + search: state.search +}); const mapDispatchToProps = (dispatch) => { return { diff --git a/components/case/summary.js b/components/case/summary.js index eda9c03f..49494e8a 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -326,6 +326,27 @@ const CaseSummary = (props) => { const buildSearchHref = (router, session) => { const { va, adv, ads, key } = router.query; + console.log(router); + + const isDnsRoute = + router.pathname === "/dns" || + router.pathname.startsWith("/dns/") || + router.pathname === "/myportal/dns" || + router.pathname.startsWith("/myportal/dns/"); + + const base = session ? "/myportal" : ""; + + if (!va && !adv && !ads) { + return { + pathname: "/myportal" + }; + } + + if (isDnsRoute) { + return { + pathname: `${base}/dnsapplications` + }; + } if (va === "true") { return { @@ -334,8 +355,6 @@ const CaseSummary = (props) => { }; } - const base = session ? "/myportal" : ""; - if (adv === "true") { return { pathname: `${base}/advancedsearchresults`, diff --git a/i18n.js b/i18n.js index 272ba0ea..aaac19af 100644 --- a/i18n.js +++ b/i18n.js @@ -6,8 +6,8 @@ module.exports = { { "domain": process.env.I18N_DOMAIN, "defaultLocale": "cy", - "locales": ["cy"], - }, + "locales": ["cy"] + } ], "pages": { "*": ["common", "search"], @@ -22,18 +22,18 @@ module.exports = { "/myportal/advancedsearchresults": ["search", "myportal", "case"], "/myportal/searchresults": ["search", "myportal", "case"], "/myportal/case": ["case"], - "/myportal/case/[ticketnumber]": ["case"], + "/myportal/case/[ticketnumber]": ["case", "myportal"], "/myportal/dnsapplications": [ "search", "dnsCommon", "dnsApplications", - "case", + "case" ], "/myportal/dnsdetails": [ "case", "search", "dnsCommon", - "dnsApplications", + "dnsApplications" ], "/myportal/dns/*": ["dnsCommon", "case", "common"], "/myportal/dns/[developmentName]": ["dnsCommon", "case", "common"], @@ -51,7 +51,7 @@ module.exports = { "case", "myrepresentations", "common", - "home", + "home" ], "/myportal/error": ["myportal", "common"], "/myportal/case/id/[incident]": ["case", "home"], @@ -78,6 +78,6 @@ module.exports = { "/auth/signin": ["common", "common", "auth"], "/auth/verify-request": ["common", "common", "auth"], "/auth/error": ["common", "common", "auth"], - "/admin": ["case"], - }, + "/admin": ["case"] + } };