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" && (
- -
-
- {t("common:service-name-breadcrumb")}
-
-
- )}
+ {shouldShowServiceName && (
+ -
+
+ {t("common:service-name-breadcrumb")}
+
+
+ )}
- {router.pathname == "/myportal" && (
+ {isPath("/myportal") && (
-
{t("myportal:page-title")}
)}
- {router.pathname == "/myportal/searchresults" && (
+ {isPath("/myportal/searchresults") && (
<>
-
{
>
)}
- {router.pathname == "/searchresults" && (
+ {isPath("/searchresults") && (
<>
-
{t("common:breadcrumb-search-results")}
>
)}
- {router.pathname == "/advancedsearch" && (
+ {isPath("/advancedsearch") && (
<>
-
{t("common:breadcrumb-advanced-search")}
>
)}
- {router.pathname == "/addresssearch" && (
+ {isPath("/addresssearch") && (
<>
-
{t("common:breadcrumb-address-search")}
>
)}
- {router.pathname == "/myportal/addresssearch" && (
+ {isPath("/myportal/addresssearch") && (
<>
-
{
>
)}
- {router.pathname == "/myportal/advancedsearch" && (
+ {isPath("/myportal/advancedsearch") && (
<>
-
{
>
)}
- {router.pathname == "/myportal/contactus" && (
+ {isPath("/myportal/contactus") && (
<>
-
{
>
)}
- {router.pathname == "/addresssearchresults" && (
+ {isPath("/contactus") && (
+ <>
+ -
+ {t("common:footer-contact-us-link-label")}
+
+ >
+ )}
+ {isPath("/addresssearchresults") && (
<>
{" "}
-
{
>
)}
- {router.pathname == "/advancedsearchresults" && (
+ {isPath("/advancedsearchresults") && (
<>
{" "}
-
{
>
)}
- {router.pathname ==
- "/myportal/advancedsearchresults" && (
+ {isPath("/myportal/advancedsearchresults") && (
<>
-
{
-
{
>
)}
- {router.pathname ==
- "/myportal/addresssearchresults" && (
+ {isPath("/myportal/addresssearchresults") && (
<>
-
{
-
{
>
)}
- {router.pathname == "/newappeal" && (
+ {isPath("/newappeal") && <>>}
+ {isPath("/newappeal/[appealtypes]") && (
<>
- {/* -
-
- {t("newappeal:parent-page-title")}
-
-
- -
- {t("newappeal:page-title")}
-
*/}
- >
- )}
- {router.pathname == "/newappeal/[appealtypes]" && (
- <>
- {/* -
-
- {t("newappeal:parent-page-title")}
-
-
- -
- {t("newappeal:page-title")}
-
*/}
-
- {props.appealType.currentSection > 1 &&
- (props.appealType.currentSection == 9999 ? (
+ {appealType.currentSection > 1 &&
+ (appealType.currentSection === 9999 ? (
-
{
href="#"
onClick={() =>
setCurrentSection(
- props.appealType
- .currentSection - 1
+ appealType.currentSection -
+ 1
)
}
>
@@ -410,30 +402,10 @@ const Breadcrumbs = (props) => {
))}
>
)}
- {router.pathname == "/myportal/[appealtypes]" && (
+ {isPath("/myportal/[appealtypes]") && (
<>
- {/*
-
-
- {t("newappeal:parent-page-title")}
-
-
- -
- {t("newappeal:page-title")}
-
- -
- {t("common:back-link")} {props.formTitle}
-
*/}
- {props.appealType.currentSection > 1 &&
- (props.appealType.currentSection == 9999 ? (
+ {appealType.currentSection > 1 &&
+ (appealType.currentSection === 9999 ? (
-
{
href="#"
onClick={() =>
setCurrentSection(
- props.appealType
- .currentSection -
+ appealType.currentSection -
1
)
}
@@ -465,7 +436,7 @@ const Breadcrumbs = (props) => {
))}
>
)}
- {router.pathname == "/newappeal/selectappeal" && (
+ {isPath("/newappeal/selectappeal") && (
<>
-
{
>
)}
- {router.pathname == "/viewall" && (
+ {isPath("/viewall") && (
<>
-
{
>
)}
- {router.pathname == "/myportal/viewall" && (
+ {isPath("/myportal/viewall") && (
<>
-
{
-
- {(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
+ )}
>
)}
- {router.pathname == "/myportal/case" && (
+ {isPath("/myportal/case") && (
<>
-
{
>
)}
- {router.pathname == "/case/[ticketnumber]" && (
+ {isPath("/case/[ticketnumber]") && (
<>
-
- {router.query.ads == "true"
- ? t(
- "common:breadcrumb-addresssearch-results"
- )
- : t(
- "common:breadcrumb-search-results"
- )}
+ {breadcrumbLabel}
-
@@ -592,12 +539,12 @@ const Breadcrumbs = (props) => {
>
)}
- {router.pathname == "/case/id/[incident]" && (
+ {isPath("/case/id/[incident]") && (
<>
-
{
-
@@ -634,7 +579,7 @@ const Breadcrumbs = (props) => {
>
)}
- {router.pathname == "/myportal/case/id/[incident]" && (
+ {isPath("/myportal/case/id/[incident]") && (
<>
{" "}
-
@@ -648,7 +593,7 @@ const Breadcrumbs = (props) => {
-
{
-
{
// spinnerState();
@@ -689,7 +632,7 @@ const Breadcrumbs = (props) => {
>
)}
- {router.pathname == "/myportal/case/[ticketnumber]" && (
+ {isPath("/myportal/case/[ticketnumber]") && (
<>
-
{
>
)}
- {router.pathname == "/myportal/dnsapplications" && (
+ {isPath("/myportal/dnsapplications") && (
<>
{" "}
-
@@ -729,7 +672,7 @@ const Breadcrumbs = (props) => {
>
)}
- {router.pathname == "/myportal/dnsdetails" && (
+ {isPath("/myportal/dnsdetails") && (
<>
-
{
>
)}
- {router.pathname ==
- "/myportal/dns/[developmentName]" && (
+ {isPath("/myportal/dns/[developmentName]") && (
<>
-
{
>
)}
- {router.pathname == "/case" && (
+ {isPath("/case") && (
<>
-
{
>
)}
- {router.pathname == "/myportal/representation" && (
+ {isPath("/myportal/representation") && (
<>
- {/* {session != null && (
- -
-
- {t("common:breadcrumb-my-portal")}
-
-
- )}
- -
-
- {
- props.props.currentView
- .caseReference.currentReference
- }
-
-
- -
- {t(
- "myrepresentations:make-a-representation-for-label"
- )}{" "}
- {
- props.props.currentView.caseReference
- .currentReference
- }
-
*/}
-
- {props.currentView.representationSubmit ==
- true &&
- props.currentView
- .representationSubmitConfirmation !=
+ {currentView.representationSubmit === true &&
+ currentView.representationSubmitConfirmation !==
true && (
-
{
)}
- {props.currentView.representationSubmit !=
- true &&
+ {currentView.representationSubmit !== true &&
hasRepDetails &&
- repDetails?.representationType !=
+ repDetails?.representationType !==
"Questionnaire" && (
-
{
)}
- {props.currentView.representationSubmit !=
- true &&
+ {currentView.representationSubmit !== true &&
hasRepDetails &&
- repDetails?.representationType ==
+ repDetails?.representationType ===
"Questionnaire" &&
- props.showQuestionnaireSection > 1 && (
+ showQuestionnaireSection > 1 && (
-
{
- props.setShowQuestionnaireSection(
- props.showQuestionnaireSection -
+ setShowQuestionnaireSection(
+ showQuestionnaireSection -
1
);
setRepresentationSubmit(
@@ -927,7 +817,7 @@ const Breadcrumbs = (props) => {
)}
>
)}
- {router.pathname == "/account/personaldetails" && (
+ {isPath("/account/personaldetails") && (
<>
-
{
>
)}
- {router.pathname == "/account/register" && (
+ {isPath("/account/register") && (
<>
-
{t("account:register-new-account-heading")}
>
)}
- {router.pathname == "/account/changepassword" && (
+ {isPath("/account/changepassword") && (
<>
-
{
>
)}
- {router.pathname == "/dns" && (
+ {isPath("/dns") && (
<>
-
{t("dnsCommon:service-name")}
@@ -972,19 +862,19 @@ const Breadcrumbs = (props) => {
>
)}
- {router.pathname == "/dnsapplications" && (
+ {isPath("/dnsapplications") && (
<>
-
{t("dnsCommon:service-name")}
>
)}
- {router.pathname == "/dnsdetails" && (
+ {isPath("/dnsdetails") && (
<>
-
{
>
)}
- {router.pathname == "/dns/[developmentName]" && (
+ {isPath("/dns/[developmentName]") && (
<>
-
{
>
)}
- {router.pathname == "/dns/application-process" && (
+ {isPath("/dns/application-process") && (
<>
-
Guidance
>
)}
- {router.pathname == "/dns/help" && (
+ {isPath("/dns/help") && (
<>
-
Help
>
)}
- {router.pathname == "/dns/contact-us" && (
+ {isPath("/dns/contact-us") && (
<>
-
{t("common:footer-contact-us-link-label")}
>
)}
- {router.pathname == "/dns/applications" && (
+ {isPath("/dns/applications") && (
<>
-
{t("dnsApplications:page-title")}
>
)}
- {router.pathname == "/dns/application-view" && (
+ {isPath("/dns/application-view") && (
<>
-
{
>
)}
- {router.pathname == "/help/cookies" && (
+ {isPath("/help/cookies") && (
<>
-
{t("cookies:cookie-breadcrumb")}
>
)}
- {router.pathname == "/privacy" && (
+ {isPath("/privacy") && (
<>
-
{t("common:footer-privacy-link-label")}
>
)}
- {router.pathname == "/accessibility" && (
+ {isPath("/accessibility") && (
<>
-
{t(
@@ -1094,28 +984,28 @@ const Breadcrumbs = (props) => {
>
)}
- {router.pathname == "/details-about-cookies" && (
+ {isPath("/details-about-cookies") && (
<>
-
{t("cookies:cookie-policy-title-heading")}
>
)}
- {router.pathname == "/auth/signin" && (
+ {isPath("/auth/signin") && (
<>
-
{t("auth:auth-page-title")}
>
)}
- {router.pathname == "/auth/verify-request" && (
+ {isPath("/auth/verify-request") && (
<>
-
{t("auth:auth-check-email-page-title")}
>
)}
- {router.pathname == "/auth/error" && (
+ {isPath("/auth/error") && (
<>
-
{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"]
+ }
};