63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getawaitingsubmission_api:
|
|
* get:
|
|
* tags: [Case]
|
|
* summary: Phase 2
|
|
* description: get awaiting case submission
|
|
* parameters:
|
|
* - name: loggedInUserId
|
|
* in: query
|
|
* required: true
|
|
* example: 9c563a87-4158-ec11-a9c6-002248008e24
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Success
|
|
*/
|
|
|
|
import { respondError } from "../middleware/apiResponse";
|
|
import { relayGet } from "../middleware/relayForwarding";
|
|
import { RELAY_POLICY_BOUNDED_READ } from "../middleware/relayPolicyPresets";
|
|
|
|
export default async function ApiProxy(req, res) {
|
|
const loggedInUserId = req.query.loggedInUserId;
|
|
|
|
if (
|
|
typeof loggedInUserId !== "string" ||
|
|
loggedInUserId.trim().length === 0
|
|
) {
|
|
return respondError(res, {
|
|
status: 400,
|
|
code: "LOGGED_IN_USER_ID_REQUIRED",
|
|
message: "loggedInUserId is required"
|
|
});
|
|
}
|
|
|
|
const queryUrl =
|
|
"incidents?$select=pinswg_environmentalstatementlocation,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference,pinswg_appellantlastname,pinswg_appellantfirstname,pinswg_appellantagent,pinswg_agentfirstname,pinswg_agentlastname,pinswg_agentcompanyname&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " +
|
|
loggedInUserId +
|
|
" and servicestage eq 1 and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true";
|
|
|
|
const relayPolicy = RELAY_POLICY_BOUNDED_READ;
|
|
|
|
return relayGet({
|
|
queryUrl,
|
|
res,
|
|
relayPolicy,
|
|
transformData: (data) => {
|
|
data.value.forEach(function (element) {
|
|
element.pinswg_title = element.title;
|
|
});
|
|
|
|
return data;
|
|
},
|
|
errorResponse: {
|
|
status: 400,
|
|
code: "AWAITING_SUBMISSION_FETCH_FAILED",
|
|
message: "Failed to fetch awaiting submissions"
|
|
}
|
|
});
|
|
}
|