generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 41
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 #16938 from CDCgov/experience/16074-Create-Test-Re…
…sult-Page-without-Download-Results Experience 16074: Create test result page without download results
- Loading branch information
Showing
22 changed files
with
917 additions
and
245 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
51 changes: 51 additions & 0 deletions
51
frontend-react/src/components/Admin/MessageTesting/AddCustomTestMessageForm.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,51 @@ | ||
import { Button, Textarea } from "@trussworks/react-uswds"; | ||
import { type ComponentProps, type FormEventHandler, useCallback, useState } from "react"; | ||
|
||
export interface AddCustomMessageFormProps extends ComponentProps<"form"> { | ||
onCancel: () => void; | ||
} | ||
|
||
export interface AddCustomMessageFormValues { | ||
customMessageTestBody: string; | ||
} | ||
|
||
const AddCustomTestMessageFormProps = ({ onCancel, onChange, ...props }: AddCustomMessageFormProps) => { | ||
const [isSubmitEnabled, setIsSubmitEnabled] = useState(false); | ||
|
||
const handleFormChange = useCallback<FormEventHandler<HTMLFormElement>>( | ||
(e) => { | ||
setIsSubmitEnabled(e.currentTarget.checkValidity()); | ||
onChange?.(e); | ||
}, | ||
[onChange], | ||
); | ||
|
||
return ( | ||
<form className="width-full" onChange={handleFormChange} {...props}> | ||
<p className="text-bold">Enter custom message</p> | ||
<p>Custom messages do not save to the bank after you log out.</p> | ||
<Textarea | ||
id="custom-message-test-body" | ||
name="customMessageTestBody" | ||
className="width-full maxw-full margin-bottom-205" | ||
required={true} | ||
/> | ||
<div className="width-full text-right"> | ||
<Button | ||
type="button" | ||
outline | ||
onClick={() => { | ||
onCancel(); | ||
}} | ||
> | ||
Cancel | ||
</Button> | ||
<Button type="submit" disabled={!isSubmitEnabled}> | ||
Add | ||
</Button> | ||
</div> | ||
</form> | ||
); | ||
}; | ||
|
||
export default AddCustomTestMessageFormProps; |
114 changes: 0 additions & 114 deletions
114
frontend-react/src/components/Admin/MessageTesting/MessageTesting.tsx
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
frontend-react/src/components/Admin/MessageTesting/MessageTestingAccordion.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,66 @@ | ||
import { Accordion, Icon, Tag } from "@trussworks/react-uswds"; | ||
import { RSMessageResult } from "../../../config/endpoints/reports"; | ||
|
||
export const MessageTestingAccordion = ({ | ||
accordionTitle, | ||
priority, | ||
resultData, | ||
fieldsToRender, | ||
}: { | ||
accordionTitle: string; | ||
priority: "error" | "warning"; | ||
resultData: RSMessageResult; | ||
fieldsToRender: (keyof RSMessageResult)[]; | ||
}) => { | ||
const fieldID = accordionTitle.toLowerCase().split(" ").join("-"); | ||
const existingFields = fieldsToRender.filter((field) => Object.keys(resultData).includes(field)); | ||
const combinedFieldData = existingFields.flatMap((field) => resultData[field]); | ||
|
||
// Immediately return if there's no warning/error data to display | ||
if (combinedFieldData.length === 0) return; | ||
|
||
return ( | ||
<div key={`${fieldID}-accordion-wrapper`} className="padding-top-4 "> | ||
<Accordion | ||
key={`${fieldID}-accordion`} | ||
items={[ | ||
{ | ||
className: "bg-gray-5", | ||
title: ( | ||
<> | ||
{priority === "error" && <Icon.Error size={3} className="text-top margin-right-1" />} | ||
|
||
{priority === "warning" && ( | ||
<Icon.Warning size={3} className="text-top margin-right-1" /> | ||
)} | ||
|
||
<span className="font-body-lg">{accordionTitle}</span> | ||
|
||
{priority === "error" && ( | ||
<Tag className="margin-left-1 bg-secondary-vivid">{combinedFieldData.length}</Tag> | ||
)} | ||
|
||
{priority === "warning" && ( | ||
<Tag className="margin-left-1 bg-accent-warm">{combinedFieldData.length}</Tag> | ||
)} | ||
</> | ||
), | ||
content: ( | ||
<div className="bg-white font-sans-sm padding-top-2 padding-bottom-2 padding-left-1 padding-right-1"> | ||
{combinedFieldData.map((item, index) => ( | ||
<div key={index}> | ||
<div>{item}</div> | ||
{index < combinedFieldData.length - 1 && <hr className="rs-hr--half-margin" />} | ||
</div> | ||
))} | ||
</div> | ||
), | ||
expanded: false, | ||
headingLevel: "h3", | ||
id: `${fieldID}-list`, | ||
}, | ||
]} | ||
/> | ||
</div> | ||
); | ||
}; |
25 changes: 13 additions & 12 deletions
25
...ts/Admin/MessageTesting/CustomMessage.tsx → ...geTesting/MessageTestingCustomMessage.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
Oops, something went wrong.