Merged PR 2266: update media tabs display and query
update media tabs display and query Related work items: #22698
This commit is contained in:
@@ -459,7 +459,7 @@ const MediaDetails = ({ mediaObj, whichTab, title, useNoCookie = true }) => {
|
|||||||
.map((item) => {
|
.map((item) => {
|
||||||
const link = isWelsh
|
const link = isWelsh
|
||||||
? item.pinswg_mediaLinkCY
|
? item.pinswg_mediaLinkCY
|
||||||
: item.pinswg_mediaLinkEN;
|
: item.pinswg_videoplatformurl;
|
||||||
|
|
||||||
const videoId = extractYouTubeId(link);
|
const videoId = extractYouTubeId(link);
|
||||||
if (!videoId) return null;
|
if (!videoId) return null;
|
||||||
@@ -468,15 +468,15 @@ const MediaDetails = ({ mediaObj, whichTab, title, useNoCookie = true }) => {
|
|||||||
key:
|
key:
|
||||||
item.pinswg_documentid ||
|
item.pinswg_documentid ||
|
||||||
item.pinswg_mediaid ||
|
item.pinswg_mediaid ||
|
||||||
`${item.pinswg_name}-${videoId}`,
|
`${item.pinswg_eventrecordingid}-${videoId}`,
|
||||||
videoId,
|
videoId,
|
||||||
name: item.pinswg_name || "Video",
|
name: item.pinswg_eventrecordingname || "Video",
|
||||||
description: item.pinswg_description || "",
|
description: item.pinswg_description || "",
|
||||||
// If you later store duration in CRM, map it here (e.g. "03:42")
|
// If you later store duration in CRM, map it here (e.g. "03:42")
|
||||||
duration: item.pinswg_duration || null,
|
duration: item.pinswg_duration || null,
|
||||||
thumbnailHQ: `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`,
|
thumbnailHQ: `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`,
|
||||||
thumbnailMax: `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`,
|
thumbnailMax: `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`,
|
||||||
raw: item,
|
raw: item
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|||||||
@@ -311,6 +311,16 @@ const CaseSummary = (props) => {
|
|||||||
|
|
||||||
let hasEndDate = typeof d != "undefined";
|
let hasEndDate = typeof d != "undefined";
|
||||||
|
|
||||||
|
const hasEventsTabData =
|
||||||
|
isObjectNotEmpty(props, "eventsObj") &&
|
||||||
|
Array.isArray(props.eventsObj?.value) &&
|
||||||
|
props.eventsObj.value.length > 0;
|
||||||
|
|
||||||
|
const hasMediaTabData =
|
||||||
|
isObjectNotEmpty(props, "mediaObj") &&
|
||||||
|
Array.isArray(props.mediaObj?.value) &&
|
||||||
|
props.mediaObj.value.length > 0;
|
||||||
|
|
||||||
let point = {};
|
let point = {};
|
||||||
let siteCoords = {};
|
let siteCoords = {};
|
||||||
let center = {};
|
let center = {};
|
||||||
@@ -448,7 +458,7 @@ const CaseSummary = (props) => {
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{isObjectNotEmpty(props, "eventsObj") && (
|
{hasEventsTabData && (
|
||||||
<li
|
<li
|
||||||
className={
|
className={
|
||||||
whichTab == "case-events"
|
whichTab == "case-events"
|
||||||
@@ -468,7 +478,7 @@ const CaseSummary = (props) => {
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{isObjectNotEmpty(props, "mediaObj") && (
|
{hasMediaTabData && (
|
||||||
<li
|
<li
|
||||||
className={
|
className={
|
||||||
whichTab == "case-media"
|
whichTab == "case-media"
|
||||||
@@ -1878,7 +1888,7 @@ const CaseSummary = (props) => {
|
|||||||
.PrimaryIdAttribute == "pinswg_sipscase" && (
|
.PrimaryIdAttribute == "pinswg_sipscase" && (
|
||||||
<EIADetails props={props} />
|
<EIADetails props={props} />
|
||||||
)}
|
)}
|
||||||
{isObjectNotEmpty(props, "eventsObj") && (
|
{hasEventsTabData && (
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
whichTab == "case-events"
|
whichTab == "case-events"
|
||||||
@@ -1891,7 +1901,7 @@ const CaseSummary = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isObjectNotEmpty(props, "mediaObj") && (
|
{hasMediaTabData && (
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
whichTab == "case-media"
|
whichTab == "case-media"
|
||||||
|
|||||||
@@ -1,114 +1,29 @@
|
|||||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
import { respondError } from "../middleware/apiResponse";
|
||||||
|
import { relayGet } from "../middleware/relayForwarding";
|
||||||
|
|
||||||
export default function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
if (req.method && req.method !== "GET") {
|
const caseid = req.query.caseid;
|
||||||
|
|
||||||
|
if (typeof caseid !== "string" || caseid.trim().length === 0) {
|
||||||
return respondError(res, {
|
return respondError(res, {
|
||||||
status: 405,
|
status: 400,
|
||||||
code: "METHOD_NOT_ALLOWED",
|
code: "CASE_ID_REQUIRED",
|
||||||
message: "Only GET is supported"
|
message: "caseid is required"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const queryUrl =
|
||||||
"@odata.count": 4,
|
"pinswg_eventrecordings?$count=true&$filter=_pinswg_regardingcase_value eq " +
|
||||||
"value": [
|
caseid +
|
||||||
{
|
" and pinswg_publishtoweb eq true&$select=pinswg_videoplatformurl,pinswg_eventrecordingid,pinswg_publishtoweb,pinswg_eventrecordingname,pinswg_eventrecordingpublisheddate,createdon";
|
||||||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"Yes",
|
return relayGet({
|
||||||
"pinswg_publishtoweb": true,
|
queryUrl,
|
||||||
"pinswg_uploadstatus": 846040000,
|
res,
|
||||||
"pinswg_name":
|
errorResponse: {
|
||||||
"Puffin Paradise? Exploring Wales’ Cutest Wildlife Spot (Skomer Travel Guide)",
|
status: 400,
|
||||||
"pinswg_description":
|
code: "SIPS_MEDIA_FETCH_FAILED",
|
||||||
"Skomer Island is a tiny uninhabited isle off the coast of Pembrokeshire in western Wales. Although it's just ten minutes from the mainland by ferry, it's home to over 40,000 puffins, the largest colony in the world of Manx Shearwaters, and lots of seals.",
|
message: "Failed to fetch SIPS media"
|
||||||
"pinswg_latestpublishedversion": "1.0",
|
}
|
||||||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
});
|
||||||
"2/2/2026",
|
|
||||||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
|
||||||
"createdon@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026 10:19 AM",
|
|
||||||
"createdon": "2026-02-02T10:19:55Z",
|
|
||||||
"pinswg_hashlink":
|
|
||||||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
|
||||||
"pinswg_mediaLinkEN":
|
|
||||||
"https://www.youtube.com/watch?v=H7S6CfF_7PI",
|
|
||||||
"pinswg_mediaLinkCY":
|
|
||||||
"https://www.youtube.com/watch?v=H7S6CfF_7PI"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"Yes",
|
|
||||||
"pinswg_publishtoweb": true,
|
|
||||||
"pinswg_uploadstatus": 846040000,
|
|
||||||
"pinswg_name": "Redstone Cross - side roads",
|
|
||||||
"pinswg_description": "Redstone Cross - side roads",
|
|
||||||
"pinswg_latestpublishedversion": "1.0",
|
|
||||||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026",
|
|
||||||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
|
||||||
"createdon@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026 10:19 AM",
|
|
||||||
"createdon": "2026-02-02T10:19:55Z",
|
|
||||||
"pinswg_hashlink":
|
|
||||||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
|
||||||
"pinswg_mediaLinkEN":
|
|
||||||
"https://www.youtube.com/watch?v=OhxeLV_jPyE",
|
|
||||||
"pinswg_mediaLinkCY":
|
|
||||||
"https://www.youtube.com/watch?v=OhxeLV_jPyE"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"Yes",
|
|
||||||
"pinswg_publishtoweb": true,
|
|
||||||
"pinswg_uploadstatus": 846040000,
|
|
||||||
"pinswg_name":
|
|
||||||
"Apprenticeships: Dinorwig Power Station (bilingual)",
|
|
||||||
"pinswg_description": "blah blah blah",
|
|
||||||
"pinswg_latestpublishedversion": "1.0",
|
|
||||||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026",
|
|
||||||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
|
||||||
"createdon@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026 10:19 AM",
|
|
||||||
"createdon": "2026-02-02T10:19:55Z",
|
|
||||||
"pinswg_hashlink":
|
|
||||||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
|
||||||
"pinswg_mediaLinkEN":
|
|
||||||
"https://www.youtube.com/watch?v=9nsmadjgW94",
|
|
||||||
"pinswg_mediaLinkCY":
|
|
||||||
"https://www.youtube.com/watch?v=9nsmadjgW94"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"Yes",
|
|
||||||
"pinswg_publishtoweb": true,
|
|
||||||
"pinswg_uploadstatus": 846040000,
|
|
||||||
"pinswg_name":
|
|
||||||
"Climate Action Wales - Cardiff Cycle Workshop - Sustainable Cycling in Cardiff",
|
|
||||||
"pinswg_description": "blah blah blah",
|
|
||||||
"pinswg_latestpublishedversion": "1.0",
|
|
||||||
"pinswg_latestpublisheddate@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026",
|
|
||||||
"pinswg_latestpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentpublisheddate": "2026-02-02T10:20:46Z",
|
|
||||||
"pinswg_documentid": "9d4550b7-2000-f111-aa10-002248008e24",
|
|
||||||
"createdon@OData.Community.Display.V1.FormattedValue":
|
|
||||||
"2/2/2026 10:19 AM",
|
|
||||||
"createdon": "2026-02-02T10:19:55Z",
|
|
||||||
"pinswg_hashlink":
|
|
||||||
"/api/documents/download/A22258739?hash=51d64c1330ed2fe1fb9aff4658b8eedadf1b062d2b0313b39bc5af786228324b",
|
|
||||||
"pinswg_mediaLinkEN":
|
|
||||||
"https://www.youtube.com/watch?v=tRW3tm2Mby8",
|
|
||||||
"pinswg_mediaLinkCY":
|
|
||||||
"https://www.youtube.com/watch?v=tRW3tm2Mby8"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,9 +172,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||||
mediaObj = await getSIPSMedia(
|
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
|
||||||
);
|
|
||||||
store.dispatch(setMediaDetails(mediaObj));
|
store.dispatch(setMediaDetails(mediaObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,9 +177,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||||
mediaObj = await getSIPSMedia(
|
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
|
||||||
);
|
|
||||||
store.dispatch(setMediaDetails(mediaObj));
|
store.dispatch(setMediaDetails(mediaObj));
|
||||||
}
|
}
|
||||||
// console.log("eventsObj:", eventsObj);
|
// console.log("eventsObj:", eventsObj);
|
||||||
|
|||||||
@@ -216,9 +216,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||||
mediaObj = await getSIPSMedia(
|
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
|
||||||
);
|
|
||||||
store.dispatch(setMediaDetails(mediaObj));
|
store.dispatch(setMediaDetails(mediaObj));
|
||||||
}
|
}
|
||||||
//console.log(
|
//console.log(
|
||||||
|
|||||||
@@ -173,9 +173,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||||
mediaObj = await getSIPSMedia(
|
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
|
||||||
);
|
|
||||||
store.dispatch(setMediaDetails(mediaObj));
|
store.dispatch(setMediaDetails(mediaObj));
|
||||||
}
|
}
|
||||||
// console.log(
|
// console.log(
|
||||||
|
|||||||
Reference in New Issue
Block a user