Merged PR 2285: tweak to live link
tweak to live link Related work items: #22423
This commit is contained in:
@@ -6,9 +6,15 @@ export function isEventLiveNow(item) {
|
|||||||
|
|
||||||
if (isNaN(start.getTime())) return false;
|
if (isNaN(start.getTime())) return false;
|
||||||
|
|
||||||
if (item.pinswg_enddateoftheevent) {
|
const endDateValue =
|
||||||
const end = new Date(item.pinswg_enddateoftheevent);
|
item.pinswg_enddateofevent || item.pinswg_enddateoftheevent;
|
||||||
|
|
||||||
|
if (endDateValue) {
|
||||||
|
const end = new Date(endDateValue);
|
||||||
if (isNaN(end.getTime())) return false;
|
if (isNaN(end.getTime())) return false;
|
||||||
|
|
||||||
|
end.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
return now >= start && now <= end;
|
return now >= start && now <= end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,16 @@
|
|||||||
import Link from "next/link";
|
|
||||||
import useTranslation from "next-translate/useTranslation";
|
import useTranslation from "next-translate/useTranslation";
|
||||||
|
import { getLivePublishedEvent } from "../case/summary/utils/liveEvent";
|
||||||
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);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const LiveLink = ({ detailsObj }) => {
|
const LiveLink = ({ detailsObj }) => {
|
||||||
let { t } = useTranslation();
|
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 (
|
return (
|
||||||
<div className="govuk-!-margin-top-3">
|
<div className="govuk-!-margin-top-3">
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ module.exports = {
|
|||||||
"search",
|
"search",
|
||||||
"dnsCommon",
|
"dnsCommon",
|
||||||
"dnsApplications",
|
"dnsApplications",
|
||||||
"case"
|
"case",
|
||||||
|
"case-stages"
|
||||||
],
|
],
|
||||||
"/myportal/dnsdetails": [
|
"/myportal/dnsdetails": [
|
||||||
"case",
|
"case",
|
||||||
@@ -36,7 +37,13 @@ module.exports = {
|
|||||||
"dnsApplications"
|
"dnsApplications"
|
||||||
],
|
],
|
||||||
"/myportal/dns/*": ["dnsCommon", "case", "common"],
|
"/myportal/dns/*": ["dnsCommon", "case", "common"],
|
||||||
"/myportal/dns/[developmentName]": ["dnsCommon", "case", "common"],
|
"/myportal/dns/[developmentName]": [
|
||||||
|
"dnsCommon",
|
||||||
|
"case",
|
||||||
|
"common",
|
||||||
|
,
|
||||||
|
"case-stages"
|
||||||
|
],
|
||||||
"/advancedsearch": ["search", "myportal"],
|
"/advancedsearch": ["search", "myportal"],
|
||||||
"/advancedsearchresults": ["search", "case"],
|
"/advancedsearchresults": ["search", "case"],
|
||||||
"/searchresults": ["search", "case"],
|
"/searchresults": ["search", "case"],
|
||||||
@@ -63,9 +70,14 @@ module.exports = {
|
|||||||
"/newappeal/*": ["newappeal", "home"],
|
"/newappeal/*": ["newappeal", "home"],
|
||||||
"/newappeal/[appealtypes]": ["newappeal", "home", "myportal"],
|
"/newappeal/[appealtypes]": ["newappeal", "home", "myportal"],
|
||||||
"/newappeal/selectappeal": ["newappeal", "home"],
|
"/newappeal/selectappeal": ["newappeal", "home"],
|
||||||
"/dns/*": ["dnsCommon", "case", "common"],
|
"/dns/*": ["dnsCommon", "case", "common", "case-stages"],
|
||||||
"/dns/[developmentName]": ["dnsCommon", "case", "common"],
|
"/dns/[developmentName]": [
|
||||||
"/dns": ["dnsCommon", "dnsHome"],
|
"dnsCommon",
|
||||||
|
"case",
|
||||||
|
"common",
|
||||||
|
"case-stages"
|
||||||
|
],
|
||||||
|
"/dns": ["dnsCommon", "dnsHome", , "case-stages"],
|
||||||
"/dns/applications": ["dnsCommon", "dnsApplications"],
|
"/dns/applications": ["dnsCommon", "dnsApplications"],
|
||||||
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
|
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
|
||||||
"/dnsapplications": ["search", "dnsCommon", "dnsApplications", "case"],
|
"/dnsapplications": ["search", "dnsCommon", "dnsApplications", "case"],
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
navigationProperty +
|
navigationProperty +
|
||||||
"($select=ticketnumber,statuscode)" +
|
"($select=ticketnumber,statuscode)" +
|
||||||
(primaryIdAttribute == "pinswg_sipscase"
|
(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 =
|
queryUrl =
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ import {
|
|||||||
setMediaDetails
|
setMediaDetails
|
||||||
} from "../../../store/searchOutput/action";
|
} from "../../../store/searchOutput/action";
|
||||||
import { wrapper } from "../../../store/store";
|
import { wrapper } from "../../../store/store";
|
||||||
import ServiceBanner from "../../../components/servicebanner";
|
import ServiceBanner from "../../../components/myportal/servicebanner";
|
||||||
|
|
||||||
const CaseHome = (props) => {
|
const CaseHome = (props) => {
|
||||||
const {
|
const {
|
||||||
footerLinks,
|
footerLinks,
|
||||||
@@ -61,7 +62,7 @@ const CaseHome = (props) => {
|
|||||||
<Header serviceName="Developments of National Significance" />
|
<Header serviceName="Developments of National Significance" />
|
||||||
<div className="govuk-width-container">
|
<div className="govuk-width-container">
|
||||||
<Breadcrumbs slug={developmentName} props={props} />
|
<Breadcrumbs slug={developmentName} props={props} />
|
||||||
<ServiceBanner />
|
<ServiceBanner props={props} />
|
||||||
<Case
|
<Case
|
||||||
props={props}
|
props={props}
|
||||||
myCases={props.myCases.myCases}
|
myCases={props.myCases.myCases}
|
||||||
|
|||||||
Reference in New Issue
Block a user