diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index 8cad3c16..bf48acf2 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -13,8 +13,8 @@ import { setRepresentationSubmit } from "../store/currentView/action"; import { - normalizeRouteStateQuery, - resolveSearchResultsHref + resolveSearchResultsHref, + resolveSearchBreadcrumbLabel } from "../lib/routing/routeState"; const Breadcrumbs = (props) => { const { @@ -73,9 +73,6 @@ const Breadcrumbs = (props) => { ? 9 : ""; - const routeState = normalizeRouteStateQuery(router.query); - const { viewAll, advanced, address, key } = routeState; - const hideServiceNamePaths = [ "/myportal/[appealtypes]", "/newappeal", @@ -112,24 +109,13 @@ const Breadcrumbs = (props) => { fallbackToMyPortalWhenNoFlags: false }); - const breadcrumbLabel = (() => { - if (viewAll) { - return getViewAllLabel(key); - } - - const keyedLabel = getViewAllLabel(key); - if (keyedLabel) return keyedLabel; - - if (advanced) { - return t("common:breadcrumb-advanced-search-results"); - } - - if (address) { - return t("common:breadcrumb-address-search-results"); - } - - return t("common:breadcrumb-search-results"); - })(); + const breadcrumbLabel = resolveSearchBreadcrumbLabel({ + query: router.query, + getViewAllLabel, + advancedLabel: t("common:breadcrumb-advanced-search-results"), + addressLabel: t("common:breadcrumb-address-search-results"), + defaultLabel: t("common:breadcrumb-search-results") + }); return ( <>