Merged PR 2449: language helper

Related work items: #23754
This commit is contained in:
Robert Bond
2026-07-01 11:29:15 +00:00
parent 49aa258fd9
commit e864049bec
63 changed files with 4008 additions and 6094 deletions
+11 -17
View File
@@ -3,7 +3,7 @@ import OSPoint from "ospoint";
import { respondError, respondSuccess } from "../middleware/apiResponse";
import { relayGetData } from "../middleware/relayForwarding";
import transLookup from "../../../data/lookuptranslations.json";
import { JSONPath as jsonpath } from "jsonpath-plus";
import resolveCrmDisplayValue from "../../../lib/i18n/crmDisplay/resolveCrmDisplayValue";
const renameKeys = (obj) => {
const keyMappings = {
@@ -132,23 +132,17 @@ const renameKeys = (obj) => {
renamedObj.northing = String(renamedObj.northing);
}
renamedObj.lpaDisplayName_cy = jsonpath({
path:
'$..[?(@ && @.value=="' +
renamedObj.lpaDisplayName +
'")].value_cy',
json: transLookup,
eval: true
})[0];
renamedObj.lpaDisplayName_cy = resolveCrmDisplayValue({
value: renamedObj.lpaDisplayName,
locale: "cy",
translations: transLookup
});
renamedObj.statusCodeDescription_cy = jsonpath({
path:
'$..[?(@ && @.value=="' +
renamedObj.statusCodeDescription +
'")].value_cy',
json: transLookup,
eval: true
})[0];
renamedObj.statusCodeDescription_cy = resolveCrmDisplayValue({
value: renamedObj.statusCodeDescription,
locale: "cy",
translations: transLookup
});
return renamedObj;
};
-8
View File
@@ -51,14 +51,6 @@ export default async function ApiProxy(req, res) {
});
}
//console.log(
// '$..[?(@ && @.name="' + lpaid + '")]',
// lpaList,
// lpaid,
// "LPAGUID=",
// lpaGUID
// );
const queryUrl =
"incidents?$select=pinswg_environmentalstatementlocation,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference,pinswg_appellantlastname,pinswg_appellantfirstname,pinswg_appellantagent,pinswg_agentfirstname,pinswg_agentlastname,pinswg_agentcompanyname&$expand=primarycontactid($select=fullname)&$filter=_pinswg_associatedlpa_value eq " +
lpaGUID[0].accountid +
-366
View File
@@ -1,369 +1,3 @@
// import fs from "fs";
// import { JSONPath as jsonpath } from "jsonpath-plus";
// import useTranslation from "next-translate/useTranslation";
// import Head from "next/head";
// import { useRouter } from "next/router";
// import { useEffect } from "react";
// import { connect } from "react-redux";
// import xpath from "xpath";
// import Breadcrumbs from "../../components/breadcrumbs";
// import CookieBanner from "../../components/cookieBanner";
// import Footer from "../../components/footer";
// import Header from "../../components/header";
// import BuildCheckSection from "../../components/newappeal/buildchecksection";
// import BuildSection from "../../components/newappeal/buildsection";
// import CompleteAppeal from "../../components/newappeal/complete";
// import TimeOut from "../../components/timeout";
// import { getSession } from "next-auth/react";
// import {
// setContainerID,
// setLoggedInUserEmail,
// setLoggedInUserId,
// setAccountDetails,
// } from "../../store/accountDetails/action";
// import {
// setAppealLPA,
// setAppealType,
// setAppealTypeID,
// setAppealTypeTitle,
// setCaseReference,
// setFilesForAppeal,
// } from "../../store/appealType/action";
// import {
// setAwaitingSubmissionDetails,
// setAwaitingSubmissionFromBlob,
// } from "../../store/awaitingSubmission/action";
// import { setCurrentView, setLocale } from "../../store/currentView/action";
// import { setForm } from "../../store/formData/action";
// import { wrapper } from "../../store/store";
// import ServiceBanner from "../../components/myportal/servicebanner";
// let Home = (props) => {
// const { footerLinks, pages, formData } = props;
// let { t, lang } = useTranslation();
// const router = useRouter();
// const { locale } = router;
// const { appealtypes } = router.query;
// useEffect(() => {
// //setFormTitle(formTitle);
// setCaseReference(router.query.casereference);
// }, []); // eslint-disable-line react-hooks/exhaustive-deps
// const formXML = props.formData.formData;
// const parser = new DOMParser();
// var doc = parser.parseFromString(formXML, "text/xml");
// var titles = xpath.select(
// "//form/tabs/tab[*]/labels/label[@description]/@description",
// doc
// );
// var sectionCount = xpath.select("/form/tabs/tab[*]", doc);
// sectionCount = sectionCount.length;
// var tabs = xpath.select("//form/tabs/tab[*]", doc);
// let optionsStr = props.appealType.appealTypeOptions.value || {};
// let selectedObj = jsonpath({
// path: "$..[?(@ && @.attributevalue=='" + router.query.apt + "')]",
// json: optionsStr,
// eval: true,
// });
// //let optionsTitleObj = [];
// //const optionsTitleObj = selectedObj.reduce(
// // (obj, arrValue) => (
// // (obj[arrValue] = arrValue
// // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
// // .toLowerCase()
// // .slice(0, 39)),
// // obj
// // ),
// // {}
// // );
// const formTitle = selectedObj[0].value;
// const { onSubmit } = props;
// return (
// <div>
// <Head>
// <title>
// {t("newappeal:page-title")} - {t("common:service-name")}
// </title>
// <>
// <link
// rel="canonical"
// href={t("common:gov-wales-link") + router.asPath}
// />
// <meta
// key="og:locale"
// property="og:locale"
// content={router.locale}
// />
// {/* If they have a Twitter Handle, include the meta details below */}
// <meta
// key="og:site_name"
// property="og:site_name"
// content={t("common:service-name")}
// />
// <meta
// key="twitter:site"
// property="twitter:site"
// content="@UKGovWales"
// />
// <meta
// name="description"
// content={t("common:service-description")}
// />
// <meta
// property="og:site_name"
// content={t("common:gov-wales-label")}
// />
// <meta
// property="og:title"
// content={t("newappeal:page-title")}
// />
// <meta
// property="og:description"
// content={t("common:service-description")}
// />
// <meta property="og:type" content="website" />
// <meta
// property="og:url"
// content={t("common:gov-wales-link")}
// />
// <meta
// property="og:image"
// content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
// />
// <meta name="twitter:card" content="summary" />
// <meta
// name="twitter:title"
// content={t("common:gov-wales-label")}
// />
// <meta
// name="twitter:url"
// content={t("common:gov-wales-link") + router.asPath}
// />
// <meta
// name="twitter:image"
// content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
// />
// </>
// </Head>
// <div id="page_wrapper">
// <CookieBanner />
// <Header />
// <div className="govuk-width-container">
// <Breadcrumbs slug={appealtypes} formTitle={formTitle} />
// <ServiceBanner props={props} />
// <main
// className="govuk-main-wrapper--auto-spacing"
// id="main-content"
// role="main"
// >
// {props.appealType.currentSection == 9999 ? (
// <CompleteAppeal props={props} />
// ) : props.appealType.currentSection ==
// sectionCount + 1 ? (
// <BuildCheckSection
// formXML={formXML}
// sectionCount={sectionCount}
// onSubmit={onSubmit}
// formTitle={formTitle}
// appealType={props.appealType}
// props={props}
// key={1}
// mandatoryFieldsData={
// props.formData.mandatoryFieldsData
// }
// />
// ) : (
// <>
// <BuildSection
// formXML={formXML}
// sectionCount={sectionCount}
// onSubmit={onSubmit}
// formTitle={formTitle}
// mandatoryFieldsData={
// props.formData.mandatoryFieldsData
// }
// props={props}
// />
// </>
// )}
// </main>
// </div>
// <Footer footerLinks={footerLinks} ticketnumber={props} />
// </div>
// <TimeOut />
// </div>
// );
// };
// export const getServerSideProps = wrapper.getServerSideProps(
// (store) => async (ctx) => {
// const { query, req, res } = ctx;
// getIP(req);
// const { cookies } = req;
// console.log("the query", query);
// let loggedInUser = cookies.pinsUser;
// let thisSession = await getSession(ctx);
// if (!thisSession) {
// console.log("not has sesssion.......");
// return {
// redirect: {
// destination: "/auth/signin",
// permanent: false,
// },
// };
// }
// console.log(ctx.locale);
// store.dispatch(setLocale(ctx.locale));
// let loggedInUserIdent = thisSession.user.id;
// let loggedInUserEmail = thisSession.user.email;
// //console.log("logged ident:", loggedInUserIdent);
// console.log("which appeal: ", query.appealtypes);
// const accountDetails = await getPersonalAccount(loggedInUser);
// const [appealTypeData, mandatoryFieldsData, pickListData, blobList] =
// await Promise.all([
// await getAppealsTypesForNewAppeal(),
// await getMandatoryFields(query.appealtypes),
// await getPickLists(query.appealtypes),
// await getFilesFromBlob(loggedInUserIdent, query.casereference),
// ]);
// const blobProgress = await getProgressFromBlob(
// loggedInUserIdent,
// query.casereference
// );
// //console.log("/////////\nappeal type data:", appealTypeData);
// //
// // Removed to make progress from Blob not CRM
// //
// // let searchResultsObj = await getPartSavedAppeal(query.casereference);
// // //console.log("eeee:", searchResultsObj);
// // let searchDetailsObj = await getPartSavedDetails(searchResultsObj);
// // searchDetailsObj = searchDetailsObj[0].value[0];
// // Object.keys(searchDetailsObj).forEach((key) => {
// // if (searchDetailsObj[key] === null) {
// // delete searchDetailsObj[key];
// // }
// // });
// //console.log("appeal:", searchDetailsObj);
// // searchDetailsObj = JSON.stringify(searchDetailsObj);
// // searchDetailsObj = searchDetailsObj.replace(/:true/gm, `:"Yes"`);
// // searchDetailsObj = searchDetailsObj.replace(/:false/gm, `:"No"`);
// // searchDetailsObj = JSON.parse(searchDetailsObj);
// let caseReference = {};
// caseReference.ticketnumber = query.casereference;
// caseReference.incidentid = query.inid;
// caseReference.caseDetails = blobProgress; //searchDetailsObj;
// var path = require("path");
// const configDirectory = path.resolve(process.cwd(), "data/formsxml");
// var xmlStr = fs.readFileSync(
// path.join(configDirectory, query.appealtypes + ".xml"),
// "utf8"
// );
// xmlStr = xmlStr.replace(/\t/g, "");
// xmlStr = xmlStr.replace(/\n/g, "");
// xmlStr = xmlStr.replace(/> <"/g, "><");
// xmlStr = xmlStr.toString();
// if (query.hasOwnProperty("key")) {
// const awaitingSubmissionFromBlob =
// await getAwaitingSubmissionFromBlob(thisSession.user.id);
// store.dispatch(
// setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob)
// );
// store.dispatch(
// setAwaitingSubmissionDetails(awaitingSubmissionFromBlob)
// );
// store.dispatch(
// setCurrentView({
// "viewName": "Awaiting Submission",
// "viewKey": "awaitingSubmissionDetails",
// })
// );
// }
// store.dispatch(setLoggedInUserId(loggedInUser));
// store.dispatch(setLoggedInUserEmail(loggedInUserEmail));
// store.dispatch(setAppealLPA(query.lpa));
// store.dispatch(setAppealTypeID(query.apt));
// store.dispatch(setCaseReference(caseReference));
// store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
// store.dispatch(setAppealType(appealTypeData));
// store.dispatch(setContainerID(thisSession.user.id));
// store.dispatch(setAccountDetails(accountDetails));
// store.dispatch(setFilesForAppeal(blobList));
// return {
// props: { url: process.env.NEXTAUTH_URL },
// };
// }
// );
// const mapStateToProps = (state) => {
// return {
// search: state.search,
// searchResultsObj: state.searchResultsObj,
// formData: state.formData,
// appealType: state.appealType,
// form: state.form,
// accountDetails: state.accountDetails,
// awaitingSubmission: state.awaitingSubmission,
// currentView: state.currentView,
// initialValues: state.appealType.caseReference.caseDetails,
// };
// };
// const mapDispatchToProps = (dispatch) => {
// return {
// setFormTitle: (title) => {
// dispatch(setAppealTypeTitle(title));
// },
// setCaseReference: (refno) => {
// dispatch(setCaseReference(refno));
// },
// setFilesForAppeal: (blobList) => {
// dispatch(setFilesForAppeal(blobList));
// },
// };
// };
// export default connect(mapStateToProps, mapDispatchToProps)(Home);
// pages/myportal/[appealtypes].js
import { JSONPath as jsonpath } from "jsonpath-plus";
import xpath from "xpath";
-315
View File
@@ -1,318 +1,3 @@
// import fs from "fs";
// import { JSONPath as jsonpath } from "jsonpath-plus";
// import useTranslation from "next-translate/useTranslation";
// import Head from "next/head";
// import { useRouter } from "next/router";
// import { useEffect } from "react";
// import { connect } from "react-redux";
// import xpath from "xpath";
// import Breadcrumbs from "../../components/breadcrumbs";
// import CookieBanner from "../../components/cookieBanner";
// import Footer from "../../components/footer";
// import Header from "../../components/header";
// import BuildCheckSection from "../../components/newappeal/buildchecksection";
// import BuildSection from "../../components/newappeal/buildsection";
// import CompleteAppeal from "../../components/newappeal/complete";
// import TimeOut from "../../components/timeout";
// import { getSession } from "next-auth/react";
// import {
// setContainerID,
// setLoggedInUserEmail,
// setLoggedInUserId,
// setAccountDetails,
// } from "../../store/accountDetails/action";
// import {
// setAppealLPA,
// setAppealType,
// setAppealTypeID,
// setAppealTypeTitle,
// setCaseReference,
// } from "../../store/appealType/action";
// import { setForm } from "../../store/formData/action";
// import { wrapper } from "../../store/store";
// import ServiceBanner from "../../components/myportal/servicebanner";
// let Home = (props) => {
// const { footerLinks, pages, formData } = props;
// let { t, lang } = useTranslation();
// const router = useRouter();
// const { locale } = router;
// const { appealtypes } = router.query;
// useEffect(() => {
// //setFormTitle(formTitle);
// setCaseReference(router.query.refno);
// }, []); // eslint-disable-line react-hooks/exhaustive-deps
// const formXML = props.formData.formData;
// const parser = new DOMParser();
// var doc = parser.parseFromString(formXML, "text/xml");
// var titles = xpath.select(
// "//form/tabs/tab[*]/labels/label[@description]/@description",
// doc
// );
// var sectionCount = xpath.select("/form/tabs/tab[*]", doc);
// sectionCount = sectionCount.length;
// var tabs = xpath.select("//form/tabs/tab[*]", doc);
// let optionsStr = props.appealType.appealTypeOptions.value;
// let selectedObj = jsonpath({
// path: "$..[?(@ && @.attributevalue=='" + router.query.apt + "')]",
// json: optionsStr,
// eval: true,
// });
// //let optionsTitleObj = [];
// //const optionsTitleObj = selectedObj.reduce(
// // (obj, arrValue) => (
// // (obj[arrValue] = arrValue
// // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
// // .toLowerCase()
// // .slice(0, 39)),
// // obj
// // ),
// // {}
// // );
// const formTitle = selectedObj[0].value;
// const { onSubmit } = props;
// return (
// <div>
// <Head>
// <title>
// {t("newappeal:page-title")} - {t("common:service-name")}
// </title>
// <>
// <link
// rel="canonical"
// href={t("common:gov-wales-link") + router.asPath}
// />
// <meta
// key="og:locale"
// property="og:locale"
// content={router.locale}
// />
// {/* If they have a Twitter Handle, include the meta details below */}
// <meta
// key="og:site_name"
// property="og:site_name"
// content={t("common:service-name")}
// />
// <meta
// key="twitter:site"
// property="twitter:site"
// content="@UKGovWales"
// />
// <meta
// name="description"
// content={t("common:service-description")}
// />
// <meta
// property="og:site_name"
// content={t("common:gov-wales-label")}
// />
// <meta
// property="og:title"
// content={t("newappeal:page-title")}
// />
// <meta
// property="og:description"
// content={t("common:service-description")}
// />
// <meta property="og:type" content="website" />
// <meta
// property="og:url"
// content={t("common:gov-wales-link")}
// />
// <meta
// property="og:image"
// content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
// />
// <meta name="twitter:card" content="summary" />
// <meta
// name="twitter:title"
// content={t("common:gov-wales-label")}
// />
// <meta
// name="twitter:url"
// content={t("common:gov-wales-link") + router.asPath}
// />
// <meta
// name="twitter:image"
// content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
// />
// </>
// </Head>
// <div id="page_wrapper">
// <CookieBanner />
// <Header />
// <div className="govuk-width-container">
// <Breadcrumbs slug={appealtypes} formTitle={formTitle} />
// <ServiceBanner props={props} />
// <main
// className="govuk-main-wrapper--auto-spacing"
// id="main-content"
// role="main"
// >
// {props.appealType.currentSection == 9999 ? (
// <CompleteAppeal props={props} />
// ) : props.appealType.currentSection ==
// sectionCount + 1 ? (
// <BuildCheckSection
// formXML={formXML}
// sectionCount={sectionCount}
// onSubmit={onSubmit}
// formTitle={formTitle}
// appealType={props.appealType}
// props={props}
// key={1}
// mandatoryFieldsData={
// props.formData.mandatoryFieldsData
// }
// />
// ) : (
// <>
// <BuildSection
// formXML={formXML}
// sectionCount={sectionCount}
// onSubmit={onSubmit}
// formTitle={formTitle}
// mandatoryFieldsData={
// props.formData.mandatoryFieldsData
// }
// props={props}
// />
// </>
// )}
// </main>
// </div>
// <Footer footerLinks={footerLinks} ticketnumber={props} />
// </div>
// <TimeOut />
// </div>
// );
// };
// export const getServerSideProps = wrapper.getServerSideProps(
// (store) => async (ctx) => {
// const { query, req, res } = ctx;
// getIP(req);
// const { cookies } = req;
// console.log(cookies);
// console.log("the query", query);
// console.log("ref:", query.id);
// let loggedInUser = cookies.pinsUser;
// let thisSession = await getSession(ctx);
// //console.log("nextAuth Session:", thisSession);
// if (!thisSession) {
// console.log("not has sesssion.......");
// return {
// redirect: {
// destination: "/auth/signin",
// permanent: false,
// },
// };
// }
// let loggedInUserIdent = thisSession.user.id;
// let loggedInUserEmail = thisSession.user.email;
// console.log("logged ident:", loggedInUserIdent, loggedInUserEmail);
// const [
// appealTypeData,
// mandatoryFieldsData,
// pickListData,
// //blobList,
// ] = await Promise.all([
// await getAppealsTypesForNewAppeal(),
// await getMandatoryFields(query.appealtypes),
// await getPickLists(query.appealtypes),
// //await getFilesFromBlob(query.casereference),
// ]);
// const blobProgress = await getProgressFromBlob(
// loggedInUserIdent,
// query.id
// );
// const accountDetails = await getPersonalAccount(loggedInUser);
// console.log("anything here", loggedInUser, query.id, blobProgress);
// let caseReference = {};
// caseReference.ticketnumber = query.id;
// caseReference.incidentid = query.id;
// caseReference.caseDetails = blobProgress; //searchDetailsObj;
// var path = require("path");
// const configDirectory = path.resolve(process.cwd(), "data/formsxml");
// var xmlStr = fs.readFileSync(
// path.join(configDirectory, query.appealtypes + ".xml"),
// "utf8"
// );
// // xmlStr = formdata.value[0].formxml;
// xmlStr = xmlStr.replace(/\t/g, "");
// xmlStr = xmlStr.replace(/\n/g, "");
// xmlStr = xmlStr.replace(/> <"/g, "><");
// xmlStr = xmlStr.toString();
// store.dispatch(setLoggedInUserId(loggedInUser));
// store.dispatch(setLoggedInUserEmail(loggedInUserEmail));
// store.dispatch(setAppealLPA(query.lpa));
// store.dispatch(setAppealTypeID(query.apt));
// store.dispatch(setCaseReference(caseReference));
// store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
// store.dispatch(setAppealType(appealTypeData));
// store.dispatch(setContainerID(thisSession.user.id));
// store.dispatch(setAccountDetails(accountDetails));
// //store.dispatch(setFilesForAppeal(blobList));
// return {
// props: { url: process.env.NEXTAUTH_URL },
// };
// }
// );
// const mapStateToProps = (state) => {
// return {
// search: state.search,
// searchResultsObj: state.searchResultsObj,
// formData: state.formData,
// appealType: state.appealType,
// form: state.form,
// accountDetails: state.accountDetails,
// };
// };
// const mapDispatchToProps = (dispatch) => {
// return {
// setFormTitle: (title) => {
// dispatch(setAppealTypeTitle(title));
// },
// setCaseReference: (refno) => {
// dispatch(setCaseReference(refno));
// },
// };
// };
// export default connect(mapStateToProps, mapDispatchToProps)(Home);
// pages/newappeal/[appealtypes].js
import { JSONPath as jsonpath } from "jsonpath-plus";
import xpath from "xpath";