From c2aea1e9d812ac4952bfd834c1ad5fa186990700 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 29 Sep 2021 16:45:56 +0100 Subject: [PATCH] updated language fix and proxy config --- .env.local | 20 ++++---- actions/index.js | 11 +++-- components/banner.js | 22 +++++---- components/case/documents.js | 23 +++++++-- components/case/summary.js | 56 +++++++++++++++++++--- components/cookieBanner.js | 37 +++++++++----- components/header.js | 1 + locales/cy/common.json | 14 +++++- locales/en/common.json | 14 +++++- next.config.js | 4 ++ pages/404.js | 7 +-- pages/api/proxy/[...route].js | 45 +++++++++++------ pages/logout.js | 4 +- styles/sass/components/_cookie-banner.scss | 38 ++++++++------- 14 files changed, 214 insertions(+), 82 deletions(-) diff --git a/.env.local b/.env.local index 4600c635..74e6fb27 100644 --- a/.env.local +++ b/.env.local @@ -1,8 +1,8 @@ -//RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ -//RELAYURI = "dev-pedw-ns.servicebus.windows.net" -//RELAYPATH = "dev-pedw-hc" -//SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=" -//SASKEYNAME = "devpedwnspolicy" +RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ +RELAYURI = "dev-pedw-ns.servicebus.windows.net" +RELAYPATH = "dev-pedw-hc" +SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=" +SASKEYNAME = "devpedwnspolicy" PORT= "3000" @@ -14,8 +14,8 @@ I18N_DOMAIN = "cymru.local" //I18N_DOMAIN ="gwaithcynllunio.gwasanaeth.llyw.cymru" -RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -RELAYURI = "test-pedw-ns.servicebus.windows.net" -RELAYPATH = "test-pedw-hc" -SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4=" -SASKEYNAME = "testpedwhcpolicy" +//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ +//RELAYURI = "test-pedw-ns.servicebus.windows.net" +//RELAYPATH = "test-pedw-hc" +//SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4=" +//SASKEYNAME = "testpedwhcpolicy" diff --git a/actions/index.js b/actions/index.js index 58ae4cb7..0fd38d3f 100644 --- a/actions/index.js +++ b/actions/index.js @@ -166,7 +166,7 @@ export const getBasicDNSSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "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=_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) @@ -188,7 +188,7 @@ export const getAdvancedSearch = (token, searchString) => { queryString += searchString.lpa != null ? (typeof searchString.q == "undefined" ? "" : " and ") + - "_customerid_value eq " + + "_pinswg_associatedlpa_value eq " + searchString.lpa : ""; queryString += @@ -268,8 +268,13 @@ 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 " + diff --git a/components/banner.js b/components/banner.js index 3736061e..7a2a557a 100644 --- a/components/banner.js +++ b/components/banner.js @@ -1,12 +1,18 @@ import Link from "next/link"; +import useTranslation from "next-translate/useTranslation"; export default function Banner() { - return ( -
-

- beta - This is a new service -

-
- ); + let { t, lang } = useTranslation(); + return ( +
+

+ + beta + + + {t("common:new-service-beta")} + +

+
+ ); } diff --git a/components/case/documents.js b/components/case/documents.js index 70c62373..09cf7c27 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -4,6 +4,7 @@ import useTranslation from "next-translate/useTranslation"; import jsonpath from "jsonpath"; import { useState, useEffect, useRef } from "react"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; +import transLookup from "../../data/lookuptranslations.json"; import { getBasicSearch, @@ -111,11 +112,22 @@ const DocumentDetails = (props) => { {t("case:documents-doc-type-label")} : - { - detailsObj[ - "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" - ] - } + + {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-date-entered-label" + )}
@@ -156,6 +168,7 @@ const DocumentDetails = (props) => { const docDetailsObj = async () => { let docObj = await getSearchDocumentDetails1(incidentid) .then((data) => { + console.log(data); setDocumentDetails(data); return data; }) diff --git a/components/case/summary.js b/components/case/summary.js index 5ad6d5c5..bfdaf26a 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -366,9 +366,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_startdate" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_startdate ) + ? formatDates( + detailsObj.pinswg_startdate + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} @@ -386,9 +392,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_questionnaireduedate" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_questionnaireduedate ) + ? formatDates( + detailsObj.pinswg_questionnaireduedate + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} @@ -406,9 +418,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_statementduedate" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_statementduedate ) + ? formatDates( + detailsObj.pinswg_statementduedate + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} @@ -426,9 +444,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_otherpartiesstatement" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_otherpartiesstatement ) + ? formatDates( + detailsObj.pinswg_otherpartiesstatement + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} @@ -446,9 +470,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_finalcommentsduedate" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_finalcommentsduedate ) + ? formatDates( + detailsObj.pinswg_finalcommentsduedate + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} @@ -465,9 +495,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_dateeventrequested" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_dateeventrequested ) + ? formatDates( + detailsObj.pinswg_dateeventrequested + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} @@ -485,9 +521,15 @@ const CaseSummary = (props) => { detailsObj, "pinswg_dateoflpadecision" ) - ? formatDates( + ? !_.isEmpty( detailsObj.pinswg_dateoflpadecision ) + ? formatDates( + detailsObj.pinswg_dateoflpadecision + ) + : t( + "case:summary-no-date-entered-label" + ) : t( "case:summary-no-date-entered-label" )} diff --git a/components/cookieBanner.js b/components/cookieBanner.js index 1666cb40..986f11e8 100644 --- a/components/cookieBanner.js +++ b/components/cookieBanner.js @@ -1,7 +1,9 @@ import CookieConsent from "react-cookie-consent"; import Link from "next/link"; +import useTranslation from "next-translate/useTranslation"; const CookieBanner = () => { + let { t, lang } = useTranslation(); return ( { buttonClasses="govuk-button" buttonWrapperClasses="govuk-width-container consentBanner" declineButtonClasses="govuk-button" - buttonText="Accept all cookies" + buttonText={t("common:cookie-banner-accept")} + declineButtonText={t("common:cookie-banner-decline")} disableStyles={true} enableDeclineButton={true} flipButtons={true} @@ -33,18 +36,30 @@ const CookieBanner = () => {
-

- Tell us whether you accept cookies -

- GOV.UK uses cookies which are essential - for the site to work. We also use - non-essential cookies to help us improve - government digital services. Any data - collected is anonymised. By continuing - to use this site, you agree to our use - of cookies. + {t("common:cookie-banner-line-1")}

+
    +
  • + {" "} + {t( + "common:cookie-banner-list-item-1" + )} +
  • +
+

{t("common:cookie-banner-line-2")}

+
    +
  • + {t( + "common:cookie-banner-list-item-2" + )} +
  • +
  • + {t( + "common:cookie-banner-list-item-3" + )} +
  • +
diff --git a/components/header.js b/components/header.js index 0f351435..1ce19ecc 100644 --- a/components/header.js +++ b/components/header.js @@ -24,6 +24,7 @@ const Header = (props) => { "/advancedsearchresults", "/dnsapplications", "/dnsdetails", + "/404", ]; const hasContactLink = [ "/dns", diff --git a/locales/cy/common.json b/locales/cy/common.json index d32f97d1..92af5164 100644 --- a/locales/cy/common.json +++ b/locales/cy/common.json @@ -2,6 +2,7 @@ "gov-wales-link": "https://llyw.cymru", "gov-wales-label": "LLYW.CYMRU", "service-name": "Cynllunio gwaith achos", + "new-service-beta": "Mae hwn yn wasanaeth newydd", "breadcrumb-back-link": "Yn ôl", "error-radio": "Dewiswch opsiwn", "error-checkbox": "Enter a value", @@ -25,5 +26,16 @@ "breadcrumb-my-portal": "Fy mhorth", "breadcrumb-case-reference": "Cyfeirnod Achos", "spinner-loading": "Llwytho...", - "spinner-searching": "Chwilio..." + "spinner-searching": "Chwilio...", + "logged-out-title": "Rydych chi wedi allgofnodi", + "logged-out-link": "Dychwelwch i'r porth Gwaith Achos Cynllunio", + "404-not-found-title": "404 - heb ei ddarganfod", + "404-not-found-link": "Ewch yn ôl adref", + "cookie-banner-line-1": "Ry'n ni wedi cadw ffeiliau a elwir yn cwcis ar eich dyfais. Mae'r cwcis hyn:", + "cookie-banner-list-item-1": "yn hanfodol i'r safle weithio", + "cookie-banner-line-2": "Byddem hefyd yn hoffi cadw rhai cwcis i'n helpu ni:", + "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" } \ No newline at end of file diff --git a/locales/en/common.json b/locales/en/common.json index c351dc59..a7921911 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -2,6 +2,7 @@ "gov-wales-link": "https://www.gov.wales", "gov-wales-label": "GOV.WALES", "service-name": "Planning casework", + "new-service-beta": "This is a new service", "breadcrumb-back-link": "Back", "error-radio": "Choose an option", "error-checkbox": "Choose an option", @@ -25,5 +26,16 @@ "breadcrumb-my-portal": "My portal", "breadcrumb-case-reference": "Case Reference", "spinner-loading": "Loading...", - "spinner-searching": "Searching..." + "spinner-searching": "Searching...", + "logged-out-title": "You have been logged out", + "logged-out-link": "Return to Planning Casework portal", + "404-not-found-title": "404 - not found", + "404-not-found-link": "Go back home", + "cookie-banner-line-1": "We've saved some files called cookies on your device. These cookies are:", + "cookie-banner-list-item-1": "essential for the site to work", + "cookie-banner-line-2": "We would also like to save some cookies to help:", + "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" } \ No newline at end of file diff --git a/next.config.js b/next.config.js index 5f422840..628fbe5b 100644 --- a/next.config.js +++ b/next.config.js @@ -41,6 +41,10 @@ module.exports = { source: "/achos", destination: "/case", }, + { + source: "/allgofnodi", + destination: "/logout", + }, { source: "/cy:path*", destination: "http://cyrmu.local/:path*", diff --git a/pages/404.js b/pages/404.js index 0741e8ec..fdf40808 100644 --- a/pages/404.js +++ b/pages/404.js @@ -15,7 +15,8 @@ const FourOhFour = (props) => {
- {t("case:page-title")} - {t("common:service-name")} + {t("common:404-not-found-title")} -{" "} + {t("common:service-name")}
@@ -25,9 +26,9 @@ const FourOhFour = (props) => {
-

404 - Page Not Found

+

{t("common:404-not-found-title")}

- Go back home + {t("common:404-not-found-link")}
diff --git a/pages/api/proxy/[...route].js b/pages/api/proxy/[...route].js index 54052bdd..ce28bc48 100644 --- a/pages/api/proxy/[...route].js +++ b/pages/api/proxy/[...route].js @@ -2,15 +2,32 @@ import axios from "axios"; import https from "https"; import CryptoJS from "crypto-js"; -const WEBAPI_URL = - process.env.RELAY_ROOT || - "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; +const PROXY_RELAY_URL = + "https://" + + (process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net") + + "/" + + (process.env.RELAYPATH || "dev-pedw-hc") + + "/"; +//"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +// const azureHeaders = { +// headers: { +// "OData-MaxVersion": "4.0", +// "OData-Version": "4.0", +// "Accept": "application/json", +// "Prefer": 'odata.include-annotations="*",return=representation', +// "Content-Type": "application/json", +// "ServiceBusAuthorization": SASToken, +// }, +// }; const getSASToken = () => { - var m_ResourceURI = "dev-pedw-ns.servicebus.windows.net"; - var m_Path = "dev-pedw-hc"; - var m_SasKey = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="; - var m_SasKeyName = "devpedwnspolicy"; + var m_ResourceURI = + process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net"; + var m_Path = process.env.RELAYPATH || "dev-pedw-hc"; + var m_SasKey = + process.env.SASKEY || "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="; + var m_SasKeyName = process.env.SASKEYNAME || "devpedwnspolicy"; var encodedResourceUri = encodeURIComponent( "https://" + m_ResourceURI + "/" + m_Path + "/" @@ -43,7 +60,7 @@ const getSASToken = () => { }; export default async function ApiProxy(req, res) { - console.log(req.method); + // console.log(req.method); var updateBody = { "pinswg_areaofsiteinhectaresdec": 21, @@ -65,8 +82,8 @@ export default async function ApiProxy(req, res) { var configNoData = { method: req.method, - //url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")", - url: WEBAPI_URL + req.url.split("/api/proxy/")[1], + //url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")", + url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1], headers: { "OData-MaxVersion": "4.0", "OData-Version": "4.0", @@ -79,8 +96,8 @@ export default async function ApiProxy(req, res) { var config = { method: req.method, - //url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")", - url: WEBAPI_URL + req.query.route[0], + //url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")", + url: PROXY_RELAY_URL + req.query.route[0], headers: { "OData-MaxVersion": "4.0", "OData-Version": "4.0", @@ -95,14 +112,14 @@ export default async function ApiProxy(req, res) { console.log(req.url.split("/api/proxy/")[1]); return new Promise((resolve, reject) => { - //console.log(config); + // console.log(config); axios(req.method == "GET" ? configNoData : config) .then((response) => { res.statusCode = 200; res.setHeader("Content-Type", "application/json"); res.setHeader("Cache-Control", "max-age=1800000"); res.end(JSON.stringify(response.data)); - //console.log("response data", response.data); + // console.log("response data", response.data); resolve(); }) .catch((error) => { diff --git a/pages/logout.js b/pages/logout.js index 21fd1d78..d633a3bd 100644 --- a/pages/logout.js +++ b/pages/logout.js @@ -28,9 +28,9 @@ const LogOut = (props) => {
-

You have been logged out

+

{t("common:logged-out-title")}

- Return to Planning Casework portal + {t("common:logged-out-link")}