refactored for correct doc location
This commit is contained in:
+73
-45
@@ -673,49 +673,77 @@ export const uploadSingleFile = async (
|
|||||||
"\n////////////////////////////"
|
"\n////////////////////////////"
|
||||||
);
|
);
|
||||||
|
|
||||||
let whichLocation =
|
// 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("_-_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("_-_Application_Form") > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Site_Ownership_Certificate") >
|
// files[prop][0].fieldName.indexOf("_-_Site_Ownership_Certificate") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Decision_Notice") > 0 ||
|
// files[prop][0].fieldName.indexOf("_-_Decision_Notice") > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Site_Location_Plan") > 0 ||
|
// files[prop][0].fieldName.indexOf("_-_Site_Location_Plan") > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Plans_Drawing_Documents") >
|
// files[prop][0].fieldName.indexOf("_-_Plans_Drawing_Documents") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf(
|
// files[prop][0].fieldName.indexOf(
|
||||||
"_-_Additional_Plans_Drawings_Documents"
|
// "_-_Additional_Plans_Drawings_Documents"
|
||||||
) > 0 ||
|
// ) > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Design_and_Access_Statement") >
|
// files[prop][0].fieldName.indexOf("_-_Design_and_Access_Statement") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf(
|
// files[prop][0].fieldName.indexOf(
|
||||||
"_-_NSB_LPA_Additional_Documents"
|
// "_-_NSB_LPA_Additional_Documents"
|
||||||
) > 0 ||
|
// ) > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_LPA_Correspondence") > 0 ||
|
// files[prop][0].fieldName.indexOf("_-_LPA_Correspondence") > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_LPA_Original_Permission") >
|
// files[prop][0].fieldName.indexOf("_-_LPA_Original_Permission") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_LPA's_Registration_Letter") >
|
// files[prop][0].fieldName.indexOf("_-_LPA's_Registration_Letter") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Environmental_Statement") >
|
// files[prop][0].fieldName.indexOf("_-_Environmental_Statement") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Cost_of_Application") > 0 ||
|
// files[prop][0].fieldName.indexOf("_-_Cost_of_Application") > 0 ||
|
||||||
files[prop][0].fieldName.indexOf("_-_Other_Relevant_Material") >
|
// files[prop][0].fieldName.indexOf("_-_Other_Relevant_Material") >
|
||||||
0 ||
|
// 0 ||
|
||||||
files[prop][0].fieldName.indexOf(
|
// files[prop][0].fieldName.indexOf(
|
||||||
"_-_S106_Agreement_or_Unilateral_Undertaking" > 0
|
// "_-_S106_Agreement_or_Unilateral_Undertaking" > 0
|
||||||
)
|
// )
|
||||||
? "846040000"
|
// ? "846040000"
|
||||||
: files[prop][0].fieldName.indexOf("_IP_") > 0
|
// : files[prop][0].fieldName.indexOf("_IP_") > 0
|
||||||
? "846040005"
|
// ? "846040005"
|
||||||
: files[prop][0].fieldName.indexOf("_Statement_") > 0
|
// : files[prop][0].fieldName.indexOf("_Statement_") > 0
|
||||||
? "846040002"
|
// ? "846040002"
|
||||||
: files[prop][0].fieldName.indexOf("_Questionnaire_") > 0
|
// : files[prop][0].fieldName.indexOf("_Questionnaire_") > 0
|
||||||
? "846040001"
|
// ? "846040001"
|
||||||
: files[prop][0].fieldName.indexOf("_Comments_") > 0
|
// : files[prop][0].fieldName.indexOf("_Comments_") > 0
|
||||||
? "846040003"
|
// ? "846040003"
|
||||||
: files[prop][0].fieldName.indexOf("_Impact_") > 0
|
// : files[prop][0].fieldName.indexOf("_Impact_") > 0
|
||||||
? "846040001"
|
// ? "846040001"
|
||||||
: "846040000";
|
// : "846040000";
|
||||||
|
|
||||||
|
const fieldName = files[prop][0].fieldName;
|
||||||
|
|
||||||
|
// Define the patterns and corresponding values
|
||||||
|
const patternMapping = [
|
||||||
|
{
|
||||||
|
pattern:
|
||||||
|
/_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_/, value: "846040005" },
|
||||||
|
{ pattern: /_Statement_/, value: "846040002" },
|
||||||
|
{ pattern: /_Questionnaire_/, value: "846040001" },
|
||||||
|
{ pattern: /_Comments_/, value: "846040003" },
|
||||||
|
{ pattern: /_Impact_/, value: "846040001" },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Find a matching pattern or fallback to default
|
||||||
|
let whichLocation = "846040000"; // Default value
|
||||||
|
|
||||||
|
for (const { pattern, value } of patternMapping) {
|
||||||
|
if (pattern.test(fieldName)) {
|
||||||
|
whichLocation = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return whichLocation;
|
||||||
|
|
||||||
const tags = {
|
const tags = {
|
||||||
containerid: containerName,
|
containerid: containerName,
|
||||||
@@ -723,6 +751,7 @@ export const uploadSingleFile = async (
|
|||||||
documentType: files[prop][0].fieldName.split(".")[1],
|
documentType: files[prop][0].fieldName.split(".")[1],
|
||||||
blobType: "RepresentationFile",
|
blobType: "RepresentationFile",
|
||||||
ishareLocation: whichLocation,
|
ishareLocation: whichLocation,
|
||||||
|
documentLocationId: whichLocation,
|
||||||
};
|
};
|
||||||
const withTags = await blockBlobClient.setTags(tags);
|
const withTags = await blockBlobClient.setTags(tags);
|
||||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||||
@@ -1275,8 +1304,7 @@ export const getAllProgressBlobs = async (containerName) => {
|
|||||||
(value, index, self) =>
|
(value, index, self) =>
|
||||||
index ===
|
index ===
|
||||||
self.findIndex(
|
self.findIndex(
|
||||||
(t) =>
|
(t) => t.name === value.name // Change 'id' to the property you're checking for uniqueness
|
||||||
t.name === value.name // Change 'id' to the property you're checking for uniqueness
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return unique;
|
return unique;
|
||||||
|
|||||||
Reference in New Issue
Block a user