Skip to content

Commit

Permalink
Added .editorconfig/prettier.config and ran prettier. (#244)
Browse files Browse the repository at this point in the history
* Added .editorconfig and prettier config.

* Ran prettier.
  • Loading branch information
manuelroemer authored May 5, 2021
1 parent 95c950c commit 14925c1
Show file tree
Hide file tree
Showing 298 changed files with 5,432 additions and 8,694 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ci:release": "lerna version --no-git-tag-version",
"ci:prerelease": "lerna version prerelease --no-git-tag-version --yes",
"verify": "lerna run lint && lerna run test && lerna run typescript",
"prettier": "prettier \"packages/**/src/**/*\" --write",
"prettier": "prettier --config prettier.config.js --write \"packages/**/*.{ts,tsx}\"",
"test": "jest --config jest.config.json --verbose false --passWithNoTests",
"test-watch": "jest --watch --config jest.config.json",
"coverage": "yarn test --coverage",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import React, { useState, useEffect } from "react";
import dayjs from "dayjs";
import AllergyForm from "./allergy-form.component";
import styles from "./allergies-detailed-summary.css";
import {
EmptyState,
SummaryCard,
openWorkspaceTab,
} from "@openmrs/esm-patient-common-lib";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { createErrorHandler } from "@openmrs/esm-framework";
import {
performPatientAllergySearch,
Allergy,
} from "./allergy-intolerance.resource";
import React, { useState, useEffect } from 'react';
import dayjs from 'dayjs';
import AllergyForm from './allergy-form.component';
import styles from './allergies-detailed-summary.css';
import { EmptyState, SummaryCard, openWorkspaceTab } from '@openmrs/esm-patient-common-lib';
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { createErrorHandler } from '@openmrs/esm-framework';
import { performPatientAllergySearch, Allergy } from './allergy-intolerance.resource';

interface AllergiesDetailedSummaryProps {
patient: fhir.Patient;
}

export default function AllergiesDetailedSummary({
patient,
}: AllergiesDetailedSummaryProps) {
export default function AllergiesDetailedSummary({ patient }: AllergiesDetailedSummaryProps) {
const [patientAllergies, setPatientAllergies] = useState<Array<Allergy>>([]);
const { t } = useTranslation();

useEffect(() => {
if (patient) {
const sub = performPatientAllergySearch(
patient.identifier[0].value
).subscribe((allergies) => {
const sub = performPatientAllergySearch(patient.identifier[0].value).subscribe((allergies) => {
setPatientAllergies(allergies);
}, createErrorHandler());

Expand All @@ -41,85 +30,61 @@ export default function AllergiesDetailedSummary({
<>
{patientAllergies?.length ? (
<SummaryCard
name={t("allergies", "Allergies")}
styles={{ width: "100%" }}
name={t('allergies', 'Allergies')}
styles={{ width: '100%' }}
addComponent
showComponent={() =>
openWorkspaceTab(
AllergyForm,
`${t("allergiesForm", "Allergies Form")}`,
{
allergyUuid: null,
setAllergies: setPatientAllergies,
allergies: patientAllergies,
}
)
}
>
openWorkspaceTab(AllergyForm, `${t('allergiesForm', 'Allergies Form')}`, {
allergyUuid: null,
setAllergies: setPatientAllergies,
allergies: patientAllergies,
})
}>
<table className={`omrs-type-body-regular ${styles.allergyTable}`}>
<thead>
<tr>
<td>{t("allergen", "Allergen")}</td>
<td>{t('allergen', 'Allergen')}</td>
<td>
<div className={styles.centerItems}>
{t("severityandReaction", "Severity & Reaction")}
{t('severityandReaction', 'Severity & Reaction')}
<svg className="omrs-icon" fill="rgba(0, 0, 0, 0.54)">
<use xlinkHref="#omrs-icon-arrow-downward" />
</svg>
</div>
</td>
<td>{t("since", "Since")}</td>
<td>{t("updated", "Updated")}</td>
<td>{t('since', 'Since')}</td>
<td>{t('updated', 'Updated')}</td>
</tr>
</thead>
<tbody>
{patientAllergies.map((allergy) => {
return (
<React.Fragment key={allergy?.id}>
<tr
className={`${
allergy?.criticality === "high"
? `${styles.high}`
: `${styles.low}`
}`}
>
<tr className={`${allergy?.criticality === 'high' ? `${styles.high}` : `${styles.low}`}`}>
<td className="omrs-medium">{allergy?.display}</td>
<td>
<div
className={`${styles.centerItems} ${
styles.allergySeverity
} ${
allergy?.criticality === "high" ? `omrs-bold` : ``
className={`${styles.centerItems} ${styles.allergySeverity} ${
allergy?.criticality === 'high' ? `omrs-bold` : ``
}`}
style={{ textTransform: "uppercase" }}
>
{allergy?.criticality === "high" && (
style={{ textTransform: 'uppercase' }}>
{allergy?.criticality === 'high' && (
<svg
className="omrs-icon omrs-margin-right-4"
fill="rgba(181, 7, 6, 1)"
style={{ height: "1.833rem" }}
>
style={{ height: '1.833rem' }}>
<use xlinkHref="#omrs-icon-important-notification" />
</svg>
)}
{allergy?.criticality}
</div>
</td>
<td>{dayjs(allergy?.recordedDate).format('MMM-YYYY') ?? '-'}</td>
<td>
{dayjs(allergy?.recordedDate).format("MMM-YYYY") ?? "-"}
</td>
<td>
<div
className={`${styles.centerItems} ${styles.alignRight}`}
>
<span>
{dayjs(allergy?.lastUpdated).format("DD-MMM-YYYY")}
</span>
<div className={`${styles.centerItems} ${styles.alignRight}`}>
<span>{dayjs(allergy?.lastUpdated).format('DD-MMM-YYYY')}</span>
<Link to={`/details/${allergy?.id}`}>
<svg
className="omrs-icon"
fill="rgba(0, 0, 0, 0.54)"
>
<svg className="omrs-icon" fill="rgba(0, 0, 0, 0.54)">
<use xlinkHref="#omrs-icon-chevron-right" />
</svg>
</Link>
Expand All @@ -128,17 +93,13 @@ export default function AllergiesDetailedSummary({
</tr>
<tr>
<td></td>
<td style={{ textAlign: "left" }}>
{allergy?.reactionManifestations?.join(", ")}
</td>
<td style={{ textAlign: 'left' }}>{allergy?.reactionManifestations?.join(', ')}</td>
</tr>
<tr>
<td></td>
<td colSpan={3}>
<span className={styles.allergyComment}>
<span style={{ textAlign: "left" }}>
{allergy?.note}
</span>
<span style={{ textAlign: 'left' }}>{allergy?.note}</span>
</span>
</td>
</tr>
Expand All @@ -150,18 +111,14 @@ export default function AllergiesDetailedSummary({
</SummaryCard>
) : (
<EmptyState
displayText={t("allergyIntolerances", "allergy intolerances")}
headerTitle={t("allergies", "Allergies")}
displayText={t('allergyIntolerances', 'allergy intolerances')}
headerTitle={t('allergies', 'Allergies')}
launchForm={() =>
openWorkspaceTab(
AllergyForm,
`${t("allergiesForm", "Allergies Form")}`,
{
allergyUuid: null,
setAllergies: setPatientAllergies,
allergies: patientAllergies,
}
)
openWorkspaceTab(AllergyForm, `${t('allergiesForm', 'Allergies Form')}`, {
allergyUuid: null,
setAllergies: setPatientAllergies,
allergies: patientAllergies,
})
}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React from "react";
import AllergiesDetailedSummary from "./allergies-detailed-summary.component";
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { of } from "rxjs/internal/observable/of";
import { mockPatientAllergies } from "../../../../__mocks__/allergies.mock";
import { performPatientAllergySearch } from "./allergy-intolerance.resource";
import React from 'react';
import AllergiesDetailedSummary from './allergies-detailed-summary.component';
import { render, screen } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import { of } from 'rxjs/internal/observable/of';
import { mockPatientAllergies } from '../../../../__mocks__/allergies.mock';
import { performPatientAllergySearch } from './allergy-intolerance.resource';

const mockPerformPatientAllergySearch = performPatientAllergySearch as jest.Mock;

const renderAllergiesDetailedSummary = () =>
render(
<BrowserRouter>
<AllergiesDetailedSummary />
</BrowserRouter>
</BrowserRouter>,
);

jest.mock("./allergy-intolerance.resource", () => ({
jest.mock('./allergy-intolerance.resource', () => ({
performPatientAllergySearch: jest.fn(),
}));

describe("AllergiesDetailedSummary />", () => {
describe('AllergiesDetailedSummary />', () => {
beforeEach(() => {
mockPerformPatientAllergySearch.mockReset;
});
Expand All @@ -29,34 +29,30 @@ describe("AllergiesDetailedSummary />", () => {

renderAllergiesDetailedSummary();

await screen.findByText("Allergies");

expect(screen.getByText("Allergen")).toBeInTheDocument();
expect(screen.getByText("Severity & Reaction")).toBeInTheDocument();
expect(screen.getByText("Since")).toBeInTheDocument();
expect(screen.getByText("Updated")).toBeInTheDocument();
expect(screen.getByText("Cephalosporins")).toBeInTheDocument();
expect(screen.getByText("Angioedema")).toBeInTheDocument();
expect(screen.getByText("happened today")).toBeInTheDocument();
expect(screen.getByText("Peanuts")).toBeInTheDocument();
expect(screen.getByText("Anaphylaxis")).toBeInTheDocument();
expect(screen.getByText("ACE inhibitors")).toBeInTheDocument();
expect(screen.getAllByText("high").length).toEqual(2);
expect(screen.getAllByText("Severe reaction").length).toEqual(2);
await screen.findByText('Allergies');

expect(screen.getByText('Allergen')).toBeInTheDocument();
expect(screen.getByText('Severity & Reaction')).toBeInTheDocument();
expect(screen.getByText('Since')).toBeInTheDocument();
expect(screen.getByText('Updated')).toBeInTheDocument();
expect(screen.getByText('Cephalosporins')).toBeInTheDocument();
expect(screen.getByText('Angioedema')).toBeInTheDocument();
expect(screen.getByText('happened today')).toBeInTheDocument();
expect(screen.getByText('Peanuts')).toBeInTheDocument();
expect(screen.getByText('Anaphylaxis')).toBeInTheDocument();
expect(screen.getByText('ACE inhibitors')).toBeInTheDocument();
expect(screen.getAllByText('high').length).toEqual(2);
expect(screen.getAllByText('Severe reaction').length).toEqual(2);
});

it("renders an empty state view when allergies are absent", async () => {
it('renders an empty state view when allergies are absent', async () => {
mockPerformPatientAllergySearch.mockReturnValue(of([]));

renderAllergiesDetailedSummary();

await screen.findByText("Allergies");
await screen.findByText('Allergies');

expect(screen.getByText("Allergies")).toBeInTheDocument();
expect(
screen.getByText(
"There are no allergy intolerances to display for this patient"
)
).toBeInTheDocument();
expect(screen.getByText('Allergies')).toBeInTheDocument();
expect(screen.getByText('There are no allergy intolerances to display for this patient')).toBeInTheDocument();
});
});
Loading

0 comments on commit 14925c1

Please sign in to comment.