diff --git a/pages/api/file/createappealcompletemessage_api.js b/pages/api/file/createappealcompletemessage_api.js index 390a4ddc..d86245e7 100644 --- a/pages/api/file/createappealcompletemessage_api.js +++ b/pages/api/file/createappealcompletemessage_api.js @@ -19,13 +19,15 @@ ApiProxy.get(async (req, res) => { // console.log(hashAPIPath(checkquerypath), checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); - //if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { - await createCaseCompleteMessage(containerName, tempCaseRef).then((data) => { - return res.status(200).json(data); - }); - // } else { - // return res.status(400).json(); - // } + if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { + await createCaseCompleteMessage(containerName, tempCaseRef).then( + (data) => { + return res.status(200).json(data); + } + ); + } else { + return res.status(400).json(); + } }); export const config = { diff --git a/pages/api/file/createappealcompletemessageproxy_api.js b/pages/api/file/createappealcompletemessageproxy_api.js new file mode 100644 index 00000000..df04081b --- /dev/null +++ b/pages/api/file/createappealcompletemessageproxy_api.js @@ -0,0 +1,60 @@ +import { + hashAPIPath, + getToken, + azureHeaders, + consoleLogger, +} from "../../../actions"; +import { + getBlobs, + createCaseCompleteMessage, +} from "../../../actions/azurestorage"; +import axios from "axios"; + +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 tempCaseRef = req.query.tempcaseref; + + console.log("/////Create Case Message:\n", tempCaseRef, "\n//////////////"); + + // console.log(hashAPIPath(checkquerypath), checkHash); + // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); + + var token = await getToken(); + + var queryUrl = + "/api/file/createappealcompletemessageproxy_api?container=" + + containerID + + "&tempcaseref=" + + caseReference; + + var config = { + method: "get", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + }; + + return axios(config) + .then((res) => { + return res.data; + }) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch((err) => { + console.log(consoleLogger(err)); + res.status(400).json(err); + }); +}); + +export const config = { + api: { + bodyParser: false, + }, +}; + +export default ApiProxy; diff --git a/pages/api/file/getbloblist.js b/pages/api/file/getbloblist.js index b46d3290..61f3c30b 100644 --- a/pages/api/file/getbloblist.js +++ b/pages/api/file/getbloblist.js @@ -21,13 +21,13 @@ ApiProxy.get(async (req, res) => { // console.log(hashAPIPath(checkquerypath), checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); - //if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { - await getBlobs(containerName, casefolderID).then((data) => { - return res.status(200).json({ files: data }); - }); - // } else { - // return res.status(400).json(); - // } + if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { + await getBlobs(containerName, casefolderID).then((data) => { + return res.status(200).json({ files: data }); + }); + } else { + return res.status(400).json(); + } }); export const config = { diff --git a/pages/api/file/getprogressobjblob.js b/pages/api/file/getprogressobjblob.js index 38c15b51..cbb921e5 100644 --- a/pages/api/file/getprogressobjblob.js +++ b/pages/api/file/getprogressobjblob.js @@ -5,6 +5,7 @@ import { import _ from "lodash"; import nextConnect from "next-connect"; import middleware from "../middleware/middleware"; +import { hashAPIPath } from "../../../actions"; const ApiProxy = nextConnect(); ApiProxy.use(middleware); @@ -20,22 +21,25 @@ ApiProxy.get(async (req, res) => { "&casefolderID=" + casefolderID; - // console.log(hashAPIPath(checkquerypath), checkHash); + //console.log(hashAPIPath(checkquerypath), checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); - //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) => { - return res.status(200).json(data); - }); - - // } else { - // return res.status(400).json(); - // } + if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { + const blobObj = await getProgressBlobs(containerName, casefolderID) + .then((data) => { + console.log("Progress blob path:", data.path); + return downloadProgressFile( + containerName, + data.path, + casefolderID + ); + }) + .then((data) => { + return res.status(200).json(data); + }); + } else { + return res.status(400).json(); + } }); export const config = { diff --git a/pages/api/file/setupcontainer.js b/pages/api/file/setupcontainer.js index 37731116..0781cebf 100644 --- a/pages/api/file/setupcontainer.js +++ b/pages/api/file/setupcontainer.js @@ -18,24 +18,21 @@ ApiProxy.get(async (req, res) => { var checkHash = req.query.hash; var checkquerypath = "/api/file/setupcontainer?ident=" + containerName; - console.log(req.query); - console.log(checkquerypath.length); - console.log(hashAPIPath(checkquerypath)); // console.log(checkquerypath, hashAPIPath(checkquerypath), checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); - //if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { - await createContainer(containerName) - .then((data) => { - return res.status(200).json({ data: "success" }); - }) - .catch((err) => { - console.log(consoleLogger(err)); - res.status(400).json(err); - }); - // } else { - // return res.status(400).json(); - // } + if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { + await createContainer(containerName) + .then((data) => { + return res.status(200).json({ data: "success" }); + }) + .catch((err) => { + console.log(consoleLogger(err)); + res.status(400).json(err); + }); + } else { + return res.status(400).json(); + } }); export const config = { diff --git a/pages/myportal/index.js b/pages/myportal/index.js index c36f3c4d..8e4558b5 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -16,8 +16,8 @@ import { consoleLogger, getCase, getPortalLogin, + createContainerProxy, } from "../../actions"; -import { createContainer } from "../../actions/azurestorage"; import Breadcrumbs from "../../components/breadcrumbs"; import CookieBanner from "../../components/cookieBanner"; import Footer from "../../components/footer"; @@ -180,10 +180,10 @@ export const getServerSideProps = wrapper.getServerSideProps( ]); loggedInUser = loggedInUser.value[0].contactid; - console.log("nextAuth Session:", thisSession); + //console.log("nextAuth Session:", thisSession); } //Create Storage container for logged in user - await createContainer(thisSession.user.id); + await createContainerProxy(thisSession.user.id); const [ accountDetails,