import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import { useSession } from "next-auth/react"; import { setCurrentView } from "../store/currentView/action"; import { change } from "redux-form"; import { setCurrentSection } from "../store/appealType/action"; import { setRepresentationCapacity, setRepresentationSubmit } from "../store/currentView/action"; import { resolveCaseBreadcrumbState } from "../lib/routing/routeState"; import { buildBreadcrumbRendererMaps, resolveMappedRouteRenderer as resolveMappedRouteRendererByMaps } from "../lib/routing/breadcrumbRouteMaps"; import { createMappedRouteRendererGroups } from "../lib/routing/breadcrumbRendererFactories"; const Breadcrumbs = (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 = currentView?.caseReference?.currentReference || nestedCurrentReference; const fallbackSearchTitle = props?.searchResultsObj?.searchResultsObj?.value?.[0]?.title || ""; const caseReferenceDisplay = currentReference || fallbackSearchTitle; 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, "repDetails" ); 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 ? 7 : caseReference.appealType === 846040005 || caseReference.appealType === 846040006 || caseReference.appealType === 846040007 ? 9 : ""; 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" }; const viewAllLabelResolver = labelsByKey[viewKey]; return typeof viewAllLabelResolver === "function" ? viewAllLabelResolver() : viewAllLabelResolver || null; }; const getStaticTextCrumbLabel = (path) => { const staticTextCrumbByPath = { "/account/register": () => t("account:register-new-account-heading"), "/dns": () => t("dnsCommon:service-name"), "/dns/application-process": () => "Guidance", "/dns/help": () => "Help", "/dns/contact-us": () => t("common:footer-contact-us-link-label"), "/dns/applications": () => t("dnsApplications:page-title"), "/help/cookies": () => t("cookies:cookie-breadcrumb"), "/privacy": () => t("common:footer-privacy-link-label"), "/accessibility": () => t("common:footer-accessibility-link-label"), "/details-about-cookies": () => t("cookies:cookie-policy-title-heading"), "/auth/signin": () => t("auth:auth-page-title"), "/auth/verify-request": () => t("auth:auth-check-email-page-title"), "/auth/error": () => t("auth:auth-error-signin-error-title") }; const staticTextCrumbResolver = staticTextCrumbByPath[path]; return staticTextCrumbResolver ? staticTextCrumbResolver() : null; }; const renderMyPortalCrumb = () => (