Skip to content

Commit

Permalink
PI1.3 26084: Withdraw Package screen and email messaging (#1400)
Browse files Browse the repository at this point in the history
Co-authored-by: Valencia McMurray <[email protected]>
  • Loading branch information
kristin-at-theta and Valencia2019 authored Nov 8, 2023
1 parent 8efedcf commit 159d0e9
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 60 deletions.
19 changes: 8 additions & 11 deletions services/app-api/email/stateWithdrawalReceipt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import dynamoDb from "../libs/dynamodb-lib";
import { USER_ROLE, USER_STATUS } from "cmscommonlib";

import { formatPackageDetails } from "./formatPackageDetails.js";
import { USER_ROLE, USER_STATUS, Workflow } from "cmscommonlib";

export const getAllActiveStateUserEmailAddresses = async (territory) => {
const stateSubmittingUserRoles = [
Expand Down Expand Up @@ -44,18 +42,17 @@ export const getAllActiveStateUserEmailAddresses = async (territory) => {
* @returns {Object} email parameters in generic format.
*/
export const stateWithdrawalReceipt = async (data, config, user) => {
const parentTypeNice =
Workflow.ONEMAC_LABEL[data.parentType] ?? config.typeLabel;

const stateReceipt = {
ToAddresses: [],
CcAddresses: [],
Subject: `${config.typeLabel} Package ${data.componentId} Withdraw Request`,
Subject: `${parentTypeNice} ${data.componentId} Withdrawal Confirmation`,
HTML: `
<p>The OneMAC submission portal received a request to withdraw a package. You are receiving this email notification as ${
data.componentId
} was withdrawn by ${user.fullName} (${
user.email
}). The package will no longer be considered for CMS review.</p>
${formatPackageDetails(data, config)}
<p>Thank you!</p>
<p>This email is to confirm ${parentTypeNice} ${data.componentId} was withdrawn by ${user.fullName}.
The review of ${parentTypeNice} ${data.componentId} has concluded.
</p>
`,
};
try {
Expand Down
5 changes: 4 additions & 1 deletion services/app-api/getMyPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const getMyPackages = async (email, group) => {
? cmsStatusUIMap
: stateStatusUIMap;

if (!userRoleObj.canAccessDashboard || territoryList === []) {
if (
!userRoleObj.canAccessDashboard ||
(Array.isArray(territoryList) && territoryList.length === 0)
) {
throw RESPONSE_CODE.USER_NOT_AUTHORIZED;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[{
"pk": "MD-5535.R00.TE01",
"sk": "OneMAC#1675108098000",
"additionalInformation": "This is just a test",
"attachments": [
{
"contentType": "application/pdf",
"filename": "15MB.pdf",
"s3Key": "1698684572020/15MB.pdf",
"title": "Waiver Extension Request",
"url": "https://uploads-develop-attachments-116229642442.s3.us-east-1.amazonaws.com/protected/us-east-1%3A86a190fe-b195-42bf-9685-9761bf0ff14b/1698684572020/15MB.pdf"
}
],
"clockEndTimestamp": 1706464175123,
"componentId": "MD-5535.R00.TE01",
"componentType": "waiverextensionb",
"currentStatus": "TE Requested",
"eventTimestamp": 1675108098000,
"GSI1pk": "OneMAC#submitwaiverextensionb",
"GSI1sk": "MD-5535.R00.TE01",
"parentId": "MD-2200.R00.00",
"parentType": "waivernew",
"submissionTimestamp": 1675108098000,
"submitterEmail": "[email protected]",
"submitterName": "Statesubmitter Nightwatch",
"temporaryExtensionType": "1915(b)",
"territory": "MD",
"transmittalNumberWarningMessage": ""
},
{
"pk": "MD-5535.R00.TE01",
"sk": "Package",
"adminChanges": [
],
"componentId": "MD-5535.R00.TE01",
"componentType": "waiverextensionb",
"cpocName": "-- --",
"currentStatus": "TE Requested",
"description": "-- --",
"GSI1pk": "OneMAC#waiver",
"GSI1sk": "MD-5535.R00.TE01",
"GSI2pk": "MD-2200.R00.00",
"GSI2sk": "waiverextensionb",
"lastEventTimestamp": 1675108098000,
"parentId": "MD-2200.R00.00",
"parentType": "waivernew",
"reverseChrono": [
{
"action": "Submitted",
"additionalInformation": "This is just a test",
"attachments": [
{
"contentType": "application/pdf",
"filename": "15MB.pdf",
"s3Key": "1698684572020/15MB.pdf",
"title": "Waiver Extension Request",
"url": "https://uploads-develop-attachments-116229642442.s3.us-east-1.amazonaws.com/protected/us-east-1%3A86a190fe-b195-42bf-9685-9761bf0ff14b/1698684572020/15MB.pdf"
}
],
"currentStatus": "TE Requested",
"eventTimestamp": 1675108098000,
"timestamp": 1675108098000,
"type": "Initial Package"
}
],
"reviewTeam": [
],
"reviewTeamEmailList": [
],
"subject": "-- --",
"submissionTimestamp": 1675108098000,
"submitterEmail": "[email protected]",
"submitterName": "Statesubmitter Nightwatch",
"temporaryExtensionType": "1915(b)"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[{
"pk": "MD-5536.R00.TE01",
"sk": "OneMAC#1675108098000",
"additionalInformation": "This is just a test",
"attachments": [
{
"contentType": "application/pdf",
"filename": "15MB.pdf",
"s3Key": "1698684572020/15MB.pdf",
"title": "Waiver Extension Request",
"url": "https://uploads-develop-attachments-116229642442.s3.us-east-1.amazonaws.com/protected/us-east-1%3A86a190fe-b195-42bf-9685-9761bf0ff14b/1698684572020/15MB.pdf"
}
],
"clockEndTimestamp": 1706464175123,
"componentId": "MD-5536.R00.TE01",
"componentType": "waiverextensionb",
"currentStatus": "TE Requested",
"eventTimestamp": 1675108098000,
"GSI1pk": "OneMAC#submitwaiverextensionb",
"GSI1sk": "MD-5536.R00.TE01",
"parentId": "MD-2200.R00.00",
"parentType": "waivernew",
"submissionTimestamp": 1675108098000,
"submitterEmail": "[email protected]",
"submitterName": "Statesubmitter Nightwatch",
"temporaryExtensionType": "1915(b)",
"territory": "MD",
"transmittalNumberWarningMessage": ""
},
{
"pk": "MD-5536.R00.TE01",
"sk": "Package",
"adminChanges": [
],
"componentId": "MD-5536.R00.TE01",
"componentType": "waiverextensionb",
"cpocName": "-- --",
"currentStatus": "TE Requested",
"description": "-- --",
"GSI1pk": "OneMAC#waiver",
"GSI1sk": "MD-5536.R00.TE01",
"GSI2pk": "MD-2200.R00.00",
"GSI2sk": "waiverextensionb",
"lastEventTimestamp": 1675108098000,
"parentId": "MD-2200.R00.00",
"parentType": "waivernew",
"reverseChrono": [
{
"action": "Submitted",
"additionalInformation": "This is just a test",
"attachments": [
{
"contentType": "application/pdf",
"filename": "15MB.pdf",
"s3Key": "1698684572020/15MB.pdf",
"title": "Waiver Extension Request",
"url": "https://uploads-develop-attachments-116229642442.s3.us-east-1.amazonaws.com/protected/us-east-1%3A86a190fe-b195-42bf-9685-9761bf0ff14b/1698684572020/15MB.pdf"
}
],
"currentStatus": "TE Requested",
"eventTimestamp": 1675108098000,
"timestamp": 1675108098000,
"type": "Initial Package"
}
],
"reviewTeam": [
],
"reviewTeamEmailList": [
],
"subject": "-- --",
"submissionTimestamp": 1675108098000,
"submitterEmail": "[email protected]",
"submitterName": "Statesubmitter Nightwatch",
"temporaryExtensionType": "1915(b)"
}
]
6 changes: 5 additions & 1 deletion services/app-api/utils/validateUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export const validateUserReadOnly = (user, checkTerritory) => {
.filter(({ status }) => status === USER_STATUS.ACTIVE)
.map(({ territory }) => territory);

if (!userRoleObj.canAccessDashboard || territoryList === []) return false;
if (
!userRoleObj.canAccessDashboard ||
(Array.isArray(territoryList) && territoryList.length === 0)
)
return false;

if (
Array.isArray(territoryList) &&
Expand Down
35 changes: 27 additions & 8 deletions services/ui-src/src/libs/formLib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type OneMACFormConfig = {
idFAQLink?: string;
pageTitle?: string;
introJSX?: JSX.Element;
buildIntroJSX?: (packageType: string) => JSX.Element;
addlIntroJSX?: JSX.Element;
detailsHeader?: string;
detailsHeaderFull?: string;
Expand Down Expand Up @@ -47,9 +48,10 @@ type ParentPackageType = {
};

type ConfirmSubmitType = {
confirmSubmitHeading: string;
confirmSubmitHeading?: string;
confirmSubmitMessage?: JSX.Element | string;
buildMessage?: (toConfirm: string) => JSX.Element;
buildHeading?: (packageType: string) => string;
buildMessage?: (toConfirm: string, packageType: string) => JSX.Element;
confirmSubmitYesButton?: string;
};

Expand Down Expand Up @@ -133,17 +135,24 @@ export const defaultConfirmSubmitRAI = {
confirmSubmitMessage: defaultConfirmSubmitMessageRAI,
};

export const defaultConfirmSubmitHeadingWithdraw = "Withdraw Package?";
export const defaultConfirmSubmitMessageWithdraw = (toConfirm: string) => (
export const defaultConfirmSubmitHeadingWithdraw = (packageType: string) =>
`Withdraw ${packageType} Package?`;
export const defaultConfirmSubmitMessageWithdraw = (
toConfirm: string,
packageType: string
) => (
<p>
You are about to withdraw {toConfirm}. Once complete, you will not be able
to resubmit this package. CMS will be notified.
You are about to withdraw {packageType} {toConfirm}. Completing this action
will conclude the review of this {packageType} package. If you are not sure
this is the correct action to select, contact your CMS point of contact for
assistance.
</p>
);

export const defaultConfirmSubmitWithdraw = {
confirmSubmitHeading: defaultConfirmSubmitHeadingWithdraw,
confirmSubmitMessage: defaultConfirmSubmitMessageWithdraw("this package"),
confirmSubmitHeading: defaultConfirmSubmitHeadingWithdraw(""),
confirmSubmitMessage: defaultConfirmSubmitMessageWithdraw("this package", ""),
buildHeading: defaultConfirmSubmitHeadingWithdraw,
buildMessage: defaultConfirmSubmitMessageWithdraw,
confirmSubmitYesButton: "Yes, withdraw package",
};
Expand All @@ -152,6 +161,7 @@ export type PackageType = {
whichTab?: string;
componentType: string;
typeLabel: string;
packageLabel?: string;
idLabel: string;
idRegex: string;
idMustExist: boolean;
Expand Down Expand Up @@ -206,6 +216,14 @@ export const buildMustNotExistMessage = (formConfig: OneMACFormConfig) => ({
statusMessage: `According to our records, this ${formConfig.idLabel} already exists. Please check the ${formConfig.idLabel} and try entering it again.`,
});

export const defaultWithdrawIntroJSX = (packageLabel: string) => (
<p id="form-intro">
Complete this action to withdraw this {packageLabel} package. Once
completed, you will not be able to resubmit the {packageLabel} package or
undo this action.
</p>
);

export const defaultWithdrawConfig = {
introJSX: (
<p id="form-intro">
Expand All @@ -216,6 +234,7 @@ export const defaultWithdrawConfig = {
email.
</p>
),
buildIntroJSX: defaultWithdrawIntroJSX,
confirmSubmit: defaultConfirmSubmitWithdraw,
attachmentsTitle: "Upload Supporting Documentation",
attachmentIntroJSX: (
Expand Down
57 changes: 35 additions & 22 deletions services/ui-src/src/page/OneMACForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,24 @@ const OneMACForm: React.FC<{ formConfig: OneMACFormConfig }> = ({
event.preventDefault();
if (isSubmissionReady && !limitSubmit.current) {
if (formConfig.confirmSubmit) {
const confirmHeading: string = formConfig.confirmSubmit.buildHeading
? formConfig.confirmSubmit.buildHeading(
presetParentTypeNice ?? "this"
)
: formConfig.confirmSubmit.confirmSubmitHeading ??
"Placeholder heading";
const confirmMessage: JSX.Element | string = formConfig.confirmSubmit
.buildMessage
? formConfig.confirmSubmit.buildMessage(oneMacFormData.componentId)
? formConfig.confirmSubmit.buildMessage(
oneMacFormData.componentId,
presetParentTypeNice ?? ""
)
: formConfig.confirmSubmit.confirmSubmitMessage ??
"Placeholder message";

confirmAction &&
confirmAction(
formConfig.confirmSubmit.confirmSubmitHeading,
confirmHeading,
formConfig.confirmSubmit.confirmSubmitYesButton ?? "Yes, Submit",
"Cancel",
confirmMessage,
Expand All @@ -406,6 +415,7 @@ const OneMACForm: React.FC<{ formConfig: OneMACFormConfig }> = ({
[
isSubmissionReady,
formConfig.confirmSubmit,
presetParentTypeNice,
confirmAction,
doSubmit,
oneMacFormData.componentId,
Expand All @@ -427,26 +437,29 @@ const OneMACForm: React.FC<{ formConfig: OneMACFormConfig }> = ({
{formConfig.detailsHeaderFull ??
formConfig.detailsHeader + " Details"}
</h2>
{formConfig.introJSX ?? (
<>
<p>
<span className="required-mark">*</span>
indicates required field.
</p>
<p id="form-intro">
Once you submit this form, a confirmation email is sent to you
and to CMS. CMS will use this content to review your package,
and you will not be able to edit this form. If CMS needs any
additional information, they will follow up by email.
<b>
{" "}
If you leave this page, you will lose your progress on this
form.
</b>
{formConfig.addlIntroJSX ?? ""}
</p>
</>
)}
{formConfig.buildIntroJSX
? formConfig.buildIntroJSX(presetParentTypeNice ?? "this")
: formConfig.introJSX ?? (
<>
<p>
<span className="required-mark">*</span>
indicates required field.
</p>
<p id="form-intro">
Once you submit this form, a confirmation email is sent to
you and to CMS. CMS will use this content to review your
package, and you will not be able to edit this form. If CMS
needs any additional information, they will follow up by
email.
<b>
{" "}
If you leave this page, you will lose your progress on
this form.
</b>
{formConfig.addlIntroJSX ?? ""}
</p>
</>
)}
{formConfig.titleLabel && (
<TextField
name="title"
Expand Down
Loading

0 comments on commit 159d0e9

Please sign in to comment.