-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
399 additions
and
25 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
19 changes: 19 additions & 0 deletions
19
services/ui-src/src/components/export/ExportedReportBanner.test.tsx
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { ExportedReportBanner } from "./ExportedReportBanner"; | ||
import userEvent from "@testing-library/user-event"; | ||
import qmVerbiage from "verbiage/export/qm-export"; | ||
|
||
describe("ExportedReportBanner", () => { | ||
beforeEach(() => { | ||
render(<ExportedReportBanner></ExportedReportBanner>); | ||
jest.spyOn(window, "print").mockImplementation(() => {}); | ||
}); | ||
it("ExportedReportBanner is visible", () => { | ||
expect(screen.getByText(qmVerbiage.reportBanner.intro)).toBeInTheDocument(); | ||
}); | ||
it("Test click of print button", async () => { | ||
const pdfButton = screen.getByText("Download PDF"); | ||
await userEvent.click(pdfButton); | ||
expect(window.print).toBeCalled(); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
services/ui-src/src/components/export/ExportedReportBanner.tsx
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Box, Text, Button, Image } from "@chakra-ui/react"; | ||
import pdfIcon from "assets/icons/pdf/icon_pdf_white.svg"; | ||
import qmVerbiage from "verbiage/export/qm-export"; | ||
|
||
export const ExportedReportBanner = () => { | ||
const { reportBanner } = qmVerbiage; | ||
|
||
const onClickHandler = () => { | ||
window?.print(); | ||
}; | ||
|
||
return ( | ||
<Box sx={sx.container}> | ||
<Text>{reportBanner.intro}</Text> | ||
<Button sx={sx.pdfButton} onClick={onClickHandler}> | ||
<Image src={pdfIcon} w={5} alt="PDF Icon" /> | ||
{reportBanner.pdfButton} | ||
</Button> | ||
</Box> | ||
); | ||
}; | ||
|
||
const sx = { | ||
container: { | ||
position: "sticky", | ||
zIndex: "sticky", | ||
top: "0", | ||
marginBottom: "2rem", | ||
padding: "2rem 2rem", | ||
background: "white", | ||
boxShadow: "0px 3px 9px rgba(0, 0, 0, 0.2)", | ||
textAlign: "center", | ||
".mobile &": { | ||
padding: "2rem 1rem", | ||
}, | ||
"@media print": { | ||
display: "none", | ||
}, | ||
p: { | ||
marginBottom: "1rem", | ||
fontSize: "xl", | ||
fontWeight: "bold", | ||
".mobile &": { | ||
fontSize: "lg", | ||
}, | ||
}, | ||
}, | ||
pdfButton: { | ||
img: { | ||
width: "1rem", | ||
marginRight: "0.5rem", | ||
}, | ||
}, | ||
}; |
37 changes: 37 additions & 0 deletions
37
services/ui-src/src/components/export/ExportedReportWrapper.test.tsx
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { ExportedReportWrapper } from "./ExportedReportWrapper"; | ||
import { ElementType, FormPageTemplate, PageElement, PageType } from "types"; | ||
|
||
const elements: PageElement[] = [ | ||
{ | ||
type: ElementType.Header, | ||
text: "General Information", | ||
}, | ||
{ | ||
type: ElementType.Textbox, | ||
label: "Contact title", | ||
helperText: | ||
"Enter person's title or a position title for CMS to contact with questions about this request.", | ||
}, | ||
{ | ||
type: ElementType.Date, | ||
label: "Reporting period start date", | ||
helperText: | ||
"What is the reporting period Start Date applicable to the measure results?", | ||
}, | ||
]; | ||
|
||
const section: FormPageTemplate = { | ||
id: "mock-id", | ||
title: "mock-title", | ||
type: PageType.Standard, | ||
elements: elements, | ||
sidebar: true, | ||
}; | ||
|
||
describe("ExportedReportWrapper", () => { | ||
it("ExportedReportWrapper is visible", () => { | ||
render(<ExportedReportWrapper section={section}></ExportedReportWrapper>); | ||
expect(screen.getByText("Contact title")).toBeInTheDocument(); | ||
}); | ||
}); |
77 changes: 77 additions & 0 deletions
77
services/ui-src/src/components/export/ExportedReportWrapper.tsx
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
Box, | ||
Stack, | ||
Table, | ||
Thead, | ||
Th, | ||
Tr, | ||
Td, | ||
Tbody, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
import { | ||
ElementType, | ||
FormPageTemplate, | ||
MeasurePageTemplate, | ||
ParentPageTemplate, | ||
} from "types"; | ||
|
||
export const ExportedReportWrapper = ({ section }: Props) => { | ||
const elements = section.elements | ||
?.filter( | ||
(element) => | ||
element.type !== ElementType.ButtonLink && | ||
element.type !== ElementType.Accordion && | ||
element.type !== ElementType.Header && | ||
element.type !== ElementType.MeasureTable | ||
) | ||
.map((element: any) => { | ||
return { | ||
label: element?.label ?? "", | ||
helperText: element.helperText ?? "", | ||
value: element.value ?? "", | ||
answer: element.answer ?? "No Response", | ||
type: element.type ?? "", | ||
}; | ||
}); | ||
|
||
return ( | ||
<Stack> | ||
{elements?.length! > 0 ? ( | ||
<Table variant="export"> | ||
<Thead> | ||
<Tr> | ||
<Th>Indicator</Th> | ||
<Th>Response</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{elements?.map( | ||
(element, idx) => | ||
element?.label && ( | ||
<Tr key={`${element.label}.${idx}`}> | ||
<Td> | ||
<Text>{element?.label}</Text> | ||
{element?.helperText && ( | ||
<Text>{element?.helperText}</Text> | ||
)} | ||
{element?.type === ElementType.Date && ( | ||
<Text>MM/DD/YYYY</Text> | ||
)} | ||
</Td> | ||
<Td>{element?.answer}</Td> | ||
</Tr> | ||
) | ||
)} | ||
</Tbody> | ||
</Table> | ||
) : ( | ||
<Box>N/A</Box> | ||
)} | ||
</Stack> | ||
); | ||
}; | ||
|
||
export interface Props { | ||
section: ParentPageTemplate | FormPageTemplate | MeasurePageTemplate; | ||
} |
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
32 changes: 32 additions & 0 deletions
32
services/ui-src/src/components/pages/Export/ExportedReportPage.test.tsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { screen, render } from "@testing-library/react"; | ||
import { useStore } from "utils"; | ||
import { ExportedReportPage } from "./ExportedReportPage"; | ||
|
||
jest.mock("utils", () => ({ | ||
useStore: jest.fn(), | ||
})); | ||
|
||
const report = { | ||
type: "QM", | ||
id: "mock-report-id", | ||
state: "CO", | ||
title: "mock-title", | ||
pages: [ | ||
{ childPageIds: ["1", "2"] }, | ||
{ title: "Section 1", id: "id-1" }, | ||
{ title: "Section 2", id: "id-2" }, | ||
], | ||
}; | ||
|
||
describe("ExportedReportPage", () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
(useStore as unknown as jest.Mock).mockReturnValue({ | ||
report: report, | ||
}); | ||
}); | ||
it("ExportReportPage is visible", () => { | ||
render(<ExportedReportPage></ExportedReportPage>); | ||
expect(screen.getByText("CO mock-title")).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.