16291 crm activity
This commit is contained in:
+40
-14
@@ -1896,22 +1896,30 @@ export const sendEmail = async (
|
||||
// personalisation,
|
||||
// reference
|
||||
// );
|
||||
var queryUrl = "/api/email/notify";
|
||||
// var queryUrl = "/api/email/notify";
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl,
|
||||
data: mailData,
|
||||
};
|
||||
// var config = {
|
||||
// method: "post",
|
||||
// url: queryUrl,
|
||||
// data: mailData,
|
||||
// };
|
||||
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
//console.log("posted ", res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
// return axios(config)
|
||||
// .then((res) => {
|
||||
// //console.log("posted ", res.data);
|
||||
// return res.data;
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// consoleLogger(error);
|
||||
// });
|
||||
|
||||
try {
|
||||
const response = await axios.post("/api/email/notify", mailData);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
consoleLogger(error); // Optional custom logging
|
||||
throw error; // ✅ Ensure the calling function sees the error
|
||||
}
|
||||
};
|
||||
|
||||
export const getNotice = () => {
|
||||
@@ -2117,3 +2125,21 @@ export const getAddressSearch = async (searchString) => {
|
||||
return ErrResponse;
|
||||
});
|
||||
};
|
||||
|
||||
export const createCRMTask = async (formValues) => {
|
||||
var queryUrl = "/api/endpoint/createcrmtask_api";
|
||||
|
||||
var data = formValues;
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl,
|
||||
data: data,
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await axios(config);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* @swagger
|
||||
* /api/endpoint/createcase_api:
|
||||
* post:
|
||||
* tags: [Case]
|
||||
* description: Create case
|
||||
* summary: Phase 2
|
||||
* parameters:
|
||||
* - name: body
|
||||
* in: requestbody
|
||||
* required: true
|
||||
* example: {}
|
||||
* schema:
|
||||
* type: object
|
||||
* - name: contactid
|
||||
* in: query
|
||||
* required: true
|
||||
* example: pinswg_planningappeals78s
|
||||
* schema:
|
||||
* type: string
|
||||
* - name: appealTypeId
|
||||
* in: query
|
||||
* required: true
|
||||
* example: pinswg_planningappeals78id
|
||||
* schema:
|
||||
* type: string
|
||||
* - name: containername
|
||||
* in: query
|
||||
* required: true
|
||||
* example: pinswg_planningappeals78id
|
||||
* schema:
|
||||
* type: string
|
||||
* - name: lpaID
|
||||
* in: query
|
||||
* required: true
|
||||
* example: pinswg_planningappeals78id
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Success
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import { getToken } from "../../../actions";
|
||||
import { getCaseBlob } from "../../../actions/azurestorage";
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
const hashAPIPath = (queryPath) => {
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
);
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
|
||||
//return "&hash=" + hashlink;
|
||||
|
||||
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var createTaskBody = req.body;
|
||||
var queryUrl = "tasks";
|
||||
var token = await getToken();
|
||||
|
||||
let contactValue = createTaskBody.typeOfContact;
|
||||
|
||||
// const whichTeam = (contactValue) => {
|
||||
// switch (contactValue) {
|
||||
// case "plq":
|
||||
// //Questions about Planning legislation or policy
|
||||
// //PD - Via Email - Planning.Directorate@gov.wales
|
||||
|
||||
// return;
|
||||
// break;
|
||||
// case "ipq":
|
||||
// //Questions or comments about applications for major infrastructure projects
|
||||
// //Infrastructure
|
||||
// return "7fb9e598-7d26-ec11-a97f-00224800e98c";
|
||||
// break;
|
||||
// case "pcpq":
|
||||
// //Questions or comments about planning and environmental appeals
|
||||
// //Casework
|
||||
// return "8ffabad9-7c26-ec11-a97f-00224800e98c";
|
||||
// break;
|
||||
// case "pi":
|
||||
// //Query about using the Casework Portal
|
||||
// // Digital Support Team - PEDW
|
||||
// return "5554882f-4606-ec11-a97f-00224800d374";
|
||||
// break;
|
||||
// case "appadvice":
|
||||
// //Advice How to submit an appeal
|
||||
// //R&D
|
||||
// return "5554882f-4606-ec11-a97f-00224800d374";
|
||||
// break;
|
||||
// case "repadvice":
|
||||
// //Advice How to comment on an appeal or application
|
||||
// //R&D
|
||||
// return "5554882f-4606-ec11-a97f-00224800d374";
|
||||
// break;
|
||||
// case "ceq":
|
||||
// //Queries about forthcoming Hearing or Inquiry event
|
||||
// //Inspector Scheduling
|
||||
// return "4fddd7e8-7d26-ec11-a97f-00224800e98c";
|
||||
// break;
|
||||
// case "other":
|
||||
// //Other enquiry for PEDW
|
||||
// //Casework
|
||||
// return "8ffabad9-7c26-ec11-a97f-00224800e98c";
|
||||
// break;
|
||||
// case "postdec":
|
||||
// //Issues or questions about a case after the decision is issued
|
||||
// //SLT Team
|
||||
// return "cc3d987e-7c26-ec11-a97f-00224800e98c";
|
||||
// break;
|
||||
// case "comp":
|
||||
// //General Complaints of Compliments
|
||||
// //SLT Team
|
||||
// return "cc3d987e-7c26-ec11-a97f-00224800e98c";
|
||||
|
||||
// break;
|
||||
// default:
|
||||
// // code block
|
||||
// }
|
||||
// };
|
||||
// let teamId = whichTeam(contactValue);
|
||||
|
||||
const teamMap = {
|
||||
ipq: "7fb9e598-7d26-ec11-a97f-00224800e98c", // Infrastructure
|
||||
pcpq: "8ffabad9-7c26-ec11-a97f-00224800e98c", // Casework
|
||||
pi: "5554882f-4606-ec11-a97f-00224800d374", // Digital Support Team
|
||||
appadvice: "5554882f-4606-ec11-a97f-00224800d374",
|
||||
repadvice: "5554882f-4606-ec11-a97f-00224800d374",
|
||||
ceq: "4fddd7e8-7d26-ec11-a97f-00224800e98c", // Inspector Scheduling
|
||||
other: "8ffabad9-7c26-ec11-a97f-00224800e98c",
|
||||
postdec: "cc3d987e-7c26-ec11-a97f-00224800e98c", // SLT Team
|
||||
comp: "cc3d987e-7c26-ec11-a97f-00224800e98c",
|
||||
};
|
||||
|
||||
let teamId = teamMap[contactValue];
|
||||
|
||||
const payload = {
|
||||
"subject": `Contact Us Enquiry - ${createTaskBody.contactSubject}`,
|
||||
"description": `From: ${createTaskBody.contactEmail}\n\n${createTaskBody.contactbody}`,
|
||||
"scheduledstart": new Date().toISOString(),
|
||||
"scheduledend": new Date(
|
||||
new Date().getTime() + 60 * 60000 * 24
|
||||
).toISOString(), // 30 mins
|
||||
...(teamId && { "ownerid@odata.bind": `/teams(${teamId})` }),
|
||||
};
|
||||
|
||||
//console.log("/////Create Task:\n", payload, "\n//////////////");
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Authorization": "Bearer " + token.access_token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: JSON.stringify(payload),
|
||||
};
|
||||
|
||||
//console.log("/////Create Task config:\n", config, "\n//////////////");
|
||||
|
||||
try {
|
||||
const { data } = await axios(config);
|
||||
return res.status(200).json(data);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"CRM Task Creation Error:",
|
||||
error.response?.data || error
|
||||
);
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Failed to create CRM task", details: error });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user