From 066612adbd99be695585a1b8e57bab80cb1a8336 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 30 Sep 2021 10:19:41 +0100 Subject: [PATCH 1/4] added error handling for relay down --- actions/index.js | 29 +++++++++++++++++++++-------- components/crmError.js | 14 +++++++++++--- pages/advancedsearch.js | 22 +++++++++++++++++----- pages/searchresults.js | 1 + 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/actions/index.js b/actions/index.js index 0fd38d3f..2c3dec21 100644 --- a/actions/index.js +++ b/actions/index.js @@ -201,11 +201,6 @@ export const getAdvancedSearch = (token, searchString) => { searchString.apt : ""; - // console.log( - // "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" + - // queryString + - // " &$count=true" - // ); return axios .get( WEBAPI_URL + @@ -217,7 +212,13 @@ export const getAdvancedSearch = (token, searchString) => { ) .then((res) => res.data) .catch((error) => { - console.log("thiserror", error); + let ErrResponse = { + value: [], + errorCode: error.response.status, + errorMsg: error.response.statusText, + }; + + return ErrResponse; }); }; @@ -373,7 +374,13 @@ export const getAppealsTypes = (token) => { ) .then((res) => res.data) .catch((error) => { - console.log("thiserror", error); + let ErrResponse = { + value: [], + errorCode: error.response.status, + errorMsg: error.response.statusText, + }; + + return ErrResponse; }); }; @@ -429,7 +436,13 @@ export const getLPA = (token) => { ) .then((res) => res.data) .catch((error) => { - console.log("thi serror", error); + let ErrResponse = { + value: [], + errorCode: error.response.status, + errorMsg: error.response.statusText, + }; + + return ErrResponse; }); }; diff --git a/components/crmError.js b/components/crmError.js index 49e40231..e067da63 100644 --- a/components/crmError.js +++ b/components/crmError.js @@ -6,10 +6,17 @@ import { DiagConsoleLogger } from "@opentelemetry/api"; const CRMError = (props) => { let { t } = useTranslation(); + const { whichError } = props; + const router = useRouter(); const { locale } = router; - const searchResultsObj = props.props.searchResultsObj.searchResultsObj; - console.log(searchResultsObj); + + const errorSwitch = _.has(props, "whichError") + ? "LPAData" + : "searchResultsObj"; + + console.log(errorSwitch); + return (
@@ -17,7 +24,8 @@ const CRMError = (props) => { Something has happened....

- {searchResultsObj.errorCode} - {searchResultsObj.errorMsg} + {props.props[errorSwitch][errorSwitch].errorCode} -{" "} + {props.props[errorSwitch][errorSwitch].errorMsg}

diff --git a/pages/advancedsearch.js b/pages/advancedsearch.js index 5a2f1178..98bf0ea2 100644 --- a/pages/advancedsearch.js +++ b/pages/advancedsearch.js @@ -14,6 +14,7 @@ import { wrapper } from "../store/store"; import Cookies from "cookies"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; +import CRMError from "../components/crmError"; import { setAppealType, @@ -39,6 +40,13 @@ const Home = (props) => { const { locale } = router; const { appealtypes } = router.query; + console.log(props, props.LPAData); + var hasError = + _.has(props.LPAData.LPAData, "errorCode") || + _.has(props.appealType.appealType, "errorCode") + ? true + : false; + return (
@@ -52,10 +60,14 @@ const Home = (props) => {
- + {hasError ? ( + + ) : ( + + )}
@@ -68,7 +80,7 @@ export const getServerSideProps = wrapper.getServerSideProps( async ({ query, req, res }) => { const token = await getSASToken(); - const [appealTypeData, lpaData, caseData] = await Promise.all([ + const [appealTypeData, lpaData] = await Promise.all([ await getAppealsTypes(token), await getLPA(token), ]); diff --git a/pages/searchresults.js b/pages/searchresults.js index 09273076..e1a81731 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -77,6 +77,7 @@ export const getServerSideProps = wrapper.getServerSideProps( searchResultsObj.status == 502 ? { value: [], + errorCode: searchResultsObj.status, errorMsg: searchResultsObj.statusText, } : searchResultsObj; From d05caec63c801807c6f2e65eb539b08db750cc7f Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 30 Sep 2021 11:55:30 +0100 Subject: [PATCH 2/4] updated dropdown search with translations --- components/case/documents.js | 7 ++++- components/case/summary.js | 2 +- components/homepage/inspectorate.js | 2 +- components/homepage/loginSoon.js | 4 +-- components/search/advancedsearch.js | 37 ++++++++++++++++++++++----- components/search/dnssearchresults.js | 2 +- components/search/searchresults.js | 4 ++- data/lookuptranslations.json | 5 ++++ locales/cy/case.json | 1 + locales/cy/common.json | 4 ++- locales/cy/home.json | 2 ++ locales/cy/search.json | 4 ++- locales/en/case.json | 1 + locales/en/common.json | 4 ++- locales/en/home.json | 2 ++ locales/en/search.json | 4 ++- 16 files changed, 68 insertions(+), 17 deletions(-) diff --git a/components/case/documents.js b/components/case/documents.js index 09cf7c27..ad128580 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -89,7 +89,12 @@ const DocumentDetails = (props) => { key={key} >
- + {t( diff --git a/components/case/summary.js b/components/case/summary.js index bfdaf26a..bd0bcd6a 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -64,7 +64,7 @@ const CaseSummary = (props) => {

- Reference:{" "} + {t("case:summary-reference-label")}:{" "} {currentType == "searchResultsObj" ? detailsObj.pinswg_name : casesObj.reference} diff --git a/components/homepage/inspectorate.js b/components/homepage/inspectorate.js index d980c2fd..82a3867b 100644 --- a/components/homepage/inspectorate.js +++ b/components/homepage/inspectorate.js @@ -12,7 +12,7 @@ export default function Inspectorate() { diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js index fad65670..f68b80b9 100644 --- a/components/search/advancedsearch.js +++ b/components/search/advancedsearch.js @@ -7,6 +7,7 @@ import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import jsonpath from "jsonpath"; import data from "../../data/collections.json"; import LoadingOverlay from "react-loading-overlay"; +import transLookup from "../../data/lookuptranslations.json"; let AdvancedSearch = (props) => { let { t } = useTranslation(); @@ -78,7 +79,7 @@ let AdvancedSearch = (props) => { //onChange={(e) => props.onChangeSelectLPA(e)} > {_.isEmpty(optionsObj) ? "" @@ -88,7 +89,20 @@ let AdvancedSearch = (props) => { key={key} value={optionsObj[key].accountid} > - {optionsObj[key].name} + {/* {optionsObj[key].name} */} + + {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + optionsObj[key] + .name + + '")].value_cy' + ) + : optionsObj[key].name || + t( + "case:summary-no-date-entered-label" + )} ); })} @@ -141,7 +155,7 @@ let AdvancedSearch = (props) => { //onChange={(e) => props.onChangeSelectAppealType(e)} > {_.isEmpty(optionsObj) ? "" @@ -180,7 +194,18 @@ let AdvancedSearch = (props) => { optionsObj[key].value ) ? "" - : optionsObj[key].value} + : router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + optionsObj[key] + .value + + '")].value_cy' + ) + : optionsObj[key].value || + t( + "case:summary-no-date-entered-label" + )} ); })} @@ -293,7 +318,7 @@ let AdvancedSearch = (props) => { component={RenderAppealTypeList} optionsObj={appealOptionsObj} // validate={[required]} - label="Select an appeal type" + label={t("search:appealtype-label")} errormsg="Appeal type is required" /> { name="search" className="govuk-button" > - Search + {t("common:search-button")}

diff --git a/components/search/dnssearchresults.js b/components/search/dnssearchresults.js index d6e47e7d..62b7f277 100644 --- a/components/search/dnssearchresults.js +++ b/components/search/dnssearchresults.js @@ -223,7 +223,7 @@ const DNSSearchResults = (props) => { ) : (
-

There are no records

+

{t("search:searchresults-no-records-label")}

)} diff --git a/components/search/searchresults.js b/components/search/searchresults.js index 33ef3e27..49b8ba4d 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -215,7 +215,9 @@ const SearchResults = (props) => { ) : (
-

There are no records

+

+ {t("search:searchresults-no-records-label")} +

)} diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index 06ad0297..15f6fa3e 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -201,6 +201,11 @@ "value_cy": "Cyngor Bwrdeistref Sirol Blaenau Gwent", "pinswg_lpa": 0 }, + { + "value": "Bridgend CBC", + "value_cy": "Cyngor Bwrdeistref Sirol Pen-y-bont ar Ogwr", + "pinswg_lpa": 0 + }, { "value": "Bridgend County Borough Council", "value_cy": "Cyngor Bwrdeistref Sirol Pen-y-bont ar Ogwr", diff --git a/locales/cy/case.json b/locales/cy/case.json index 503fcbb6..0f8b1184 100644 --- a/locales/cy/case.json +++ b/locales/cy/case.json @@ -1,6 +1,7 @@ { "page-title": "Cyfeirnod", "case-card-title": "Reference: APP/B1415/W/20/3271702", + "summary-reference-label": "Cyfeirnod", "summary-applicant-label": "Apelydd/Ymgeisydd", "summary-agent-label": "Asiant", "summary-site-address-label": "Cyfeiriad y Safle", diff --git a/locales/cy/common.json b/locales/cy/common.json index 92af5164..d19421e8 100644 --- a/locales/cy/common.json +++ b/locales/cy/common.json @@ -9,6 +9,7 @@ "error-textbox": "Choose an option", "available-in": "English", "continue-button": "Parhewch", + "search-button": "Chwilio", "submit-and-start": "Cyflwyno a dechrau'r cwrs", "footer-terms-conditions-link": "Telerau ac amodau", "footer-privacy-link": "Rhybudd Preifatrwydd", @@ -37,5 +38,6 @@ "cookie-banner-list-item-2": "i wella'n gwefan drwy gasglu ac adrodd gwybodaeth ar sut yr ydych yn defnyddio'r safle", "cookie-banner-list-item-3": "i deilwra cyfathrebu", "cookie-banner-decline": "Rwy'n dirywio", - "cookie-banner-accept": "Derbyn cwcis" + "cookie-banner-accept": "Derbyn cwcis", + "drop-down-select": "Dewiswch..." } \ No newline at end of file diff --git a/locales/cy/home.json b/locales/cy/home.json index 516fcf8c..a27edd0c 100644 --- a/locales/cy/home.json +++ b/locales/cy/home.json @@ -2,6 +2,7 @@ "login-card-title-temp": "Croeso", "login-comingsoon-temp-1": "Mae’r wefan hon yn cael ei datblygu o hyd. Os hoffech gyflwyno apêl neu gais newydd, neu wneud sylwadau ar un sydd eisoes yn bodoli, cyflwynwch yr apêl, y cais neu’r sylwadau, ynghyd ag unrhyw ddogfennau cysylltiedig perthnasol, i ", "login-comingsoon-temp-2": "Gellir gofyn am ffurflenni apelio a ffurflenni cais trwy e-bost neu gellir eu lawrlwytho trwy ddilyn y ddolen isod. ", + "login-comingsoon-forms-link": "https://llyw.cymru/ffurflenni-apelio", "login-card-title": "Mewngofnodi i apelio yn erbyn penderfyniad cynllunio", "login-card-id-label": "Dynodydd Defnyddiwr (ID) Porth y Llywodraeth", "login-card-id-hint": "Gallai hyn fod hyd at 12 o gymeriadau.", @@ -23,6 +24,7 @@ "casescomment-card-paragraph-two": "O ran apeliadau Deiliaid Tai a Masnachol, ni all partïon â buddiant wneud sylwadau yn ystod y cam apêl. Bydd unrhyw sylwadau a wnaed yn ystod y cam ymgeisio’n cael eu darparu gan yr awdurdod cynllunio lleol a’u hystyried gan yr arolygydd.", "inspectorate-card-visit-label": "Ymweld Yr Arolygiaeth Gynllunio", "inspectorate-card-visit-link": "Hafan", + "inspectorate-card-alt-text": "Yr Arolygiaeth Gynllunio", "dns-card-title": "Datblygiadau o Arwyddocâd Cenedlaethol", "dns-card-paragraph": "Mae Datblygiad o Arwyddocâd Cenedlaethol (DAC) yn fath o gais cynllunio ar gyfer prosiect seilwaith mawr sydd o bwysigrwydd cenedlaethol yng Nghymru. Yn y fan hon, gallwch gael gwybod am geisiadau DAC arfaethedig. Rheolir y safle hwn gan yr Arolygiaeth Gynllunio.", "dns-card-button": "Gweld pob cais" diff --git a/locales/cy/search.json b/locales/cy/search.json index c6bc59a3..4929abd7 100644 --- a/locales/cy/search.json +++ b/locales/cy/search.json @@ -9,6 +9,7 @@ "postcode-label": "Cod Post", "lpa-label": "Awdurdod Cynllunio Lleol", "lpa-reference-label": "Cyfeirnod yr Awdurdod Cynllunio Lleol", + "appealtype-label": "Dewiswch fath o apêl", "case-type-label": "Math o Achos", "case-type-option-1": "--Dewiswch--", "case-type-option-2": "Unrhyw fath/Pob math", @@ -57,5 +58,6 @@ "searchresults-status-label": "Statws", "searchresults-watch-label": "Gwylio", "searchresults-search-button-label": "Mireinio'r chwiliad", - "searchresults-new-search-button-label": "Chwiliad newydd" + "searchresults-new-search-button-label": "Chwiliad newydd", + "searchresults-no-records-label": "Nid oes unrhyw gofnodion" } \ No newline at end of file diff --git a/locales/en/case.json b/locales/en/case.json index 2f447cc6..82e5a216 100644 --- a/locales/en/case.json +++ b/locales/en/case.json @@ -1,6 +1,7 @@ { "page-title": "Reference", "case-card-title": "Reference: APP/B1415/W/20/3271702", + "summary-reference-label": "Reference", "summary-applicant-label": "Appellant/Applicant", "summary-agent-label": "Agent", "summary-site-address-label": "Site Address", diff --git a/locales/en/common.json b/locales/en/common.json index a7921911..ab29b7bd 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -9,6 +9,7 @@ "error-textbox": "Choose an option", "available-in": "Cymraeg", "continue-button": "Continue", + "search-button": "Search", "submit-and-start": "Submit and start course", "footer-terms-conditions-link": "Terms and conditions", "footer-privacy-link": "Privacy Notice", @@ -37,5 +38,6 @@ "cookie-banner-list-item-2": "improve our website by collecting and reporting information on how you use it", "cookie-banner-list-item-3": "tailor communications", "cookie-banner-decline": "I decline", - "cookie-banner-accept": "Accept cookies" + "cookie-banner-accept": "Accept cookies", + "drop-down-select": "Select..." } \ No newline at end of file diff --git a/locales/en/home.json b/locales/en/home.json index 394217e9..6bbd5f83 100644 --- a/locales/en/home.json +++ b/locales/en/home.json @@ -2,6 +2,7 @@ "login-card-title-temp": "Welcome", "login-comingsoon-temp-1": "This website is still in development, if you wish to submit a new appeal or application please submit it, along with any relevant associated documentation, to ", "login-comingsoon-temp-2": "Appeal and application forms can be requested by e-mail or downloaded following the below link.", + "login-comingsoon-forms-link": "https://gov.wales/planning-appeal-forms", "login-card-title": "Sign in to appeal a planning decision", "login-card-id-label": "Government Gateway user ID", "login-card-id-hint": "This could be up to 12 characters.", @@ -23,6 +24,7 @@ "casescomment-card-paragraph-two": "For Householder and Commercial appeals, interested parties are unable to make representations at appeal stage. Any representations made at application stage will be provided by the local planning authority and considered by the inspector.", "inspectorate-card-visit-label": "Visit the Planning Inspectorate", "inspectorate-card-visit-link": "Home", + "inspectorate-card-alt-text": "The Planning Inspectorate", "dns-card-title": "Developments of National Significance", "dns-card-paragraph": "A Development of National Significance (DNS) is a type of planning application for a large infrastructure project of national importance in Wales. Here you can find out about proposed DNS applications. This site is managed by the Planning Inspectorate.", "dns-card-button": "View all applications" diff --git a/locales/en/search.json b/locales/en/search.json index 0558704b..ade4a9e0 100644 --- a/locales/en/search.json +++ b/locales/en/search.json @@ -9,6 +9,7 @@ "postcode-label": "Postcode", "lpa-label": "Local Planning Authority", "lpa-reference-label": "LPA reference number", + "appealtype-label": "Select an appeal type", "case-type-label": "Case type", "case-type-option-1": "-- Select --", "case-type-option-2": "Any/All", @@ -57,5 +58,6 @@ "searchresults-status-label": "Status", "searchresults-watch-label": "Watch", "searchresults-search-button-label": "Refine Search", - "searchresults-new-search-button-label": "New Search" + "searchresults-new-search-button-label": "New Search", + "searchresults-no-records-label": "There are no records" } \ No newline at end of file From 4a7245db203d648a4654f166d7daea8d64336ae6 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 30 Sep 2021 17:11:33 +0100 Subject: [PATCH 3/4] logic to let child cases be shown in case details --- actions/index.js | 34 +++++--- components/case.js | 1 + components/case/documents.js | 4 +- components/case/summary.js | 130 ++++++++++++++++++++++++---- components/crmError.js | 2 +- components/dnssearchresults.js | 2 +- components/search/advancedsearch.js | 2 +- components/searchresults.js | 2 +- locales/cy/case.json | 1 + locales/en/case.json | 1 + pages/myportal/index.js | 17 ++-- store/currentView/action.js | 8 ++ store/currentView/reducer.js | 7 ++ 13 files changed, 171 insertions(+), 40 deletions(-) diff --git a/actions/index.js b/actions/index.js index 2c3dec21..f6f4a99c 100644 --- a/actions/index.js +++ b/actions/index.js @@ -143,7 +143,7 @@ export const getBasicSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" + + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" + searchString + "') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201", azureHeaders(token) @@ -166,7 +166,7 @@ export const getBasicDNSSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true", + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true", azureHeaders(token) ) .then((res) => res.data) @@ -204,7 +204,7 @@ export const getAdvancedSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" + + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" + queryString + " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201", @@ -269,13 +269,8 @@ export const getSearchDocumentHistory = (token, documentID) => { }; export const getSearchDocumentDetails1 = (incidentID) => { - console.log(incidentID); + //console.log(incidentID); var token = getSASToken(); - console.log( - "/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " + - incidentID + - "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" - ); return axios .get( "/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " + @@ -289,7 +284,7 @@ export const getSearchDocumentDetails1 = (incidentID) => { }; export const getSearchDocumentHistory1 = (documentID) => { - console.log(documentID); + // console.log(documentID); var token = getSASToken(); return axios .get( @@ -318,6 +313,25 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { }); }; +export const getLinkedCases = (parentIncidentid) => { + console.log(parentIncidentid); + var token = getSASToken(); + + return axios + .get( + "/api/proxy/incidents?$count=true&$filter=_parentcaseid_value eq " + + parentIncidentid + + " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid," + ) + .then((res) => { + console.log(" linked date", res.data); + return res.data; + }) + .catch((error) => { + console.log("thiserror", error); + }); +}; + export const getFormData = (token, whichForm) => { //console.log("got to axios", whichForm); //console.log("api_root: ", BASE_URL); diff --git a/components/case.js b/components/case.js index 1a9feb83..317dbd05 100644 --- a/components/case.js +++ b/components/case.js @@ -30,6 +30,7 @@ const CaseSummary = (props) => { searchResultsObj={props.searchResultsObj} searchDetailsObj={props.searchDetailsObj} searchString={props.searchString} + incidentid={props.incidentid} /> { var documentDetailsArr = documentDetailsObj || []; const DocumentView = (documentDetailsArr) => { - console.log(documentDetailsArr); + //console.log(documentDetailsArr); documentDetailsArr = documentDetailsArr.value; @@ -173,7 +173,7 @@ const DocumentDetails = (props) => { const docDetailsObj = async () => { let docObj = await getSearchDocumentDetails1(incidentid) .then((data) => { - console.log(data); + //console.log(data); setDocumentDetails(data); return data; }) diff --git a/components/case/summary.js b/components/case/summary.js index bd0bcd6a..76b629b0 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -1,18 +1,26 @@ import Link from "next/link"; import { useRouter } from "next/router"; -import { useState } from "react"; +import { useState, useEffect, useRef } from "react"; +import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import useTranslation from "next-translate/useTranslation"; import jsonpath from "jsonpath"; import _ from "lodash"; import transLookup from "../../data/lookuptranslations.json"; import LoadingOverlay from "react-loading-overlay"; +import { getLinkedCases } from "../../actions"; +import { + setCurrentLinkedCases, + setCurrentReference, +} from "../../store/currentView/action"; + const CaseSummary = (props) => { let { t } = useTranslation(); const router = useRouter(); const { locale } = router; const { + incidentid, caseReference, myCases, myRepresentations, @@ -21,6 +29,9 @@ const CaseSummary = (props) => { searchResultsObj, searchDetailsObj, currentType, + setCurrentLinkedCases, + linkedCasesReference, + setCurrentReference, } = props; const noRepresentationLink = ["/case", "/dnsdetails"]; @@ -322,28 +333,39 @@ const CaseSummary = (props) => { )}
- {_.has(detailsObj, [ - "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue", + {_.has(casesObj, [ + "numberofchildincidents", ]) - ? detailsObj[ - "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue" - ] + ? casesObj.numberofchildincidents > + 0 + ? t( + "case:summary-case-link-status-linked" + ) + : t( + "case:summary-case-link-status-not-linked" + ) : t( "case:summary-case-link-status-not-linked" )}
-
-
- {t( - "case:summary-linked-cases-label" - )} -
-
- {/* {casesObj.caseDetails.linkedCases || - ""} */} -
-
+ {casesObj.numberofchildincidents > 0 ? ( +
+
+ {t( + "case:summary-linked-cases-label" + )} +
+
+ {linkedCasesList( + props.currentView + .linkedCaseReferences + )} +
+
+ ) : ( + "" + )} @@ -582,6 +604,20 @@ const CaseSummary = (props) => { ); + useEffect(() => { + const linkCaseObj = async () => { + let docObj = await getLinkedCases(incidentid).then((data) => { + console.log(data); + setCurrentLinkedCases(data); + return data; + }); + + return linkCaseObj; + }; + + const linkedCases = linkCaseObj(); + }, [incidentid, setCurrentLinkedCases]); + const [showSpinnerState, setShowSpinnerState] = useState(false); let spinnerState = () => { @@ -599,6 +635,47 @@ const CaseSummary = (props) => { return dd + "/" + mm + "/" + yyyy; } + function linkedCasesList(linkedCasesReference) { + console.log(linkedCasesReference); + + linkedCasesReference = linkedCasesReference.value || []; + + return ( + <> + + + ); + } + return ( <> {showDetailsBlock} @@ -611,4 +688,21 @@ const CaseSummary = (props) => { ); }; -export default CaseSummary; +const mapStateToProps = (state) => { + return { + ...state, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setCurrentLinkedCases: (parentIncidentid) => { + dispatch(setCurrentLinkedCases(parentIncidentid)); + }, + setCurrentReference: (currentReference) => { + dispatch(setCurrentReference(currentReference)); + }, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(CaseSummary); diff --git a/components/crmError.js b/components/crmError.js index e067da63..8a9e8d12 100644 --- a/components/crmError.js +++ b/components/crmError.js @@ -15,7 +15,7 @@ const CRMError = (props) => { ? "LPAData" : "searchResultsObj"; - console.log(errorSwitch); + //console.log(errorSwitch); return (
diff --git a/components/dnssearchresults.js b/components/dnssearchresults.js index 12a27db1..d75c3b3b 100644 --- a/components/dnssearchresults.js +++ b/components/dnssearchresults.js @@ -17,7 +17,7 @@ export default function Search(props) { ? true : false; - console.log("has an error", hasError); + //console.log("has an error", hasError); return (
{ event.preventDefault(); spinnerState(); - console.log(values); + //console.log(values); // var appTypeCollection = values.appealTypes.split(",")[1]; // appTypeCollection = getFormCollection( diff --git a/components/searchresults.js b/components/searchresults.js index 02964fd9..ebd5743e 100644 --- a/components/searchresults.js +++ b/components/searchresults.js @@ -17,7 +17,7 @@ export default function Search(props) { ? true : false; - console.log("has an error", hasError); + //console.log("has an error", hasError); return (
async ({ query, req, res }) => { //console.log("the query", query); + + const token = await getSASToken(); + const [ myCases, myRepresentations, watchedCases, awaitingSubmission, ] = await Promise.all([ - await getMyCases("f8b454ed-eded-eb11-aac7-00224800be9c"), - await getMyRepresentations(), - await getWatchedCases(), - await getAwaitingSubmission(), + await getMyCases(token, "f8b454ed-eded-eb11-aac7-00224800be9c"), + await getMyRepresentations(token), + await getWatchedCases(token), + await getAwaitingSubmission(token), ]); const cookies = new Cookies(req, res); @@ -109,7 +113,7 @@ export const getServerSideProps = wrapper.getServerSideProps( // watchedCasesDetails, // awaitingSubmissionDetails, ] = await Promise.all([ - await getDetails(myCases), + await getDetails(token, myCases), // await getDetails(myRepresentations), // await getDetails(watchedCases), // await getDetails(awaitingSubmission), @@ -142,7 +146,7 @@ const getFormCollection = (formtype) => { return collectionName[0]; }; -const getDetails = (resultsObj) => { +const getDetails = (token, resultsObj) => { //console.log(resultsObj); let detailsArr = []; resultsObj = resultsObj.value; @@ -152,6 +156,7 @@ const getDetails = (resultsObj) => { } else { detailsArr.push( getPortalModuelDetails( + token, getFormCollection( "pinswg_" + searchDetail[ diff --git a/store/currentView/action.js b/store/currentView/action.js index 292372d3..028ce0a1 100644 --- a/store/currentView/action.js +++ b/store/currentView/action.js @@ -5,6 +5,7 @@ export const currentViewActionTypes = { SETREPRESENTATIONCAPACITY: "SETREPRESENTATIONCAPACITY", SETREPRESENTATIONSUBMIT: "SETREPRESENTATIONSUBMIT", SETREPRESENTATIONSUBMITCONFIRMATION: "SETREPRESENTATIONSUBMITCONFIRMATION", + SETCURRENTLINKEDCASES: "SETCURRENTLINKEDCASES", }; export const getCurrentViewObj = () => (dispatch) => { @@ -56,3 +57,10 @@ export const setRepresentationSubmitConfirmation = representationSubmitConfirmation: representationSubmitConfirmation, }); }; + +export const setCurrentLinkedCases = (linkedCaseReferences) => (dispatch) => { + return dispatch({ + type: currentViewActionTypes.SETCURRENTLINKEDCASES, + linkedCaseReferences: linkedCaseReferences, + }); +}; diff --git a/store/currentView/reducer.js b/store/currentView/reducer.js index 683089b6..1e2c4b68 100644 --- a/store/currentView/reducer.js +++ b/store/currentView/reducer.js @@ -6,6 +6,7 @@ const currentViewInitialState = { representationCapacity: {}, representationSubmit: null, representationSubmitConfirmation: {}, + linkedCaseReferences: {}, }; export default function reducer(state = currentViewInitialState, action) { @@ -20,6 +21,12 @@ export default function reducer(state = currentViewInitialState, action) { ...state, caseReference: action.caseReference, }; + + case currentViewActionTypes.SETCURRENTLINKEDCASES: + return { + ...state, + linkedCaseReferences: action.linkedCaseReferences, + }; case currentViewActionTypes.SETREPRESENTATIONCAPACITY: return { ...state, From c061650fe4cd5d30832d7edf6e2b09c669c71f92 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 1 Oct 2021 11:08:24 +0100 Subject: [PATCH 4/4] updated translations for lpas --- actions/index.js | 16 ++++++++++----- components/newappeal/createCase.js | 33 ++++++++++++++++++++++-------- data/lookuptranslations.json | 13 ++++++++---- locales/cy/newappeal.json | 8 ++++++-- locales/en/newappeal.json | 6 +++++- pages/newappeal/[appealtypes].js | 13 ++++++------ pages/newappeal/index.js | 14 ++++++++++--- 7 files changed, 74 insertions(+), 29 deletions(-) diff --git a/actions/index.js b/actions/index.js index f6f4a99c..60c8b26d 100644 --- a/actions/index.js +++ b/actions/index.js @@ -388,6 +388,7 @@ export const getAppealsTypes = (token) => { ) .then((res) => res.data) .catch((error) => { + console.log(error); let ErrResponse = { value: [], errorCode: error.response.status, @@ -445,10 +446,14 @@ export const getLPA = (token) => { // console.log("api_root: ", BASE_URL); return axios .get( - WEBAPI_URL + "accounts?$count=true&$select=name", + WEBAPI_URL + + "accounts?$count=true&$filter=pinswg_isalocalplanningauthorityaccount eq 846040000&$select=name", azureHeaders(token) ) - .then((res) => res.data) + .then((res) => { + // console.log(res.data); + return res.data; + }) .catch((error) => { let ErrResponse = { value: [], @@ -502,7 +507,7 @@ export const getAppealID = ( }); }; -export const createCase = (appealTypeId) => { +export const createCase = (token, appealTypeId) => { appealTypeId = parseInt(appealTypeId); var data = JSON.stringify({ "title": "insertion test case", @@ -521,7 +526,7 @@ export const createCase = (appealTypeId) => { "Accept": "application/json", "Prefer": 'odata.include-annotations="*",return=representation', "Content-Type": "application/json", - "ServiceBusAuthorization": SASToken, + "ServiceBusAuthorization": token, }, data: data, }; @@ -537,6 +542,7 @@ export const createCase = (appealTypeId) => { }; export const updateCase = async ( + token, incidentId, updateBody, updateFormCollection, @@ -563,7 +569,7 @@ export const updateCase = async ( "Accept": "application/json", "Prefer": 'odata.include-annotations="*",return=representation', "Content-Type": "application/json", - "ServiceBusAuthorization": SASToken, + "ServiceBusAuthorization": token, }, data: data, }; diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index 952cd50b..6272b555 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -7,6 +7,7 @@ import BuildRow from "./buildrow"; import { reduxForm, formValueSelector, Field } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import jsonpath from "jsonpath"; +import transLookup from "../../data/lookuptranslations.json"; import data from "../../data/collections.json"; import { @@ -90,7 +91,7 @@ let CreateCase = (props) => { //onChange={(e) => props.onChangeSelectLPA(e)} > {_.isEmpty(optionsObj) ? "" @@ -100,7 +101,15 @@ let CreateCase = (props) => { key={key} value={optionsObj[key].accountid} > - {optionsObj[key].name} + {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + optionsObj[key] + .name + + '")].value_cy' + ) + : optionsObj[key].name} ); })} @@ -151,7 +160,7 @@ let CreateCase = (props) => { //onChange={(e) => props.onChangeSelectAppealType(e)} > {_.isEmpty(optionsObj) ? "" @@ -190,6 +199,14 @@ let CreateCase = (props) => { optionsObj[key].value ) ? "" + : router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + optionsObj[key] + .value + + '")].value_cy' + ) : optionsObj[key].value} ); @@ -248,8 +265,8 @@ let CreateCase = (props) => { component={RenderLPAList} optionsObj={lpaOptionsObj} validate={[required]} - label="Select your local planning authority" - errorMsg="Local authority is required" + label={t("newappeal:select-lpa-label")} + errorMsg={t("newappeal:select-lpa-label-error-msg")} /> { component={RenderAppealTypeList} optionsObj={appealOptionsObj} validate={[required]} - label="Select an appeal type" - errorMsg="Appeal type is required" + label={t("newappeal:select-appeal-type-label")} + errorMsg={t("newappeal:select-appeal-type-label-error-msg")} /> ); diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index 15f6fa3e..cd76555b 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -217,7 +217,7 @@ "pinswg_lpa": 0 }, { - "value": "Cardiff Council", + "value": "Cardiff County Council", "value_cy": "Cyngor Caerdydd", "pinswg_lpa": 0 }, @@ -322,19 +322,24 @@ "pinswg_lpa": 0 }, { - "value": "Brecon Beacons National Park", + "value": "Brecon Beacons National Park Authority", "value_cy": "Parc Cenedlaethol Bannau Brycheiniog", "pinswg_lpa": 0 }, { - "value": "Pembrokeshire Coast National Park", + "value": "Pembrokeshire Coast National Park Authority", "value_cy": "Parc Cenedlaethol Arfordir Penfro", "pinswg_lpa": 0 }, { - "value": "Snowdonia National Park", + "value": "Snowdonia National Park Authority", "value_cy": "Parc Cenedlaethol Eryri", "pinswg_lpa": 0 + }, + { + "value": "Developments of National Significance", + "value_cy": "Datblygiadau o Arwyddocâd Cenedlaethol", + "pinswg_lpa": 0 } ], "pinswg_procedure": [ diff --git a/locales/cy/newappeal.json b/locales/cy/newappeal.json index 054e5030..8cf41621 100644 --- a/locales/cy/newappeal.json +++ b/locales/cy/newappeal.json @@ -1,5 +1,9 @@ { "viewall-link": "View all", - "parent-page-title": "My portal", - "page-title": "New appeal" + "parent-page-title": "Fy Mhorth", + "page-title": "Apêl newydd", + "select-lpa-label": "Dewiswch eich awdurdod cynllunio lleol", + "select-lpa-label-error-msg": "Mae angen awdurdod lleol", + "select-appeal-type-label": "Dewiswch fath o apêl", + "select-appeal-type-label-error-msg": "Mae angen math o apêl" } \ No newline at end of file diff --git a/locales/en/newappeal.json b/locales/en/newappeal.json index 054e5030..c0b6e084 100644 --- a/locales/en/newappeal.json +++ b/locales/en/newappeal.json @@ -1,5 +1,9 @@ { "viewall-link": "View all", "parent-page-title": "My portal", - "page-title": "New appeal" + "page-title": "New appeal", + "select-lpa-label": "Select your local planning authority", + "select-lpa-label-error-msg": "Local authority is required", + "select-appeal-type-label": "Select an appeal type", + "select-appeal-type-label-error-msg": "Appeal type is required" } \ No newline at end of file diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js index 6ae4b039..7255fa75 100644 --- a/pages/newappeal/[appealtypes].js +++ b/pages/newappeal/[appealtypes].js @@ -28,6 +28,7 @@ import { } from "../../store/appealType/action"; import { setForm, getFormObj } from "../../store/formData/action"; import { + getSASToken, getFormData, getAppealsTypes, getMandatoryFields, @@ -170,7 +171,7 @@ export const getServerSideProps = wrapper.getServerSideProps( (store) => async ({ query, req, res }) => { console.log("the query", query); - + const token = await getSASToken(); const [ caseReferenceData, appealTypeData, @@ -178,11 +179,11 @@ export const getServerSideProps = wrapper.getServerSideProps( pickListData, formdata, ] = await Promise.all([ - await createCase(query.apt), - await getAppealsTypes(), - await getMandatoryFields(query.appealtypes), - await getPickLists(query.appealtypes), - await getFormData(query.appealtypes), + await createCase(token, query.apt), + await getAppealsTypes(token), + await getMandatoryFields(token, query.appealtypes), + await getPickLists(token, query.appealtypes), + await getFormData(token, query.appealtypes), ]); // let updateCaseReferenceData = await updateCase( diff --git a/pages/newappeal/index.js b/pages/newappeal/index.js index 183d2d06..4ffb8cba 100644 --- a/pages/newappeal/index.js +++ b/pages/newappeal/index.js @@ -26,7 +26,13 @@ import { setAppealLPA, getAppealTypeObj, } from "../../store/appealType/action"; -import { getAppealsTypes, getLPA, updateCase, createCase } from "../../actions"; +import { + getAppealsTypes, + getLPA, + updateCase, + createCase, + getSASToken, +} from "../../actions"; import { setLPA } from "../../store/lpa/action"; const Home = (props) => { @@ -80,9 +86,11 @@ const Home = (props) => { export const getServerSideProps = wrapper.getServerSideProps( (store) => async ({ query, req, res }) => { + const token = await getSASToken(); + const [appealTypeData, lpaData, caseData] = await Promise.all([ - await getAppealsTypes(), - await getLPA(), + await getAppealsTypes(token), + await getLPA(token), ]); store.dispatch(setAppealType(appealTypeData));