diff --git a/components/case/events.js b/components/case/events.js index 958e90d1..6867d3dd 100644 --- a/components/case/events.js +++ b/components/case/events.js @@ -3,6 +3,10 @@ import { setCurrentPage } from "../../store/currentView/action"; import { connect } from "react-redux"; import useTranslation from "next-translate/useTranslation"; import { formatDates } from "../utils"; +import { + getLivePublishedEvent, + isEventLiveNow +} from "./summary/utils/liveEvent"; const EventsDetails = (props) => { let { t } = useTranslation(); @@ -23,8 +27,6 @@ const EventsDetails = (props) => { return obj.hasOwnProperty(property) && obj[property] !== null; } - //console.log(eventsArr.length > 0); - return ( eventsArr.length > 0 && (
@@ -63,76 +65,26 @@ const EventsDetails = (props) => { {item.pinswg_eventname}
)} - -
{hasOwnPropertyAndNotNull( item, - "pinswg_eventaddressline1" - ) && ( - <> -
- - {t( - "case:event-address-label" - )} - - : -
-
- { - item.pinswg_eventaddressline1 - } -
- - )} - - {hasOwnPropertyAndNotNull( - item, - "pinswg_eventaddressline2" + [ + "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" + ] ) && (
+ + {t( + "case:event-type-of-event-label" + )} + + :{" "} { - item.pinswg_eventaddressline2 + item[ + "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" + ] }
)} - {hasOwnPropertyAndNotNull( - item, - "pinswg_eventaddresstown" - ) && ( -
- { - item.pinswg_eventaddresstown - } -
- )} - {hasOwnPropertyAndNotNull( - item, - "pinswg_eventaddresscounty" - ) && ( -
- { - item.pinswg_eventaddresscounty - } -
- )} - {hasOwnPropertyAndNotNull( - item, - "pinswg_eventaddresscounty" - ) && ( -
- { - item.pinswg_eventaddresspostcode - } -
- )} -
- {/* type of event - start date date of event - end date of event - - if virtual event no address showNoOfRecords - show event address */} -
{hasOwnPropertyAndNotNull( item, "pinswg_dateeventrequested" @@ -171,25 +123,109 @@ const EventsDetails = (props) => {
{hasOwnPropertyAndNotNull( item, - [ - "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue", - ] + "pinswg_eventaddressline1" ) && ( -
- - {t( - "case:event-type-of-event-label" - )} - - :{" "} - { - item[ - "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" - ] - } -
+ <> +
+ + {t( + "case:event-address-label" + )} + + : +
+ {hasOwnPropertyAndNotNull( + item, + "pinswg_eventaddressline1" + ) && ( + + { + item.pinswg_eventaddressline1 + } + + )} + {hasOwnPropertyAndNotNull( + item, + "pinswg_eventaddressline2" + ) && ( + + { + item.pinswg_eventaddressline2 + } + + )} + {hasOwnPropertyAndNotNull( + item, + "pinswg_eventaddresstown" + ) && ( + + { + item.pinswg_eventaddresstown + } + + )} + {hasOwnPropertyAndNotNull( + item, + "pinswg_eventaddresscounty" + ) && ( + + { + item.pinswg_eventaddresscounty + } + + )} + {hasOwnPropertyAndNotNull( + item, + "pinswg_eventaddresscounty" + ) && ( + + { + item.pinswg_eventaddresspostcode + } + + )} +
+
+ )}
+ {/* type of event + start date date of event - end date of event + + if virtual event no address showNoOfRecords + show event address */} + + {hasOwnPropertyAndNotNull( + item, + "pinswg_linktotheevent" + ) && + isEventLiveNow(item) && ( +
+ + Watch live stream + +
+ )}
) @@ -203,7 +239,7 @@ const EventsDetails = (props) => { const mapStateToProps = (state) => { return { - ...state, + ...state }; }; @@ -214,7 +250,7 @@ const mapDispatchToProps = (dispatch) => { }, setCurrentPage: (currentPage) => { dispatch(setCurrentPage(currentPage)); - }, + } }; }; diff --git a/components/case/summary.js b/components/case/summary.js index 6cc08be5..02548408 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -32,6 +32,10 @@ import { import { signIn, useSession } from "next-auth/react"; import { destroyCookie, parseCookies, setCookie } from "nookies"; import { getFormCollectionByID, getDetailsProxy } from "../utils"; +import { + getLivePublishedEvent, + isEventLiveNow +} from "./summary/utils/liveEvent"; import * as CaseTypes from "./summaryTypes"; // ✅ must match filename exactly import { @@ -321,6 +325,10 @@ const CaseSummary = (props) => { Array.isArray(props.mediaObj?.value) && props.mediaObj.value.length > 0; + const livePublishedEvent = hasEventsTabData + ? getLivePublishedEvent(props.eventsObj) + : null; + let point = {}; let siteCoords = {}; let center = {}; @@ -359,6 +367,45 @@ const CaseSummary = (props) => { showDetails == true ? ( <>
+ {livePublishedEvent && ( +
+
+

+ Live event +

+
+
+

+ A live streamed event is happening now. +

+ + {livePublishedEvent.pinswg_eventname && ( +

+ {livePublishedEvent.pinswg_eventname} +

+ )} + + + Watch live stream + +
+
+ )}

@@ -373,6 +420,7 @@ const CaseSummary = (props) => {

+

Contents