diff --git a/actions/azurestorage.js b/actions/azurestorage.js index b7e9db59..f52bb013 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -1288,22 +1288,38 @@ export const getAllProgressBlobs = async (containerName) => { for await (const blob of containerClient.findBlobsByTags( "blobType='Appeal'" )) { - blob.name.split("/")[1].indexOf("_appeal.json") > 0 && - blob.name.split("/")[1].indexOf("undefined") < 0 && - blobObj.push({ - "name": blob.name.split("/")[1], - "path": blob.name, - //"versionId": blob.versionId, - "caseObj": - blob.name.split("/")[0] + - "/" + - blob.name.split("/")[0] + - "_case.json" - // "isCurrentVersion": blob.isCurrentVersion, - // "contentLength": blob.properties.contentLength, - // "contentType": blob.contentType, - // "lastModified": blob.properties.lastModified, - }); + const namePart = blob.name.split("/")[1] ?? ""; + + // keep your existing name filters + if ( + namePart.indexOf("_appeal.json") <= 0 || + namePart.indexOf("undefined") >= 0 + ) + continue; + + // existence check (filters out soft-deleted / stale index hits) + const blobClient = containerClient.getBlobClient(blob.name); + try { + await blobClient.getProperties(); + } catch (e) { + // errors usually expose statusCode + if (e?.statusCode === 404) continue; + throw e; + } + blobObj.push({ + "name": blob.name.split("/")[1], + "path": blob.name, + //"versionId": blob.versionId, + "caseObj": + blob.name.split("/")[0] + + "/" + + blob.name.split("/")[0] + + "_case.json" + // "isCurrentVersion": blob.isCurrentVersion, + // "contentLength": blob.properties.contentLength, + // "contentType": blob.contentType, + // "lastModified": blob.properties.lastModified, + }); } // console.log( diff --git a/components/myportal/awaitingsubmissionfromblob.js b/components/myportal/awaitingsubmissionfromblob.js index 33f9e6f4..21b50bc9 100644 --- a/components/myportal/awaitingsubmissionfromblob.js +++ b/components/myportal/awaitingsubmissionfromblob.js @@ -6,17 +6,17 @@ import { parseCookies } from "nookies"; import { connect } from "react-redux"; import { deleteAwaitingSubmissionsFromBlob, - getAwaitingSubmissionFromBlobProxy, + getAwaitingSubmissionFromBlobProxy } from "../../actions"; import { getFormCollectionByID } from "../../components/utils"; import transLookup from "../../data/lookuptranslations.json"; import { setAwaitingSubmissionDetails, - setAwaitingSubmissionFromBlob, + setAwaitingSubmissionFromBlob } from "../../store/awaitingSubmission/action"; import { setCurrentReference, - setCurrentView, + setCurrentView } from "../../store/currentView/action"; const AwaitingSubmissionFromBlob = (props) => { @@ -149,7 +149,7 @@ const AwaitingSubmissionFromBlob = (props) => { "appealType": showTopThreeArr[key] - .pinswg_appealcasetype, + .pinswg_appealcasetype }); }} > @@ -195,7 +195,7 @@ const AwaitingSubmissionFromBlob = (props) => {
{t("myportal:lpa-reference-label")}:{" "} { - showTopThreeArr[key] + showTopThreeArrDets[key] .pinswg_lpaapplicationreference }
@@ -211,7 +211,7 @@ const AwaitingSubmissionFromBlob = (props) => { ).value + '")].value_cy', json: transLookup, - eval: true, + eval: true }) : getFormCollectionByID( showTopThreeArr[key] @@ -223,32 +223,38 @@ const AwaitingSubmissionFromBlob = (props) => { {_.isEmpty(showTopThreeArr) ? t("myportal:case-address-not-entered") : _.isEmpty(showTopThreeArr[index]) - ? t("myportal:case-address-not-entered") - : _.isEmpty(showTopThreeArr[index]) - ? t("myportal:case-address-not-entered") - : _.isEmpty( - showTopThreeArr[index] - .pinswg_siteaddressline1 - ) - ? t("myportal:case-address-not-entered") - : showTopThreeArr[index] - .pinswg_siteaddressline1 + - (!_.isEmpty( - showTopThreeArr[index] - .pinswg_siteaddressline2 - ) - ? ", " + - showTopThreeArr[index] - .pinswg_siteaddressline2 - : "") + - (!_.isEmpty( - showTopThreeArr[index] - .pinswg_siteaddresstown - ) - ? ", " + - showTopThreeArr[index] - .pinswg_siteaddresstown - : "")} + ? t( + "myportal:case-address-not-entered" + ) + : _.isEmpty(showTopThreeArr[index]) + ? t( + "myportal:case-address-not-entered" + ) + : _.isEmpty( + showTopThreeArr[index] + .pinswg_siteaddressline1 + ) + ? t( + "myportal:case-address-not-entered" + ) + : showTopThreeArr[index] + .pinswg_siteaddressline1 + + (!_.isEmpty( + showTopThreeArr[index] + .pinswg_siteaddressline2 + ) + ? ", " + + showTopThreeArr[index] + .pinswg_siteaddressline2 + : "") + + (!_.isEmpty( + showTopThreeArr[index] + .pinswg_siteaddresstown + ) + ? ", " + + showTopThreeArr[index] + .pinswg_siteaddresstown + : "")} {showTopThreeArr[key].pinswg_appellantagent != null && ( @@ -257,7 +263,8 @@ const AwaitingSubmissionFromBlob = (props) => { .pinswg_appellantagent != 846040000 && ( - {t("myportal:raised-by-label")}:{" "} + {t("myportal:raised-by-label")} + :{" "} )} {showTopThreeArr[key] @@ -280,7 +287,8 @@ const AwaitingSubmissionFromBlob = (props) => { 846040000 && (
- {t("myportal:on-behalf-of-label")}:{" "} + {t("myportal:on-behalf-of-label")} + :{" "} {showTopThreeArr[key] .pinswg_appellantfirstname + @@ -303,7 +311,7 @@ const AwaitingSubmissionFromBlob = (props) => { ] + '")].value_cy', json: transLookup, - eval: true, + eval: true }) : showTopThreeArr[key][ "pinswg_lpaname" @@ -361,7 +369,7 @@ const AwaitingSubmissionFromBlob = (props) => { onClick={() => { setCurrentView({ "viewName": "Awaiting Submission", - "viewKey": "awaitingSubmissionDetails", + "viewKey": "awaitingSubmissionDetails" }); }} > @@ -387,7 +395,7 @@ const mapDispatchToProps = (dispatch) => { }, setAwaitingSubmissionDetails: (awaitingSubmissionDetails) => { dispatch(setAwaitingSubmissionDetails(awaitingSubmissionDetails)); - }, + } }; }; diff --git a/pages/api/file/getawaitingsubmissionfromblob.js b/pages/api/file/getawaitingsubmissionfromblob.js index 9b93f962..ce3efa45 100644 --- a/pages/api/file/getawaitingsubmissionfromblob.js +++ b/pages/api/file/getawaitingsubmissionfromblob.js @@ -1,6 +1,6 @@ import { downloadAllProgressFiles, - getAllProgressBlobs, + getAllProgressBlobs } from "../../../actions/azurestorage"; import _ from "lodash"; import nextConnect from "next-connect"; @@ -40,8 +40,8 @@ ApiProxy.get(async (req, res) => { export const config = { api: { - bodyParser: false, - }, + bodyParser: false + } }; export default ApiProxy; diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js index 33e232c0..695dea76 100644 --- a/pages/newappeal/[appealtypes].js +++ b/pages/newappeal/[appealtypes].js @@ -364,7 +364,7 @@ let Home = (props) => { const selectedObj = jsonpath({ path: "$..[?(@ && @.attributevalue=='" + apt + "')]", json: optionsStr, - eval: true, + eval: true }); const title = selectedObj?.[0]?.value; @@ -389,6 +389,7 @@ let Home = (props) => { formTitle={formTitle} mandatoryFieldsData={props.formData?.mandatoryFieldsData} propsForChildren={props} + docsOffline={props.docsOffline} /> ); @@ -406,7 +407,10 @@ export const getServerSideProps = wrapper.getServerSideProps( hydrateNewAppealStore(store, ctx.query, result); return { - props: { url: process.env.NEXTAUTH_URL }, + props: { + url: process.env.NEXTAUTH_URL, + docsOffline: process.env.DOCAPI_OFFLINE || false + } }; } ); @@ -418,7 +422,7 @@ const mapStateToProps = (state) => { formData: state.formData, appealType: state.appealType, form: state.form, - accountDetails: state.accountDetails, + accountDetails: state.accountDetails }; }; @@ -430,7 +434,7 @@ const mapDispatchToProps = (dispatch) => { }, setCaseReference: (refno) => { // dispatch(setCaseReferenceAction(refno)); // optional later - }, + } }; };