From c061650fe4cd5d30832d7edf6e2b09c669c71f92 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 1 Oct 2021 11:08:24 +0100 Subject: [PATCH] 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));