refactor of code
This commit is contained in:
@@ -261,24 +261,11 @@ const ViewAllResults = (props) => {
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</dd>
|
</dd>
|
||||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
{/* <dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||||
<span className="results-visually-hidden">
|
<span className="results-visually-hidden">
|
||||||
{t("search:searchresults-site-address-label")}:
|
{t("search:searchresults-site-address-label")}:
|
||||||
</span>
|
</span>
|
||||||
{/* {getFormCollectionByID(appealTypeID).PrimaryIdAttribute ==
|
|
||||||
"pinswg_dnsid"
|
|
||||||
? detailsObj.pinswg_projectlocation != null
|
|
||||||
? detailsObj.pinswg_projectlocation.indexOf(";") < 0
|
|
||||||
? detailsObj.pinswg_projectlocation
|
|
||||||
: router.locale == "cy"
|
|
||||||
? detailsObj.pinswg_projectlocation.split(
|
|
||||||
";"
|
|
||||||
)[1]
|
|
||||||
: detailsObj.pinswg_projectlocation.split(
|
|
||||||
";"
|
|
||||||
)[0]
|
|
||||||
: ""
|
|
||||||
: ""} */}
|
|
||||||
{currentView.viewKey == "awaitingSubmissionDetails" &&
|
{currentView.viewKey == "awaitingSubmissionDetails" &&
|
||||||
_.has(searchDetailsObj[key], "pinswg_siteaddressline1")
|
_.has(searchDetailsObj[key], "pinswg_siteaddressline1")
|
||||||
? searchDetailsObj[key].pinswg_siteaddressline1
|
? searchDetailsObj[key].pinswg_siteaddressline1
|
||||||
@@ -329,14 +316,12 @@ const ViewAllResults = (props) => {
|
|||||||
) &&
|
) &&
|
||||||
searchDetailsObj[key].pinswg_siteaddressline2 !=
|
searchDetailsObj[key].pinswg_siteaddressline2 !=
|
||||||
null && <br />}
|
null && <br />}
|
||||||
|
|
||||||
{currentView.viewKey == "myRepresentations" &&
|
{currentView.viewKey == "myRepresentations" &&
|
||||||
_.has(
|
_.has(
|
||||||
searchDetailsObj[key].pinswg_siteaddressline2
|
searchDetailsObj[key].pinswg_siteaddressline2
|
||||||
) &&
|
) &&
|
||||||
searchDetailsObj[key].pinswg_siteaddressline1 !=
|
searchDetailsObj[key].pinswg_siteaddressline1 !=
|
||||||
null && <br />}
|
null && <br />}
|
||||||
|
|
||||||
{_.has(detailsObj, "pinswg_siteaddressline2") &&
|
{_.has(detailsObj, "pinswg_siteaddressline2") &&
|
||||||
detailsObj.pinswg_siteaddressline2 != null && (
|
detailsObj.pinswg_siteaddressline2 != null && (
|
||||||
<br />
|
<br />
|
||||||
@@ -359,7 +344,6 @@ const ViewAllResults = (props) => {
|
|||||||
) &&
|
) &&
|
||||||
searchDetailsObj[key].pinswg_siteaddresstown !=
|
searchDetailsObj[key].pinswg_siteaddresstown !=
|
||||||
null && <br />}
|
null && <br />}
|
||||||
|
|
||||||
{currentView.viewKey == "myRepresentations" &&
|
{currentView.viewKey == "myRepresentations" &&
|
||||||
_.has(
|
_.has(
|
||||||
searchDetailsObj[key],
|
searchDetailsObj[key],
|
||||||
@@ -367,7 +351,6 @@ const ViewAllResults = (props) => {
|
|||||||
) &&
|
) &&
|
||||||
searchDetailsObj[key].pinswg_siteaddresstown !=
|
searchDetailsObj[key].pinswg_siteaddresstown !=
|
||||||
null && <br />}
|
null && <br />}
|
||||||
|
|
||||||
{_.has(detailsObj, "pinswg_siteaddresstown") &&
|
{_.has(detailsObj, "pinswg_siteaddresstown") &&
|
||||||
detailsObj.pinswg_siteaddresstown != null && <br />}
|
detailsObj.pinswg_siteaddresstown != null && <br />}
|
||||||
{currentView.viewKey == "awaitingSubmissionDetails" &&
|
{currentView.viewKey == "awaitingSubmissionDetails" &&
|
||||||
@@ -402,7 +385,51 @@ const ViewAllResults = (props) => {
|
|||||||
{_.has(detailsObj, "pinswg_siteaddresspostcode")
|
{_.has(detailsObj, "pinswg_siteaddresspostcode")
|
||||||
? detailsObj.pinswg_siteaddresspostcode
|
? detailsObj.pinswg_siteaddresspostcode
|
||||||
: ""}
|
: ""}
|
||||||
|
</dd> */}
|
||||||
|
|
||||||
|
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||||
|
<span className="results-visually-hidden">
|
||||||
|
{t("search:searchresults-site-address-label")}:
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{/* Helper function to extract address lines based on current view and data */}
|
||||||
|
{[
|
||||||
|
"pinswg_siteaddressline1",
|
||||||
|
"pinswg_siteaddressline2",
|
||||||
|
"pinswg_siteaddresstown",
|
||||||
|
"pinswg_siteaddresscounty",
|
||||||
|
"pinswg_siteaddresspostcode",
|
||||||
|
].map((field, idx) => {
|
||||||
|
const isAwaitingSubmission =
|
||||||
|
currentView.viewKey ===
|
||||||
|
"awaitingSubmissionDetails";
|
||||||
|
const isMyRepresentations =
|
||||||
|
currentView.viewKey === "myRepresentations";
|
||||||
|
const searchValue = _.get(
|
||||||
|
searchDetailsObj,
|
||||||
|
`${key}.${field}`
|
||||||
|
);
|
||||||
|
const detailsValue = _.get(detailsObj, field);
|
||||||
|
|
||||||
|
// Determine the display value based on current view
|
||||||
|
const valueToDisplay =
|
||||||
|
(isAwaitingSubmission && searchValue) ||
|
||||||
|
(isMyRepresentations && searchValue) ||
|
||||||
|
detailsValue ||
|
||||||
|
"";
|
||||||
|
|
||||||
|
// Only render a line break if there is a valid value and it's not the last address part
|
||||||
|
const renderLineBreak = valueToDisplay && idx < 4; // Only insert <br> if it's not the last element
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{valueToDisplay}
|
||||||
|
{renderLineBreak && <br />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||||
<span className="results-visually-hidden">
|
<span className="results-visually-hidden">
|
||||||
{currentView.viewKey == "awaitingSubmissionDetails"
|
{currentView.viewKey == "awaitingSubmissionDetails"
|
||||||
|
|||||||
Reference in New Issue
Block a user