Skip to content

Commit

Permalink
Merge pull request #358 from USEPA/develop
Browse files Browse the repository at this point in the history
Sync staging with develop
  • Loading branch information
courtneymyers authored Sep 13, 2023
2 parents d3545ba + 532a5bc commit 4c28b85
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 60 deletions.
14 changes: 7 additions & 7 deletions app/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@formio/premium": "1.18.4",
"@formio/react": "5.2.3",
"@formio/uswds": "2.5.0",
"@formio/uswds": "2.4.8",
"@headlessui/react": "1.7.17",
"@heroicons/react": "2.0.18",
"@radix-ui/react-tooltip": "1.0.6",
Expand Down
4 changes: 4 additions & 0 deletions app/client/src/routes/frfNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ function createInitialSubmissionData(options: {
_user_title: title,
_user_name: name,
_bap_entity_combo_key: comboKey,
_bap_elec_bus_poc_email: entity.ELEC_BUS_POC_EMAIL__c,
_bap_alt_elec_bus_poc_email: entity.ALT_ELEC_BUS_POC_EMAIL__c,
_bap_govt_bus_poc_email: entity.GOVT_BUS_POC_EMAIL__c,
_bap_alt_govt_bus_poc_email: entity.ALT_GOVT_BUS_POC_EMAIL__c,
_bap_applicant_email: email,
_bap_applicant_title: title,
_bap_applicant_name: name,
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/utilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type BapFormSubmission = {
Record_Type_Name__c:
| "CSB Funding Request"
| "CSB Payment Request"
| "CSB Closeout Request";
| "CSB Close Out Request";
Parent_CSB_Rebate__r: {
CSB_Funding_Request_Status__c: string;
CSB_Payment_Request_Status__c: string;
Expand Down Expand Up @@ -356,7 +356,7 @@ export function useSubmissionsQueries(rebateYear: RebateYear) {
? "frfs"
: submission.Record_Type_Name__c === "CSB Payment Request"
? "prfs"
: submission.Record_Type_Name__c === "CSB Closeout Request"
: submission.Record_Type_Name__c === "CSB Close Out Request"
? "crfs"
: null;

Expand Down
4 changes: 2 additions & 2 deletions app/server/app/routes/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ router.get("/formio/:rebateYear/:formType/:id", (req, res) => {
? Parent_CSB_Rebate__r?.CSB_Funding_Request_Status__c
: Record_Type_Name__c === "CSB Payment Request"
? Parent_CSB_Rebate__r?.CSB_Payment_Request_Status__c
: Record_Type_Name__c === "CSB Closeout Request"
: Record_Type_Name__c === "CSB Close Out Request"
? Parent_CSB_Rebate__r?.CSB_Closeout_Request_Status__c
: "",
},
Expand All @@ -125,7 +125,7 @@ router.get("/formio/:rebateYear/:formType/:id", (req, res) => {
const errorMessage = `Error getting ${rebateYear} ${formName} submission '${CSB_Form_ID__c}'.`;
return res.status(errorStatus).json({ message: errorMessage });
});
}
},
);
});

Expand Down
2 changes: 1 addition & 1 deletion app/server/app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ router.use("/api/bap", require("./bap"));
router.use("/api/formio/2022", require("./formio2022"));
router.use("/api/formio/2023", require("./formio2023"));
router.use("/api/help", require("./help"));
router.use("/status", require("./status"));
router.use("/api/status", require("./status"));

module.exports = router;
47 changes: 28 additions & 19 deletions app/server/app/routes/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ const express = require("express");
const { axiosFormio, formUrl } = require("../config/formio");
const { getSamEntities } = require("../utilities/bap");

/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
function verifySchema(schema) {
return schema.type === "form" && !!schema.title;
}

const router = express.Router();

router.get("/app", (req, res) => {
return res.json({ status: true });
});

router.get("/bap-sam-data", (req, res) => {
router.get("/bap/sam", (req, res) => {
getSamEntities(req, "[email protected]")
.then((bapRes) => {
if (!Array.isArray(bapRes)) {
Expand All @@ -24,50 +32,51 @@ router.get("/bap-sam-data", (req, res) => {
});
});

router.get("/formio-application-schema", (req, res) => {
router.get("/formio/2022/frf", (req, res) => {
axiosFormio(req)
.get(formUrl["2022"].frf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
return res.json({ status: schema.type === "form" && !!schema.title });
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
return res.json({ status: false });
});
});

router.get("/formio-payment-request-schema", (req, res) => {
router.get("/formio/2022/prf", (req, res) => {
axiosFormio(req)
.get(formUrl["2022"].prf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
return res.json({ status: schema.type === "form" && !!schema.title });
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
return res.json({ status: false });
});
});

router.get("/formio-close-out-schema", (req, res) => {
router.get("/formio/2022/crf", (req, res) => {
axiosFormio(req)
.get(formUrl["2022"].crf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
/**
* Verify that schema has type of form and a title exists
* (confirming Formio returned a valid schema).
*/
return res.json({ status: schema.type === "form" && !!schema.title });
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
return res.json({ status: false });
});
});

router.get("/formio/2023/frf", (req, res) => {
axiosFormio(req)
.get(formUrl["2023"].frf)
.then((axiosRes) => axiosRes.data)
.then((schema) => {
return res.json({ status: verifySchema(schema) });
})
.catch((error) => {
// NOTE: error is logged in axiosFormio response interceptor
Expand Down
38 changes: 20 additions & 18 deletions app/server/app/utilities/bap.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ async function queryForSamEntities(req, email) {
PHYSICAL_ADDRESS_PROVINCE_OR_STATE__c: 1,
PHYSICAL_ADDRESS_ZIPPOSTAL_CODE__c: 1,
PHYSICAL_ADDRESS_ZIP_CODE_4__c: 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));
}
Expand Down Expand Up @@ -360,7 +360,7 @@ async function queryForBapFormSubmissionData(req, formType, rebateId, mongoId) {
{
// "*": 1,
Id: 1, // Salesforce record ID
}
},
)
.limit(1)
.execute(async (err, records) => ((await err) ? err : records));
Expand All @@ -374,7 +374,9 @@ async function queryForBapFormSubmissionData(req, formType, rebateId, mongoId) {
// CSB_Review_Item_ID__c,
// Parent_Rebate_ID__c,
// Record_Type_Name__c,
// Parent_CSB_Rebate__r.CSB_Funding_Request_Status__c
// Parent_CSB_Rebate__r.CSB_Funding_Request_Status__c,
// Parent_CSB_Rebate__r.CSB_Payment_Request_Status__c,
// Parent_CSB_Rebate__r.CSB_Closeout_Request_Status__c
// FROM
// ${BAP_FORMS_TABLE}
// WHERE
Expand All @@ -398,11 +400,11 @@ async function queryForBapFormSubmissionData(req, formType, rebateId, mongoId) {
CSB_Modified_Full_String__c: 1, // ISO 8601 date time string
CSB_Review_Item_ID__c: 1, // CSB Rebate ID with form/version ID (9 digits)
Parent_Rebate_ID__c: 1, // CSB Rebate ID (6 digits)
Record_Type_Name__c: 1, // 'CSB Funding Request' | 'CSB Payment Request' | 'CSB Closeout Request'
Record_Type_Name__c: 1, // 'CSB Funding Request' | 'CSB Payment Request' | 'CSB Close Out Request'
"Parent_CSB_Rebate__r.CSB_Funding_Request_Status__c": 1,
"Parent_CSB_Rebate__r.CSB_Payment_Request_Status__c": 1,
"Parent_CSB_Rebate__r.CSB_Closeout_Request_Status__c": 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));

Expand Down Expand Up @@ -446,7 +448,7 @@ async function queryForBapFormSubmissionsStatuses(req, comboKeys) {
{
// "*": 1,
Parent_Rebate_ID__c: 1, // CSB Rebate ID (6 digits)
}
},
)
.sort({ CreatedDate: -1 })
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -491,11 +493,11 @@ async function queryForBapFormSubmissionsStatuses(req, comboKeys) {
CSB_Modified_Full_String__c: 1, // ISO 8601 date time string
CSB_Review_Item_ID__c: 1, // CSB Rebate ID with form/version ID (9 digits)
Parent_Rebate_ID__c: 1, // CSB Rebate ID (6 digits)
Record_Type_Name__c: 1, // 'CSB Funding Request' | 'CSB Payment Request' | 'CSB Closeout Request'
Record_Type_Name__c: 1, // 'CSB Funding Request' | 'CSB Payment Request' | 'CSB Close Out Request'
"Parent_CSB_Rebate__r.CSB_Funding_Request_Status__c": 1,
"Parent_CSB_Rebate__r.CSB_Payment_Request_Status__c": 1,
"Parent_CSB_Rebate__r.CSB_Closeout_Request_Status__c": 1,
}
},
)
.sort({ CreatedDate: -1 })
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -539,7 +541,7 @@ async function queryBapForPRFData(req, frfReviewItemId) {
{
// "*": 1,
Id: 1, // Salesforce record ID
}
},
)
.limit(1)
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -598,7 +600,7 @@ async function queryBapForPRFData(req, frfReviewItemId) {
School_District_Prioritized__c: 1,
Total_Rebate_Funds_Requested__c: 1,
Total_Infrastructure_Funds__c: 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));

Expand All @@ -623,7 +625,7 @@ async function queryBapForPRFData(req, frfReviewItemId) {
{
// "*": 1,
Id: 1, // Salesforce record ID
}
},
)
.limit(1)
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -660,7 +662,7 @@ async function queryBapForPRFData(req, frfReviewItemId) {
CSB_Fuel_Type__c: 1,
CSB_Replacement_Fuel_Type__c: 1,
CSB_Funds_Requested__c: 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));

Expand Down Expand Up @@ -705,7 +707,7 @@ async function queryBapForCRFData(req, frfReviewItemId, prfReviewItemId) {
{
// "*": 1,
Id: 1, // Salesforce record ID
}
},
)
.limit(1)
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -752,7 +754,7 @@ async function queryBapForCRFData(req, frfReviewItemId, prfReviewItemId) {
Fleet_Contact_Email__c: 1,
"School_District_Contact__r.FirstName": 1,
"School_District_Contact__r.LastName": 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));

Expand All @@ -775,7 +777,7 @@ async function queryBapForCRFData(req, frfReviewItemId, prfReviewItemId) {
{
// "*": 1,
Id: 1, // Salesforce record ID
}
},
)
.limit(1)
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -854,7 +856,7 @@ async function queryBapForCRFData(req, frfReviewItemId, prfReviewItemId) {
Total_Level_2_Charger_Costs__c: 1,
Total_DC_Fast_Charger_Costs__c: 1,
Total_Other_Infrastructure_Costs__c: 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));

Expand All @@ -879,7 +881,7 @@ async function queryBapForCRFData(req, frfReviewItemId, prfReviewItemId) {
{
// "*": 1,
Id: 1, // Salesforce record ID
}
},
)
.limit(1)
.execute(async (err, records) => ((await err) ? err : records));
Expand Down Expand Up @@ -936,7 +938,7 @@ async function queryBapForCRFData(req, frfReviewItemId, prfReviewItemId) {
New_Bus_GVWR__c: 1,
New_Bus_Rebate_Amount__c: 1,
New_Bus_Purchase_Price__c: 1,
}
},
)
.execute(async (err, records) => ((await err) ? err : records));

Expand Down
Loading

0 comments on commit 4c28b85

Please sign in to comment.