From e484640051fdfebccb99ef57f430e8045c28ad95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Valc=C3=A1rcel=20Mart=C3=ADnez?= <99458559+karla-vm@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:56:48 -0500 Subject: [PATCH] MCPAR PDF Feedback (Empty State) (#11960) --- services/app-api/forms/mcpar.json | 2 +- .../export/ExportedReportFieldTable.test.tsx | 37 ++++++++++++++++ .../export/ExportedReportFieldTable.tsx | 43 +++++++++++++------ .../export/ExportedSectionHeading.tsx | 8 ++++ services/ui-src/src/utils/other/export.tsx | 19 +++----- 5 files changed, 80 insertions(+), 29 deletions(-) diff --git a/services/app-api/forms/mcpar.json b/services/app-api/forms/mcpar.json index ef3be7157..5fa07877f 100644 --- a/services/app-api/forms/mcpar.json +++ b/services/app-api/forms/mcpar.json @@ -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." } ] }, diff --git a/services/ui-src/src/components/export/ExportedReportFieldTable.test.tsx b/services/ui-src/src/components/export/ExportedReportFieldTable.test.tsx index 02feb40a5..02a715e57 100644 --- a/services/ui-src/src/components/export/ExportedReportFieldTable.test.tsx +++ b/services/ui-src/src/components/export/ExportedReportFieldTable.test.tsx @@ -9,6 +9,8 @@ import { mockStandardReportPageJson, mockMlrReportStore, mockMcparReportStore, + mockVerbiageIntro, + mockDrawerForm, } from "utils/testing/setupJest"; import { useStore } from "utils"; // components @@ -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: { @@ -115,11 +129,19 @@ const hintJson = { const exportedStandardTableComponent = ( ); + const exportedDrawerTableComponent = ( ); + +const exportedMissingEntitiesComponent = ( + +); + const emptyTableComponent = ( ); @@ -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"); diff --git a/services/ui-src/src/components/export/ExportedReportFieldTable.tsx b/services/ui-src/src/components/export/ExportedReportFieldTable.tsx index 53fe01093..2269bb0ff 100644 --- a/services/ui-src/src/components/export/ExportedReportFieldTable.tsx +++ b/services/ui-src/src/components/export/ExportedReportFieldTable.tsx @@ -13,6 +13,7 @@ import { FormLayoutElement, isFieldElement, ReportType, + entityTypes, } from "types"; // verbiage import verbiage from "verbiage/pages/mcpar/mcpar-export"; @@ -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 - {renderIlosVerbiage() ? ( - - {parseCustomHtml(missingVerbiage ?? "")} + {entityType === entityTypes[0] && missingPlansOrIlos ? ( + + {parseCustomHtml(renderMissingEntityVerbiage() || "")} + + ) : entityType === entityTypes[1] && !hasBss ? ( + // if there are no BSS entities added, render the appropriate verbiage + + {parseCustomHtml( + (section as DrawerReportPageShape).verbiage.missingEntityMessage || + "" + )} ) : ( {missingEntryVerbiage}; - // 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 ( - {`${verbiage.missingEntry.noResponse}, optional`} + !isIlos && {missingEntryVerbiage} ); + // 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,