Merge branch 'Development' into SIPS-Development
This commit is contained in:
+99
-2
@@ -309,7 +309,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
|
||||
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: formContent.caseRef,
|
||||
caseID: formContent.ticketnumber,
|
||||
blobType: "Representation",
|
||||
};
|
||||
|
||||
@@ -317,7 +317,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
|
||||
return formContent.pinswg_name;
|
||||
return formContent.ticketnumber;
|
||||
};
|
||||
|
||||
export const createAppealPDFBlob = async (
|
||||
@@ -1702,3 +1702,100 @@ export const listBlobHierarchical = async (
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function formatTimeSince(date) {
|
||||
if (!date) return "Unknown date";
|
||||
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffDays < 7) {
|
||||
return `${diffDays} day${diffDays !== 1 ? "s" : ""} ago`;
|
||||
} else {
|
||||
const diffWeeks = Math.floor(diffDays / 7);
|
||||
return `${diffWeeks} week${diffWeeks !== 1 ? "s" : ""} ago`;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateDisplay(date) {
|
||||
return date
|
||||
? `${date.toLocaleString("en-GB")} (${formatTimeSince(date)})`
|
||||
: "Unknown";
|
||||
}
|
||||
|
||||
export async function listBlobHierarchicalForUser(containerClient) {
|
||||
const blobNames = [];
|
||||
for await (const blob of containerClient.listBlobsFlat()) {
|
||||
const lastModifiedDate = blob.properties?.lastModified || null;
|
||||
const createdOnDate = blob.properties?.createdOn || null;
|
||||
|
||||
let displayDate = "";
|
||||
|
||||
if (createdOnDate && lastModifiedDate) {
|
||||
if (
|
||||
createdOnDate.toDateString() === lastModifiedDate.toDateString()
|
||||
) {
|
||||
// Same day — show just one
|
||||
displayDate = `Date: ${formatDateDisplay(lastModifiedDate)}`;
|
||||
} else {
|
||||
// Different days — show both
|
||||
displayDate = `Created: ${formatDateDisplay(
|
||||
createdOnDate
|
||||
)}, Modified: ${formatDateDisplay(lastModifiedDate)}`;
|
||||
}
|
||||
} else if (lastModifiedDate) {
|
||||
displayDate = `Modified: ${formatDateDisplay(lastModifiedDate)}`;
|
||||
} else if (createdOnDate) {
|
||||
displayDate = `Created: ${formatDateDisplay(createdOnDate)}`;
|
||||
} else {
|
||||
displayDate = "Unknown date";
|
||||
}
|
||||
|
||||
blobNames.push({
|
||||
name: blob.name,
|
||||
size: blob.properties.contentLength || 0,
|
||||
lastModified: lastModifiedDate
|
||||
? lastModifiedDate.toISOString()
|
||||
: null,
|
||||
createdOn: createdOnDate ? createdOnDate.toISOString() : null,
|
||||
displayDate,
|
||||
});
|
||||
}
|
||||
return blobNames;
|
||||
}
|
||||
|
||||
export async function listContainersForUser(
|
||||
blobServiceClient,
|
||||
containerNamePrefix,
|
||||
emailAddress
|
||||
) {
|
||||
const options = {
|
||||
includeDeleted: false,
|
||||
includeMetadata: true,
|
||||
includeSystem: true,
|
||||
prefix: containerNamePrefix,
|
||||
};
|
||||
|
||||
const results = [];
|
||||
|
||||
for await (const containerItem of blobServiceClient.listContainers(
|
||||
options
|
||||
)) {
|
||||
const containerClient = blobServiceClient.getContainerClient(
|
||||
containerItem.name
|
||||
);
|
||||
const blobNames = await listBlobHierarchicalForUser(
|
||||
containerClient
|
||||
).catch(console.error);
|
||||
|
||||
if (blobNames && blobNames.length > 0) {
|
||||
results.push({
|
||||
container: containerItem.name,
|
||||
blobs: blobNames,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return results; // array of non-empty containers
|
||||
}
|
||||
|
||||
+7
-9
@@ -1492,7 +1492,7 @@ export const deleteMyRepresentationsFromBlob = (
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteWatchedCases = (watchedCaseID) => {
|
||||
export const deleteWatchedCases = async (watchedCaseID) => {
|
||||
var queryUrl =
|
||||
"/api/endpoint/deletewatchedcasesproxy_api?watchedCaseID=" +
|
||||
watchedCaseID;
|
||||
@@ -1501,14 +1501,12 @@ export const deleteWatchedCases = (watchedCaseID) => {
|
||||
url: queryUrl,
|
||||
};
|
||||
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
//console.log("deleted ", res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
try {
|
||||
const res = await axios(config);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const createAccount = (formValues) => {
|
||||
|
||||
Reference in New Issue
Block a user