diff --git a/.env.local b/.env.local index 98e959e7..74edfee6 100644 --- a/.env.local +++ b/.env.local @@ -59,7 +59,7 @@ API_ROOT = "http://localhost:3000" CY_API_ROOT = "http://cymru.local:3000" I18N_DOMAIN = "cymru.local" DOCAPI_OFFLINE = "12:00:00,14:00:00" -SHOWFILTERDOCS = true +SHOWFILTERDOCS = false // Next Auth vars diff --git a/components/case/representation/representationLPA.js b/components/case/representation/representationLPA.js index 8061ab8b..9289b761 100644 --- a/components/case/representation/representationLPA.js +++ b/components/case/representation/representationLPA.js @@ -486,7 +486,7 @@ let RepLPA = (props) => { className="govuk-button" data-module="govuk-button" > - wwwww {t("common:continue-button")} + {t("common:continue-button")} {/* {router.query.state != "edit" && ( { query: { case: resultsArr[key].caseRef, state: "edit", + created: + resultsArr[key] + .repfile_name, }, } : currentView.viewKey == diff --git a/components/search/addresssearchresults.js b/components/search/addresssearchresults.js index 7d50145c..88bcec57 100644 --- a/components/search/addresssearchresults.js +++ b/components/search/addresssearchresults.js @@ -29,6 +29,7 @@ import { deleteWatchedCases, getWatchedCasesProxy, } from "../../actions"; +import RepsOnResults from "./repsonresults"; const SearchResults = (props) => { const { @@ -291,6 +292,9 @@ const SearchResults = (props) => { {item.pinswg_name} +
diff --git a/components/search/repsonresults.js b/components/search/repsonresults.js new file mode 100644 index 00000000..b7b9a48b --- /dev/null +++ b/components/search/repsonresults.js @@ -0,0 +1,196 @@ +import useTranslation from "next-translate/useTranslation"; +import { useRouter } from "next/router"; +import _ from "lodash"; + +const RepsOnResults = (props) => { + let { t } = useTranslation(); + + const detailsObj = props.detailsObj; + + function showReps(startDate, endDate) { + let date = new Date(); + date = new Date(date.toDateString()); + const start = new Date(startDate); + const end = new Date(endDate); + + return date >= start && date <= end ? true : false; + } + + function showRepButton(appealType) { + switch (appealType) { + case 846040012: + case 846040013: + case 846040014: + //for ROW case 846040015: + case 846040020: + case 846040021: + case 846040023: + case 846040024: + return false; + case 846040004: + return isLPA ? true : false; + + case 846040015: + return props.searchDetailsObj[0].value[0] + .pinswg_specialistcaseprocess == 846040001 + ? showReps( + props.searchDetailsObj[0].value[0].pinswg_startdate, + props.searchDetailsObj[0].value[0] + .pinswg_finalcommentsduedate + ) + : true; + + case 846040018: + let shouldShow = + props.searchDetailsObj[0].value[0] + .pinswg_speacialistcaseprocess == 846040000 && isLPA + ? true + : props.searchDetailsObj[0].value[0] + .pinswg_speacialistcaseprocess == 846040001 + ? true + : false; + + return shouldShow; + + case 846040019: + return showReps( + props.searchDetailsObj[0].value[0].pinswg_startdate, + props.searchDetailsObj[0].value[0].pinswg_statementduedate + ); + + default: + return true; + } + } + + function showRepsEnded(startDate, endDate) { + let date = new Date(); + date = new Date(date.toDateString()); + const start = new Date(startDate); + const end = new Date(endDate); + return date > start && date > end ? true : false; + } + + function formatDates(dateObj, showTime) { + var dateObj = new Date(dateObj); + var dd = String(dateObj.getDate()).padStart(2, "0"); + var mm = String(dateObj.getMonth() + 1).padStart(2, "0"); //January is 0! + var yyyy = dateObj.getFullYear(); + var hh = dateObj.getHours(); + hh = ("0" + hh).slice(-2); + var mins = dateObj.getMinutes(); + mins = ("0" + mins).slice(-2); + + const dateStr = showTime + ? hh == 0 && mins == 0 + ? "" + : hh + ":" + mins + : dd + "/" + mm + "/" + yyyy + " "; + return dateStr; + } + + return ( + <> +
+
+ {(_.has(detailsObj, "pinswg_startdate") || + _.has(detailsObj, "pinswg_applicationacceptedasvalid")) && + showReps( + detailsObj.pinswg_startdate || + detailsObj.pinswg_applicationacceptedasvalid, + detailsObj.pinswg_finalcommentsduedate || + detailsObj.pinswg_endofrepresentationperiod + ) && ( + <> + {showRepButton(detailsObj.appealType) ? ( + <> + {/* + {t( + "case:summary-make-representation-label" + )} + */} +
+ {t( + "case:summary-representation-open-label" + )}{" "} +
+ + ) : !isLPA && + props.currentView.caseReference.appealType == + 846040004 ? ( + "" + ) : ( + <> +
+
+

+ {t( + "case:representation-date-passed-label", + { + startDate: formatDates( + detailsObj.pinswg_startdate + ), + endDate: + props.currentView + .caseReference + .appealType == + 846040019 + ? formatDates( + detailsObj.pinswg_statementduedate + ) + : formatDates( + detailsObj.pinswg_finalcommentsduedate + ), + } + )} +
{" "} + {t( + "case:representation-date-passed-additional-label" + )}{" "} + + {t("home:login-contact-email")} + +

+
+
+ + )} + + )}{" "} + {_.has(detailsObj, "pinswg_startdate") && + (detailsObj.pinswg_startdate != null || + detailsObj.pinswg_finalcommentsduedate != null) && + showRepsEnded( + detailsObj.pinswg_startdate, + detailsObj.pinswg_finalcommentsduedate + ) && ( +
+ {t("case:representation-period-ended-on-label")} + {detailsObj.appealType == 846040019 + ? formatDates(detailsObj.pinswg_statementduedate) + : formatDates( + detailsObj.pinswg_finalcommentsduedate + )} +
+ )} + + ); +}; + +export default RepsOnResults; diff --git a/components/search/searchresults.js b/components/search/searchresults.js index df41b120..3fa9bc7d 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -35,6 +35,7 @@ import { } from "../../actions"; import { sendGAEvent } from "@next/third-parties/google"; +import RepsOnResults from "./repsonresults"; const SearchResults = (props) => { const { @@ -250,6 +251,7 @@ const SearchResults = (props) => { key={key} >
+
{ {item.title} +
diff --git a/locales/cy/case.json b/locales/cy/case.json index b36d34ea..8cbbc357 100644 --- a/locales/cy/case.json +++ b/locales/cy/case.json @@ -11,6 +11,7 @@ "summary-case-stage-label": "Cyfnod Achos", "summary-last-modified-label": "Addaswyd ddiwethaf", "summary-make-representation-label": "Cyflwyno cynrychiolaeth", + "summary-representation-open-label": "Cynrychioliadau yn agor", "summary-back-button-label": "Ewch yn ôl", "summary-case-details-label": "Manylion yr Achos", "summary-project-details-label": "Manylion y Prosiect", diff --git a/locales/en/case.json b/locales/en/case.json index 62ee9e92..848635bf 100644 --- a/locales/en/case.json +++ b/locales/en/case.json @@ -11,6 +11,7 @@ "summary-case-stage-label": "Case Stage", "summary-last-modified-label": "Last modified", "summary-make-representation-label": "Make representation", + "summary-representation-open-label": "Representations open", "summary-back-button-label": "Go back", "summary-case-details-label": "Case Details", "summary-project-details-label": "Project Details", diff --git a/pages/api/endpoint/getbasicsearch_by_address_api.js b/pages/api/endpoint/getbasicsearch_by_address_api.js index 46291fc7..674d4965 100644 --- a/pages/api/endpoint/getbasicsearch_by_address_api.js +++ b/pages/api/endpoint/getbasicsearch_by_address_api.js @@ -413,6 +413,47 @@ export default async function ApiProxy(req, res) { "')) " : "") + "&$orderby=createdon desc&$select=modifiedon,_pinswg_appellant_value,pinswg_name," + + (item.LogicalCollectionName == "pinswg_planningappeals78s" || + item.LogicalCollectionName == + "pinswg_lawfuldevelopmentcertificates" || + item.LogicalCollectionName == "pinswg_householderappealhases" || + item.LogicalCollectionName == "pinswg_advertses" || + item.LogicalCollectionName == "pinswg_callinss77s" || + item.LogicalCollectionName == "pinswg_commonlands" || + item.LogicalCollectionName == + "pinswg_communityinfrastructurelevys117118119s" || + item.LogicalCollectionName == + "pinswg_compulsorypurchaseorderses" || + item.LogicalCollectionName == + "pinswg_enforcementnoticeappeals174s" || + item.LogicalCollectionName == + "pinswg_environmentalpermittings" || + item.LogicalCollectionName == + "pinswg_hedgeshedgerowstreepreservationreplacems" || + item.LogicalCollectionName == + "pinswg_lawfuldevelopmentcertificates" || + item.LogicalCollectionName == "pinswg_miscellaneouscaseworks" || + item.LogicalCollectionName == + "pinswg_planningconditionss73s79s" || + item.LogicalCollectionName == + "pinswg_planningobligationappeals106s" || + item.LogicalCollectionName == "pinswg_rows" || + item.LogicalCollectionName == "pinswg_wayleaves" + ? "pinswg_startdate,pinswg_finalcommentsduedate," + : "") + + (item.LogicalCollectionName == + "pinswg_enforcementlistedbuildingconservationaps" || + item.LogicalCollectionName == "pinswg_maintenanceoflands217s" + ? "pinswg_startdates,pinswg_finalcommentsduedate," + : "") + + (item.LogicalCollectionName == "pinswg_nonvalidations" + ? "pinswg_validdate," + : "") + + (item.LogicalCollectionName == "pinswg_electricityacts" || + item.LogicalCollectionName == "pinswg_dnses" || + item.LogicalCollectionName == "pinswg_transportandworkacts" + ? "pinswg_applicationacceptedasvalid,pinswg_endofrepresentationperiod," + : "") + (item.LogicalCollectionName == "pinswg_ldps" || item.LogicalCollectionName == "pinswg_harbourrevisionorders" ? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_addresspostcode" diff --git a/pages/myportal/representation.js b/pages/myportal/representation.js index 9639403c..d8b417fe 100644 --- a/pages/myportal/representation.js +++ b/pages/myportal/representation.js @@ -274,7 +274,10 @@ export const getServerSideProps = wrapper.getServerSideProps( store.dispatch( setCurrentReference({ - "ticketnumber": result.ticketnumber, + "ticketnumber": + result.ticketnumber || + result.caseRef || + result.pinswg_name, "currentReference": result.caseRef, "currentType": "myRepresentations", "incidentid": result.incidentID,