diff --git a/actions/azurestorage.js b/actions/azurestorage.js
index 6df4b509..095a4836 100644
--- a/actions/azurestorage.js
+++ b/actions/azurestorage.js
@@ -328,6 +328,10 @@ export const uploadFile = async (formContent, containerName, foldername) => {
const tags = {
containerid: containerName,
caseID: foldername,
+ documentType: files[prop][0].fieldName.slice(
+ 0,
+ files[prop][0].fieldName.indexOf("_")
+ ),
};
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -362,10 +366,13 @@ export const downloadProgressFile = async (
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
const containerClient = new ContainerClient(sasUrl);
const blobClient = containerClient.getBlobClient(blobName);
- const downloadedBlob = await blobClient.download(0);
+ const downloadedBlob = await blobClient.download();
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
- return downloaded;
+
+ console.log("Downloaded blob content:", downloaded.toString());
+
+ return JSON.parse(downloaded.toString());
};
export const downloadAllProgressFiles = async (
diff --git a/actions/index.js b/actions/index.js
index c1c7c5b0..3d35652b 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -1371,19 +1371,19 @@ export const getProgressFromBlob = async (containerName, casereference) => {
};
export const sendEmail = async (
- emailToAddress,
- emailSubject,
- emailContentTitle,
- emailContent
+ templateId,
+ emailAddress,
+ personalisation,
+ reference
) => {
var mailData = {
- "email": emailToAddress,
- "subject": emailSubject,
- "emailcontenttitle": emailContentTitle,
- "emailcontent": emailContent,
+ "templateId": templateId,
+ "emailAddress": emailAddress,
+ "reference": reference,
+ "personalisation": personalisation,
};
- var queryUrl = "/api/email";
+ var queryUrl = "/api/email/notify";
var config = {
method: "post",
diff --git a/components/elements/index.js b/components/elements/index.js
index 111e05dd..49746593 100644
--- a/components/elements/index.js
+++ b/components/elements/index.js
@@ -1540,7 +1540,8 @@ const RenderFileUpload = (field) => {
width="50"
/>
- {file.name} ({bytesToSize(file.size)})
+ {file.name.slice(file.name.indexOf("_") + 1)} (
+ ({bytesToSize(file.size)})
))}
@@ -1588,7 +1589,8 @@ const RenderFileUpload = (field) => {
}
>
- {blob.name} ({bytesToSize(blob.contentLength)})
+ {blob.name.slice(blob.name.indexOf("_") + 1)} (
+ {bytesToSize(blob.contentLength)})
diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js
index f1617f87..56b690d9 100644
--- a/components/newappeal/buildchecksection.js
+++ b/components/newappeal/buildchecksection.js
@@ -139,9 +139,9 @@ let BuildCheckSection = (props) => {
-
-
- {_.has(props.props.appealType.fileList.files) &&
- props.props.appealType.fileList.files.length > 0
+
-
+ {props.props.appealType.fileList.files.length >
+ 0
? props.props.appealType.fileList.files.map(
(blob, i) => (
{
src={getThumbnailIconByExtension(
blob.name
)}
- alt={blob.name}
+ alt={blob.name.slice(
+ blob.name.indexOf(
+ "_"
+ ) + 1
+ )}
width="50"
/>
- {blob.name} (
+ {blob.name.slice(
+ blob.name.indexOf(
+ "_"
+ ) + 1
+ )}
+ (
{bytesToSize(
blob.contentLength
)}
diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js
index e592936e..eed58f38 100644
--- a/components/newappeal/buildsection.js
+++ b/components/newappeal/buildsection.js
@@ -125,7 +125,11 @@ let BuildSection = (props) => {
});
};
- const updateCaseProgress = (values, sendSavedEmail, useSaveStatus) => {
+ const updateCaseProgress = async (
+ values,
+ sendSavedEmail,
+ useSaveStatus
+ ) => {
let incidentId = props.appealType.caseReference.incidentid;
let updateBody = values || {};
@@ -169,35 +173,29 @@ let BuildSection = (props) => {
let updateFormCollection = appTypeCollection.LogicalCollectionName;
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
- // updateCase(
- // incidentId,
- // updateBody,
- // updateFormCollection,
- // primaryAttribute,
- // props.appealType.caseReference.ticketnumber
- // );
+ const reference = "PEDW-PARTIAL";
+ const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75";
+ const emailAddress = props.props.accountDetails.loggedinUserEmail;
+ const personalisation = {
+ "caseReference": props.appealType.caseReference.ticketnumber,
+ "emailAddress": props.props.accountDetails.loggedinUserEmail,
+ "returnLink":
+ props.props.url +
+ "/myportal/" +
+ appTypeCollection.UrlName +
+ "?lpa=" +
+ props.appealType.appealLPA +
+ "&apt=" +
+ appTypeCollection.appealTypeID +
+ "&casereference=" +
+ props.appealType.caseReference.ticketnumber +
+ "&inid=" +
+ props.appealType.caseReference.incidentid,
+ "linkExpiry": 10 * 60,
+ };
sendSavedEmail == true &&
- sendEmail(
- props.props.accountDetails.loggedinUserEmail,
- "Saved progress for appeal " +
- props.appealType.caseReference.ticketnumber,
- "Your saved appeal " +
- props.appealType.caseReference.ticketnumber,
- "You can resume your application at a later date from here "
- );
+ sendEmail(templateId, emailAddress, personalisation, reference);
useSaveStatus &&
router.replace(
diff --git a/components/newappeal/complete.js b/components/newappeal/complete.js
index 9670ee4a..7d915d0a 100644
--- a/components/newappeal/complete.js
+++ b/components/newappeal/complete.js
@@ -50,13 +50,15 @@ let CompleteAppeal = (props) => {
props.appealType.caseReference.ticketnumber
);
- sendEmail(
- props.props.accountDetails.loggedinUserEmail,
- "Saved progress for appeal " +
- props.appealType.caseReference.ticketnumber,
- "Your saved appeal " + props.appealType.caseReference.ticketnumber,
- "You have now completed your appeal."
- );
+ const reference = "PEDW-COMPLETE";
+ const templateId = "618e0463-b092-4733-a024-bf8a3bbde808";
+ const emailAddress = props.props.accountDetails.loggedinUserEmail;
+ const personalisation = {
+ "caseReference": props.appealType.caseReference.ticketnumber,
+ "emailAddress": props.props.accountDetails.loggedinUserEmail,
+ "linkExpiry": 10 * 60,
+ };
+ sendEmail(templateId, emailAddress, personalisation, reference);
console.log("patching////////");
patchCase(incidentId);
diff --git a/pages/api/email/notify.js b/pages/api/email/notify.js
new file mode 100644
index 00000000..2a0d5d9b
--- /dev/null
+++ b/pages/api/email/notify.js
@@ -0,0 +1,26 @@
+import { consoleLogger } from "../../../actions";
+
+export default async function ApiProxy(req, res) {
+ var data = req.body;
+
+ var NotifyClient = require("notifications-node-client").NotifyClient;
+
+ const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
+ //const emailReplyToId = process.env.EMAIL_REPLY_TO_ID;
+
+ notifyClient
+ .sendEmail(data.templateId, data.emailAddress, {
+ personalisation: data.personalisation,
+ reference: data.reference,
+ // emailReplyToId: emailReplyToId,
+ })
+ .then((response) => {
+ //console.log("thisis the response", response);
+ return res.status(200).json(data);
+ })
+ .catch((err) => {
+ consoleLogger(err);
+ return res.status(400).json(err);
+ });
+ //return res.status(200).json(data);
+}
diff --git a/pages/api/file/downloadblob.js b/pages/api/file/downloadblob.js
index 6067189a..9a765710 100644
--- a/pages/api/file/downloadblob.js
+++ b/pages/api/file/downloadblob.js
@@ -32,7 +32,8 @@ ApiProxy.get(async (req, res) => {
res.setHeader(
"content-disposition",
- "attachment; filename=" + decodeURI(blobName)
+ "attachment; filename=" +
+ decodeURI(blobName.slice(blobName.indexOf("_") + 1))
);
return res.status(200).send(downloaded);
} else {
diff --git a/pages/api/file/getprogressobjblob.js b/pages/api/file/getprogressobjblob.js
index bb76532b..38c15b51 100644
--- a/pages/api/file/getprogressobjblob.js
+++ b/pages/api/file/getprogressobjblob.js
@@ -26,6 +26,7 @@ ApiProxy.get(async (req, res) => {
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getProgressBlobs(containerName, casefolderID)
.then((data) => {
+ console.log("ertyuikjhgfg", data.path);
return downloadProgressFile(containerName, data.path, casefolderID);
})
.then((data) => {