22541 extract breadcrumb route-state helper and align phase22 auth locale test
This commit is contained in:
+22
-50
@@ -12,6 +12,10 @@ import {
|
||||
setRepresentationCapacity,
|
||||
setRepresentationSubmit
|
||||
} from "../store/currentView/action";
|
||||
import {
|
||||
normalizeRouteStateQuery,
|
||||
resolveSearchResultsHref
|
||||
} from "../lib/routing/routeState";
|
||||
const Breadcrumbs = (props) => {
|
||||
const {
|
||||
currentView,
|
||||
@@ -69,9 +73,8 @@ const Breadcrumbs = (props) => {
|
||||
? 9
|
||||
: "";
|
||||
|
||||
const { va, adv, ads, key } = router.query;
|
||||
const isAdv = adv === "true";
|
||||
const isAds = ads === "true";
|
||||
const routeState = normalizeRouteStateQuery(router.query);
|
||||
const { viewAll, advanced, address, key } = routeState;
|
||||
|
||||
const hideServiceNamePaths = [
|
||||
"/myportal/[appealtypes]",
|
||||
@@ -95,55 +98,33 @@ const Breadcrumbs = (props) => {
|
||||
return labelsByKey[viewKey] || null;
|
||||
};
|
||||
|
||||
const breadcrumbHref = (() => {
|
||||
if (va === "true") {
|
||||
return {
|
||||
pathname: "/myportal/viewall",
|
||||
query: { key }
|
||||
};
|
||||
}
|
||||
const breadcrumbHref = resolveSearchResultsHref({
|
||||
query: router.query,
|
||||
hasSession: Boolean(session),
|
||||
includeViewAll: true,
|
||||
fallbackToMyPortalWhenNoFlags: true
|
||||
});
|
||||
|
||||
const base = session ? "/myportal" : "";
|
||||
|
||||
if (!va && !adv && !ads) {
|
||||
return {
|
||||
pathname: "/myportal"
|
||||
};
|
||||
}
|
||||
|
||||
if (adv === "true") {
|
||||
return {
|
||||
pathname: `${base}/advancedsearchresults`,
|
||||
query: router.query
|
||||
};
|
||||
}
|
||||
|
||||
if (ads === "true") {
|
||||
return {
|
||||
pathname: `${base}/addresssearchresults`,
|
||||
query: router.query
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
pathname: `${base}/searchresults`,
|
||||
query: router.query
|
||||
};
|
||||
})();
|
||||
const caseResultsHref = resolveSearchResultsHref({
|
||||
query: router.query,
|
||||
hasSession: Boolean(session),
|
||||
includeViewAll: false,
|
||||
fallbackToMyPortalWhenNoFlags: false
|
||||
});
|
||||
|
||||
const breadcrumbLabel = (() => {
|
||||
if (va === "true") {
|
||||
if (viewAll) {
|
||||
return getViewAllLabel(key);
|
||||
}
|
||||
|
||||
const keyedLabel = getViewAllLabel(key);
|
||||
if (keyedLabel) return keyedLabel;
|
||||
|
||||
if (isAdv) {
|
||||
if (advanced) {
|
||||
return t("common:breadcrumb-advanced-search-results");
|
||||
}
|
||||
|
||||
if (isAds) {
|
||||
if (address) {
|
||||
return t("common:breadcrumb-address-search-results");
|
||||
}
|
||||
|
||||
@@ -518,16 +499,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={{
|
||||
pathname:
|
||||
(session ? "/myportal" : "") +
|
||||
(isAdv
|
||||
? "/advancedsearchresults"
|
||||
: isAds
|
||||
? "/addresssearchresults"
|
||||
: "/searchresults"),
|
||||
query: router.query
|
||||
}}
|
||||
href={caseResultsHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{breadcrumbLabel}
|
||||
|
||||
Reference in New Issue
Block a user