Merged PR 1068: cleaned up rep functionality

cleaned up rep functionality

Related work items: #6653, #6654, #7500, #7501, #7502, #7958, #7959, #8422, #8423, #9072, #9073, #9295, #9297
This commit is contained in:
Robert Bond
2024-01-24 17:17:37 +00:00
15 changed files with 57 additions and 235 deletions
+28 -23
View File
@@ -263,7 +263,7 @@ export const createBlob = async (formContent, containerName, caseref) => {
blobType: "Appeal",
};
console.log("the tags:", tags);
//console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -296,7 +296,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
blobType: "Representation",
};
console.log("the tags:", tags);
//console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -464,7 +464,7 @@ export const uploadPDFRepFiles = async (
blobType: "RepresentationPDF",
};
console.log("the tags:", tags);
//console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -486,21 +486,21 @@ export const uploadPDFAppealFiles = async (
const files = formContent;
console.log(
"///////////////////////////// \n",
formContent,
containerName,
foldername,
"\n///////////////////////////// \n"
);
console.log(
"///////////////////////////// \n",
"appeal pdf files...",
files,
Object.keys(files).length,
foldername,
"\n///////////////////////////// \n"
);
// console.log(
// "///////////////////////////// \n",
// formContent,
// containerName,
// foldername,
// "\n///////////////////////////// \n"
// );
// console.log(
// "///////////////////////////// \n",
// "appeal pdf files...",
// files,
// Object.keys(files).length,
// foldername,
// "\n///////////////////////////// \n"
// );
// console.log(`files[${prop}] = ${files[prop][0].size}`);
console.log(foldername + "/files/" + formContent.split("tmp/")[1]);
@@ -517,7 +517,7 @@ export const uploadPDFAppealFiles = async (
blobType: "AppealPDF",
};
console.log("the tags:", tags);
//console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -556,7 +556,7 @@ export const uploadPDFCaseFiles = async (
blobType: "AppealPDF",
};
console.log("the tags:", tags);
//console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -775,7 +775,7 @@ export const getCaseBlob = async (
blobType: "Case",
};
console.log("the tags:", tags);
//console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -893,7 +893,12 @@ export const getAllProgressBlobs = async (containerName) => {
});
}
console.log("blobObj:", blobObj);
console.log(
"\n////////////////////////////\n",
"blobObj:",
blobObj,
"\n////////////////////////////"
);
return blobObj;
};
@@ -932,7 +937,7 @@ export const getRepsBlobs = async (containerName) => {
listOptions
)) {
const blobClient = await containerClient.getBlobClient(blob.name);
console.log("getreps blob blob", blob);
console.log("getreps blob:", blob);
blob.name.split("/")[2].indexOf("_rep.json") > 0 &&
blob.name.split("/")[2].indexOf("undefined") < 0 &&
blobObj.push({
+4 -20
View File
@@ -165,12 +165,6 @@ let MakeRepresentation = (props) => {
};
const whichControl = () => {
// console.log(isLPA);
// console.log(
// currentView.representationCapacity,
// _.isEmpty(currentView.representationCapacity)
// );
if (isLPA && _.isEmpty(currentView.representationCapacity)) {
return (
<RepLPACapacitySelection
@@ -334,7 +328,6 @@ let MakeRepresentation = (props) => {
const whichProgress = () => {
{
console.log("curr");
switch (currentView.caseReference.appealType) {
case 846040000:
case 846040001:
@@ -456,10 +449,6 @@ let MakeRepresentation = (props) => {
}
});
//console.log(updateBody);
//window.alert(`form is :\n\n${JSON.stringify(updateBody, null, 2)}`);
const reference = "PEDW-PARTIAL-REP";
const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75";
const emailAddress = props.props.accountDetails.loggedinUserEmail;
@@ -568,7 +557,6 @@ let MakeRepresentation = (props) => {
: values.representationCapacity,
"locale": locale,
}));
console.log(values);
currentView.representationSubmit != true
? _.isEmpty(currentView.representationCapacity)
? isLPA
@@ -610,11 +598,12 @@ let MakeRepresentation = (props) => {
return _.includes(key, "representationDocuments");
});
console.log(fileListObj);
console.log(
"\n////////////////////////\n upload files:",
values.containerID
values.containerID,
"\n////////////////////////\n fileListObj:",
fileListObj,
"\n////////////////////////\n"
);
var dataObj = values;
@@ -630,8 +619,6 @@ let MakeRepresentation = (props) => {
values.containerID,
props.caseReference + "/" + dataObj.repfile_name
).then((data) => {
//console.log("hello", data);
return data;
});
};
@@ -640,7 +627,6 @@ let MakeRepresentation = (props) => {
try {
let value = props.initialValues;
//console.log("has props"), value;
setRepresentationCapacity(
props.initialValues.representationCapacity.toLowerCase()
);
@@ -1192,8 +1178,6 @@ let MakeRepresentation = (props) => {
};
const mapStateToProps = (state) => {
//console.log("\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n in map state", state);
return {
search: state.search,
searchResultsObj: state.searchResultsObj,
@@ -41,8 +41,6 @@ const RepAppellant = (props) => {
} = props;
const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
// console.log(props);
return (
<>
<div className="govuk-grid-row">
@@ -41,7 +41,6 @@ const RepCompleteSubmit = (props) => {
const whichQuestionnaireCheck = () => {
{
console.log("curr");
switch (currentView.caseReference.appealType) {
case 846040000:
return (
@@ -36,8 +36,6 @@ const RepDetails = (props) => {
detailsObj = detailsObj[0];
console.log("-----detailsObj:", detailsObj);
return (
<>
{" "}
@@ -980,7 +980,6 @@ export const RenderFileUpload = (field) => {
getblobshash,
casefolderID
) => {
//console.log(containerName, blobName, deleteblobhash);
deleteBlob(containerName, blobName, deleteblobhash, casefolderID)
.then((data) => data)
.then(() => {
@@ -55,7 +55,6 @@ let RepLPA = (props) => {
const whichQuestionnaire = () => {
{
console.log("curr");
switch (currentView.caseReference.appealType) {
case 846040000:
case 846040001:
@@ -107,7 +106,6 @@ let RepLPA = (props) => {
const whichProgress = () => {
{
console.log("curr");
switch (currentView.caseReference.appealType) {
case 846040000:
case 846040001:
@@ -190,8 +188,6 @@ let RepLPA = (props) => {
);
resultsObj = resultsObj[0];
//console.log(resultsObj, detailsObj);
return (
<>
<div className="govuk-grid-row">
@@ -57,7 +57,6 @@ RepLPAQuestionnaire = connect((state) => {
})(RepLPAQuestionnaire);
const mapStateToProps = (state, props) => {
console.log();
return {
search: state.search,
searchResultsObj: state.searchResultsObj,
@@ -1192,7 +1192,6 @@ Enforcement_Questionnaire = connect((state) => {
})(Enforcement_Questionnaire);
const mapStateToProps = (state, props) => {
console.log();
return {
search: state.search,
searchResultsObj: state.searchResultsObj,
-45
View File
@@ -30,10 +30,6 @@ import { DOMParser, XMLSerializer } from "@xmldom/xmldom";
export const AppealRow_pdf = (props) => {
let { t } = useTranslation();
// const router = useRouter();
// console.log(router);
// const { locale } = router;
const {
formXML,
whichSection,
@@ -131,8 +127,6 @@ export const AppealRow_pdf = (props) => {
doc
);
//console.log(rowXML);
function formatDate(dateObj) {
var m = new Date(dateObj);
var dateString;
@@ -149,20 +143,10 @@ export const AppealRow_pdf = (props) => {
}
const FieldsTranslations = (label) => {
// const router = useRouter();
// const { locale } = router;
const { appealtypes } = router.query;
let formObj = jsonpath.query(fieldLookup, "$['" + appealtypes + "']");
// let labelTrans =
// router.locale == "cy"
// ? jsonpath.query(
// formObj,
// "$..[?(@.value=='" + label + "')].value_cy"
// )
// : label;
let labelTrans = label;
return labelTrans;
};
@@ -173,9 +157,7 @@ export const AppealRow_pdf = (props) => {
var newRowXML = new XMLSerializer().serializeToString(
rowXML[key]
);
//console.log(newRowXML);
var doc = parser.parseFromString(newRowXML, "text/xml");
var rows = xpath.select("//label/@description", doc);
var fieldtype = xpath.select("//@classid", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
@@ -190,7 +172,6 @@ export const AppealRow_pdf = (props) => {
"//@ishareDocumentCode",
doc
);
console.log(datafieldname[0].value);
return (
<>
@@ -460,32 +441,6 @@ export const AppealRow_pdf = (props) => {
break;
}
})()}
{/* <Text className="govuk-summary-list__value">
{fieldtype[0].value ==
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}"
? formatDate(
props.props.values[datafieldname[0].value]
)
: fieldtype[0].value ==
"{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}"
? getPickListLabel(
props.props.formData.pickListData,
datafieldname[0].value,
props.props.values[datafieldname[0].value]
)
: fieldtype[0].value ==
"{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}"
? getRadioLabel(
props.props.formData.pickListData,
datafieldname[0].value,
props.props.values[datafieldname[0].value]
)
: fieldtype[0].value ==
"{16D63FD6-119B-4353-BDCA-18358721C3FE}"
? "ssss"
: props.props.values[datafieldname[0].value]}
</Text> */}
</>
);
})}
@@ -143,7 +143,7 @@ export const planningappeals78_pdf = ({ docProps, pickListData }) => {
doc
);
console.log("\n//////////\n The Case:\n", docProps.caseObj);
//console.log("\n//////////\n The Case:\n", docProps.caseObj);
return (
<Document>
@@ -514,7 +514,6 @@ export const planningappeals78_pdf = ({ docProps, pickListData }) => {
</Text>
<View style={styles.sectionContainer}>
<View
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
@@ -542,60 +541,6 @@ export const planningappeals78_pdf = ({ docProps, pickListData }) => {
</View>
</View>
))}
{/* <View>
<View
style={{
marginTop: 10,
fontFamily: "Helvetica-Bold",
}}
>
<Text style={{ fontSize: 14 }}>
Supporting documents
</Text>
</View>
<View style={styles.sectionContainer}>
<View
style={{
flexDirection: "column",
marginBottom: 10,
}}
>
<View
wrap={false}
style={{
flexDirection: "row",
marginBottom: 10,
}}
>
<Text style={styles.questionText}>
List of attached files
</Text>
</View>
<View
style={{
color: "#757575",
width: "100%",
fontSize: 12,
border: 1,
borderColor: "#eee",
backgroundColor: "white",
padding: 5,
marginBottom: 10,
lineHeight: 1.2,
}}
>
{values.hasOwnProperty("filesList") &&
values.filesList.map((key) => (
<Text style={{ marginBottom: 10 }}>
{key.name} -{" "}
{bytesToSize(key.contentLength)}
</Text>
))}
</View>
</View>
</View>
</View> */}
</View>
<Text
style={styles.pageNumber}
+2 -45
View File
@@ -113,32 +113,13 @@ export default async function handler(req, res) {
var appealType = req.query.appealType;
let appealBodyObj = req.body; //JSON.parse(req.body);
// console.log(
// "//////////////////////\nappealBodyObj" +
// req +
// "\n//////////////////////\n"
// );
console.log(
"//////////////////////\nappealBodyObj" +
req.body +
"\n//////////////////////\n"
);
var containerID = appealBodyObj.containerID;
var casefolderID = appealBodyObj.casefolderID;
var caseRef = appealBodyObj.caseRef;
var filesList = appealBodyObj.filesList;
//console.log("there are files:", Object.keys(req.files).length);
var checkquerypath = "/api/file/generateappealpdf";
//console.log("-------", checkHash);
// console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
console.log(casefolderID, caseRef);
// Create Document Component
const MyDocument = (values) => {
switch (values.docProps.pinswg_appealcasetype) {
case "846040000":
@@ -168,12 +149,9 @@ export default async function handler(req, res) {
};
const tempCaseBlob = await getTempCaseBlob(containerID, casefolderID);
console.log("\n////////////////// the temp case blob obj:\n", tempCaseBlob);
const blobProgress = await getProgressBlobs(containerID, casefolderID).then(
(data) => {
console.log("Progress blob path:", data);
//console.log("Progress blob path:", data);
return downloadProgressFile(containerID, data.path, casefolderID);
}
);
@@ -187,14 +165,6 @@ export default async function handler(req, res) {
"caseObj": tempCaseBlob,
});
//console.log(blobProgress);
//if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
// //createContainer(containerID).then((containerName) => {
// console.log("does this get folder name:", containerID, casefolderID);
// createRepBlob(req.body, containerID, caseRef);
const pickListData = await getPickLists(appealType);
ReactPDF.render(
@@ -203,30 +173,17 @@ export default async function handler(req, res) {
);
console.log(
"///////////////////////////////////\n file created: \n" +
"///////////////////////////////////\nfile created: " +
`tmp/${blobProgress.pinswg_name}.pdf` +
"\n/////////////////////////"
);
console.log(
"///////////////////////////////////\n uploadPDFAppealFiles: \n" +
`tmp/${appealBodyObj.pinswg_name}.pdf` +
"\n" +
containerID +
"\n" +
appealBodyObj.pinswg_name +
"\n" +
"\n/////////////////////////"
);
uploadPDFAppealFiles(
`tmp/${appealBodyObj.pinswg_name}.pdf`,
containerID,
appealBodyObj.pinswg_name
);
// to do upload file to storage account
// then remove from local folder
// fs.unlinkSync( `tmp/${appealBodyObj.repfile_name}.pdf`,);
+4 -1
View File
@@ -58,7 +58,10 @@ ApiProxy.get(async (req, res) => {
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getRepsBlobs(containerName, casefolderID)
.then(async (data) => {
console.log("----------xxxxxx------", data);
console.log(
"\n////////////////////////////\n getRepsBlobs:",
data
);
let result = await downloadAllRepsFiles(containerName, data);
return res.status(200).json(result);
})
+7 -31
View File
@@ -90,40 +90,16 @@ const SignIn = (props) => {
);
};
// export async function getServerSideProps(context) {
// //console.log("-1-1-1-1-", context.query.callbackUrl, context.locale);
// //console.log("------ " + context.query.callbackUrl);
// // setCookie(context, "next-auth.callback-url", context.query.callbackUrl, {
// // path: "/",
// // });
// const csrfToken = await getCsrfToken(context);
// let callback =
// context.locale != "cy"
// ? process.env.NEXTAUTH_URL
// : "https://" + process.env.I18N_DOMAIN + ":3000";
// context.query.callbackUrl = callback;
// let formURL =
// new URL(callback).protocol +
// "//" +
// new URL(callback).hostname +
// ":" +
// new URL(callback).port; // +
// // "/api/auth/signin/email";
// //console.log("******", formURL, callback, csrfToken);
// return {
// props: { csrfToken: csrfToken, callbackUrl: formURL, redirect: true },
// };
// }
export async function getServerSideProps(context) {
const csrfToken = await getCsrfToken(context);
console.log("-1-1-1-1-", context.query.callbackUrl, context.locale);
console.log(
"\n//////////////////////\n",
"Sign in callbackurl: " + context.query.callbackUrl,
context.locale,
"\n//////////////////////\n"
);
let formURL = context.query.callbackUrl;
console.log("formUrl:", formURL);
//console.log("formUrl:", formURL);
formURL = typeof formURL == "undefined" ? null : formURL;
return {
+11 -2
View File
@@ -137,7 +137,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
const { req, res } = ctx;
const { cookies } = req;
console.log("/newappeal - cookies ", cookies);
console.log(
"\n////////////////////////////\n",
"/newappeal - cookies ",
cookies,
"\n////////////////////////////\n"
);
let thisSession = await getSession(ctx);
//console.log("nextAuth Session:", thisSession);
@@ -172,7 +177,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
]
);
console.log("wewerwe s s", accountDetails);
console.log(
"\n////////////////////////////\n Acccount Details:",
accountDetails,
"\n////////////////////////////\n"
);
// const lpaData = require("../../data/lpa.json");
// const appealTypeData = require("../../data/appealtypes.json");