Merged PR 1255: added in info banner for case summary

added in info banner for case summary

Related work items: #12376
This commit is contained in:
Robert Bond
2024-10-07 08:55:58 +00:00
10 changed files with 190 additions and 6 deletions
+12
View File
@@ -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) => { export const getIncidentbyID = (searchString) => {
return axios return axios
.get( .get(
+1
View File
@@ -36,6 +36,7 @@ const Case = (props) => {
incidentid={props.incidentid} incidentid={props.incidentid}
showMap={props.showMap} showMap={props.showMap}
currentView={props.currentView} currentView={props.currentView}
messagesObj={props.messagesObj}
/> />
<Documents <Documents
incidentid={props.incidentid} incidentid={props.incidentid}
+83
View File
@@ -0,0 +1,83 @@
import cookie from "cookie-cutter";
import useTranslation from "next-translate/useTranslation";
import { useRouter } from "next/router";
import { useState } from "react";
import { formatDates } from "../utils";
export default function CaseNoticeBanner(props) {
let { t, lang } = useTranslation();
const { messagesObj } = props;
const router = useRouter();
const noticeContent = messagesObj.value[0].description;
const noticeTitle = messagesObj.value[0].subject.split("Banner ")[1];
const bannerOpenCookie = typeof cookie.get("pedwNotice") == "undefined";
let messagesObjArr = messagesObj.value;
return (
<>
{messagesObjArr.map((message, index) => (
<div className="govuk-warning-text noticebanner" key={index}>
<strong className="govuk-warning-text__text">
<span className="govuk-visually-hidden">Warning</span>
</strong>
<div>
<div className=" govuk-body-s">
<h2 className="govuk-heading-s">
{(
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]}
</h2>
</div>
<div className="govuk-body-s">
{(
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}
</div>
<div className="govuk-body-xs govuk-!-margin-bottom-0 ">
{t("case:date-raised")}:{" "}
{formatDates(message.createdon)}
</div>
</div>
</div>
))}
</>
);
}
+5 -2
View File
@@ -54,7 +54,7 @@ import Pinswg_planningobligationappeals106id from "./summaryTypes/pinswg_plannin
import Pinswg_rowid from "./summaryTypes/pinswg_rowid"; import Pinswg_rowid from "./summaryTypes/pinswg_rowid";
import Pinswg_transportandworkactid from "./summaryTypes/pinswg_transportandworkactid"; import Pinswg_transportandworkactid from "./summaryTypes/pinswg_transportandworkactid";
import Pinswg_wayleaveid from "./summaryTypes/pinswg_wayleaveid"; import Pinswg_wayleaveid from "./summaryTypes/pinswg_wayleaveid";
import CaseNoticeBanner from "./caseNoticeBanner";
const CaseSummary = (props) => { const CaseSummary = (props) => {
let { t } = useTranslation(); let { t } = useTranslation();
@@ -79,6 +79,7 @@ const CaseSummary = (props) => {
setWatchedCasesDetails, setWatchedCasesDetails,
showMap, showMap,
currentView, currentView,
messagesObj,
} = props; } = props;
const showLoginCheck = const showLoginCheck =
@@ -224,7 +225,9 @@ const CaseSummary = (props) => {
? casesObj.pinswg_title ? casesObj.pinswg_title
: casesObj.reference} : casesObj.reference}
</h1> </h1>
{props.messagesObj["@odata.count"] > 0 && (
<CaseNoticeBanner messagesObj={props.messagesObj} />
)}
<dl className="govuk-summary-list govuk-!-margin-bottom-9"> <dl className="govuk-summary-list govuk-!-margin-bottom-9">
<div className="govuk-summary-list__row"> <div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key"> <dt className="govuk-summary-list__key">
+2 -1
View File
@@ -97,5 +97,6 @@
"do-you-want-to-delete-case-label": "Ydych chi am ddileu achos", "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.", "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-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"
} }
+2 -1
View File
@@ -97,5 +97,6 @@
"do-you-want-to-delete-case-label": "Do you want to delete case ", "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.", "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-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"
} }
+74
View File
@@ -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;
}
+5
View File
@@ -5,6 +5,7 @@ import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { import {
getBasicSearch, getBasicSearch,
getCaseMessage,
getIP, getIP,
getPersonalAccount, getPersonalAccount,
getPortalLogin, getPortalLogin,
@@ -90,6 +91,7 @@ const CaseHome = (props) => {
props.searchResultsObj.representationsObj props.searchResultsObj.representationsObj
} }
showLoginCheck={true} showLoginCheck={true}
messagesObj={props.messagesObj}
/> />
</div> </div>
<Footer <Footer
@@ -208,6 +210,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
// }, // },
currentType: "directResultsObj", currentType: "directResultsObj",
docsOffline: process.env.DOCAPI_OFFLINE || false, docsOffline: process.env.DOCAPI_OFFLINE || false,
messagesObj: await getCaseMessage(
searchResultsObj.value[0].incidentid
),
}, },
}; };
} }
+5
View File
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { import {
getBasicSearch, getBasicSearch,
getCaseMessage,
getIP, getIP,
getMyCases, getMyCases,
getMyLPACases, getMyLPACases,
@@ -100,6 +101,7 @@ const CaseHome = (props) => {
props.searchResultsObj.representationsObj props.searchResultsObj.representationsObj
} }
showLoginCheck={true} showLoginCheck={true}
messagesObj={props.messagesObj}
/> />
</div> </div>
<Footer <Footer
@@ -340,6 +342,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
// }, // },
currentType: "directResultsObj", currentType: "directResultsObj",
docsOffline: process.env.DOCAPI_OFFLINE || false, docsOffline: process.env.DOCAPI_OFFLINE || false,
messagesObj: await getCaseMessage(
searchResultsObj.value[0].incidentid
),
}, },
}; };
} }
+1 -2
View File
@@ -2642,7 +2642,6 @@ fade {
border-left: 10px solid $blue; border-left: 10px solid $blue;
color: $black; color: $black;
display: flex; display: flex;
justify-content: space-between;
font-size: 18px; font-size: 18px;
padding: 20px 20px 30px 5px; padding: 20px 20px 30px 5px;
margin-top: 20px; margin-top: 20px;
@@ -2673,7 +2672,7 @@ fade {
display: block; display: block;
float: left; float: left;
left: -14px; left: -14px;
top: -40%;
} }
} }