From 8239d9ff77c4bbbc2c03612bc973110400e6b80a Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 7 Oct 2024 09:51:10 +0100 Subject: [PATCH] added in info banner for case summary --- actions/index.js | 12 ++++ components/case.js | 1 + components/case/caseNoticeBanner.js | 83 ++++++++++++++++++++++++ components/case/summary.js | 7 +- locales/cy/case.json | 3 +- locales/en/case.json | 3 +- pages/api/endpoint/getcasemessage_api.js | 74 +++++++++++++++++++++ pages/case/[ticketnumber].js | 5 ++ pages/myportal/case/[ticketnumber].js | 5 ++ styles/sass/welshgov/_application.scss | 3 +- 10 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 components/case/caseNoticeBanner.js create mode 100644 pages/api/endpoint/getcasemessage_api.js diff --git a/actions/index.js b/actions/index.js index cda58bdc..16f16f00 100644 --- a/actions/index.js +++ b/actions/index.js @@ -227,6 +227,18 @@ export const getBasicSearch = (searchString) => { }); }; +export const getCaseMessage = (searchString) => { + return axios + .get(BASE_URL + "/api/endpoint/getcasemessage_api?id=" + searchString) + .then((res) => { + return res.data; + }) + .catch((error) => { + consoleLogger(error); + return error.response; + }); +}; + export const getIncidentbyID = (searchString) => { return axios .get( diff --git a/components/case.js b/components/case.js index f829bd44..b7d10f44 100644 --- a/components/case.js +++ b/components/case.js @@ -36,6 +36,7 @@ const Case = (props) => { incidentid={props.incidentid} showMap={props.showMap} currentView={props.currentView} + messagesObj={props.messagesObj} /> + {messagesObjArr.map((message, index) => ( +
+ + Warning + +
+
+

+ {( + message.subject.match( + new RegExp(">>>", "g") + ) || [] + ).length > 0 + ? router.locale == "cy" + ? message.subject + .split("Banner ")[1] + .split(">>>")[1] + : message.subject + .split("Banner ")[1] + .split(">>>")[0] + : ( + message.subject.match( + new RegExp(";", "g") + ) || [] + ).length > 0 + ? router.locale == "cy" + ? message.subject + .split("Banner ")[1] + .split(";")[1] + : message.subject + .split("Banner ")[1] + .split(";")[0] + : message.subject.split("Banner ")[1]} +

+
+
+ {( + message.description.match( + new RegExp(">>>", "g") + ) || [] + ).length > 0 + ? router.locale == "cy" + ? message.description.split(">>>")[1] + : message.description.split(">>>")[0] + : ( + message.description.match( + new RegExp(";", "g") + ) || [] + ).length > 0 + ? router.locale == "cy" + ? message.description.split(";")[1] + : message.description.split(";")[0] + : message.description} +
+
+ {t("case:date-raised")}:{" "} + {formatDates(message.createdon)} +
+
+
+ ))} + + ); +} diff --git a/components/case/summary.js b/components/case/summary.js index e802f4a6..39a7888d 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -54,7 +54,7 @@ import Pinswg_planningobligationappeals106id from "./summaryTypes/pinswg_plannin import Pinswg_rowid from "./summaryTypes/pinswg_rowid"; import Pinswg_transportandworkactid from "./summaryTypes/pinswg_transportandworkactid"; import Pinswg_wayleaveid from "./summaryTypes/pinswg_wayleaveid"; - +import CaseNoticeBanner from "./caseNoticeBanner"; const CaseSummary = (props) => { let { t } = useTranslation(); @@ -79,6 +79,7 @@ const CaseSummary = (props) => { setWatchedCasesDetails, showMap, currentView, + messagesObj, } = props; const showLoginCheck = @@ -224,7 +225,9 @@ const CaseSummary = (props) => { ? casesObj.pinswg_title : casesObj.reference} - + {props.messagesObj["@odata.count"] > 0 && ( + + )}
diff --git a/locales/cy/case.json b/locales/cy/case.json index b1f3a287..b36d34ea 100644 --- a/locales/cy/case.json +++ b/locales/cy/case.json @@ -97,5 +97,6 @@ "do-you-want-to-delete-case-label": "Ydych chi am ddileu achos", "do-you-want-to-delete-case-disclaimer-label": "Unwaith y caiff ei dileu, bydd yr holl wybodaeth a gyflwynwyd gennych yn cael ei cholli.", "representation-date-passed-label": "Y cyfnod cynrychioli ar gyfer yr apĂȘl hon yw rhwng {{startDate}} a {{endDate}}", - "representation-date-passed-additional-label": "Gallwch wneud sylw drwy e-bostio," + "representation-date-passed-additional-label": "Gallwch wneud sylw drwy e-bostio,", + "date-raised": "Dyddiad codi" } \ No newline at end of file diff --git a/locales/en/case.json b/locales/en/case.json index e5ba50d7..62ee9e92 100644 --- a/locales/en/case.json +++ b/locales/en/case.json @@ -97,5 +97,6 @@ "do-you-want-to-delete-case-label": "Do you want to delete case ", "do-you-want-to-delete-case-disclaimer-label": "Once deleted all information you have submited, will be lost.", "representation-date-passed-label": "The representation period for this appeal is between {{startDate}} and {{endDate}}", - "representation-date-passed-additional-label": "You can make a representation by emailing," + "representation-date-passed-additional-label": "You can make a representation by emailing,", + "date-raised": "Date raised" } \ No newline at end of file diff --git a/pages/api/endpoint/getcasemessage_api.js b/pages/api/endpoint/getcasemessage_api.js new file mode 100644 index 00000000..6f96f4fb --- /dev/null +++ b/pages/api/endpoint/getcasemessage_api.js @@ -0,0 +1,74 @@ +/** + * @swagger + * /api/endpoint/getmessage_api: + * get: + * tags: [Search] + * description: Gets banner message from activities + * parameters: + * - name: searchString + * in: query + * required: true + * schema: + * type: string + * responses: + * 200: + * description: Success + */ + +import axios from "axios"; +import CryptoJS from "crypto-js"; +import _ from "lodash"; +import { azureHeadersPaged, consoleLogger, getToken } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var searchString = req.query.id; + var token = await getToken(); + + var queryUrl = `tasks?$select=_regardingobjectid_value,subject,description,createdon,statuscode,scheduledend,scheduledstart&$count=true&$filter=_regardingobjectid_value eq ${searchString} and contains(subject, 'Banner') and statuscode ne 5&$orderby=createdon desc`; + + console.log( + "\n==========================================\n", + "\nCase messages ", + "\nSearch String: " + searchString, + "\n\nQuery url: " + queryUrl, + "\n\nRelay link: " + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + "\n==========================================\n" + ); + + var apiResponse = _.isEmpty(req.query) + ? res.status(400).json() + : searchString.length > 0 + ? axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch((error) => { + consoleLogger(error); + res.status(400).json(error); + }) + : res.status(400).json(); + + return apiResponse; +} diff --git a/pages/case/[ticketnumber].js b/pages/case/[ticketnumber].js index ee903caa..2ad53a95 100644 --- a/pages/case/[ticketnumber].js +++ b/pages/case/[ticketnumber].js @@ -5,6 +5,7 @@ import { useRouter } from "next/router"; import { connect } from "react-redux"; import { getBasicSearch, + getCaseMessage, getIP, getPersonalAccount, getPortalLogin, @@ -90,6 +91,7 @@ const CaseHome = (props) => { props.searchResultsObj.representationsObj } showLoginCheck={true} + messagesObj={props.messagesObj} />