-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from USEPA/feature/add-bap-query-for-2023-sub…
…missions Feature/add bap query for 2023 submissions
- Loading branch information
Showing
12 changed files
with
437 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,23 @@ import icons from "uswds/img/sprite.svg"; | |
// --- | ||
import { serverUrl, messages } from "@/config"; | ||
import { | ||
FormioFRF2023Submission, | ||
getData, | ||
postData, | ||
useContentData, | ||
useConfigData, | ||
useBapSamData, | ||
useSubmissionsQueries, | ||
// useSubmissions, | ||
// submissionNeedsEdits, | ||
useSubmissions, | ||
submissionNeedsEdits, | ||
getUserInfo, | ||
} from "@/utilities"; | ||
import { Loading } from "@/components/loading"; | ||
import { Message } from "@/components/message"; | ||
import { MarkdownContent } from "@/components/markdownContent"; | ||
import { useDialogActions } from "@/contexts/dialog"; | ||
import { useNotificationsActions } from "@/contexts/notifications"; | ||
import { useRebateYearState } from "@/contexts/rebateYear"; | ||
import type { FormioFRF2023Submission } from "@/utilities"; | ||
|
||
type ServerResponse = | ||
| { | ||
|
@@ -117,15 +118,17 @@ function FundingRequestForm(props: { email: string }) { | |
const content = useContentData(); | ||
const configData = useConfigData(); | ||
const bapSamData = useBapSamData(); | ||
const { displayDialog } = useDialogActions(); | ||
const { | ||
displayInfoNotification, | ||
displaySuccessNotification, | ||
displayErrorNotification, | ||
dismissNotification, | ||
} = useNotificationsActions(); | ||
const { rebateYear } = useRebateYearState(); | ||
|
||
const submissionsQueries = useSubmissionsQueries("2023"); | ||
// const submissions = useSubmissions("2023"); | ||
const submissions = useSubmissions("2023"); | ||
|
||
const { query, mutation } = useFormioSubmissionQueryAndMutation(mongoId); | ||
const { userAccess, formSchema, submission } = query.data ?? {}; | ||
|
@@ -181,16 +184,130 @@ function FundingRequestForm(props: { email: string }) { | |
return <Message type="error" text={messages.formSubmissionError} />; | ||
} | ||
|
||
// const rebate = submissions.find((r) => r.frf.formio._id === mongoId); | ||
const rebate = submissions.find((r) => r.frf.formio._id === mongoId); | ||
|
||
// const frfNeedsEdits = !rebate | ||
// ? false | ||
// : submissionNeedsEdits({ | ||
// formio: rebate.frf.formio, | ||
// bap: rebate.frf.bap, | ||
// }); | ||
const frfNeedsEdits = !rebate | ||
? false | ||
: submissionNeedsEdits({ | ||
formio: rebate.frf.formio, | ||
bap: rebate.frf.bap, | ||
}); | ||
|
||
const frfNeedsEdits = false; // TODO: update when BAP FRF work is completed | ||
const frfNeedsEditsAndPRFExists = frfNeedsEdits && !!rebate?.prf.formio; | ||
|
||
/** | ||
* NOTE: If the FRF submission needs edits and there's a corresponding PRF | ||
* submission, display a confirmation dialog prompting the user to delete the | ||
* PRF submission, as it's data will no longer valid when the FRF submission's | ||
* data is changed. | ||
*/ | ||
if (frfNeedsEditsAndPRFExists) { | ||
displayDialog({ | ||
dismissable: true, | ||
heading: "Submission Edits Requested", | ||
description: ( | ||
<> | ||
<p> | ||
This Application form submission has been opened at the request of | ||
the applicant to make edits, but before you can make edits, the | ||
associated Payment Request form submission needs to be deleted. If | ||
the request to make edits to your Application form submission was | ||
made in error, contact the Clean School Bus Program helpline at{" "} | ||
<a href="mailto:[email protected]">[email protected]</a>. | ||
</p> | ||
|
||
<p> | ||
If you’d like to view the Payment Request form submission before | ||
deletion, please close this dialog box, and you will be re-directed | ||
to the associated Payment Request form. | ||
</p> | ||
|
||
<p> | ||
To proceed with deleting the associated Payment Request form | ||
submission, please select the{" "} | ||
<strong>Delete Payment Request Form Submission</strong> button | ||
below, and the Payment Request form submission will be deleted. The | ||
Application form will then be open for editing. | ||
</p> | ||
|
||
<div className="usa-alert usa-alert--error" role="alert"> | ||
<div className="usa-alert__body"> | ||
<p className="usa-alert__text"> | ||
<strong>Please note:</strong> Once deleted, the Payment Request | ||
form submission will be removed from your dashboard and cannot | ||
be recovered. | ||
</p> | ||
</div> | ||
</div> | ||
</> | ||
), | ||
confirmText: "Delete Payment Request Form Submission", | ||
confirmedAction: () => { | ||
const prf = rebate.prf.formio; | ||
|
||
if (!prf) { | ||
displayErrorNotification({ | ||
id: Date.now(), | ||
body: ( | ||
<> | ||
<p className="tw-text-sm tw-font-medium tw-text-gray-900"> | ||
Error deleting Payment Request <em>{rebate.rebateId}</em>. | ||
</p> | ||
<p className="tw-mt-1 tw-text-sm tw-text-gray-500"> | ||
Please notify the helpdesk that a problem exists preventing | ||
the deletion of Payment Request form submission{" "} | ||
<em>{rebate.rebateId}</em>. | ||
</p> | ||
</> | ||
), | ||
}); | ||
|
||
// NOTE: logging rebate for helpdesk debugging purposes | ||
console.log(rebate); | ||
return; | ||
} | ||
|
||
displayInfoNotification({ | ||
id: Date.now(), | ||
body: ( | ||
<p className="tw-text-sm tw-font-medium tw-text-gray-900"> | ||
Deleting Payment Request <em>{rebate.rebateId}</em>... | ||
</p> | ||
), | ||
}); | ||
|
||
const url = `${serverUrl}/api/formio/2023/delete-prf-submission`; | ||
|
||
postData(url, { | ||
mongoId: prf._id, | ||
rebateId: prf.data.hidden_bap_rebate_id, | ||
comboKey: prf.data.bap_hidden_entity_combo_key, | ||
}) | ||
.then((_res) => { | ||
window.location.reload(); | ||
}) | ||
.catch((_err) => { | ||
displayErrorNotification({ | ||
id: Date.now(), | ||
body: ( | ||
<> | ||
<p className="tw-text-sm tw-font-medium tw-text-gray-900"> | ||
Error deleting Payment Request <em>{rebate.rebateId}</em>. | ||
</p> | ||
<p className="tw-mt-1 tw-text-sm tw-text-gray-500"> | ||
Please reload the page to attempt the deletion again, or | ||
contact the helpdesk if the problem persists. | ||
</p> | ||
</> | ||
), | ||
}); | ||
}); | ||
}, | ||
dismissedAction: () => navigate(`/prf/2023/${rebate.rebateId}`), | ||
}); | ||
|
||
return null; | ||
} | ||
|
||
const frfSubmissionPeriodOpen = | ||
configData.submissionPeriodOpen[rebateYear].frf; | ||
|
@@ -241,6 +358,19 @@ function FundingRequestForm(props: { email: string }) { | |
<strong>Application ID:</strong> {submission._id} | ||
</div> | ||
</li> | ||
|
||
{rebate?.frf.bap?.rebateId && ( | ||
<li className="usa-icon-list__item"> | ||
<div className="usa-icon-list__icon text-primary"> | ||
<svg className="usa-icon" aria-hidden="true" role="img"> | ||
<use href={`${icons}#local_offer`} /> | ||
</svg> | ||
</div> | ||
<div className="usa-icon-list__content"> | ||
<strong>Rebate ID:</strong> {rebate.frf.bap.rebateId} | ||
</div> | ||
</li> | ||
)} | ||
</ul> | ||
|
||
<Dialog as="div" open={dataIsPosting.current} onClose={(_value) => {}}> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.