Merged PR 2266: update media tabs display and query
update media tabs display and query Related work items: #22698
This commit is contained in:
@@ -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) {
|
||||
if (req.method && req.method !== "GET") {
|
||||
export default async function ApiProxy(req, res) {
|
||||
const caseid = req.query.caseid;
|
||||
|
||||
if (typeof caseid !== "string" || caseid.trim().length === 0) {
|
||||
return respondError(res, {
|
||||
status: 405,
|
||||
code: "METHOD_NOT_ALLOWED",
|
||||
message: "Only GET is supported"
|
||||
status: 400,
|
||||
code: "CASE_ID_REQUIRED",
|
||||
message: "caseid is required"
|
||||
});
|
||||
}
|
||||
|
||||
const data = {
|
||||
"@odata.count": 4,
|
||||
"value": [
|
||||
{
|
||||
"pinswg_publishtoweb@OData.Community.Display.V1.FormattedValue":
|
||||
"Yes",
|
||||
"pinswg_publishtoweb": true,
|
||||
"pinswg_uploadstatus": 846040000,
|
||||
"pinswg_name":
|
||||
"Puffin Paradise? Exploring Wales’ Cutest Wildlife Spot (Skomer Travel Guide)",
|
||||
"pinswg_description":
|
||||
"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.",
|
||||
"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);
|
||||
const queryUrl =
|
||||
"pinswg_eventrecordings?$count=true&$filter=_pinswg_regardingcase_value eq " +
|
||||
caseid +
|
||||
" and pinswg_publishtoweb eq true&$select=pinswg_videoplatformurl,pinswg_eventrecordingid,pinswg_publishtoweb,pinswg_eventrecordingname,pinswg_eventrecordingpublisheddate,createdon";
|
||||
|
||||
return relayGet({
|
||||
queryUrl,
|
||||
res,
|
||||
errorResponse: {
|
||||
status: 400,
|
||||
code: "SIPS_MEDIA_FETCH_FAILED",
|
||||
message: "Failed to fetch SIPS media"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -172,9 +172,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
|
||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||
mediaObj = await getSIPSMedia(
|
||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
||||
);
|
||||
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||
store.dispatch(setMediaDetails(mediaObj));
|
||||
}
|
||||
|
||||
|
||||
@@ -177,9 +177,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
|
||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||
mediaObj = await getSIPSMedia(
|
||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
||||
);
|
||||
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||
|
||||
store.dispatch(setMediaDetails(mediaObj));
|
||||
}
|
||||
// console.log("eventsObj:", eventsObj);
|
||||
|
||||
@@ -216,9 +216,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
|
||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||
mediaObj = await getSIPSMedia(
|
||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
||||
);
|
||||
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||
|
||||
store.dispatch(setMediaDetails(mediaObj));
|
||||
}
|
||||
//console.log(
|
||||
|
||||
@@ -173,9 +173,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
}
|
||||
|
||||
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
|
||||
mediaObj = await getSIPSMedia(
|
||||
searchDetailsObj[0].value[0].pinswg_sipsid
|
||||
);
|
||||
mediaObj = await getSIPSMedia(searchResultsObj.value[0].incidentid);
|
||||
|
||||
store.dispatch(setMediaDetails(mediaObj));
|
||||
}
|
||||
// console.log(
|
||||
|
||||
Reference in New Issue
Block a user