diff --git a/actions/index.js b/actions/index.js index f0fbafe0..c099b55e 100644 --- a/actions/index.js +++ b/actions/index.js @@ -34,7 +34,7 @@ export const getIP = (req) => { console.info( "\n====================\n Client IP address: " + ip, - "\n=====================\n" + "\n=====================\n", ); }; @@ -42,7 +42,7 @@ export const consoleLogger = (err) => { console.log( "\n\n/////////////////////////////////////////////////\nRaw Error " + err + - "\n\n/////////////////////////////////////////////////\n" + "\n\n/////////////////////////////////////////////////\n", ); var errStr = "\n\n/////////////////////////////////////////////////\nServer Error " + @@ -102,7 +102,7 @@ export const getToken = () => { .post( `${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`, tokenBody, - tokenConfig + tokenConfig, ) .then((res) => res.data) .then((data) => { @@ -191,7 +191,7 @@ export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => { export const hashAPIPath = (queryPath) => { var hashlink = CryptoJS.HmacSHA256( queryPath, - CryptoJS.enc.Hex.parse(WORDKEY) + CryptoJS.enc.Hex.parse(WORDKEY), ); hashlink = hashlink.toString(CryptoJS.enc.Hex); return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; @@ -216,7 +216,7 @@ export const getBasicSearch = (searchString) => { .get( BASE_URL + "/api/endpoint/getbasicsearch_api?searchString=" + - searchString + searchString, ) .then((res) => { return res.data; @@ -244,7 +244,7 @@ export const getIncidentbyID = (searchString) => { .get( BASE_URL + "/api/endpoint/getincidentbyid_api?searchString=" + - searchString + searchString, ) .then((res) => { return res.data; @@ -258,7 +258,7 @@ export const getIncidentbyID = (searchString) => { export const getIsPublishedbyID = (searchString) => { return axios .get( - "/api/endpoint/getispublishedbyid_api?searchString=" + searchString + "/api/endpoint/getispublishedbyid_api?searchString=" + searchString, ) .then((res) => { return res.data; @@ -274,7 +274,7 @@ export const getPartSavedAppeal = (searchString) => { .get( BASE_URL + "/api/endpoint/getpartsavedappeal_api?searchString=" + - searchString + searchString, ) .then((res) => { return res.data; @@ -290,7 +290,7 @@ export const getBasicDNSURLSearch = (searchString) => { .get( BASE_URL + "/api/endpoint/getbasicdnsurlsearch_api?searchString=" + - searchString + searchString, ) .then((res) => { return res.data; @@ -313,12 +313,24 @@ export const getSIPSEvents = async (caseid) => { }); }; +export const getSIPSMedia = async (caseid) => { + return axios + .get(BASE_URL + "/api/endpoint/getsipsmedia_api?caseid=" + caseid) + .then((res) => { + return res.data; + }) + .catch((error) => { + consoleLogger(error); + return error.response; + }); +}; + export const getAddressSearchPaged = ( searchString, pageNumber, orderBy, fieldSort, - showNumberOfRecords + showNumberOfRecords, ) => { return axios .get( @@ -331,7 +343,7 @@ export const getAddressSearchPaged = ( "&fieldSort=" + fieldSort + "&showNumberOfRecords=" + - showNumberOfRecords + showNumberOfRecords, ) .then((res) => { return res.data; @@ -347,7 +359,7 @@ export const getBasicSearchPaged = ( pageNumber, orderBy, fieldSort, - showNumberOfRecords + showNumberOfRecords, ) => { return axios .get( @@ -360,7 +372,7 @@ export const getBasicSearchPaged = ( "&fieldSort=" + fieldSort + "&showNumberOfRecords=" + - showNumberOfRecords + showNumberOfRecords, ) .then((res) => { return res.data; @@ -413,7 +425,7 @@ export const getBasicDNSSearchPaged = ( pageNumber, orderBy, fieldSort, - showNumberOfRecords + showNumberOfRecords, ) => { return axios .get( @@ -424,7 +436,7 @@ export const getBasicDNSSearchPaged = ( "&fieldSort=" + fieldSort + "&showNumberOfRecords=" + - showNumberOfRecords + showNumberOfRecords, ) .then((res) => res.data) .catch((error) => { @@ -438,7 +450,7 @@ export const getAdvancedSearch = (searchString) => { .get( BASE_URL + "/api/endpoint/getadvancedsearch_api?searchstring=" + - JSON.stringify(searchString) + JSON.stringify(searchString), ) .then((res) => res.data) .catch((error) => { @@ -458,7 +470,7 @@ export const getAdvancedSearchPaged = ( pageNumber, orderBy, fieldSort, - showNumberOfRecords + showNumberOfRecords, ) => { return axios .get( @@ -471,7 +483,7 @@ export const getAdvancedSearchPaged = ( "&fieldSort=" + fieldSort + "&showNumberOfRecords=" + - showNumberOfRecords + showNumberOfRecords, ) .then((res) => res.data) .catch((error) => { @@ -490,7 +502,7 @@ export const getBasicSearchDetails = async ( appealTypeName, caseReference, primaryIdAttribute, - incidentID + incidentID, ) => { return axios .get( @@ -500,7 +512,7 @@ export const getBasicSearchDetails = async ( "&primaryIdAttribute=" + primaryIdAttribute + "&incidentID=" + - incidentID + incidentID, ) .then((res) => res.data) .catch((error) => { @@ -512,7 +524,7 @@ export const getBasicPartSavedDetails = ( appealTypeName, caseReference, primaryIdAttribute, - incidentID + incidentID, ) => { //console.log( // "///////api call: ", @@ -532,7 +544,7 @@ export const getBasicPartSavedDetails = ( "&primaryIdAttribute=" + primaryIdAttribute + "&incidentID=" + - incidentID + incidentID, ) .then((res) => res.data) .catch((error) => { @@ -544,7 +556,7 @@ export const getBasicSearchDetailsPaged = async ( appealTypeName, caseReference, primaryIdAttribute, - incidentIDs + incidentIDs, ) => { if (!incidentIDs || incidentIDs.length === 0) return []; @@ -566,11 +578,11 @@ export const getBasicSearchDetailsPaged = async ( .join(" or "); const url = `/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=${appealTypeName}&primaryIdAttribute=${primaryIdAttribute}&incidentID=${encodeURIComponent( - filter + filter, )}`; console.log( - `Fetching ${incidentIDs.length} incidents for appeal type: ${appealTypeName}` + `Fetching ${incidentIDs.length} incidents for appeal type: ${appealTypeName}`, ); try { @@ -586,7 +598,7 @@ export const getSearchDocumentDetails = (incidentID) => { return axios .get( "/api/endpoint/getsearchdocumentdetails_api?incidentid=" + - incidentID + incidentID, ) .then((res) => res.data) .catch((error) => { @@ -598,7 +610,7 @@ export const getSearchDocumentDetails = (incidentID) => { export const getSearchDocumentTypes = (incidentID) => { return axios .get( - "/api/endpoint/getsearchdocumentTypes_api?incidentid=" + incidentID + "/api/endpoint/getsearchdocumentTypes_api?incidentid=" + incidentID, ) .then((res) => res.data) .catch((error) => { @@ -611,7 +623,7 @@ export const getAppealPDFDocs = (incidentID) => { .get( BASE_URL + "/api/endpoint/getappealpdfdocuments_api?incidentid=" + - incidentID + incidentID, ) .then((res) => res.data) .catch((error) => { @@ -625,7 +637,7 @@ export const getSearchDocumentDetailsPaged = ( orderBy, fieldSort, showNumberOfRecords, - documentType + documentType, ) => { //console.log("to api:", documentType); return axios @@ -641,7 +653,7 @@ export const getSearchDocumentDetailsPaged = ( "&showNumberOfRecords=" + showNumberOfRecords + "&documentType=" + - documentType + documentType, ) .then((res) => res.data) .catch((error) => { @@ -653,7 +665,7 @@ export const getLinkedCases = (parentIncidentid) => { return axios .get( "/api/endpoint/getlinkedcases_api?parentincidentid=" + - parentIncidentid + parentIncidentid, ) .then((res) => { return res.data; @@ -745,7 +757,7 @@ export const getMandatoryFields = (whichForm) => { .get( BASE_URL + "/api/endpoint/getmandatoryfields_api?whichForm=" + - whichForm + whichForm, ) .then((res) => res.data) .catch((error) => { @@ -767,7 +779,7 @@ export const getPersonalAccount = (contactid) => { .get( BASE_URL + "/api/endpoint/getpersonalaccount_api?contactid=" + - contactid + contactid, ) .then((res) => { return res.data; @@ -787,7 +799,7 @@ export const getPersonalAccount = (contactid) => { export const getAppealID = ( caseReference, updateFormCollection, - primaryAttribute + primaryAttribute, ) => { //console.log( // "is this the collection?:", @@ -803,11 +815,11 @@ export const getAppealID = ( "&primaryAttribute=" + primaryAttribute + "&caseReference=" + - caseReference + caseReference, ) .then((res) => { const result = Object.entries(res.data.value[0]).filter( - ([key]) => !key.startsWith("_") + ([key]) => !key.startsWith("_"), )[0][1]; // console.log("result:", res.data); var appealID = result; @@ -824,7 +836,7 @@ export const getLogin = (emailAddress, pwd) => { "/api/endpoint/getlogin_api?emailAddress=" + emailAddress + "&pwd=" + - pwd + pwd, ) .then((res) => res.data) .catch((error) => { @@ -837,7 +849,7 @@ export const getMyCases = (loggedInUserId) => { .get( BASE_URL + "/api/endpoint/getmycases_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => { return res.data; @@ -852,7 +864,7 @@ export const getMyInvolvements = async (loggedInUserId) => { const res = await axios.get( BASE_URL + "/api/endpoint/getmyinvolvements_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ); return res.data; } catch (error) { @@ -876,7 +888,7 @@ export const getMyRepresentations = (loggedInUserId) => { .get( BASE_URL + "/api/endpoint/getmyrepresentations_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => res.data) .catch((error) => { @@ -888,7 +900,7 @@ export const getMyRepresentationsProxy = (loggedInUserId) => { return axios .get( "/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => res.data) .catch((error) => { @@ -908,7 +920,8 @@ export const getRepresentations = (incidentID) => { export const getRepresentationsProxy = (incidentID) => { return axios .get( - "/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID + "/api/endpoint/getrepresentationsproxy_api?incidentID=" + + incidentID, ) .then((res) => res.data) .catch((error) => { @@ -921,7 +934,7 @@ export const getWatchedCases = (loggedInUserId) => { .get( BASE_URL + "/api/endpoint/getwatchedcases_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => res.data) .catch((error) => { @@ -933,7 +946,7 @@ export const getWatchedCasesProxy = (loggedInUserId) => { return axios .get( "/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => res.data) .catch((error) => { @@ -945,7 +958,7 @@ export const getAwaitingSubmissionProxy = (loggedInUserId) => { return axios .get( "/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => res.data) .catch((error) => { @@ -958,7 +971,7 @@ export const getAwaitingSubmission = (loggedInUserId) => { .get( BASE_URL + "/api/endpoint/getawaitingsubmission_api?loggedInUserId=" + - loggedInUserId + loggedInUserId, ) .then((res) => { return res.data; @@ -988,8 +1001,8 @@ export const getAwaitingSubmissionFromBlob = (containerName) => { containerName + hashAPIPath( "/api/file/getawaitingsubmissionfromblob?container=" + - containerName - ) + containerName, + ), ) .then((res) => { return res.data; @@ -1015,7 +1028,7 @@ export const getRepsFromBlob = (containerName) => { BASE_URL + "/api/file/getrepsblob?container=" + containerName + - hashAPIPath("/api/file/getrepsblob?container=" + containerName) + hashAPIPath("/api/file/getrepsblob?container=" + containerName), ) .then((res) => { return res.data; @@ -1042,7 +1055,7 @@ export const getRepsFromBlobProxy = async (containerName) => { try { const res = await axios.get( // BASE_URL + - "/api/file/getrepsblobproxy?container=" + containerName + "/api/file/getrepsblobproxy?container=" + containerName, // + // hashAPIPath( // "/api/file/getawaitingsubmissionfromblob?container=" + @@ -1061,14 +1074,14 @@ export const getAwaitingSubmissionFromBlobProxy = async (containerName) => { containerName, "/api/file/getawaitingsubmissionfromblobproxy?container=" + containerName, - "\n///////////////////////\n" + "\n///////////////////////\n", ); try { const res = await axios.get( BASE_URL + "/api/file/getawaitingsubmissionfromblobproxy?container=" + - containerName + containerName, // + // hashAPIPath( // "/api/file/getawaitingsubmissionfromblob?container=" + @@ -1129,7 +1142,7 @@ export const getPortalModuleDetailsProxy = (appealType, caseReference) => { "/api/endpoint/getportalmoduledetailsproxy_api?appealType=" + appealType + "&caseReference=" + - caseReference.replace(/\'/g, "''") + caseReference.replace(/\'/g, "''"), ) .then((res) => res.data) .catch((error) => { @@ -1141,7 +1154,7 @@ export const getEmailAccountCheck = (emailAddress) => { return axios .get( "/api/endpoint/getemailaccountcheck_api?emailAddress=" + - emailAddress + emailAddress, ) .then((res) => res.data) .catch((error) => { @@ -1213,7 +1226,7 @@ export const createNewCase = ( lpaID, contactid, createBody, - containerName + containerName, ) => { appealTypeId = parseInt(appealTypeId); @@ -1250,7 +1263,7 @@ export const createNewCaseBlob = ( contactid, createBody, containerName, - lpaName + lpaName, ) => { appealTypeId = parseInt(appealTypeId); @@ -1302,14 +1315,14 @@ export const updateCase = async ( updateBody, updateFormCollection, primaryAttribute, - caseReference + caseReference, ) => { var data = updateBody; var appealObj = await getAppealID( caseReference, updateFormCollection, - primaryAttribute + primaryAttribute, ); var queryUrl = @@ -1340,14 +1353,14 @@ export const updateCaseBlob = async ( updateBody, updateFormCollection, primaryAttribute, - caseReference + caseReference, ) => { var data = updateBody; var appealObj = await getAppealID( caseReference, updateFormCollection, - primaryAttribute + primaryAttribute, ); var queryUrl = @@ -1415,7 +1428,7 @@ export const getCaseByID = (incidentID) => { // ); return axios .get( - BASE_URL + "/api/endpoint/getcasebyid_api?incidentID=" + incidentID + BASE_URL + "/api/endpoint/getcasebyid_api?incidentID=" + incidentID, ) .then((res) => { return res.data; @@ -1473,7 +1486,7 @@ export const deleteAwaitingSubmissions = (incidentID) => { export const deleteAwaitingSubmissionsFromBlob = ( containerID, - casefolderID + casefolderID, ) => { var queryUrl = "/api/file/deleteblobcase?container=" + @@ -1499,7 +1512,7 @@ export const deleteAwaitingSubmissionsFromBlob = ( export const deleteMyRepresentationsFromBlob = ( containerID, casefolderID, - repfile + repfile, ) => { var queryUrl = "/api/file/deleteblobrep?container=" + @@ -1563,7 +1576,7 @@ export const uploadFiles = async ( formValues, filesObj, containerID, - casefolderID + casefolderID, ) => { let files = filesObj; @@ -1644,7 +1657,7 @@ export const uploadRepFiles = async ( formValues, filesObj, containerID, - casefolderID + casefolderID, ) => { let files = filesObj; @@ -1721,7 +1734,7 @@ export const generateAppealPDF = async ( containerID, casefolderID, appealType, - fileList + fileList, ) => { //let files = filesObj; @@ -1779,8 +1792,8 @@ export const getFilesFromBlob = (containerName, casefolderID) => { "/api/file/getbloblist?container=" + containerName + "&casefolderID=" + - casefolderID - ) + casefolderID, + ), ) .then((res) => { //console.log("//////////----", res.data); @@ -1798,7 +1811,7 @@ export const getFilesFromBlobproxy = (containerName, casefolderID) => { "/api/file/getbloblistproxy?container=" + containerName + "&casefolderID=" + - casefolderID + casefolderID, ) .then((res) => { //console.log("//////////----", res.data); @@ -1812,7 +1825,7 @@ export const getFilesFromBlobproxy = (containerName, casefolderID) => { export const getFilesFromBlobHashed = ( containerName, getblobshash, - casefolderID + casefolderID, ) => { return axios .get( @@ -1820,7 +1833,7 @@ export const getFilesFromBlobHashed = ( containerName + "&casefolderID=" + casefolderID + - getblobshash + getblobshash, ) .then((res) => { //console.log("//////////----", res.data); @@ -1835,7 +1848,7 @@ export const deleteBlob = async ( containerName, blobName, deleteblobhash, - casefolderID + casefolderID, ) => { try { const res = await axios.get( @@ -1845,7 +1858,7 @@ export const deleteBlob = async ( encodeURIComponent(casefolderID) + "&blobname=" + encodeURIComponent(blobName) + - deleteblobhash + deleteblobhash, ); return res.data; } catch (error) { @@ -1858,7 +1871,7 @@ export const deleteRepBlob = async ( blobName, deleteblobhash, casefolderID, - filenamePrefix + filenamePrefix, ) => { try { const res = await axios.get( @@ -1868,7 +1881,7 @@ export const deleteRepBlob = async ( encodeURIComponent(casefolderID + "/" + filenamePrefix) + "&blobname=" + encodeURIComponent(blobName) + - deleteblobhash + deleteblobhash, ); return res.data; } catch (error) { @@ -1884,14 +1897,14 @@ export const downloadBlob = (containerName, blobName) => { containerName.toLowerCase() + "&blobname=" + blobName, - { responseType: "blob" } + { responseType: "blob" }, ) .then((response) => { //console.log("Downloaded blob content:"); res.setHeader( "content-disposition", - "attachment; filename=" + blobName + "attachment; filename=" + blobName, ); //console.log("has downloaded"); @@ -1928,8 +1941,8 @@ export const getProgressFromBlob = async (containerName, casereference) => { "/api/file/getprogressobjblob?container=" + encodeURIComponent(containerName) + "&casefolderID=" + - encodeURIComponent(casereference) - ) + encodeURIComponent(casereference), + ), ); return res.data; } catch (error) { @@ -1941,7 +1954,7 @@ export const sendEmail = async ( templateId, emailAddress, personalisation, - reference + reference, ) => { var mailData = { "templateId": templateId, @@ -2042,7 +2055,7 @@ export const createContainerProxy = (containerName) => { export const sendCaseCompleteMessage = async ( containerID, caseReference, - inv + inv, ) => { var queryUrl = "/api/file/createappealcompletemessage_api?container=" + @@ -2071,7 +2084,7 @@ export const sendCaseCompleteMessage = async ( export const sendCaseCompleteMessageProxy = async ( containerID, - caseReference + caseReference, ) => { var queryUrl = "/api/file/createappealcompletemessageproxy_api?container=" + @@ -2098,7 +2111,7 @@ export const sendCaseCompleteMessageProxy = async ( export const sendRepCompleteMessage = async ( containerID, caseReference, - fileName + fileName, ) => { var queryUrl = "/api/file/createrepcompletemessage_api?container=" + @@ -2210,7 +2223,7 @@ export const getPreferredLanguage = async (email) => { .get( BASE_URL + "/api/endpoint/getpreferredlanguage_api?emailAddress=" + - email + email, ) .then((res) => { return res.data; @@ -2226,7 +2239,7 @@ export const getAppealPDFDocument = async (incidentid) => { .get( BASE_URL + "/api/endpoint/getappealpdfdocuments_api?incidentid=" + - incidentid + incidentid, ) .then((res) => { return res.data; @@ -2251,7 +2264,7 @@ export const getNewAppealsPage = async ( pageNumber, orderBy, fieldSort, - showNumberOfRecords + showNumberOfRecords, ) => { return axios .get( @@ -2264,7 +2277,7 @@ export const getNewAppealsPage = async ( "&fieldSort=" + fieldSort + "&showNumberOfRecords=" + - showNumberOfRecords + showNumberOfRecords, ) .then((res) => { return res.data; @@ -2282,7 +2295,7 @@ export const getNewDocumentsPaged = async ( showNumberOfRecords, documentType, documentOrigin, - selectedWeeks + selectedWeeks, ) => { console.log( "/api/admin/getlatestdocuments_api?pageNumber=" + @@ -2298,7 +2311,7 @@ export const getNewDocumentsPaged = async ( "&numberWeeks=" + selectedWeeks + "&documentOrigin=" + - documentOrigin + documentOrigin, ); return axios .get( @@ -2315,7 +2328,7 @@ export const getNewDocumentsPaged = async ( "&numberWeeks=" + selectedWeeks + "&documentOrigin=" + - documentOrigin + documentOrigin, ) .then((res) => { return res.data; diff --git a/components/case.js b/components/case.js index 915dc95d..c47b2f52 100644 --- a/components/case.js +++ b/components/case.js @@ -41,7 +41,9 @@ const Case = (props) => { docsOffline={props.props.docsOffline} documentDetailsObj={props.documentDetailsObj} showFilteredDocs={props.showFilteredDocs} + showLoginCheck={props.showLoginCheck} eventsObj={props.eventsObj} + mediaObj={props.mediaObj} /> {showRepresentations == true && ( { +// // let { t } = useTranslation(); + +// // const MediaView = (mediaArr) => { +// // mediaArr = mediaArr.value; + +// // return mediaArr.map((item, key) => { +// //
{item.pinswg_name}
; +// // }); +// // }; + +// // const mediaArr = props.mediaObj?.value || []; + +// // // event publishiing flag set to true displa + +// // function hasOwnPropertyAndNotNull(obj, property) { +// // return obj.hasOwnProperty(property) && obj[property] !== null; +// // } + +// // //console.log(eventsArr.length > 0); + +// // return ( +// // mediaArr.length > 0 && ( +// //
+// //
+// //
+// //

+// // {t("case:event-title")}Media +// //

+// // {mediaArr.map( +// // (item, key) => +// // item.pinswg_publishtoweb && ( +// // <> +// // {" "} +// //
+// //
+// //
+// // +// // {" "} +// // {t( +// // "case:event-name-label", +// // )} +// // +// // : {item.pinswg_name} +// //
+// // {hasOwnPropertyAndNotNull( +// // item, +// // "pinswg_description", +// // ) && ( +// //
+// // +// // {t( +// // "case:event-event-name-label", +// // )} +// // +// // :{" "} +// // { +// // item.pinswg_description +// // } +// //
+// // )} +// //
+// //
+// // +// // ), +// // )}{" "} +// //
+// //
+// //
+// // ) +// // ); +// // }; + +// // const mapStateToProps = (state) => { +// // return { +// // ...state, +// // }; +// // }; + +// // const mapDispatchToProps = (dispatch) => { +// // return { +// // setEventDetails: (mediaObj) => { +// // dispatch(setEventDetails(mediaObj)); +// // }, +// // setCurrentPage: (currentPage) => { +// // dispatch(setCurrentPage(currentPage)); +// // }, +// // }; +// // }; + +// // export default connect(mapStateToProps, mapDispatchToProps)(MediaDetails); +// import { useEffect, useMemo, useState } from "react"; +// import { connect } from "react-redux"; +// import useTranslation from "next-translate/useTranslation"; +// import { useRouter } from "next/router"; + +// const extractYouTubeId = (input) => { +// if (!input) return null; +// if (/^[a-zA-Z0-9_-]{11}$/.test(input)) return input; + +// try { +// const url = new URL(input); +// if (url.hostname.includes("youtu.be")) +// return url.pathname.slice(1) || null; + +// const v = url.searchParams.get("v"); +// if (v) return v; + +// const embedMatch = url.pathname.match(/\/embed\/([^/]+)/); +// if (embedMatch?.[1]) return embedMatch[1]; + +// const shortsMatch = url.pathname.match(/\/shorts\/([^/]+)/); +// if (shortsMatch?.[1]) return shortsMatch[1]; + +// return null; +// } catch { +// return null; +// } +// }; + +// export default function MediaDetails({ mediaObj, whichTab }) { +// const router = useRouter(); +// const mediaArr = mediaObj?.value || []; + +// const videoItems = useMemo(() => { +// const isWelsh = router.locale === "cy"; + +// return (mediaArr || []) +// .filter((x) => x?.pinswg_publishtoweb) +// .map((item) => { +// const url = isWelsh +// ? item.pinswg_mediaLinkCY +// : item.pinswg_mediaLinkEN; +// const videoId = extractYouTubeId(url); +// if (!videoId) return null; + +// return { +// key: +// item.pinswg_documentid || +// `${item.pinswg_name}-${videoId}`, +// videoId, +// name: item.pinswg_name || "Video", +// description: item.pinswg_description || "", +// thumbnail: `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`, +// }; +// }) +// .filter(Boolean); +// }, [mediaArr, router.locale]); + +// const [watchedIds, setWatchedIds] = useState(new Set()); +// const [selectedIndex, setSelectedIndex] = useState(0); + +// // Forces a fresh iframe instance whenever we need to hard-stop playback +// const [playerInstance, setPlayerInstance] = useState(0); + +// const isActive = whichTab === "case-media"; +// const selected = videoItems[selectedIndex] || null; + +// // When leaving the media tab, hard-stop playback by unmounting (and bumping instance) +// useEffect(() => { +// if (!isActive) { +// setPlayerInstance((n) => n + 1); +// } +// }, [isActive]); + +// // When list/locale changes, reset to first (no autoplay) +// useEffect(() => { +// setSelectedIndex(0); +// setPlayerInstance((n) => n + 1); +// }, [videoItems.length, router.locale]); + +// if (!videoItems.length) return null; + +// const embedBase = "https://www.youtube-nocookie.com/embed"; + +// // IMPORTANT: +// // - autoplay=0 for initial load +// // - autoplay=1 only when user clicks an item +// const [autoplay, setAutoplay] = useState(false); + +// useEffect(() => { +// // whenever we leave tab or reset player, don't autoplay next time +// if (!isActive) setAutoplay(false); +// }, [isActive]); + +// const embedSrc = selected +// ? `${embedBase}/${selected.videoId}?rel=0&modestbranding=1&playsinline=1&autoplay=${autoplay ? "1" : "0"}` +// : ""; + +// return ( +//
+//
+//
+//

Media

+ +// {/* Player: only render when tab is active */} +// {isActive && ( +//
+//