fixed breacrumb and label
This commit is contained in:
+132
-206
@@ -1,5 +1,3 @@
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
@@ -7,7 +5,7 @@ import { connect } from "react-redux";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { setCurrentView } from "../store/currentView/action";
|
||||
import { Field, change, reduxForm } from "redux-form";
|
||||
import { change } from "redux-form";
|
||||
|
||||
import { setCurrentSection } from "../store/appealType/action";
|
||||
import {
|
||||
@@ -15,35 +13,114 @@ import {
|
||||
setRepresentationSubmit
|
||||
} from "../store/currentView/action";
|
||||
const Breadcrumbs = (props) => {
|
||||
const {
|
||||
currentView,
|
||||
setCurrentView,
|
||||
setCurrentSection,
|
||||
setRepresentationCapacity,
|
||||
setRepresentationSubmit
|
||||
} = props;
|
||||
const { currentView, setCurrentSection, setRepresentationSubmit } = props;
|
||||
const router = useRouter();
|
||||
let { t } = useTranslation();
|
||||
|
||||
const { data: session, status } = useSession();
|
||||
const { data: session } = useSession();
|
||||
|
||||
const currentReference =
|
||||
props?.props?.currentView?.caseReference?.currentReference || "";
|
||||
const fallbackSearchTitle =
|
||||
props?.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 caseReference = currentView?.caseReference || {};
|
||||
const repDetails = caseReference?.repDetails;
|
||||
const hasRepDetails = Object.prototype.hasOwnProperty.call(
|
||||
caseReference,
|
||||
"repDetails"
|
||||
);
|
||||
|
||||
const qcount =
|
||||
currentView.caseReference.appealType == 846040000 ||
|
||||
currentView.caseReference.appealType == 846040001 ||
|
||||
currentView.caseReference.appealType == 846040025 ||
|
||||
currentView.caseReference.appealType == 846040004 ||
|
||||
currentView.caseReference.appealType == 846040018 ||
|
||||
currentView.caseReference.appealType == 846040003 ||
|
||||
currentView.caseReference.appealType == 846040009 ||
|
||||
currentView.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
|
||||
: currentView.caseReference.appealType == 846040005 ||
|
||||
currentView.caseReference.appealType == 846040006 ||
|
||||
currentView.caseReference.appealType == 846040007
|
||||
: caseReference.appealType == 846040005 ||
|
||||
caseReference.appealType == 846040006 ||
|
||||
caseReference.appealType == 846040007
|
||||
? 9
|
||||
: "";
|
||||
|
||||
var viewAllKey = currentView?.viewKey || router.query.viewKey;
|
||||
const { va, adv, ads, key } = router.query;
|
||||
|
||||
const breadcrumbHref = (() => {
|
||||
if (va === "true") {
|
||||
return {
|
||||
pathname: "/myportal/viewall",
|
||||
query: { key }
|
||||
};
|
||||
}
|
||||
|
||||
const base = session ? "/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 breadcrumbLabel = (() => {
|
||||
if (va === "true") {
|
||||
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 === "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") {
|
||||
return t("common:breadcrumb-advanced-search-results");
|
||||
}
|
||||
|
||||
if (ads === "true") {
|
||||
return t("common:breadcrumb-address-search-results");
|
||||
}
|
||||
|
||||
return t("common:breadcrumb-search-results");
|
||||
})();
|
||||
return (
|
||||
<>
|
||||
<nav
|
||||
@@ -76,13 +153,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<a
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -118,13 +189,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -139,13 +204,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -160,13 +219,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -228,13 +281,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -265,13 +312,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -428,13 +469,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("newappeal:parent-page-title")}
|
||||
@@ -442,13 +477,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("newappeal:page-title")}
|
||||
@@ -463,13 +492,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -484,13 +507,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -540,10 +557,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
{currentReference}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -574,10 +588,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.searchResultsObj
|
||||
.searchResultsObj.value[0].title
|
||||
}
|
||||
{fallbackSearchTitle}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -619,10 +630,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
{currentReference}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -631,13 +639,7 @@ const Breadcrumbs = (props) => {
|
||||
{" "}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -683,10 +685,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
{currentReference}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -694,13 +693,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -708,37 +701,15 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={{
|
||||
pathname:
|
||||
(session ? "/myportal" : "") +
|
||||
(router.query.adv == "true"
|
||||
? "/advancedsearchresults"
|
||||
: router.query.ads == "true"
|
||||
? "/addresssearchresults"
|
||||
: "/searchresults"),
|
||||
query: router.query
|
||||
}}
|
||||
href={breadcrumbHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{router.query.adv == "true"
|
||||
? t(
|
||||
"common:breadcrumb-advanced-search-results"
|
||||
)
|
||||
: router.query.ads == "true"
|
||||
? t(
|
||||
"common:breadcrumb-address-search-results"
|
||||
)
|
||||
: t(
|
||||
"common:breadcrumb-search-results"
|
||||
)}
|
||||
{breadcrumbLabel}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{props.props.currentView.caseReference
|
||||
.currentReference ||
|
||||
props.props.searchResultsObj
|
||||
.searchResultsObj.value[0].title}
|
||||
{caseReferenceDisplay}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -747,13 +718,7 @@ const Breadcrumbs = (props) => {
|
||||
{" "}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -768,13 +733,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={myPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -790,10 +749,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
{currentReference}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -822,10 +778,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{props.props.currentView.caseReference
|
||||
.currentReference ||
|
||||
props.props.searchResultsObj
|
||||
.searchResultsObj.value[0].title}
|
||||
{caseReferenceDisplay}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -856,10 +809,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
{currentReference}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -934,11 +884,8 @@ const Breadcrumbs = (props) => {
|
||||
)}
|
||||
{props.currentView.representationSubmit !=
|
||||
true &&
|
||||
props.currentView.caseReference.hasOwnProperty(
|
||||
"repDetails"
|
||||
) &&
|
||||
props.currentView.caseReference.repDetails
|
||||
.representationType !=
|
||||
hasRepDetails &&
|
||||
repDetails?.representationType !=
|
||||
"Questionnaire" && (
|
||||
<li className="govuk-breadcrumbs__link-item backChevron">
|
||||
<a
|
||||
@@ -956,11 +903,8 @@ const Breadcrumbs = (props) => {
|
||||
)}
|
||||
{props.currentView.representationSubmit !=
|
||||
true &&
|
||||
props.currentView.caseReference.hasOwnProperty(
|
||||
"repDetails"
|
||||
) &&
|
||||
props.currentView.caseReference.repDetails
|
||||
.representationType ==
|
||||
hasRepDetails &&
|
||||
repDetails?.representationType ==
|
||||
"Questionnaire" &&
|
||||
props.showQuestionnaireSection > 1 && (
|
||||
<li className="govuk-breadcrumbs__link-item backChevron">
|
||||
@@ -987,13 +931,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={cyMyPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -1015,13 +953,7 @@ const Breadcrumbs = (props) => {
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
href={cyMyPortalHref}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
@@ -1064,10 +996,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
{currentReference}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
@@ -1088,10 +1017,7 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{props.props.currentView.caseReference
|
||||
.currentReference ||
|
||||
props.props.searchResultsObj
|
||||
.searchResultsObj.value[0].title}
|
||||
{caseReferenceDisplay}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
|
||||
+35
-18
@@ -324,6 +324,35 @@ const CaseSummary = (props) => {
|
||||
|
||||
const zoom = isNaN(parseFloat(siteCoords.latitude)) ? 7 : 12;
|
||||
|
||||
const buildSearchHref = (router, session) => {
|
||||
const { va, adv, ads, key } = router.query;
|
||||
|
||||
if (va === "true") {
|
||||
return {
|
||||
pathname: "/myportal/viewall",
|
||||
query: { key }
|
||||
};
|
||||
}
|
||||
|
||||
const base = session ? "/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 };
|
||||
};
|
||||
|
||||
let showDetailsBlock =
|
||||
showDetails == true ? (
|
||||
<>
|
||||
@@ -996,23 +1025,10 @@ const CaseSummary = (props) => {
|
||||
|
||||
<Link
|
||||
className="govuk-button govuk-button--secondary"
|
||||
href={{
|
||||
pathname:
|
||||
(session
|
||||
? "/myportal"
|
||||
: "") +
|
||||
(router.query
|
||||
.adv ==
|
||||
"true"
|
||||
? "/advancedsearchresults"
|
||||
: router
|
||||
.query
|
||||
.ads ==
|
||||
"true"
|
||||
? "/addresssearchresults"
|
||||
: "/searchresults"),
|
||||
query: router.query
|
||||
}}
|
||||
href={buildSearchHref(
|
||||
router,
|
||||
session
|
||||
)}
|
||||
>
|
||||
{" "}
|
||||
{t(
|
||||
@@ -2134,7 +2150,8 @@ const mapStateToProps = (state) => {
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
mySubmittedReps: state.myRepresentations.mySubmittedReps
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+376
-507
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user