update formatting

This commit is contained in:
2026-03-17 09:22:31 +00:00
parent 1e690608fb
commit f1775c2a96
3 changed files with 159 additions and 133 deletions
+105 -97
View File
@@ -5,7 +5,7 @@ import { PrismaClient } from "@prisma/client";
import CryptoJS from "crypto-js";
import { getUpToLastSlash, streamToString } from "../utils/adminHelper";
import { listContainersForUser } from "../../../actions/azurestorage";
import pLimit from "p-limit";
const prisma = global.prisma || new PrismaClient();
const WORDKEY = process.env.HASHKEY;
/**
@@ -34,112 +34,120 @@ export async function fetchAdminStorageData() {
const users = await prisma.user.findMany();
const limit = pLimit(5);
let data = await Promise.all(
users.map(async (user) => {
const containers = await listContainersForUser(
blobServiceClient,
`${user.id}`,
user.email
);
limit(async () => {
const containers = await listContainersForUser(
blobServiceClient,
`${user.id}`,
user.email
);
const containersWithHashes = await Promise.all(
containers.map(async (container) => {
const groupedByFolder = await container.blobs.reduce(
async (accP, blob) => {
const acc = await accP;
const folderPath =
getUpToLastSlash(blob.name.trim()) || "";
const containersWithHashes = await Promise.all(
containers.map(async (container) => {
const groupedByFolder = await container.blobs.reduce(
async (accP, blob) => {
const acc = await accP;
const folderPath =
getUpToLastSlash(blob.name.trim()) || "";
const hashedfilepath = hashAPIPath(
`/api/file/downloadblob?container=${
container.container
}&casefolderID=${folderPath}&blobname=${blob.name
.substring(blob.name.lastIndexOf("/") + 1)
.trim()}`,
process.env.HASHKEY
);
const fileNameOnly = blob.name.substring(
blob.name.lastIndexOf("/") + 1
);
const isTmpFile = fileNameOnly.startsWith("TMP-");
const blobWithHash = {
...blob,
hashedfilepath,
isTmpFile
};
let folderGroup = acc.find(
(f) => f.folderPath === folderPath
);
if (!folderGroup) {
folderGroup = {
folderPath,
blobs: [],
hasRepJson: false,
repJsonBlob: null,
repComplete: false,
hasTmpFile: false
};
acc.push(folderGroup);
}
folderGroup.blobs.push(blobWithHash);
if (isTmpFile) {
folderGroup.hasTmpFile = true;
}
// rep.json handling
if (blob.name.toLowerCase().endsWith("rep.json")) {
folderGroup.hasRepJson = true;
folderGroup.repJsonBlob = blobWithHash;
const containerClient =
blobServiceClient.getContainerClient(
const hashedfilepath = hashAPIPath(
`/api/file/downloadblob?container=${
container.container
);
const blockBlobClient =
containerClient.getBlockBlobClient(
blob.name
);
}&casefolderID=${folderPath}&blobname=${blob.name
.substring(
blob.name.lastIndexOf("/") + 1
)
.trim()}`,
process.env.HASHKEY
);
try {
const downloadResponse =
await blockBlobClient.download(0);
const downloaded = await streamToString(
downloadResponse.readableStreamBody
);
const json = JSON.parse(downloaded);
folderGroup.repComplete = Boolean(
json.repComplete
);
} catch (err) {
console.error(
"Error reading rep.json",
err
);
folderGroup.repComplete = false;
const fileNameOnly = blob.name.substring(
blob.name.lastIndexOf("/") + 1
);
const isTmpFile =
fileNameOnly.startsWith("TMP-");
const blobWithHash = {
...blob,
hashedfilepath,
isTmpFile
};
let folderGroup = acc.find(
(f) => f.folderPath === folderPath
);
if (!folderGroup) {
folderGroup = {
folderPath,
blobs: [],
hasRepJson: false,
repJsonBlob: null,
repComplete: false,
hasTmpFile: false
};
acc.push(folderGroup);
}
}
return acc;
},
Promise.resolve([])
);
folderGroup.blobs.push(blobWithHash);
return { ...container, folders: groupedByFolder };
})
);
if (isTmpFile) {
folderGroup.hasTmpFile = true;
}
return containersWithHashes.length > 0
? {
id: user.id,
email: user.email,
containers: containersWithHashes
}
: null;
// rep.json handling
if (
blob.name.toLowerCase().endsWith("rep.json")
) {
folderGroup.hasRepJson = true;
folderGroup.repJsonBlob = blobWithHash;
const containerClient =
blobServiceClient.getContainerClient(
container.container
);
const blockBlobClient =
containerClient.getBlockBlobClient(
blob.name
);
try {
const downloadResponse =
await blockBlobClient.download(0);
const downloaded = await streamToString(
downloadResponse.readableStreamBody
);
const json = JSON.parse(downloaded);
folderGroup.repComplete = Boolean(
json.repComplete
);
} catch (err) {
console.error(
"Error reading rep.json",
err
);
folderGroup.repComplete = false;
}
}
return acc;
},
Promise.resolve([])
);
return { ...container, folders: groupedByFolder };
})
);
return containersWithHashes.length > 0
? {
id: user.id,
email: user.email,
containers: containersWithHashes
}
: null;
});
})
);
+1 -1
View File
@@ -450,7 +450,7 @@ let BuildCheckSection = (props) => {
data-module="govuk-button"
onClick={async () => {
await triggerAppealDownload();
finaliseAppeal();
// finaliseAppeal();
}}
>
{t("newappeal:submit-appeal-button")}
+53 -35
View File
@@ -112,7 +112,8 @@ export const AppealRow_pdf = (props) => {
color: "grey"
},
documentList: {
fontSize: 10
fontSize: 10,
lineHeight: 1.4
},
richArea: {
fontSize: 12,
@@ -432,51 +433,68 @@ export const AppealRow_pdf = (props) => {
flexDirection: "column",
marginBottom: 10
}}
wrap={false}
>
<View
wrap={false}
style={{
flexDirection: "row",
flexDirection: "column",
marginBottom: 10
}}
>
<Text
{/* Removed wrap={false} here so the list can flow to page 2 */}
<View
style={{
flexDirection: "row",
marginBottom: 10
}}
>
<Text
style={
styles.questionTextWide
}
>
{rows[0].value}
</Text>
</View>
<View
style={
styles.questionTextWide
styles.questionAnswerWide
}
>
{rows[0].value}
</Text>
</View>
<View
style={
styles.questionAnswerWide
}
>
{blobList.map((blob, i) => (
<Text key={i}>
{getDocumentTypeFromFilename(
blob.name
) ===
{blobList.map((blob, i) => {
const isTargetType =
getDocumentTypeFromFilename(
blob.name
) ===
documentTypeCode[0]
.value && (
<Text
style={
styles.documentList
}
.value;
if (!isTargetType)
return null;
return (
/* wrap={false} here ensures a single filename stays together */
<View
key={i}
wrap={false}
style={{
marginBottom: 4
}}
>
{blob.name}
{blob?.size &&
" - " +
bytesToSize(
blob?.size
)}{" "}
{"\n"}
</Text>
)}
</Text>
))}
<Text
style={
styles.documentList
}
>
{blob.name}
{blob?.size &&
` - ${bytesToSize(blob.size)}`}
</Text>
</View>
);
})}
</View>
</View>
</View>
);