Merged PR 895: awaiting submissions from storage acc

awaiting submissions from storage acc

Related work items: #7907
This commit is contained in:
Robert Bond
2022-09-06 07:26:14 +00:00
25 changed files with 653 additions and 69 deletions
+134 -4
View File
@@ -120,7 +120,7 @@ export const getBlobs = async (containerName, casefolderID) => {
),
});
}
console.log("blobObj:", blobObj);
//console.log("blobObj:", blobObj);
return blobObj;
};
@@ -230,13 +230,46 @@ export const downloadProgressFile = async (
);
const blobClient = containerClient.getBlobClient(blobName);
console.log("herher:", containerName, blobName, casefolderID);
const downloadedBlob = await blobClient.download(0);
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
return downloaded;
};
export const downloadAllProgressFiles = async (
containerName,
progressBlobObj
) => {
//console.log(progressBlobObj);
const creds = new DefaultAzureCredential();
const containerClient = new ContainerClient(
`${STORAGE_PATH}/${containerName}`,
creds
);
let blobClient = {};
let downloadedBlob = {};
let downloaded = "";
let blobCount = 0;
for (const prop in progressBlobObj) {
//console.log(`${prop}: ${progressBlobObj[prop].path}`);
blobClient = containerClient.getBlobClient(progressBlobObj[prop].path);
downloadedBlob = await blobClient.download(0);
downloaded =
downloaded +
(await streamToBuffer(downloadedBlob.readableStreamBody)) +
",";
blobCount++;
}
downloaded = downloaded.substring(0, downloaded.length - 1);
//console.log(downloaded);
return '{ "@odata.count": ' + blobCount + ',"value": [' + downloaded + "]}";
};
const streamToBuffer = async (readableStream) => {
return new Promise((resolve, reject) => {
const chunks = [];
@@ -250,6 +283,42 @@ const streamToBuffer = async (readableStream) => {
});
};
export const getCaseBlob = async (
containerName,
caseReference,
formContent
) => {
const creds = new DefaultAzureCredential();
const containerClient = new ContainerClient(
`${STORAGE_PATH}/${containerName}`,
creds
);
console.log("have got to create case");
containerClient.createIfNotExists();
let blobCount = 0;
for await (const blob of containerClient.listBlobsFlat({
prefix: caseReference,
})) {
blobCount++;
}
const content = JSON.stringify(formContent);
const blobName = caseReference + "/case/" + caseReference + ".json";
console.log("blobName:", blobName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient.upload(
content,
Buffer.byteLength(content)
);
return blobName;
};
export const getProgressBlobs = async (containerName, caseReference) => {
const creds = new DefaultAzureCredential();
@@ -260,7 +329,15 @@ export const getProgressBlobs = async (containerName, caseReference) => {
containerClient.createIfNotExists();
console.log("thisi s the caasefolder:", caseReference);
let blobCount = 0;
for await (const blob of containerClient.listBlobsFlat({
prefix: caseReference,
})) {
blobCount++;
}
//console.log("this is the caasefolder:", caseReference, blobCount);
let blobObj = [];
for await (const blob of containerClient.listBlobsFlat({
prefix: caseReference + "/" + caseReference + ".json",
@@ -304,7 +381,60 @@ export const getProgressBlobs = async (containerName, caseReference) => {
},
]).reverse()[0];
console.log("blobObj:", blobObj);
//console.log("blobObjwwwww:", blobObj);
return blobObj;
};
export const getAllProgressBlobs = async (containerName) => {
const creds = new DefaultAzureCredential();
const containerClient = new ContainerClient(
`${STORAGE_PATH}/${containerName}`,
creds
);
containerClient.createIfNotExists();
let blobCount = 0;
for await (const blob of containerClient.listBlobsFlat({
// prefix: caseReference,
})) {
blobCount++;
}
//console.log("this is the caasefolder:", caseReference, blobCount);
let blobObj = [];
for await (const blob of containerClient.listBlobsFlat({
//prefix: caseReference + "/" + caseReference + ".json",
})) {
blob.name.split("/")[1].indexOf(".json") > 0 &&
blob.name.split("/")[1].indexOf("undefined") < 0 &&
blobObj.push({
"name": blob.name.split("/")[1],
"path": blob.name,
"versionId": blob.versionId,
"isCurrentVersion": blob.isCurrentVersion,
"contentLength": blob.properties.contentLength,
"contentType": blob.contentType,
"lastModified": blob.properties.lastModified,
// "hashedfilepath": hashAPIPath(
// "/api/file/downloadblob?container=" +
// containerName +
// ),
// "hasheddeletepath": hashAPIPath(
// "/api/file/deleteblob?container=" +
// containerName +
// ),
// "hashgetblobs": hashAPIPath(
// "/api/file/getbloblist?container=" +
// containerName +
// ),
});
}
//console.log("blobObj:", blobObj);
return blobObj;
};
+93 -6
View File
@@ -3,7 +3,8 @@ import https from "https";
import CryptoJS from "crypto-js";
import HmacSHA256 from "crypto-js/hmac-sha256";
import { getFormCollection } from "../components/utils";
import { downloadFile } from "./azurestorage";
import { downloadFile, getCaseBlob } from "./azurestorage";
let BASE_URL;
const port = parseInt(process.env.PORT, 10) || 3000;
@@ -132,7 +133,6 @@ export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
};
export const hashAPIPath = (queryPath) => {
console.log(queryPath);
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
@@ -744,6 +744,11 @@ export const getAwaitingSubmissionProxy = (loggedInUserId) => {
};
export const getAwaitingSubmission = (loggedInUserId) => {
console.log(
BASE_URL +
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
loggedInUserId
);
return axios
.get(
BASE_URL +
@@ -758,6 +763,25 @@ export const getAwaitingSubmission = (loggedInUserId) => {
});
};
export const getAwaitingSubmissionFromBlob = (containerName) => {
return axios
.get(
BASE_URL +
"/api/file/getawaitingsubmissionfromblob?container=" +
containerName +
hashAPIPath(
"/api/file/getawaitingsubmissionfromblob?container=" +
containerName
)
)
.then((res) => {
return res.data;
})
.catch((error) => {
//console.log("API call error", error);
});
};
export const getPortalModuleDetails = (appealType, caseReference) => {
//console.log(
// BASE_URL +
@@ -864,7 +888,13 @@ export const createWatchedCases = (formValues) => {
});
};
export const createNewCase = (appealTypeId, lpaID, contactid, createBody) => {
export const createNewCase = (
appealTypeId,
lpaID,
contactid,
createBody,
containerName
) => {
appealTypeId = parseInt(appealTypeId);
var data = createBody;
@@ -875,7 +905,9 @@ export const createNewCase = (appealTypeId, lpaID, contactid, createBody) => {
"&lpaID=" +
lpaID +
"&contactid=" +
contactid;
contactid +
"&containername=" +
containerName;
var config = {
method: "post",
@@ -1004,6 +1036,31 @@ export const deleteAwaitingSubmissions = (incidentID) => {
});
};
export const deleteAwaitingSubmissionsFromBlob = (
containerID,
casefolderID
) => {
var queryUrl =
"/api/file/deleteawaitingsubmissionsfromblob?container=" +
containerID +
"&casefolderID=" +
casefolderID;
var config = {
method: "get",
url: queryUrl,
};
//console.log(config);
return axios(config)
.then((res) => {
//console.log("deleted ", res.data);
return res.data;
})
.catch((error) => {
console.log("this serror", error);
});
};
export const deleteWatchedCases = (watchedCaseID) => {
var queryUrl =
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
@@ -1165,7 +1222,7 @@ export const downloadBlob = (containerName, blobName) => {
{ responseType: "blob" }
)
.then((response) => {
console.log("Downloaded blob content:www");
console.log("Downloaded blob content:");
res.setHeader(
"content-disposition",
@@ -1181,7 +1238,6 @@ export const downloadBlob = (containerName, blobName) => {
};
export const getProgressFromBlob = async (containerName, casereference) => {
console.log("cont:", containerName);
try {
const res = await axios.get(
BASE_URL +
@@ -1201,3 +1257,34 @@ export const getProgressFromBlob = async (containerName, casereference) => {
console.log("this serror", error);
}
};
export const sendEmail = async (
emailToAddress,
emailSubject,
emailContentTitle,
emailContent
) => {
var mailData = {
"email": emailToAddress,
"subject": emailSubject,
"emailcontenttitle": emailContentTitle,
"emailcontent": emailContent,
};
var queryUrl = "/api/email";
var config = {
method: "post",
url: queryUrl,
data: mailData,
};
return axios(config)
.then((res) => {
//console.log("posted ", res.data);
return res.data;
})
.catch((error) => {
console.log("this serror", error);
});
};
+7 -7
View File
@@ -246,13 +246,13 @@ let Login = (props) => {
</button>
)}
{session && (
<button
className="govuk-button"
type="button"
onClick={() => signOut()}
>
Magic Link Sign Out
</button>
// <button
// className="govuk-button"
// type="button"
// onClick={() => signOut()}
// >
// Magic Link Sign Out
// </button>
)}
</div>
<form onSubmit={handleSubmit(onHandleSubmit)}>
+12
View File
@@ -5,6 +5,8 @@ import { useRouter } from "next/router";
import { destroyCookie } from "nookies";
import TimeOut from "../components/timeout";
import AwaitingSubmission from "./myportal/awaitingsubmission";
import AwaitingSubmissionFromBlob from "./myportal/awaitingsubmissionfromblob";
import Dns from "./myportal/dns";
import MakeNewAppeal from "./myportal/makenewappeal";
import MyCases from "./myportal/mycases";
@@ -101,6 +103,16 @@ const MyPortal = (props) => {
}
/>
)}
{props.awaitingSubmission
.awaitingSubmissionFromBlob["@odata.count"] >
0 && (
<AwaitingSubmissionFromBlob
awaitingSubmissionFromBlob={
props.awaitingSubmission
.awaitingSubmissionFromBlob
}
/>
)}
{props.myCases.myCases["@odata.count"] > 0 && (
<MyCases myCases={props.myCases} />
)}
@@ -0,0 +1,105 @@
import Link from "next/link";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import TopThree from "./topthree";
import { connect } from "react-redux";
import { setCurrentView } from "../../store/currentView/action";
const AwaitingSubmissionFromBlob = (props) => {
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
const { setCurrentView } = props;
let topthreeRow = [];
let showTopThreeArr = props.awaitingSubmissionFromBlob.value;
let topThreeOnlyArr = showTopThreeArr;
Object.keys(topThreeOnlyArr).map((key, index) => {
topthreeRow.push(
<div className="cardModuleItem" key={index}>
<div className="cardModuleDetails">
<div className="cardModuleReference">
<b>{t("myportal:case-reference")}:</b>
{showTopThreeArr[index].pinswg_name}
</div>
<div className="carModuleAddress">
<b>{t("myportal:case-address")}:</b>{" "}
{_.isEmpty(showTopThreeArr)
? t("myportal:case-address-not-entered")
: _.isEmpty(showTopThreeArr[index])
? t("myportal:case-address-not-entered")
: _.isEmpty(showTopThreeArr[index])
? t("myportal:case-address-not-entered")
: _.isEmpty(
showTopThreeArr[index].pinswg_siteaddressline1
)
? t("myportal:case-address-not-entered")
: showTopThreeArr[index].pinswg_siteaddressline1 +
(!_.isEmpty(
showTopThreeArr[index].pinswg_siteaddressline2
)
? ", " +
showTopThreeArr[index]
.pinswg_siteaddressline2
: "") +
(!_.isEmpty(
showTopThreeArr[index].pinswg_siteaddresstown
)
? ", " +
showTopThreeArr[index]
.pinswg_siteaddresstown
: "")}
</div>
</div>
</div>
);
});
return (
<div className="card" id="casescomment-card">
<div className="card-body">
<h3 className="heading-small card-heading">
{t("myportal:awatitingsubmission-card-title")}
</h3>
<div className="cardModuleContainer">
{topthreeRow}
{/* <TopThree
showTopThree={props.awaitingSubmissionFromBlob}
showDetails={props.awaitingSubmissionFromBlob}
topThreeType={"awaitingSubmissionFromBlob"}
/> */}
</div>
{props.awaitingSubmissionFromBlob["@odata.count"] > 3 && (
<div className="cardVieAll">
<Link href="/myportal/viewall">
<a
className="govuk-link--no-underline"
onClick={() => {
setCurrentView({
"viewName": "Awaiting Submission",
"viewKey": "awaitingSubmission",
});
}}
>
{t("myportal:viewall-link")}
</a>
</Link>
</div>
)}
</div>
</div>
);
};
const mapDispatchToProps = (dispatch) => {
return {
setCurrentView: (currentView) => {
dispatch(setCurrentView(currentView));
},
};
};
export default connect(null, mapDispatchToProps)(AwaitingSubmissionFromBlob);
+2 -1
View File
@@ -142,7 +142,8 @@ const TopThree = (props) => {
<b>{t("myportal:case-reference")}:</b>
<Link
href={
topThreeType == "awaitingSubmission"
topThreeType == "awaitingSubmission" ||
topThreeType == "awaitingSubmissionFromBlob"
? router.locale == "cy"
? "/fymhorth/parhauigyflwyno"
: "/myportal" +
+27 -7
View File
@@ -15,7 +15,7 @@ import {
setNewAppealProgress,
} from "../../store/appealType/action";
import { getFormCollectionByID, getProgressObj } from "../utils";
import { updateCase, patchCase, uploadFiles } from "../../actions";
import { updateCase, patchCase, uploadFiles, sendEmail } from "../../actions";
import { FieldsTranslations } from "../elements";
import jsonpath from "jsonpath";
@@ -134,7 +134,7 @@ let BuildSection = (props) => {
});
};
const updateCaseProgress = (values) => {
const updateCaseProgress = (values, sendSavedEmail) => {
let incidentId = props.appealType.caseReference.incidentid;
let updateBody = values || {};
@@ -183,8 +183,28 @@ let BuildSection = (props) => {
primaryAttribute,
props.appealType.caseReference.ticketnumber
);
//console.log("patching////////");
//patchCase(incidentId);
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 <a href='" +
props.props.url +
"/myportal/" +
appTypeCollection.UrlName +
"?lpa=" +
props.appealType.appealLPA +
"&apt=" +
appTypeCollection.appealTypeID +
"&casereference=" +
props.appealType.caseReference.ticketnumber +
"&inid=" +
props.appealType.caseReference.incidentid +
"'> from here </a>"
);
};
const onHandleSubmit = (values) => {
@@ -193,7 +213,7 @@ let BuildSection = (props) => {
delete valuesObj["_pinswg_appellant_value"];
console.log("has errors:", props.invalid);
props.invalid == false && updateCaseProgress(valuesObj);
props.invalid == false && updateCaseProgress(valuesObj, false);
setCurrentSection(currentSection + 1);
};
@@ -309,7 +329,7 @@ let BuildSection = (props) => {
delete valuesObj["_pinswg_appellant_value"];
//console.log("on save:", valuesObj);
updateCaseProgress(valuesObj);
updateCaseProgress(valuesObj, false);
}}
>
{t("common:continue-button")}
@@ -373,7 +393,7 @@ let BuildSection = (props) => {
delete valuesObj["_pinswg_appellant_value"];
console.log("on save:", valuesObj);
updateCaseProgress(valuesObj);
updateCaseProgress(valuesObj, true);
router.replace(
router.locale != "en"
? router.locale + "/myportal"
+10 -1
View File
@@ -6,7 +6,7 @@ import { useEffect } from "react";
import { connect } from "react-redux";
import { formValueSelector } from "redux-form";
import xpath from "xpath";
import { updateCase, patchCase } from "../../actions";
import { updateCase, patchCase, sendEmail } from "../../actions";
import data from "../../data/collections.json";
import { setCurrentSection } from "../../store/appealType/action";
import { getFormCollectionByID } from "../utils";
@@ -49,6 +49,15 @@ let CompleteAppeal = (props) => {
primaryAttribute,
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."
);
console.log("patching////////");
patchCase(incidentId);
}, [
+2 -1
View File
@@ -454,7 +454,8 @@ let CreateCase = (props) => {
appTypeCollection.appealTypeID,
values.lpaTypes,
props.loggedInUser,
values
values,
props.containerID
)
.then((data) => {
router.replace(
+2 -2
View File
@@ -49,7 +49,7 @@
"next-redux-wrapper": "^7.0.5",
"next-translate": "^1.2.0",
"nextjs-basic-auth-middleware": "^0.2.1",
"nodemailer": "^6.7.3",
"nodemailer": "^6.7.8",
"nookies": "^2.5.2",
"ospoint": "^0.2.1",
"path": "^0.12.7",
@@ -86,4 +86,4 @@
"prettier": "2.5.1",
"prisma": "^3.12.0"
}
}
}
+81
View File
@@ -0,0 +1,81 @@
import nodemailer from "nodemailer";
export default function handler(req, res) {
const { email, subject, emailcontenttitle, emailcontent } = req.body;
console.log(email);
//console.log(process.env);
const client = nodemailer.createTransport({
auth: {
user: process.env.EMAIL_SERVER_USER,
pass: process.env.EMAIL_SERVER_PASSWORD,
},
host: process.env.EMAIL_SERVER_HOST,
port: process.env.EMAIL_SERVER_PORT,
secure: true,
});
//console.log(client);
// Some simple styling options
const backgroundColor = "#ffffff";
const textColor = "#444444";
const mainBackgroundColor = "#ffffff";
const buttonBackgroundColor = "#aa1111";
const buttonBorderColor = "#aa1111";
const buttonTextColor = "#ffffff";
const headerBackgroundColor = "#000000";
const url = process.env.API_ROOT;
let emailBodyContent = ` <body style="background: ${backgroundColor};">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="padding: 10px 0px 20px 0px; font-size: 22px; font-family: Helvetica, Arial, sans-serif; color: #fff;background-color: ${headerBackgroundColor};border-bottom: 10px solid #ffd530;>
<strong>PEDW - Planning Casework</strong>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="20" cellpadding="0" style="background: ${mainBackgroundColor}; max-width: 600px; margin: auto; border-radius: 10px;">
<tr>
<td align="left" style="padding: 10px 0px 0px 0px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; color: ${textColor};">
${emailcontenttitle}
</td>
<img src ="${url}/assets/images/planning-casework-en.svg"/>
</tr>
<tr>
<td align="left" style="padding: 10px 0px 0px 0px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; color: ${textColor};">
${emailcontent}
</td>
</tr>
<tr>
<td align="center" style="padding: 20px 0;">
</td>
</tr>
<tr>
<td align="center" style="padding: 0px 0px 10px 0px; font-size: 16px; line-height: 22px; font-family: Helvetica, Arial, sans-serif; color: ${textColor};">
If you did not request this email you can safely ignore it.
</td>
</tr>
</table>
</body>`;
const mailData = {
from: "no-reply@rdbdigital.com",
to: email,
subject: subject,
text: emailBodyContent,
html: emailBodyContent,
};
client.sendMail(mailData, (err, data) => {
if (err) {
console.log(err);
res.status(400);
} else {
console.log("mail sent");
res.status(200).json(data);
}
});
}
+7 -6
View File
@@ -2,7 +2,7 @@ import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions";
import { getCaseBlob } from "../../../actions/azurestorage";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
@@ -25,6 +25,7 @@ export default async function ApiProxy(req, res) {
var createCaseBody = req.body;
var contactid = req.query.contactid;
var appealTypeId = req.query.appealTypeId;
var containerName = req.query.containername;
var lpaID = req.query.lpaID;
var queryUrl = "incidents";
var token = await getToken();
@@ -42,7 +43,7 @@ export default async function ApiProxy(req, res) {
delete newData.lpaTypes;
delete newData.appealTypes;
console.log("/////Create Case:", newData);
console.log("/////Create Case:\n", newData, "\n//////////////");
var config = {
method: "post",
@@ -55,18 +56,18 @@ export default async function ApiProxy(req, res) {
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
data: JSON.stringify(data),
data: JSON.stringify(newData),
};
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: axios(config)
.then(({ data }) => {
console.log(data);
getCaseBlob(containerName, data.ticketnumber, createCaseBody);
res.status(200).json(data);
})
.catch((err) => {
console.log(consoleLogger(err));
//console.log(consoleLogger(err));
res.status(400).json(err);
});
@@ -0,0 +1,45 @@
import { hashAPIPath } from "../../../actions";
import { deleteBlob } from "../../../actions/azurestorage";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
const ApiProxy = nextConnect();
ApiProxy.use(middleware);
ApiProxy.get(async (req, res) => {
var containerName = req.query.container;
var casefolderID = req.query.casefolderID;
var blobName = req.query.blobname;
var checkHash = req.query.hash;
var checkquerypath =
"/api/file/deleteblob?container=" +
containerName +
"&casefolderID=" +
casefolderID +
"&blobname=" +
blobName;
// console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await deleteBlob(
containerName,
casefolderID + "/files/" + blobName
).then((data) => {
return res.status(200).json({ data: data });
});
} else {
return res.status(400).json();
}
});
export const config = {
api: {
bodyParser: false,
},
};
export default ApiProxy;
@@ -0,0 +1,44 @@
import {
downloadAllProgressFiles,
getAllProgressBlobs,
} from "../../../actions/azurestorage";
import _ from "lodash";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
import { hashAPIPath } from "../../../actions";
const ApiProxy = nextConnect();
ApiProxy.use(middleware);
ApiProxy.get(async (req, res) => {
var containerName = req.query.container;
var checkHash = req.query.hash;
var checkquerypath =
"/api/file/getawaitingsubmissionfromblob?container=" + containerName;
// console.log(req.url);
// console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getAllProgressBlobs(containerName)
.then((data) => {
//console.log(data);
return downloadAllProgressFiles(containerName, data);
})
.then((data) => {
return res.status(200).json(data);
});
} else {
return res.status(400).json();
}
});
export const config = {
api: {
bodyParser: false,
},
};
export default ApiProxy;
+4 -4
View File
@@ -2,7 +2,7 @@ import {
downloadProgressFile,
getProgressBlobs,
} from "../../../actions/azurestorage";
import _ from "lodash";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
@@ -25,9 +25,9 @@ ApiProxy.get(async (req, res) => {
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getProgressBlobs(containerName, casefolderID)
.then((data) =>
downloadProgressFile(containerName, data.path, casefolderID)
)
.then((data) => {
return downloadProgressFile(containerName, data.path, casefolderID);
})
.then((data) => {
return res.status(200).json(data);
});
+1 -5
View File
@@ -32,11 +32,7 @@ ApiProxy.post(async (req, res) => {
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
//createContainer(containerID).then((containerName) => {
console.log(
"does this et folder name:",
appealData.pinswg_name,
casefolderID
);
console.log("does this get folder name:", containerID, casefolderID);
createBlob(appealData, containerID, casefolderID).then((data) => {
Object.keys(req.files).length > 0 &&
uploadFile(req.files, containerID, casefolderID);
+1 -1
View File
@@ -32,7 +32,7 @@ const SignIn = (props) => {
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds govuk-body">
A link has been sent to your email so you can
continue
continue. Please close this window.
</div>
</div>
<div className="govuk-grid-row">
+1 -1
View File
@@ -132,7 +132,7 @@ const Home = (props) => {
<CookieBanner />
<Header courseName="Appeals Casework Portal" />
<div className="govuk-width-container">
{hasGGCode ? (
{hasLoginCode ? (
<>
<h1>
{ggLocale == "cy"
+25 -19
View File
@@ -7,7 +7,7 @@ import { useEffect } from "react";
import { connect } from "react-redux";
import xpath from "xpath";
import {
getAppealsTypes,
getAppealsTypesForNewAppeal,
getMandatoryFields,
getPickLists,
getPartSavedAppeal,
@@ -26,6 +26,7 @@ import TimeOut from "../../components/timeout";
import {
setLoggedInUserId,
setLoggedInUserEmail,
setContainerID,
} from "../../store/accountDetails/action";
import {
@@ -217,32 +218,32 @@ export const getServerSideProps = wrapper.getServerSideProps(
const { query, req, res } = ctx;
const { cookies } = req;
console.log(cookies);
console.log("the query", query.appealtypes);
//console.log(cookies);
//console.log("the query", query.appealtypes);
let loggedInUser = cookies.pinsUser;
let thisSession = await getSession(ctx);
console.log("nextAuth Session:", thisSession);
//console.log("nextAuth Session:", thisSession);
let loggedInUserIdent = thisSession.user.id;
let loggedInUserEmail = thisSession.user.email;
console.log("logged ident:", loggedInUserIdent);
//console.log("logged ident:", loggedInUserIdent);
const [
appealTypeData,
mandatoryFieldsData,
pickListData,
blobList,
blobProgress,
] = await Promise.all([
await getAppealsTypes(),
await getMandatoryFields(query.appealtypes),
await getPickLists(query.appealtypes),
await getFilesFromBlob(loggedInUserIdent, query.casereference),
await getProgressFromBlob(loggedInUserIdent, query.casereference),
]);
const [appealTypeData, mandatoryFieldsData, pickListData, blobList] =
await Promise.all([
await getAppealsTypesForNewAppeal(),
await getMandatoryFields(query.appealtypes),
await getPickLists(query.appealtypes),
await getFilesFromBlob(loggedInUserIdent, query.casereference),
]);
console.log("has blobprogess:", loggedInUserIdent, query.casereference);
const blobProgress = await getProgressFromBlob(
loggedInUserIdent,
query.casereference
);
console.log("/////////\nappela tupe data:", appealTypeData);
//
// Removed to make progress from Blob not CRM
@@ -288,6 +289,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
const providerConfig = await getProviderConfig();
store.dispatch(getGovGatewayConfig(providerConfig));
store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setLoggedInUserEmail(loggedInUserEmail));
store.dispatch(setAppealLPA(query.lpa));
store.dispatch(setAppealTypeID(query.apt));
store.dispatch(setCaseReference(caseReference));
@@ -295,6 +297,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setFilesForAppeal(blobList));
store.dispatch(setContainerID(thisSession.user.id));
return {
props: { url: process.env.API_ROOT },
};
}
);
+8
View File
@@ -5,6 +5,7 @@ import Head from "next/head";
import { useRouter } from "next/router";
import { connect } from "react-redux";
import {
getAwaitingSubmissionFromBlob,
getAwaitingSubmission,
getMyCases,
getMyRepresentations,
@@ -27,6 +28,7 @@ import {
} from "../../store/accountDetails/action";
import {
setAwaitingSubmission,
setAwaitingSubmissionFromBlob,
setAwaitingSubmissionDetails,
} from "../../store/awaitingSubmission/action";
import { getGovGatewayConfig } from "../../store/govgateway/action";
@@ -185,12 +187,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
myRepresentations,
watchedCases,
awaitingSubmission,
awaitingSubmissionFromBlob,
] = await Promise.all([
await getPersonalAccount(loggedInUser),
await getMyCases(loggedInUser),
await getMyRepresentations(loggedInUser),
await getWatchedCases(loggedInUser),
await getAwaitingSubmission(loggedInUser),
await getAwaitingSubmissionFromBlob(thisSession.user.id),
]);
if (_.has(accountDetails, "errorCode") != false) {
@@ -224,6 +228,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setWatchedCases(watchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setAwaitingSubmission(awaitingSubmission));
store.dispatch(
setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob)
);
store.dispatch(
setAwaitingSubmissionDetails(awaitingSubmissionDetails)
);
+13 -3
View File
@@ -26,6 +26,7 @@ import TimeOut from "../../components/timeout";
import {
setLoggedInUserId,
setLoggedInUserEmail,
setContainerID,
} from "../../store/accountDetails/action";
import {
@@ -226,8 +227,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
console.log("nextAuth Session:", thisSession);
let loggedInUserIdent = thisSession.user.id;
let loggedInUserEmail = thisSession.user.email;
console.log("logged ident:", loggedInUserIdent);
console.log("logged ident:", loggedInUserIdent, loggedInUserEmail);
const [
caseReferenceData,
@@ -235,17 +237,20 @@ export const getServerSideProps = wrapper.getServerSideProps(
mandatoryFieldsData,
pickListData,
//blobList,
blobProgress,
] = await Promise.all([
await getCase(query.id),
await getAppealsTypes(),
await getMandatoryFields(query.appealtypes),
await getPickLists(query.appealtypes),
await getProgressFromBlob(loggedInUserIdent, query.casereference),
//await getFilesFromBlob(query.casereference),
]);
const blobProgress = await getProgressFromBlob(
loggedInUserIdent,
caseReferenceData.ticketnumber
);
console.log("anything here", loggedInUser, query.id, caseReferenceData);
let caseReference = caseReferenceData; //caseReferenceData.ticketnumber;
@@ -265,6 +270,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
const providerConfig = await getProviderConfig();
store.dispatch(getGovGatewayConfig(providerConfig));
store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setLoggedInUserEmail(loggedInUserEmail));
store.dispatch(setAppealLPA(query.lpa));
store.dispatch(setAppealTypeID(query.apt));
store.dispatch(setCaseReference(caseReference));
@@ -273,6 +279,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setContainerID(thisSession.user.id));
//store.dispatch(setFilesForAppeal(blobList));
return {
props: { url: process.env.API_ROOT },
};
}
);
+8 -1
View File
@@ -3,13 +3,13 @@ export const AccountDetailsDataActionTypes = {
GETACCOUNTDETAILSDATA: "GETACCOUNTDETAILSDATA",
SETACCOUNTDETAILSDATA: "SETACCOUNTDETAILSDATA",
SETLOGGEDINUSER: "SETLOGGEDINUSER",
SETLOGGEDINUSEREMAIL: "SETLOGGEDINUSEREMAIL",
SETACCOUNTCREATED: "SETACCOUNTCREATED",
USER_LOGOUT: "USER_LOGOUT",
SETCONTAINERID: "SETCONTAINERID",
};
export const setCookieConsent = (cookieObj) => (dispatch) => {
console.log("wertyewrtyt", cookieObj);
return dispatch({
type: AccountDetailsDataActionTypes.SETCOOKIECONSENT,
cookieObj: cookieObj,
@@ -36,6 +36,13 @@ export const setLoggedInUserId = (loggedinUserId) => (dispatch) => {
});
};
export const setLoggedInUserEmail = (loggedinUserEmail) => (dispatch) => {
return dispatch({
type: AccountDetailsDataActionTypes.SETLOGGEDINUSEREMAIL,
loggedinUserEmail: loggedinUserEmail,
});
};
export const setLogout = () => (dispatch) => {
return dispatch({
type: "USER_LOGOUT",
+6
View File
@@ -3,6 +3,7 @@ import { AccountDetailsDataActionTypes } from "./action";
const AccountDetailsDataInitialState = {
accountDetails: {},
loggedinUserId: "",
loggedinUserEmail: "",
accCr: false,
cookieObj: "",
containerID: "",
@@ -23,6 +24,11 @@ export default function reducer(
...state,
loggedinUserId: action.loggedinUserId,
};
case AccountDetailsDataActionTypes.SETLOGGEDINUSEREMAIL:
return {
...state,
loggedinUserEmail: action.loggedinUserEmail,
};
case AccountDetailsDataActionTypes.SETACCOUNTCREATED:
return {
...state,
+9
View File
@@ -1,6 +1,7 @@
export const awaitingSubmissionActionTypes = {
GETAWAITINGSUBMISSION: "GETAWAITINGSUBMISSION",
SETAWAITINGSUBMISSION: "SETAWAITINGSUBMISSION",
SETAWAITINGSUBMISSIONFROMBLOB: "SETAWAITINGSUBMISSIONFROMBLOB",
SETAWAITINGSUBMISSIONDETAILS: "SETAWAITINGSUBMISSIONDETAILS",
UPDATEAWAITINGSUBMISSION: "UPDATEAWAITINGSUBMISSION",
};
@@ -18,6 +19,14 @@ export const setAwaitingSubmission = (awaitingSubmission) => (dispatch) => {
});
};
export const setAwaitingSubmissionFromBlob =
(awaitingSubmissionFromBlob) => (dispatch) => {
return dispatch({
type: awaitingSubmissionActionTypes.SETAWAITINGSUBMISSIONFROMBLOB,
awaitingSubmissionFromBlob: awaitingSubmissionFromBlob,
});
};
export const setAwaitingSubmissionDetails =
(awaitingSubmissionDetails) => (dispatch) => {
return dispatch({
+6
View File
@@ -3,6 +3,7 @@ import { awaitingSubmissionActionTypes } from "./action";
const awaitingSubmissionInitialState = {
awaitingSubmission: {},
awaitingSubmissionDetails: {},
awaitingSubmissionFromBlob: {},
};
export default function reducer(
@@ -15,6 +16,11 @@ export default function reducer(
...state,
awaitingSubmission: action.awaitingSubmission,
};
case awaitingSubmissionActionTypes.SETAWAITINGSUBMISSIONFROMBLOB:
return {
...state,
awaitingSubmissionFromBlob: action.awaitingSubmissionFromBlob,
};
case awaitingSubmissionActionTypes.SETAWAITINGSUBMISSIONDETAILS:
return {
...state,