Merged PR 2285: tweak to live link

tweak to live link

Related work items: #22423
This commit is contained in:
Robert Bond
2026-04-29 17:03:50 +00:00
parent baf5b1838d
commit 9140476a2a
5 changed files with 37 additions and 34 deletions
+8 -2
View File
@@ -6,9 +6,15 @@ export function isEventLiveNow(item) {
if (isNaN(start.getTime())) return false;
if (item.pinswg_enddateoftheevent) {
const end = new Date(item.pinswg_enddateoftheevent);
const endDateValue =
item.pinswg_enddateofevent || item.pinswg_enddateoftheevent;
if (endDateValue) {
const end = new Date(endDateValue);
if (isNaN(end.getTime())) return false;
end.setHours(23, 59, 59, 999);
return now >= start && now <= end;
}
+8 -24
View File
@@ -1,32 +1,16 @@
import Link from "next/link";
import useTranslation from "next-translate/useTranslation";
const isSameDay = (dateA, dateB) =>
dateA.getFullYear() === dateB.getFullYear() &&
dateA.getMonth() === dateB.getMonth() &&
dateA.getDate() === dateB.getDate();
const getLiveEvent = (detailsObj) => {
const events = detailsObj?.pinswg_sips_pinswg_sipsevent || [];
if (!Array.isArray(events) || events.length === 0) return null;
const now = new Date();
return events.find((event) => {
if (!event?.pinswg_dateeventrequested) return false;
const eventDate = new Date(event.pinswg_dateeventrequested);
return isSameDay(eventDate, now);
});
};
import { getLivePublishedEvent } from "../case/summary/utils/liveEvent";
const LiveLink = ({ detailsObj }) => {
let { t } = useTranslation();
const liveEvent = getLiveEvent(detailsObj);
if (!liveEvent || !liveEvent.pinswg_linktotheevent) return null;
const eventsObj = {
value: detailsObj?.pinswg_sips_pinswg_sipsevent || []
};
const liveEvent = getLivePublishedEvent(eventsObj);
if (!liveEvent) return null;
return (
<div className="govuk-!-margin-top-3">
+17 -5
View File
@@ -27,7 +27,8 @@ module.exports = {
"search",
"dnsCommon",
"dnsApplications",
"case"
"case",
"case-stages"
],
"/myportal/dnsdetails": [
"case",
@@ -36,7 +37,13 @@ module.exports = {
"dnsApplications"
],
"/myportal/dns/*": ["dnsCommon", "case", "common"],
"/myportal/dns/[developmentName]": ["dnsCommon", "case", "common"],
"/myportal/dns/[developmentName]": [
"dnsCommon",
"case",
"common",
,
"case-stages"
],
"/advancedsearch": ["search", "myportal"],
"/advancedsearchresults": ["search", "case"],
"/searchresults": ["search", "case"],
@@ -63,9 +70,14 @@ module.exports = {
"/newappeal/*": ["newappeal", "home"],
"/newappeal/[appealtypes]": ["newappeal", "home", "myportal"],
"/newappeal/selectappeal": ["newappeal", "home"],
"/dns/*": ["dnsCommon", "case", "common"],
"/dns/[developmentName]": ["dnsCommon", "case", "common"],
"/dns": ["dnsCommon", "dnsHome"],
"/dns/*": ["dnsCommon", "case", "common", "case-stages"],
"/dns/[developmentName]": [
"dnsCommon",
"case",
"common",
"case-stages"
],
"/dns": ["dnsCommon", "dnsHome", , "case-stages"],
"/dns/applications": ["dnsCommon", "dnsApplications"],
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
"/dnsapplications": ["search", "dnsCommon", "dnsApplications", "case"],
@@ -88,7 +88,7 @@ export default async function ApiProxy(req, res) {
navigationProperty +
"($select=ticketnumber,statuscode)" +
(primaryIdAttribute == "pinswg_sipscase"
? ",pinswg_sipscase($select=ticketnumber),pinswg_CaseDeadlineExtension_pinswg_sips($select=pinswg_casedeadlineextensionid,pinswg_noofdaysextended,pinswg_reasonforextension,pinswg_agreedorimposedextension,pinswg_newcasedeadline),pinswg_sips_pinswg_sipsevent($select=pinswg_linktotheevent,pinswg_name,pinswg_dateeventrequested,pinswg_typeofevent,createdon,modifiedon)"
? ",pinswg_sipscase($select=ticketnumber),pinswg_CaseDeadlineExtension_pinswg_sips($select=pinswg_casedeadlineextensionid,pinswg_noofdaysextended,pinswg_reasonforextension,pinswg_agreedorimposedextension,pinswg_newcasedeadline),pinswg_sips_pinswg_sipsevent($select=pinswg_eventpublishflag,pinswg_linktotheevent,pinswg_name,pinswg_dateeventrequested,pinswg_typeofevent,createdon,modifiedon)"
: "");
queryUrl =
+3 -2
View File
@@ -30,7 +30,8 @@ import {
setMediaDetails
} from "../../../store/searchOutput/action";
import { wrapper } from "../../../store/store";
import ServiceBanner from "../../../components/servicebanner";
import ServiceBanner from "../../../components/myportal/servicebanner";
const CaseHome = (props) => {
const {
footerLinks,
@@ -61,7 +62,7 @@ const CaseHome = (props) => {
<Header serviceName="Developments of National Significance" />
<div className="govuk-width-container">
<Breadcrumbs slug={developmentName} props={props} />
<ServiceBanner />
<ServiceBanner props={props} />
<Case
props={props}
myCases={props.myCases.myCases}