Skip to content

Commit

Permalink
fix: consistent spacing between sub-sections, reactify (#2955)
Browse files Browse the repository at this point in the history
* fix: consistent spacing between sub-sections, reactify

* fix: actually return clinical notes

* refactor: move to accordions sub section in utils

* refactor: use sub section for ecr metadata

* fix: remove commented out code

* refactor: use sub section with unavailable info

* refactor: use sub section for encounter info

* refactor: formatString => toKebabCase

* refactor: use sub section for lab info

* refactor: move data wrangling into main body

* test: update snapshots

* docs: fix comments to say hyphens
  • Loading branch information
mcmcgrath13 authored Nov 25, 2024
1 parent 6a51c72 commit 594ea46
Show file tree
Hide file tree
Showing 17 changed files with 1,071 additions and 1,007 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Accordion, HeadingLevel } from "@trussworks/react-uswds";
import { formatString } from "@/app/services/formatService";
import { toKebabCase } from "@/app/services/formatService";
import { RenderableNode } from "../view-data/utils/utils";

export interface AccordionItemProps {
Expand All @@ -27,7 +27,7 @@ const AccordionContainer = ({
accordionItems,
}: AccordionContainerProps): React.JSX.Element => {
const items: AccordionItemProps[] = accordionItems.map((item, index) => {
let formattedTitle = formatString(`${item["title"]}`);
let formattedTitle = toKebabCase(`${item["title"]}`);
return {
...item,
id: `${formattedTitle}_${index + 1}`,
Expand Down
8 changes: 4 additions & 4 deletions containers/ecr-viewer/src/app/services/formatService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,18 @@ export const formatVitals = (
};

/**
* Formats a string by converting it to lowercase, replacing spaces with underscores, and removing special characters except underscores.
* Formats a string by converting it to lowercase, replacing spaces with hyphens, and removing special characters except underscores.
* @param input - The input string to be formatted.
* @returns The formatted string.
*/
export const formatString = (input: string): string => {
export const toKebabCase = (input: string): string => {
// Convert to lowercase
let result = input.toLowerCase();

// Replace spaces with underscores
// Replace spaces with hyphens
result = result.replace(/\s+/g, "-");

// Remove all special characters except underscores
// Remove all special characters except hyphens
result = result.replace(/[^a-z0-9\-]/g, "");

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
class="usa-summary-box__body"
>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Demographics
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -516,13 +516,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Social History
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -681,13 +681,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Encounter Details
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -770,13 +770,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Facility Details
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -897,13 +897,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Clinical Notes
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand All @@ -929,13 +929,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Provider Details
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -1056,13 +1056,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Symptoms and Problems
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -1107,13 +1107,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Diagnostics and Vital Signs
</h3>
Diagnostics and Vital Signs
</h4>
<div
class="usa-summary-box__text"
>
Expand All @@ -1139,13 +1139,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Immunizations
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand All @@ -1171,13 +1171,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
Treatment Details
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -1279,13 +1279,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
eCR Metadata
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down Expand Up @@ -1524,13 +1524,13 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
</div>
</div>
<div
class="margin-bottom-4"
class="gutter-3"
>
<h3
class="usa-summary-box__heading padding-bottom-205 unavailable-info"
<h4
class="usa-summary-box__heading padding-y-105"
>
eICR Author Details for Practitioner
</h3>
</h4>
<div
class="usa-summary-box__text"
>
Expand Down
Loading

0 comments on commit 594ea46

Please sign in to comment.