awaiting submissions from storage acc

This commit is contained in:
2022-09-05 16:46:30 +01:00
parent b0dde836b0
commit c66883b4c5
25 changed files with 653 additions and 69 deletions
+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);