Skip to content

Commit

Permalink
MCPAR PDF Feedback (Empty State) (#11960)
Browse files Browse the repository at this point in the history
  • Loading branch information
karla-vm authored Dec 9, 2024
1 parent 96c91b4 commit e484640
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 29 deletions.
2 changes: 1 addition & 1 deletion services/app-api/forms/mcpar.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
},
{
"type": "html",
"content": "See Glossary in Excel Workbook for the definition of BSS entities."
"content": ". See Glossary in Excel Workbook for the definition of BSS entities."
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
mockStandardReportPageJson,
mockMlrReportStore,
mockMcparReportStore,
mockVerbiageIntro,
mockDrawerForm,
} from "utils/testing/setupJest";
import { useStore } from "utils";
// components
Expand Down Expand Up @@ -73,6 +75,18 @@ const mockDrawerPageJson = {
...mockDrawerReportPageJson,
drawerForm: { id: "drawer", fields: reportJsonFields },
};
const mockMissingPlansPageJson = {
name: "mock-route-2a",
path: "/mcpar/plan-level-indicators/ilos",
pageType: "drawer",
entityType: "plans",
verbiage: {
intro: mockVerbiageIntro,
dashboardTitle: "Mock dashboard title",
drawerTitle: "Mock drawer title",
},
drawerForm: mockDrawerForm,
};
const mockEmptyPageJson = {
...mockStandardReportPageJson,
form: {
Expand Down Expand Up @@ -115,11 +129,19 @@ const hintJson = {
const exportedStandardTableComponent = (
<ExportedReportFieldTable section={mockStandardPageJson} />
);

const exportedDrawerTableComponent = (
<ExportedReportFieldTable
section={mockDrawerPageJson as DrawerReportPageShape}
/>
);

const exportedMissingEntitiesComponent = (
<ExportedReportFieldTable
section={mockMissingPlansPageJson as DrawerReportPageShape}
/>
);

const emptyTableComponent = (
<ExportedReportFieldTable section={mockEmptyPageJson} />
);
Expand All @@ -141,6 +163,21 @@ describe("ExportedReportFieldRow", () => {
expect(row).toBeVisible();
});

test("handles drawer pages with missing plans", async () => {
const missingEntitiesStore = {
...mockMcparReportStore,
report: {
fieldData: {},
},
};
mockedUseStore.mockReturnValue({
...missingEntitiesStore,
});
render(exportedMissingEntitiesComponent);
const row = screen.getByTestId("missingEntityMessage");
expect(row).toBeVisible();
});

test("handles a table with no form fields", async () => {
render(emptyTableComponent);
const row = screen.getByTestId("exportTable");
Expand Down
43 changes: 29 additions & 14 deletions services/ui-src/src/components/export/ExportedReportFieldTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
FormLayoutElement,
isFieldElement,
ReportType,
entityTypes,
} from "types";
// verbiage
import verbiage from "verbiage/pages/mcpar/mcpar-export";
Expand Down Expand Up @@ -45,24 +46,39 @@ export const ExportedReportFieldTable = ({ section }: Props) => {
const reportType = report?.reportType as ReportType;
const hideHintText = reportType === ReportType.MLR;

// handle ILOS rendering logic
const renderIlosVerbiage = () => {
const hasIlos = report?.fieldData["ilos"]?.length;
return section.path === "/mcpar/plan-level-indicators/ilos" && !hasIlos;
};

const hasPlans = report?.fieldData["plans"]?.length;
const hasIlos = report?.fieldData["ilos"]?.length;
const hasBss = report?.fieldData["bssEntities"]?.length;

// handle missing plans / ilos rendering logic
const renderMissingEntityVerbiage = () => {
const { path, verbiage: v } = section as DrawerReportPageShape;

// verbiage for ILOS
if (path === "/mcpar/plan-level-indicators/ilos" && !hasIlos) {
return !hasPlans ? v.missingPlansAndIlosMessage : v.missingIlosMessage;
}

const missingVerbiage = !hasPlans
? (section as DrawerReportPageShape).verbiage.missingPlansAndIlosMessage
: (section as DrawerReportPageShape).verbiage.missingIlosMessage;
// verbiage for missing plans
return !hasPlans ? v.missingEntityMessage : undefined;
};

const missingPlansOrIlos = !(hasIlos || hasPlans);

return (
// if there are no ILOS added, render the appropriate verbiage
// if there are no plans added, render the appropriate verbiage
<Box>
{renderIlosVerbiage() ? (
<Box sx={sx.missingEntityMessage}>
{parseCustomHtml(missingVerbiage ?? "")}
{entityType === entityTypes[0] && missingPlansOrIlos ? (
<Box sx={sx.missingEntityMessage} data-testid="missingEntityMessage">
{parseCustomHtml(renderMissingEntityVerbiage() || "")}
</Box>
) : entityType === entityTypes[1] && !hasBss ? (
// if there are no BSS entities added, render the appropriate verbiage
<Box sx={sx.missingEntityMessage} data-testid="missingEntityMessage">
{parseCustomHtml(
(section as DrawerReportPageShape).verbiage.missingEntityMessage ||
""
)}
</Box>
) : (
<Table
Expand Down Expand Up @@ -222,7 +238,6 @@ const sx = {
},
missingEntityMessage: {
fontWeight: "bold",

ol: {
paddingLeft: "1rem",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ const sx = {
p: {
margin: "1.5rem 0",
},
a: {
color: "palette.base",
textDecoration: "none",
"&:hover": {
color: "palette.base",
textDecoration: "none",
},
},
h3: {
fontSize: "xl",
},
Expand Down
19 changes: 5 additions & 14 deletions services/ui-src/src/utils/other/export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,15 @@ export const renderResponseData = (

const missingEntryStyle = notApplicable ? sx.notApplicable : sx.noResponse;

if (!hasResponse && !isChoiceListField) {
return <Text sx={missingEntryStyle}>{missingEntryVerbiage}</Text>;
// need to explicitly make this else if conditional so
}

if (
!hasResponse &&
isChoiceListField &&
formField.id !== "plan_ilosOfferedByPlan"
) {
if (!hasResponse) {
const isIlos = formField.id === "plan_ilosOfferedByPlan";
return (
<Text
sx={sx.noResponseOptional}
>{`${verbiage.missingEntry.noResponse}, optional`}</Text>
!isIlos && <Text sx={missingEntryStyle}>{missingEntryVerbiage}</Text>
);
// need to explicitly make this else if conditional so
}

// chandle choice list fields (checkbox, radio)
// handle choice list fields (checkbox, radio)
if (isChoiceListField) {
return renderChoiceListFieldResponse(
formField,
Expand Down

0 comments on commit e484640

Please sign in to comment.