From d406d97ddf9319c26e458e9ef12db198840cdb36 Mon Sep 17 00:00:00 2001 From: Robert Bond Date: Fri, 24 Apr 2026 14:44:24 +0000 Subject: [PATCH] Merged PR 2272: final comments added and update _IP_ precendence to be lower final comments added and update _IP_ precendence to be lower Related work items: #22573, #22661 --- actions/azurestorage.js | 134 +++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 79 deletions(-) diff --git a/actions/azurestorage.js b/actions/azurestorage.js index f0c43add..1e1db67d 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -476,20 +476,19 @@ export const createRepPDFBlob = async ( ? await blockBlobClient.uploadData(content) : await blockBlobClient.uploadStream(content); - let whichLocation = - repName.indexOf("_IP_") > 0 - ? "846040005" - : repName.indexOf("_Statement_") > 0 - ? "846040002" - : repName.indexOf("_Questionnaire_") > 0 - ? "846040001" - : repName.indexOf("_Comments") > 0 - ? "846040003" - : repName.indexOf("_Impact") > 0 - ? "846040029" - : repName.indexOf("_Consultation_Response_") > 0 - ? "846040036" - : "846040002"; + const locationMap = [ + { key: "_IP_Comments_", value: "846040038" }, // most specific first + { key: "_IP_", value: "846040005" }, + { key: "_Statement_", value: "846040002" }, + { key: "_Questionnaire_", value: "846040001" }, + { key: "_Comments", value: "846040003" }, + { key: "_Impact", value: "846040029" }, + { key: "_Consultation_Response_", value: "846040036" } + ]; + + const whichLocation = + locationMap.find((item) => repName.includes(item.key))?.value || + "846040002"; const tags = { containerid: containerName, @@ -618,71 +617,46 @@ export const uploadFile = async (formContent, containerName, foldername) => { ); console.log(data); - let whichLocation = - files[prop][0].fieldName.indexOf("_Statement_of_Case") > - 0 || - files[prop][0].fieldName.indexOf("_-_Statement_of_Case") > - 0 || - files[prop][0].fieldName.indexOf("_-_Application_Form") > - 0 || - files[prop][0].fieldName.indexOf( - "_-_Site_Ownership_Certificate" - ) > 0 || - files[prop][0].fieldName.indexOf("_-_Decision_Notice") > - 0 || - files[prop][0].fieldName.indexOf("_-_Site_Location_Plan") > - 0 || - files[prop][0].fieldName.indexOf( - "_-_Plans_Drawing_Documents" - ) > 0 || - files[prop][0].fieldName.indexOf( - "_-_Additional_Plans_Drawings_Documents" - ) > 0 || - files[prop][0].fieldName.indexOf( - "_-_Design_and_Access_Statement" - ) > 0 || - files[prop][0].fieldName.indexOf( - "_-_NSB_LPA_Additional_Documents" - ) > 0 || - files[prop][0].fieldName.indexOf("_-_LPA_Correspondence") > - 0 || - files[prop][0].fieldName.indexOf( - "_-_LPA_Original_Permission" - ) > 0 || - files[prop][0].fieldName.indexOf( - "_-_LPA's_Registration_Letter" - ) > 0 || - files[prop][0].fieldName.indexOf( - +"_-_Environmental_Statement" - ) > 0 || - files[prop][0].fieldName.indexOf("_-_Cost_of_Application") > - 0 || - files[prop][0].fieldName.indexOf( - "_-_Other_Relevant_Material" - ) > 0 || - files[prop][0].fieldName.indexOf( - "_-_S106_Agreement_or_Unilateral_Undertaking" > 0 - ) - ? "846040000" - : files[prop][0].fieldName.indexOf("_IP_") > 0 - ? "846040005" - : files[prop][0].fieldName.indexOf("_Statement_") > 0 - ? "846040002" - : files[prop][0].fieldName.indexOf( - "_Questionnaire_" - ) > 0 - ? "846040001" - : files[prop][0].fieldName.indexOf("_Comments_") > - 0 - ? "846040003" - : files[prop][0].fieldName.indexOf("_Impact_") > - 0 - ? "846040001" - : files[prop][0].fieldName.indexOf( - "_Consultation_Response_" - ) > 0 - ? "846040036" - : "846040000"; + const fieldName = files[prop][0].fieldName; + + const whichLocation = + [ + // 1️⃣ LPA docs (grouped) + { + match: [ + "_Statement_of_Case", + "_-_Statement_of_Case", + "_-_Application_Form", + "_-_Site_Ownership_Certificate", + "_-_Decision_Notice", + "_-_Site_Location_Plan", + "_-_Plans_Drawing_Documents", + "_-_Additional_Plans_Drawings_Documents", + "_-_Design_and_Access_Statement", + "_-_NSB_LPA_Additional_Documents", + "_-_LPA_Correspondence", + "_-_LPA_Original_Permission", + "_-_LPA's_Registration_Letter", + "_-_Environmental_Statement", + "_-_Cost_of_Application", + "_-_Other_Relevant_Material", + "_-_S106_Agreement_or_Unilateral_Undertaking" + ], + value: "846040000" + }, + { match: ["_IP_Comments_"], value: "846040038" }, + { + match: ["_Consultation_Response_"], + value: "846040036" + }, + { match: ["_Questionnaire_"], value: "846040001" }, + { match: ["_Statement_"], value: "846040002" }, + { match: ["_Comments_"], value: "846040003" }, + { match: ["_Impact_"], value: "846040001" }, + { match: ["_IP_"], value: "846040005" } + ].find((rule) => + rule.match.some((key) => fieldName.includes(key)) + )?.value || "846040000"; const tags = { containerid: containerName, @@ -803,6 +777,8 @@ export const uploadSingleFile = async ( /_Statement_of_Case|_-_Statement_of_Case|_-_Application_Form|_-_Site_Ownership_Certificate|_-_Decision_Notice|_-_Site_Location_Plan|_-_Plans_Drawing_Documents|_-_Additional_Plans_Drawings_Documents|_-_Design_and_Access_Statement|_-_NSB_LPA_Additional_Documents|_-_LPA_Correspondence|_-_LPA_Original_Permission|_-_LPA's_Registration_Letter|_-_Environmental_Statement|_-_Cost_of_Application|_-_Other_Relevant_Material|_-_S106_Agreement_or_Unilateral_Undertaking/, value: "846040000" }, + + { pattern: /_IP_Comments_/, value: "846040038" }, { pattern: /_IP_/, value: "846040005" }, { pattern: /_Statement_/, value: "846040002" }, { pattern: /_Questionnaire_/, value: "846040001" },