From 653202870b4eafad6f960136b63ef76639ca005c Mon Sep 17 00:00:00 2001 From: Maksim Sinik Date: Tue, 16 Jun 2020 10:04:39 +0200 Subject: [PATCH 01/83] fix(toolchain): extends scripts tsconfig.json from base one re #2113 --- scripts/tsconfig.json | 8 ++++++-- tsconfig.json | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index f1141d0082..c93f174398 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,8 +1,12 @@ { - "include": ["./checkMissingTranslations.ts"], + "extends": "../tsconfig.json", + "include": [ + "./checkMissingTranslations.ts" + ], "compilerOptions": { "module": "commonjs", "outDir": "../bin", - "target": "es5" + "target": "es5", + "sourceMap": false } } diff --git a/tsconfig.json b/tsconfig.json index f37b7e2b46..1d9146dac9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,6 @@ "resolveJsonModule": true, "importHelpers": true, "jsx": "react", - // "baseUrl": "./src", "allowJs": true, "skipLibCheck": true, "noEmit": true, From d0c35db60aef95d0892fe7650960635eeda25df8 Mon Sep 17 00:00:00 2001 From: Maksim Sinik Date: Tue, 16 Jun 2020 18:00:58 +0200 Subject: [PATCH 02/83] fix(toolchain): fix broken deps and updates translate-check script --- .eslintrc.js | 30 +++++++++--------- {scripts => check-translations}/.eslintrc.js | 0 .../index.ts | 0 {scripts => check-translations}/tsconfig.json | 7 +++-- package.json | 31 +++++++++++-------- .../clients/db/LabRepository.test.ts | 2 -- src/clients/db/Repository.ts | 1 - .../network-status/NetworkStatusMessage.tsx | 2 +- src/custom-pouchdb.d.ts | 6 ++-- src/hooks/useUpdateEffect.ts | 4 +-- 10 files changed, 43 insertions(+), 40 deletions(-) rename {scripts => check-translations}/.eslintrc.js (100%) rename scripts/checkMissingTranslations.ts => check-translations/index.ts (100%) rename {scripts => check-translations}/tsconfig.json (60%) diff --git a/.eslintrc.js b/.eslintrc.js index a91ef4dcd7..ef1ede40e0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,18 +21,18 @@ module.exports = { }, parser: '@typescript-eslint/parser', parserOptions: { - project: ['./tsconfig.json', './scripts/tsconfig.json'], + project: ['./tsconfig.json', './check-translations/tsconfig.json'], tsconfigRootDir: './', }, settings: { 'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts', '.tsx'], - moduleDirectory: ["node_modules"], + moduleDirectory: ['node_modules'], }, - "typescript": { + typescript: { alwaysTryTypes: true, - } + }, }, 'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'], @@ -61,19 +61,17 @@ module.exports = { 'no-nested-ternary': 'off', 'import/no-unresolved': 'off', 'import/extensions': ['error', 'never'], - 'import/order': ["error", { - "groups": [ - "external", - ["sibling","parent","internal"], - "builtin", - "unknown", - ], - "newlines-between": "always", - "alphabetize": { - "order": 'asc', - "caseInsensitive": true, + 'import/order': [ + 'error', + { + groups: ['external', ['sibling', 'parent', 'internal'], 'builtin', 'unknown'], + 'newlines-between': 'always', + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, }, - }], + ], curly: ['error', 'all'], }, } diff --git a/scripts/.eslintrc.js b/check-translations/.eslintrc.js similarity index 100% rename from scripts/.eslintrc.js rename to check-translations/.eslintrc.js diff --git a/scripts/checkMissingTranslations.ts b/check-translations/index.ts similarity index 100% rename from scripts/checkMissingTranslations.ts rename to check-translations/index.ts diff --git a/scripts/tsconfig.json b/check-translations/tsconfig.json similarity index 60% rename from scripts/tsconfig.json rename to check-translations/tsconfig.json index c93f174398..aa1518f5d2 100644 --- a/scripts/tsconfig.json +++ b/check-translations/tsconfig.json @@ -1,12 +1,13 @@ { "extends": "../tsconfig.json", "include": [ - "./checkMissingTranslations.ts" + "./index.ts" ], "compilerOptions": { "module": "commonjs", - "outDir": "../bin", + "outDir": "compiled", "target": "es5", - "sourceMap": false + "sourceMap": false, + "noEmit": false } } diff --git a/package.json b/package.json index da12935cb6..5882dc6a71 100644 --- a/package.json +++ b/package.json @@ -27,13 +27,13 @@ "react-dom": "~16.13.0", "react-i18next": "~11.5.0", "react-redux": "~7.2.0", - "react-router": "~5.1.2", - "react-router-dom": "~5.1.2", + "react-router": "~5.2.0", + "react-router-dom": "~5.2.0", "react-scripts": "~3.4.0", "redux": "~4.0.5", "redux-thunk": "~2.3.0", "shortid": "^2.2.15", - "typescript": "~3.8.2", + "typescript": "~3.8.3", "uuid": "^8.0.0", "validator": "^13.0.0" }, @@ -57,7 +57,7 @@ "@commitlint/config-conventional": "~8.3.4", "@commitlint/core": "~8.3.5", "@commitlint/prompt": "~8.3.5", - "@testing-library/react": "~10.1.0", + "@testing-library/react": "~10.2.1", "@testing-library/react-hooks": "~3.3.0", "@types/enzyme": "^3.10.5", "@types/jest": "~26.0.0", @@ -73,8 +73,8 @@ "@types/shortid": "^0.0.29", "@types/uuid": "^8.0.0", "@types/validator": "~13.0.0", - "@typescript-eslint/eslint-plugin": "~2.34.0", - "@typescript-eslint/parser": "~2.34.0", + "@typescript-eslint/eslint-plugin": "~3.3.0", + "@typescript-eslint/parser": "~3.3.0", "chalk": "^4.0.0", "commitizen": "~4.1.2", "commitlint-config-cz": "~0.13.0", @@ -92,7 +92,7 @@ "eslint-plugin-jsx-a11y": "~6.2.3", "eslint-plugin-prettier": "~3.1.2", "eslint-plugin-react": "~7.20.0", - "eslint-plugin-react-hooks": "~2.5.0", + "eslint-plugin-react-hooks": "~4.0.4", "history": "~4.10.1", "husky": "~4.2.1", "jest": "~24.9.0", @@ -100,24 +100,29 @@ "memdown": "~5.1.0", "prettier": "~2.0.4", "redux-mock-store": "~1.5.4", + "rimraf": "~3.0.2", "source-map-explorer": "^2.2.2", "standard-version": "~8.0.0", - "ts-jest": "~24.3.0" + "ts-jest": "~26.1.0" }, "scripts": { "analyze": "source-map-explorer 'build/static/js/*.js'", "commit": "npx git-cz", - "start": "yarn translation:check && react-scripts start", + "start": "npm run translation:check && react-scripts start", "build": "react-scripts build", + "update": "npx npm-check -u", "prepublishOnly": "npm run build", - "test": "yarn translation:check && react-scripts test --detectOpenHandles", + "test": "npm run translation:check && react-scripts test --detectOpenHandles", "test:ci": "cross-env CI=true react-scripts test --passWithNoTests", - "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/**/*.{js,ts}\"", - "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/**/*.{js,ts}\" --fix", + "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"check-translations/**/*.{js,ts}\"", + "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"check-translations/**/*.{js,ts}\" --fix", "lint-staged": "lint-staged", "commitlint": "commitlint", "coveralls": "npm run test:ci -- --coverage --watchAll=false && cat ./coverage/lcov.info", - "translation:check": "cd scripts && tsc && node ../bin/scripts/checkMissingTranslations.js" + "remove-compiled-translations": "rimraf ./check-translations/compiled", + "pretranslation:check": "npm run remove-compiled-translations", + "translation:check": "tsc -p ./check-translations/tsconfig.json && node ./check-translations/compiled/check-translations/index.js", + "posttranslation:check": "npm run remove-compiled-translations" }, "browserslist": { "production": [ diff --git a/src/__tests__/clients/db/LabRepository.test.ts b/src/__tests__/clients/db/LabRepository.test.ts index cbbc7238a0..83589483a0 100644 --- a/src/__tests__/clients/db/LabRepository.test.ts +++ b/src/__tests__/clients/db/LabRepository.test.ts @@ -1,5 +1,3 @@ -/* eslint "@typescript-eslint/camelcase": "off" */ - import shortid from 'shortid' import LabRepository from '../../../clients/db/LabRepository' diff --git a/src/clients/db/Repository.ts b/src/clients/db/Repository.ts index 7a82d2631b..7ced8d0086 100644 --- a/src/clients/db/Repository.ts +++ b/src/clients/db/Repository.ts @@ -1,4 +1,3 @@ -/* eslint "@typescript-eslint/camelcase": "off" */ import { v4 as uuidv4 } from 'uuid' import AbstractDBModel from '../../model/AbstractDBModel' diff --git a/src/components/network-status/NetworkStatusMessage.tsx b/src/components/network-status/NetworkStatusMessage.tsx index c8269d22d6..c9e1b35227 100644 --- a/src/components/network-status/NetworkStatusMessage.tsx +++ b/src/components/network-status/NetworkStatusMessage.tsx @@ -8,7 +8,7 @@ const OFFLINE_COLOR = 'rgba(255, 0, 0, 0.65)' const OPACITY_TRANSITION_TIME = 4000 const BASE_STYLE = { height: '50px', - pointerEvents: 'none' as 'none', + pointerEvents: 'none' as const, transition: `opacity ${OPACITY_TRANSITION_TIME}ms ease-in`, } diff --git a/src/custom-pouchdb.d.ts b/src/custom-pouchdb.d.ts index 2910c943e6..a3211e3398 100644 --- a/src/custom-pouchdb.d.ts +++ b/src/custom-pouchdb.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ declare namespace PouchDB { interface SearchQuery { // Search string @@ -16,8 +17,8 @@ declare namespace PouchDB { filter?: (content: Content) => boolean - include_docs?: boolean highlighting?: boolean + include_docs?: boolean highlighting_pre?: string highlighting_post?: string @@ -36,10 +37,11 @@ declare namespace PouchDB { interface SearchResponse { rows: Array> + total_rows: number } - interface Database { + interface Database = Record> { search(query: SearchQuery): SearchResponse } } diff --git a/src/hooks/useUpdateEffect.ts b/src/hooks/useUpdateEffect.ts index 7b2e4c7908..12f93ca4fa 100644 --- a/src/hooks/useUpdateEffect.ts +++ b/src/hooks/useUpdateEffect.ts @@ -1,6 +1,6 @@ -import { useRef, useEffect } from 'react' +import { useRef, useEffect, EffectCallback } from 'react' -export default function (effect: Function, dependencies: any[]) { +export default function (effect: EffectCallback, dependencies: any[]): void { const isInitialMount = useRef(true) useEffect(() => { From 0f3a202c565c50efafe6ccecd1a7c416aeea7404 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 16 Jun 2020 16:00:59 +0000 Subject: [PATCH 03/83] chore(deps): bump react-i18next from 11.5.1 to 11.6.0 Bumps [react-i18next](https://github.com/i18next/react-i18next) from 11.5.1 to 11.6.0. - [Release notes](https://github.com/i18next/react-i18next/releases) - [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/react-i18next/compare/v11.5.1...v11.6.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da12935cb6..4ed73028a6 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "react-bootstrap": "~1.0.0-beta.16", "react-bootstrap-typeahead": "~4.2.0", "react-dom": "~16.13.0", - "react-i18next": "~11.5.0", + "react-i18next": "~11.6.0", "react-redux": "~7.2.0", "react-router": "~5.1.2", "react-router-dom": "~5.1.2", From e4607df6cd86636f20fca68bffbe0a52ad7d1f94 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 16 Jun 2020 19:02:31 +0200 Subject: [PATCH 04/83] ci(node): add node 14 on windows and mac (#2131) --- .github/workflows/ci.yml | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1daeac015..24cae26305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # node-version: [12.x, 14.x] - node-version: [12.x] + node-version: [12.x, 14.x] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - run: git config --global core.autocrlf false # this is needed to prevent git changing EOL after cloning on Windows OS @@ -36,29 +35,3 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage/lcov.info - - npm-node14: - runs-on: ${{ matrix.os }} - strategy: - matrix: - node-version: [14.x] - os: [ubuntu-latest] - steps: - - run: git config --global core.autocrlf false # this is needed to prevent git changing EOL after cloning on Windows OS - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Install with npm - run: | - npm install - - name: Lint code - run: | - npm run lint - - name: Build - run: | - npm run build - - name: Run tests - run: | - npm run test:ci From ceb96a4af48d4108babb7ff4f5d3e75bf74ec1fb Mon Sep 17 00:00:00 2001 From: Kumiko Date: Wed, 17 Jun 2020 16:57:54 -0700 Subject: [PATCH 05/83] feat(patient): multiple contact info (#2113) Co-authored-by: Jack Meyer --- src/__tests__/patients/ContactInfo.test.tsx | 231 +++++++++ .../patients/GeneralInformation.test.tsx | 437 ++++++++++-------- .../patients/edit/EditPatient.test.tsx | 11 +- .../patients/new/NewPatient.test.tsx | 10 +- src/__tests__/patients/patient-slice.test.ts | 19 +- .../input/SelectWithLableFormGroup.tsx | 4 +- .../input/TextFieldWithLabelFormGroup.tsx | 4 +- .../input/TextInputWithLabelFormGroup.tsx | 4 +- .../enUs/translations/actions/index.ts | 1 + .../enUs/translations/patient/index.ts | 10 + src/model/ContactInformation.ts | 13 +- src/patients/ContactInfo.tsx | 146 ++++++ src/patients/ContactInfoTypes.ts | 9 + src/patients/GeneralInformation.tsx | 197 ++++---- src/patients/edit/EditPatient.tsx | 29 +- src/patients/new/NewPatient.tsx | 26 +- src/patients/patient-slice.ts | 47 +- src/patients/util/set-patient-helper.ts | 39 ++ 18 files changed, 872 insertions(+), 365 deletions(-) create mode 100644 src/__tests__/patients/ContactInfo.test.tsx create mode 100644 src/patients/ContactInfo.tsx create mode 100644 src/patients/ContactInfoTypes.ts create mode 100644 src/patients/util/set-patient-helper.ts diff --git a/src/__tests__/patients/ContactInfo.test.tsx b/src/__tests__/patients/ContactInfo.test.tsx new file mode 100644 index 0000000000..207d946d72 --- /dev/null +++ b/src/__tests__/patients/ContactInfo.test.tsx @@ -0,0 +1,231 @@ +import '../../__mocks__/matchMediaMock' +import { Column, Spinner } from '@hospitalrun/components' +import { mount } from 'enzyme' +import { createMemoryHistory } from 'history' +import React from 'react' +import { act } from 'react-dom/test-utils' +import { Router } from 'react-router-dom' + +import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' +import { ContactInfoPiece } from '../../model/ContactInformation' +import ContactInfo from '../../patients/ContactInfo' +import * as uuid from '../../util/uuid' + +describe('Contact Info in its Editable mode', () => { + const data = [ + { id: '123', value: '123456', type: 'home' }, + { id: '456', value: '789012', type: undefined }, + ] + const dataForNoAdd = [ + { id: '123', value: '123456', type: 'home' }, + { id: '456', value: ' ', type: undefined }, + ] + const errors = ['this is an error', ''] + const label = 'this is a label' + const name = 'this is a name' + let onChange: jest.Mock + + const setup = (_data?: ContactInfoPiece[], _errors?: string[]) => { + const history = createMemoryHistory() + history.push('/patients/new') + onChange = jest.fn() + + const wrapper = mount( + + + , + ) + return wrapper + } + + it('should show a spinner if no data is present', () => { + const wrapper = setup() + const spinnerWrapper = wrapper.find(Spinner) + + expect(spinnerWrapper).toHaveLength(1) + }) + + it('should call onChange if no data is provided', () => { + const newId = 'newId' + jest.spyOn(uuid, 'uuid').mockReturnValue(newId) + setup() + + const expectedNewData = [{ id: newId, value: '' }] + expect(onChange).toHaveBeenCalledTimes(1) + expect(onChange).toHaveBeenCalledWith(expectedNewData) + }) + + it('should render the labels if data is provided', () => { + const wrapper = setup(data) + const headerWrapper = wrapper.find('.header') + const columnWrappers = headerWrapper.find(Column) + const expectedTypeLabel = 'patient.contactInfoType.label' + + expect(columnWrappers.at(0).text()).toEqual(`${expectedTypeLabel} & ${label}`) + expect(columnWrappers.at(1).text()).toEqual(label) + }) + + it('should display the entries if data is provided', () => { + const wrapper = setup(data) + for (let i = 0; i < wrapper.length; i += 1) { + const inputWrapper = wrapper.findWhere((w: any) => w.prop('name') === `${name}${i}`) + + expect(inputWrapper.prop('value')).toEqual(data[i].value) + } + }) + + it('should display the error if error is provided', () => { + const wrapper = setup(data, errors) + const feedbackWrappers = wrapper.find('.invalid-feedback') + + expect(feedbackWrappers).toHaveLength(errors.length * 2) + + for (let i = 0; i < feedbackWrappers.length; i += 1) { + if (i % 2 === 1) { + const j = (i - 1) / 2 + expect(feedbackWrappers.at(i).text()).toEqual(errors[j]) + } + } + }) + + it('should display the add button', () => { + const wrapper = setup(data) + const buttonWrapper = wrapper.find('button') + + expect(buttonWrapper.text().trim()).toEqual('actions.add') + }) + + it('should call the onChange callback if select is changed', () => { + const wrapper = setup(data) + const select = wrapper.findWhere((w: any) => w.prop('name') === `${name}Type0`).find('select') + select.getDOMNode().value = 'mobile' + select.simulate('change') + + const expectedNewData = [ + { id: '123', value: '123456', type: 'mobile' }, + { id: '456', value: '789012', type: undefined }, + ] + expect(onChange).toHaveBeenCalledTimes(1) + expect(onChange).toHaveBeenCalledWith(expectedNewData) + }) + + it('should call the onChange callback if input is changed', () => { + const wrapper = setup(data) + const input = wrapper.findWhere((w: any) => w.prop('name') === `${name}0`).find('input') + input.getDOMNode().value = '777777' + input.simulate('change') + + const expectedNewData = [ + { id: '123', value: '777777', type: 'home' }, + { id: '456', value: '789012', type: undefined }, + ] + expect(onChange).toHaveBeenCalledTimes(1) + expect(onChange).toHaveBeenCalledWith(expectedNewData) + }) + + it('should call the onChange callback if an add button is clicked with valid entries', () => { + const wrapper = setup(data) + const buttonWrapper = wrapper.find('button') + const onClick = buttonWrapper.prop('onClick') as any + const newId = 'newId' + jest.spyOn(uuid, 'uuid').mockReturnValue(newId) + + act(() => { + onClick() + }) + + const expectedNewData = [...data, { id: newId, value: '' }] + + expect(onChange).toHaveBeenCalledTimes(1) + expect(onChange).toHaveBeenCalledWith(expectedNewData) + }) + + it('should call the onChange callback if an add button is clicked with an empty entry', () => { + const wrapper = setup(dataForNoAdd) + const buttonWrapper = wrapper.find('button') + const onClick = buttonWrapper.prop('onClick') as any + const newId = 'newId' + jest.spyOn(uuid, 'uuid').mockReturnValue(newId) + + act(() => { + onClick() + }) + + const expectedNewData = [ + { id: '123', value: '123456', type: 'home' }, + { id: newId, value: '' }, + ] + + expect(onChange).toHaveBeenCalledTimes(1) + expect(onChange).toHaveBeenCalledWith(expectedNewData) + }) +}) + +describe('Contact Info in its non-Editable mode', () => { + const data = [ + { id: '123', value: '123456', type: 'home' }, + { id: '456', value: '789012', type: undefined }, + ] + const label = 'this is a label' + const name = 'this is a name' + + const setup = (_data?: ContactInfoPiece[]) => { + const history = createMemoryHistory() + history.push('/patients/new') + + const wrapper = mount( + + + , + ) + return wrapper + } + + it('should render an empty element if no data is present', () => { + const wrapper = setup() + const contactInfoWrapper = wrapper.find(ContactInfo) + + expect(contactInfoWrapper.find('div')).toHaveLength(1) + expect(contactInfoWrapper.containsMatchingElement(
)).toEqual(true) + }) + + it('should render the labels if data is provided', () => { + const wrapper = setup(data) + const headerWrapper = wrapper.find('.header') + const columnWrappers = headerWrapper.find(Column) + const expectedTypeLabel = 'patient.contactInfoType.label' + + expect(columnWrappers.at(0).text()).toEqual(`${expectedTypeLabel} & ${label}`) + expect(columnWrappers.at(1).text()).toEqual(label) + }) + + it('should display the entries if data is provided', () => { + const wrapper = setup(data) + for (let i = 0; i < wrapper.length; i += 1) { + const inputWrapper = wrapper.findWhere((w: any) => w.prop('name') === `${name}${i}`) + + expect(inputWrapper.prop('value')).toEqual(data[i].value) + } + }) + + it('should show inputs that are not editable', () => { + const wrapper = setup(data) + const inputWrappers = wrapper.find(TextInputWithLabelFormGroup) + for (let i = 0; i < inputWrappers.length; i += 1) { + expect(inputWrappers.at(i).prop('isEditable')).toBeFalsy() + } + }) +}) diff --git a/src/__tests__/patients/GeneralInformation.test.tsx b/src/__tests__/patients/GeneralInformation.test.tsx index 353334e293..dde42ec3b5 100644 --- a/src/__tests__/patients/GeneralInformation.test.tsx +++ b/src/__tests__/patients/GeneralInformation.test.tsx @@ -4,7 +4,7 @@ import { Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' import { startOfDay, subYears } from 'date-fns' import { mount, ReactWrapper } from 'enzyme' -import { createMemoryHistory } from 'history' +import { createMemoryHistory, MemoryHistory } from 'history' import React from 'react' import { Router } from 'react-router-dom' @@ -17,32 +17,50 @@ describe('Error handling', () => { message: 'some message', givenName: 'given name message', dateOfBirth: 'date of birth message', - phoneNumber: 'phone number message', - email: 'email message', + phoneNumbers: ['phone number message'], + emails: ['email message'], } - const wrapper = mount() + const wrapper = mount( + , + ) wrapper.update() const errorMessage = wrapper.find(Alert) const givenNameInput = wrapper.findWhere((w: any) => w.prop('name') === 'givenName') const dateOfBirthInput = wrapper.findWhere((w: any) => w.prop('name') === 'dateOfBirth') - const emailInput = wrapper.findWhere((w: any) => w.prop('name') === 'email') - const phoneNumberInput = wrapper.findWhere((w: any) => w.prop('name') === 'phoneNumber') + const phoneNumberInput = wrapper.findWhere((w: any) => w.prop('name') === 'phoneNumber0') + const emailInput = wrapper.findWhere((w: any) => w.prop('name') === 'email0') + expect(errorMessage).toBeTruthy() expect(errorMessage.prop('message')).toMatch(error.message) + expect(givenNameInput.prop('isInvalid')).toBeTruthy() expect(givenNameInput.prop('feedback')).toEqual(error.givenName) + expect(dateOfBirthInput.prop('isInvalid')).toBeTruthy() expect(dateOfBirthInput.prop('feedback')).toEqual(error.dateOfBirth) - expect(emailInput.prop('feedback')).toEqual(error.email) - expect(emailInput.prop('isInvalid')).toBeTruthy() - expect(phoneNumberInput.prop('feedback')).toEqual(error.phoneNumber) + expect(phoneNumberInput.prop('isInvalid')).toBeTruthy() + expect(phoneNumberInput.prop('feedback')).toEqual(error.phoneNumbers[0]) + + expect(emailInput.prop('isInvalid')).toBeTruthy() + expect(emailInput.prop('feedback')).toEqual(error.emails[0]) }) }) describe('General Information, without isEditable', () => { + let wrapper: ReactWrapper + let history = createMemoryHistory() const patient = { id: '123', prefix: 'prefix', @@ -51,19 +69,25 @@ describe('General Information, without isEditable', () => { suffix: 'suffix', sex: 'male', type: 'charity', + dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(), + isApproximateDateOfBirth: false, occupation: 'occupation', preferredLanguage: 'preferredLanguage', - phoneNumber: 'phoneNumber', - email: 'email@email.com', - address: 'address', + phoneNumbers: [ + { value: '123456', type: undefined }, + { value: '789012', type: undefined }, + ], + emails: [ + { value: 'abc@email.com', type: undefined }, + { value: 'xyz@email.com', type: undefined }, + ], + addresses: [ + { value: 'address A', type: undefined }, + { value: 'address B', type: undefined }, + ], code: 'P00001', - dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(), - isApproximateDateOfBirth: false, } as Patient - let wrapper: ReactWrapper - let history = createMemoryHistory() - beforeEach(() => { Date.now = jest.fn().mockReturnValue(new Date().valueOf()) jest.restoreAllMocks() @@ -139,6 +163,23 @@ describe('General Information, without isEditable', () => { expect(dateOfBirthInput.prop('isEditable')).toBeFalsy() }) + it('should render the approximate age if patient.isApproximateDateOfBirth is true', async () => { + patient.isApproximateDateOfBirth = true + await act(async () => { + wrapper = await mount( + + ) + , + ) + }) + + const approximateAgeInput = wrapper.findWhere((w: any) => w.prop('name') === 'approximateAge') + + expect(approximateAgeInput.prop('value')).toEqual('30') + expect(approximateAgeInput.prop('label')).toEqual('patient.approximateAge') + expect(approximateAgeInput.prop('isEditable')).toBeFalsy() + }) + it('should render the occupation of the patient', () => { const occupationInput = wrapper.findWhere((w: any) => w.prop('name') === 'occupation') expect(occupationInput.prop('value')).toEqual(patient.occupation) @@ -155,48 +196,35 @@ describe('General Information, without isEditable', () => { expect(preferredLanguageInput.prop('isEditable')).toBeFalsy() }) - it('should render the phone number of the patient', () => { - const phoneNumberInput = wrapper.findWhere((w: any) => w.prop('name') === 'phoneNumber') - expect(phoneNumberInput.prop('value')).toEqual(patient.phoneNumber) - expect(phoneNumberInput.prop('label')).toEqual('patient.phoneNumber') - expect(phoneNumberInput.prop('isEditable')).toBeFalsy() - }) - - it('should render the email of the patient', () => { - const emailInput = wrapper.findWhere((w: any) => w.prop('name') === 'email') - expect(emailInput.prop('value')).toEqual(patient.email) - expect(emailInput.prop('label')).toEqual('patient.email') - expect(emailInput.prop('isEditable')).toBeFalsy() + it('should render the phone numbers of the patient', () => { + patient.phoneNumbers.forEach((phoneNumber, i) => { + const phoneNumberInput = wrapper.findWhere((w: any) => w.prop('name') === `phoneNumber${i}`) + expect(phoneNumberInput.prop('value')).toEqual(phoneNumber.value) + expect(phoneNumberInput.prop('isEditable')).toBeFalsy() + }) }) - it('should render the address of the patient', () => { - const addressInput = wrapper.findWhere((w: any) => w.prop('name') === 'address') - expect(addressInput.prop('value')).toEqual(patient.address) - expect(addressInput.prop('label')).toEqual('patient.address') - expect(addressInput.prop('isEditable')).toBeFalsy() + it('should render the emails of the patient', () => { + patient.emails.forEach((email, i) => { + const emailInput = wrapper.findWhere((w: any) => w.prop('name') === `email${i}`) + expect(emailInput.prop('value')).toEqual(email.value) + expect(emailInput.prop('isEditable')).toBeFalsy() + }) }) - it('should render the approximate age if patient.isApproximateDateOfBirth is true', async () => { - patient.isApproximateDateOfBirth = true - await act(async () => { - wrapper = await mount( - - ) - , - ) + it('should render the addresses of the patient', () => { + patient.addresses.forEach((address, i) => { + const addressInput = wrapper.findWhere((w: any) => w.prop('name') === `address${i}`) + expect(addressInput.prop('value')).toEqual(address.value) + expect(addressInput.prop('isEditable')).toBeFalsy() }) - - wrapper.update() - - const ageInput = wrapper.findWhere((w: any) => w.prop('name') === 'approximateAge') - - expect(ageInput.prop('value')).toEqual('30') - expect(ageInput.prop('label')).toEqual('patient.approximateAge') - expect(ageInput.prop('isEditable')).toBeFalsy() }) }) describe('General Information, isEditable', () => { + let wrapper: ReactWrapper + let history: MemoryHistory + let onFieldChange: jest.Mock const patient = { id: '123', prefix: 'prefix', @@ -205,28 +233,33 @@ describe('General Information, isEditable', () => { suffix: 'suffix', sex: 'male', type: 'charity', + dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(), + isApproximateDateOfBirth: false, occupation: 'occupation', preferredLanguage: 'preferredLanguage', - phoneNumber: 'phoneNumber', - email: 'email@email.com', - address: 'address', + phoneNumbers: [ + { value: '123456', type: undefined }, + { value: '789012', type: undefined }, + ], + emails: [ + { value: 'abc@email.com', type: undefined }, + { value: 'xyz@email.com', type: undefined }, + ], + addresses: [ + { value: 'address A', type: undefined }, + { value: 'address B', type: undefined }, + ], code: 'P00001', - dateOfBirth: startOfDay(subYears(new Date(), 30)).toISOString(), - isApproximateDateOfBirth: false, } as Patient - let wrapper: ReactWrapper - let history = createMemoryHistory() - - const onFieldChange = jest.fn() - beforeEach(() => { jest.restoreAllMocks() Date.now = jest.fn().mockReturnValue(new Date().valueOf()) history = createMemoryHistory() + onFieldChange = jest.fn() wrapper = mount( - ) + ) , ) }) @@ -235,87 +268,92 @@ describe('General Information, isEditable', () => { const expectedGivenName = 'expectedGivenName' const expectedFamilyName = 'expectedFamilyName' const expectedSuffix = 'expectedSuffix' - const expectedSex = 'expectedSex' - const expectedType = 'expectedType' + const expectedSex = 'unknown' + const expectedType = 'private' + const expectedDateOfBirth = '1937-06-14T05:00:00.000Z' const expectedOccupation = 'expectedOccupation' const expectedPreferredLanguage = 'expectedPreferredLanguage' - const expectedPhoneNumber = 'expectedPhoneNumber' - const expectedEmail = 'expectedEmail' - const expectedAddress = 'expectedAddress' - const expectedDateOfBirth = '1937-06-14T05:00:00.000Z' + const expectedPhoneNumbers = [ + { value: '111111', type: undefined }, + { value: '222222', type: undefined }, + ] + const expectedEmails = [ + { value: 'def@email.com', type: undefined }, + { value: 'uvw@email.com', type: undefined }, + ] + const expectedAddresses = [ + { value: 'address C', type: undefined }, + { value: 'address D', type: undefined }, + ] it('should render the prefix', () => { const prefixInput = wrapper.findWhere((w: any) => w.prop('name') === 'prefix') - const generalInformation = wrapper.find(GeneralInformation) + expect(prefixInput.prop('value')).toEqual(patient.prefix) expect(prefixInput.prop('label')).toEqual('patient.prefix') expect(prefixInput.prop('isEditable')).toBeTruthy() - act(() => { - prefixInput.prop('onChange')({ target: { value: expectedPrefix } }) - }) + const input = prefixInput.find('input') + input.getDOMNode().value = expectedPrefix + input.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith('prefix', expectedPrefix) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, prefix: expectedPrefix }) }) it('should render the given name', () => { const givenNameInput = wrapper.findWhere((w: any) => w.prop('name') === 'givenName') - const generalInformation = wrapper.find(GeneralInformation) + expect(givenNameInput.prop('value')).toEqual(patient.givenName) expect(givenNameInput.prop('label')).toEqual('patient.givenName') expect(givenNameInput.prop('isEditable')).toBeTruthy() - act(() => { - givenNameInput.prop('onChange')({ target: { value: expectedGivenName } }) - }) + const input = givenNameInput.find('input') + input.getDOMNode().value = expectedGivenName + input.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'givenName', - expectedGivenName, - ) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, givenName: expectedGivenName }) }) it('should render the family name', () => { const familyNameInput = wrapper.findWhere((w: any) => w.prop('name') === 'familyName') - const generalInformation = wrapper.find(GeneralInformation) expect(familyNameInput.prop('value')).toEqual(patient.familyName) expect(familyNameInput.prop('label')).toEqual('patient.familyName') expect(familyNameInput.prop('isEditable')).toBeTruthy() - act(() => { - familyNameInput.prop('onChange')({ target: { value: expectedFamilyName } }) - }) + const input = familyNameInput.find('input') + input.getDOMNode().value = expectedFamilyName + input.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'familyName', - expectedFamilyName, - ) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, familyName: expectedFamilyName }) }) it('should render the suffix', () => { const suffixInput = wrapper.findWhere((w: any) => w.prop('name') === 'suffix') - const generalInformation = wrapper.find(GeneralInformation) expect(suffixInput.prop('value')).toEqual(patient.suffix) expect(suffixInput.prop('label')).toEqual('patient.suffix') expect(suffixInput.prop('isEditable')).toBeTruthy() - act(() => { - suffixInput.prop('onChange')({ target: { value: expectedSuffix } }) - }) + const input = suffixInput.find('input') + input.getDOMNode().value = expectedSuffix + input.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith('suffix', expectedSuffix) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, suffix: expectedSuffix }) }) it('should render the sex select', () => { const sexSelect = wrapper.findWhere((w: any) => w.prop('name') === 'sex') - const generalInformation = wrapper.find(GeneralInformation) expect(sexSelect.prop('value')).toEqual(patient.sex) expect(sexSelect.prop('label')).toEqual('patient.sex') expect(sexSelect.prop('isEditable')).toBeTruthy() expect(sexSelect.prop('options')).toHaveLength(4) + expect(sexSelect.prop('options')[0].label).toEqual('sex.male') expect(sexSelect.prop('options')[0].value).toEqual('male') expect(sexSelect.prop('options')[1].label).toEqual('sex.female') @@ -325,36 +363,37 @@ describe('General Information, isEditable', () => { expect(sexSelect.prop('options')[3].label).toEqual('sex.unknown') expect(sexSelect.prop('options')[3].value).toEqual('unknown') - act(() => { - sexSelect.prop('onChange')({ target: { value: expectedSex } }) - }) + const select = sexSelect.find('select') + select.getDOMNode().value = expectedSex + select.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith('sex', expectedSex) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, sex: expectedSex }) }) it('should render the patient type select', () => { const typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type') - const generalInformation = wrapper.find(GeneralInformation) expect(typeSelect.prop('value')).toEqual(patient.type) expect(typeSelect.prop('label')).toEqual('patient.type') expect(typeSelect.prop('isEditable')).toBeTruthy() + expect(typeSelect.prop('options')).toHaveLength(2) expect(typeSelect.prop('options')[0].label).toEqual('patient.types.charity') expect(typeSelect.prop('options')[0].value).toEqual('charity') expect(typeSelect.prop('options')[1].label).toEqual('patient.types.private') expect(typeSelect.prop('options')[1].value).toEqual('private') - act(() => { - typeSelect.prop('onChange')({ target: { value: expectedType } }) - }) + const select = typeSelect.find('select') + select.getDOMNode().value = expectedType + select.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith('type', expectedType) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, type: expectedType }) }) it('should render the date of the birth of the patient', () => { const dateOfBirthInput = wrapper.findWhere((w: any) => w.prop('name') === 'dateOfBirth') - const generalInformation = wrapper.find(GeneralInformation) expect(dateOfBirthInput.prop('value')).toEqual(new Date(patient.dateOfBirth)) expect(dateOfBirthInput.prop('label')).toEqual('patient.dateOfBirth') @@ -365,126 +404,156 @@ describe('General Information, isEditable', () => { dateOfBirthInput.prop('onChange')(new Date(expectedDateOfBirth)) }) - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'dateOfBirth', - expectedDateOfBirth, - ) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, dateOfBirth: expectedDateOfBirth }) + }) + + it('should render the approximate age if patient.isApproximateDateOfBirth is true', async () => { + patient.isApproximateDateOfBirth = true + await act(async () => { + wrapper = await mount( + + ) + , + ) + }) + + const approximateAgeInput = wrapper.findWhere((w: any) => w.prop('name') === 'approximateAge') + + expect(approximateAgeInput.prop('value')).toEqual('30') + expect(approximateAgeInput.prop('label')).toEqual('patient.approximateAge') + expect(approximateAgeInput.prop('isEditable')).toBeTruthy() + + const input = approximateAgeInput.find('input') + input.getDOMNode().value = '20' + input.simulate('change') + + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ + ...patient, + dateOfBirth: startOfDay(subYears(new Date(Date.now()), 20)).toISOString(), + }) }) it('should render the occupation of the patient', () => { const occupationInput = wrapper.findWhere((w: any) => w.prop('name') === 'occupation') - const generalInformation = wrapper.find(GeneralInformation) expect(occupationInput.prop('value')).toEqual(patient.occupation) expect(occupationInput.prop('label')).toEqual('patient.occupation') expect(occupationInput.prop('isEditable')).toBeTruthy() - act(() => { - occupationInput.prop('onChange')({ target: { value: expectedOccupation } }) - }) + const input = occupationInput.find('input') + input.getDOMNode().value = expectedOccupation + input.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'occupation', - expectedOccupation, - ) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ ...patient, occupation: expectedOccupation }) }) it('should render the preferred language of the patient', () => { const preferredLanguageInput = wrapper.findWhere( (w: any) => w.prop('name') === 'preferredLanguage', ) - const generalInformation = wrapper.find(GeneralInformation) expect(preferredLanguageInput.prop('value')).toEqual(patient.preferredLanguage) expect(preferredLanguageInput.prop('label')).toEqual('patient.preferredLanguage') expect(preferredLanguageInput.prop('isEditable')).toBeTruthy() - act(() => { - preferredLanguageInput.prop('onChange')({ target: { value: expectedPreferredLanguage } }) - }) + const input = preferredLanguageInput.find('input') + input.getDOMNode().value = expectedPreferredLanguage + input.simulate('change') - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'preferredLanguage', - expectedPreferredLanguage, - ) - }) - - it('should render the phone number of the patient', () => { - const phoneNumberInput = wrapper.findWhere((w: any) => w.prop('name') === 'phoneNumber') - const generalInformation = wrapper.find(GeneralInformation) - - expect(phoneNumberInput.prop('value')).toEqual(patient.phoneNumber) - expect(phoneNumberInput.prop('label')).toEqual('patient.phoneNumber') - expect(phoneNumberInput.prop('isEditable')).toBeTruthy() - - act(() => { - phoneNumberInput.prop('onChange')({ target: { value: expectedPhoneNumber } }) + expect(onFieldChange).toHaveBeenCalledTimes(1) + expect(onFieldChange).toHaveBeenCalledWith({ + ...patient, + preferredLanguage: expectedPreferredLanguage, }) - - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'phoneNumber', - expectedPhoneNumber, - ) }) - it('should render the email of the patient', () => { - const emailInput = wrapper.findWhere((w: any) => w.prop('name') === 'email') - const generalInformation = wrapper.find(GeneralInformation) + it('should render the phone numbers of the patient', () => { + patient.phoneNumbers.forEach((phoneNumber, i) => { + const phoneNumberInput = wrapper.findWhere((w: any) => w.prop('name') === `phoneNumber${i}`) + expect(phoneNumberInput.prop('value')).toEqual(phoneNumber.value) + expect(phoneNumberInput.prop('isEditable')).toBeTruthy() - expect(emailInput.prop('value')).toEqual(patient.email) - expect(emailInput.prop('label')).toEqual('patient.email') - expect(emailInput.prop('isEditable')).toBeTruthy() + const input = phoneNumberInput.find('input') + input.getDOMNode().value = expectedPhoneNumbers[i].value + input.simulate('change') + }) - act(() => { - emailInput.prop('onChange')({ target: { value: expectedEmail } }) + const calledWith = [] as any + patient.phoneNumbers.forEach((_, i) => { + const newPhoneNumbers = [] as any + patient.phoneNumbers.forEach((__, j) => { + if (j <= i) { + newPhoneNumbers.push(expectedPhoneNumbers[j]) + } else { + newPhoneNumbers.push(patient.phoneNumbers[j]) + } + }) + calledWith.push({ ...patient, phoneNumbers: newPhoneNumbers }) }) - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith('email', expectedEmail) + expect(onFieldChange).toHaveBeenCalledTimes(calledWith.length) + expect(onFieldChange).toHaveBeenNthCalledWith(1, calledWith[0]) + // expect(onFieldChange).toHaveBeenNthCalledWith(2, calledWith[1]) }) - it('should render the address of the patient', () => { - const addressInput = wrapper.findWhere((w: any) => w.prop('name') === 'address') - const generalInformation = wrapper.find(GeneralInformation) + it('should render the emails of the patient', () => { + patient.emails.forEach((email, i) => { + const emailInput = wrapper.findWhere((w: any) => w.prop('name') === `email${i}`) + expect(emailInput.prop('value')).toEqual(email.value) + expect(emailInput.prop('isEditable')).toBeTruthy() - expect(addressInput.prop('value')).toEqual(patient.address) - expect(addressInput.prop('label')).toEqual('patient.address') - expect(addressInput.prop('isEditable')).toBeTruthy() + const input = emailInput.find('input') + input.getDOMNode().value = expectedEmails[i].value + input.simulate('change') + }) - act(() => { - addressInput.prop('onChange')({ currentTarget: { value: expectedAddress } }) + const calledWith = [] as any + patient.emails.forEach((_, i) => { + const newEmails = [] as any + patient.emails.forEach((__, j) => { + if (j <= i) { + newEmails.push(expectedEmails[j]) + } else { + newEmails.push(patient.emails[j]) + } + }) + calledWith.push({ ...patient, emails: newEmails }) }) - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'address', - expectedAddress, - ) + expect(onFieldChange).toHaveBeenCalledTimes(calledWith.length) + expect(onFieldChange).toHaveBeenNthCalledWith(1, calledWith[0]) + // expect(onFieldChange).toHaveBeenNthCalledWith(2, calledWith[1]) }) - it('should render the approximate age if patient.isApproximateDateOfBirth is true', async () => { - patient.isApproximateDateOfBirth = true - await act(async () => { - wrapper = await mount( - - ) - , - ) - }) - - wrapper.update() + it('should render the addresses of the patient', () => { + patient.addresses.forEach((address, i) => { + const addressTextArea = wrapper.findWhere((w: any) => w.prop('name') === `address${i}`) + expect(addressTextArea.prop('value')).toEqual(address.value) + expect(addressTextArea.prop('isEditable')).toBeTruthy() - const approximateAgeInput = wrapper.findWhere((w: any) => w.prop('name') === 'approximateAge') - const generalInformation = wrapper.find(GeneralInformation) - expect(approximateAgeInput.prop('value')).toEqual('30') - expect(approximateAgeInput.prop('label')).toEqual('patient.approximateAge') - expect(approximateAgeInput.prop('isEditable')).toBeTruthy() + const textarea = addressTextArea.find('textarea') + textarea.getDOMNode().value = expectedAddresses[i].value + textarea.simulate('change') + }) - act(() => { - approximateAgeInput.prop('onChange')({ target: { value: '20' } }) + const calledWith = [] as any + patient.addresses.forEach((_, i) => { + const newAddresses = [] as any + patient.addresses.forEach((__, j) => { + if (j <= i) { + newAddresses.push(expectedAddresses[j]) + } else { + newAddresses.push(patient.addresses[j]) + } + }) + calledWith.push({ ...patient, addresses: newAddresses }) }) - expect(generalInformation.prop('onFieldChange')).toHaveBeenCalledWith( - 'dateOfBirth', - startOfDay(subYears(new Date(Date.now()), 20)).toISOString(), - ) + expect(onFieldChange).toHaveBeenCalledTimes(calledWith.length) + expect(onFieldChange).toHaveBeenNthCalledWith(1, calledWith[0]) + // expect(onFieldChange).toHaveBeenNthCalledWith(2, calledWith[1]) }) }) diff --git a/src/__tests__/patients/edit/EditPatient.test.tsx b/src/__tests__/patients/edit/EditPatient.test.tsx index 1eab177acb..671d2bc446 100644 --- a/src/__tests__/patients/edit/EditPatient.test.tsx +++ b/src/__tests__/patients/edit/EditPatient.test.tsx @@ -1,6 +1,5 @@ import '../../../__mocks__/matchMediaMock' -import { Button } from '@hospitalrun/components' import { subDays } from 'date-fns' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -33,9 +32,9 @@ describe('Edit Patient', () => { type: 'charity', occupation: 'occupation', preferredLanguage: 'preferredLanguage', - phoneNumber: '123456789', - email: 'email@email.com', - address: 'address', + phoneNumbers: [{ value: '123456789' }], + emails: [{ value: 'email@email.com' }], + addresses: [{ value: 'address' }], code: 'P00001', dateOfBirth: subDays(new Date(), 2).toISOString(), index: 'givenName familyName suffixP00001', @@ -107,7 +106,7 @@ describe('Edit Patient', () => { wrapper.update() - const saveButton = wrapper.find(Button).at(0) + const saveButton = wrapper.find('.btn-save').at(0) const onClick = saveButton.prop('onClick') as any expect(saveButton.text().trim()).toEqual('actions.save') @@ -128,7 +127,7 @@ describe('Edit Patient', () => { wrapper.update() - const cancelButton = wrapper.find(Button).at(1) + const cancelButton = wrapper.find('.btn-cancel').at(1) const onClick = cancelButton.prop('onClick') as any expect(cancelButton.text().trim()).toEqual('actions.cancel') diff --git a/src/__tests__/patients/new/NewPatient.test.tsx b/src/__tests__/patients/new/NewPatient.test.tsx index f5237c1091..947c00e882 100644 --- a/src/__tests__/patients/new/NewPatient.test.tsx +++ b/src/__tests__/patients/new/NewPatient.test.tsx @@ -96,12 +96,12 @@ describe('New Patient', () => { const generalInformationForm = wrapper.find(GeneralInformation) act(() => { - generalInformationForm.prop('onFieldChange')('givenName', 'first') + generalInformationForm.prop('onChange')(patient) }) wrapper.update() - const saveButton = wrapper.find(components.Button).at(0) + const saveButton = wrapper.find('.btn-save').at(0) const onClick = saveButton.prop('onClick') as any expect(saveButton.text().trim()).toEqual('actions.save') @@ -125,12 +125,12 @@ describe('New Patient', () => { const generalInformationForm = wrapper.find(GeneralInformation) act(() => { - generalInformationForm.prop('onFieldChange')('givenName', 'first') + generalInformationForm.prop('onChange')(patient) }) wrapper.update() - const saveButton = wrapper.find(components.Button).at(0) + const saveButton = wrapper.find('.btn-save').at(0) const onClick = saveButton.prop('onClick') as any expect(saveButton.text().trim()).toEqual('actions.save') @@ -152,7 +152,7 @@ describe('New Patient', () => { wrapper = await setup() }) - const cancelButton = wrapper.find(components.Button).at(1) + const cancelButton = wrapper.find('.btn-cancel').at(0) const onClick = cancelButton.prop('onClick') as any expect(cancelButton.text().trim()).toEqual('actions.cancel') diff --git a/src/__tests__/patients/patient-slice.test.ts b/src/__tests__/patients/patient-slice.test.ts index 9ce0c2ddf6..829fb43d56 100644 --- a/src/__tests__/patients/patient-slice.test.ts +++ b/src/__tests__/patients/patient-slice.test.ts @@ -167,6 +167,7 @@ describe('patients slice', () => { const expectedPatient = { id: 'sliceId1', givenName: 'some name', + fullName: 'some name', } as Patient await store.dispatch(createPatient(expectedPatient)) @@ -251,13 +252,13 @@ describe('patients slice', () => { ) }) - it('should validate that the patient email is a valid email', async () => { + it('should validate that the patient phone number is a valid phone number', async () => { const store = mockStore() const expectedPatientId = 'sliceId10' const expectedPatient = { id: expectedPatientId, givenName: 'some given name', - phoneNumber: 'not a phone number', + phoneNumbers: [{ value: 'not a phone number' }], } as Patient const saveOrUpdateSpy = jest .spyOn(PatientRepository, 'saveOrUpdate') @@ -271,18 +272,18 @@ describe('patients slice', () => { expect(store.getActions()[1]).toEqual( createPatientError({ message: 'patient.errors.createPatientError', - phoneNumber: 'patient.errors.invalidPhoneNumber', + phoneNumbers: ['patient.errors.invalidPhoneNumber'], }), ) }) - it('should validate that the patient phone number is a valid phone number', async () => { + it('should validate that the patient email is a valid email', async () => { const store = mockStore() const expectedPatientId = 'sliceId10' const expectedPatient = { id: expectedPatientId, givenName: 'some given name', - phoneNumber: 'not a phone number', + emails: [{ value: 'not an email' }], } as Patient const saveOrUpdateSpy = jest .spyOn(PatientRepository, 'saveOrUpdate') @@ -296,7 +297,7 @@ describe('patients slice', () => { expect(store.getActions()[1]).toEqual( createPatientError({ message: 'patient.errors.createPatientError', - phoneNumber: 'patient.errors.invalidPhoneNumber', + emails: ['patient.errors.invalidEmail'], }), ) }) @@ -383,7 +384,11 @@ describe('patients slice', () => { it('should call the PatientRepository saveOrUpdate function with the correct data', async () => { const store = mockStore() const expectedPatientId = 'sliceId9' - const expectedPatient = { id: expectedPatientId, givenName: 'some name' } as Patient + const expectedPatient = { + id: expectedPatientId, + givenName: 'some name', + fullName: 'some name', + } as Patient jest.spyOn(PatientRepository, 'saveOrUpdate').mockResolvedValue(expectedPatient) await store.dispatch(updatePatient(expectedPatient)) diff --git a/src/components/input/SelectWithLableFormGroup.tsx b/src/components/input/SelectWithLableFormGroup.tsx index fff067037c..c61cf415c7 100644 --- a/src/components/input/SelectWithLableFormGroup.tsx +++ b/src/components/input/SelectWithLableFormGroup.tsx @@ -8,7 +8,7 @@ interface Option { interface Props { value: string - label: string + label?: string name: string isRequired?: boolean isEditable?: boolean @@ -33,7 +33,7 @@ const SelectWithLabelFormGroup = (props: Props) => { const id = `${name}Select` return (
-
) } SelectWithLabelFormGroup.defaultProps = { - value: '', + placeholder: '-- Choose --', } export default SelectWithLabelFormGroup +export type { Option } diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx index 4cb0213561..4fe6d09a5f 100644 --- a/src/incidents/list/ViewIncidents.tsx +++ b/src/incidents/list/ViewIncidents.tsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup' import Incident from '../../model/Incident' import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' import useTitle from '../../page-header/useTitle' @@ -48,11 +48,7 @@ const ViewIncidents = () => { history.push(`incidents/${incident.id}`) } - const onFilterChange = (event: React.ChangeEvent) => { - setSearchFilter(event.target.value as IncidentFilter) - } - - const filterOptions = Object.values(IncidentFilter).map((filter) => ({ + const filterOptions: Option[] = Object.values(IncidentFilter).map((filter) => ({ label: t(`incidents.status.${filter}`), value: `${filter}`, })) @@ -63,11 +59,11 @@ const ViewIncidents = () => {
value === searchFilter)} + onChange={(values) => setSearchFilter(values[0] as IncidentFilter)} + isEditable />
@@ -86,9 +82,15 @@ const ViewIncidents = () => { {incidents.map((incident: Incident) => ( onTableRowClick(incident)} key={incident.id}> {incident.code} - {format(new Date(incident.date), 'yyyy-MM-dd hh:mm a')} + + {incident.date ? format(new Date(incident.date), 'yyyy-MM-dd hh:mm a') : ''} + {incident.reportedBy} - {format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a')} + + {incident.reportedOn + ? format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a') + : ''} + {incident.status} ))} diff --git a/src/labs/ViewLabs.tsx b/src/labs/ViewLabs.tsx index 8587ae4739..c8a724d240 100644 --- a/src/labs/ViewLabs.tsx +++ b/src/labs/ViewLabs.tsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup' import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' import useDebounce from '../hooks/debounce' import Lab from '../model/Lab' @@ -15,7 +15,7 @@ import useTitle from '../page-header/useTitle' import { RootState } from '../store' import { searchLabs } from './labs-slice' -type filter = 'requested' | 'completed' | 'canceled' | 'all' +type LabFilter = 'requested' | 'completed' | 'canceled' | 'all' const ViewLabs = () => { const { t } = useTranslation() @@ -26,7 +26,7 @@ const ViewLabs = () => { const { permissions } = useSelector((state: RootState) => state.user) const dispatch = useDispatch() const { labs, isLoading } = useSelector((state: RootState) => state.labs) - const [searchFilter, setSearchFilter] = useState('all') + const [searchFilter, setSearchFilter] = useState('all') const [searchText, setSearchText] = useState('') const debouncedSearchText = useDebounce(searchText, 500) @@ -50,15 +50,6 @@ const ViewLabs = () => { return buttons }, [permissions, history, t]) - const setFilter = (filter: string) => - filter === 'requested' - ? 'requested' - : filter === 'completed' - ? 'completed' - : filter === 'canceled' - ? 'canceled' - : 'all' - useEffect(() => { dispatch(searchLabs(debouncedSearchText, searchFilter)) }, [dispatch, debouncedSearchText, searchFilter]) @@ -76,21 +67,24 @@ const ViewLabs = () => { history.push(`/labs/${lab.id}`) } - const onSelectChange = (event: React.ChangeEvent) => { - setSearchFilter(setFilter(event.target.value)) - } - const onSearchBoxChange = (event: React.ChangeEvent) => { setSearchText(event.target.value) } + const filterOptions: Option[] = [ + { label: t('labs.status.requested'), value: 'requested' }, + { label: t('labs.status.completed'), value: 'completed' }, + { label: t('labs.status.canceled'), value: 'canceled' }, + { label: t('labs.filter.all'), value: 'all' }, + ] + const listBody = ( {labs.map((lab) => ( onTableRowClick(lab)} key={lab.id}> {lab.code} {lab.type} - {format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')} + {lab.requestedOn ? format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a') : ''} {lab.status} ))} @@ -103,18 +97,11 @@ const ViewLabs = () => {
value === searchFilter)} + onChange={(values) => setSearchFilter(values[0] as LabFilter)} isEditable - options={[ - { label: t('labs.status.requested'), value: 'requested' }, - { label: t('labs.status.completed'), value: 'completed' }, - { label: t('labs.status.canceled'), value: 'canceled' }, - { label: t('labs.filter.all'), value: 'all' }, - ]} - onChange={(event: React.ChangeEvent) => { - onSelectChange(event) - }} />
diff --git a/src/patients/ContactInfo.tsx b/src/patients/ContactInfo.tsx index d6d491352c..7d3a9be3de 100644 --- a/src/patients/ContactInfo.tsx +++ b/src/patients/ContactInfo.tsx @@ -2,7 +2,7 @@ import { Spinner, Row, Column, Icon } from '@hospitalrun/components' import React, { useEffect, ReactElement } from 'react' import { useTranslation } from 'react-i18next' -import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup' import TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup' import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' import { ContactInfoPiece } from '../model/ContactInformation' @@ -30,7 +30,7 @@ const ContactInfo = (props: Props): ReactElement => { } }, [data, onChange]) - const typeOptions = Object.values(ContactInfoTypes).map((value) => ({ + const typeOptions: Option[] = Object.values(ContactInfoTypes).map((value) => ({ label: t(`patient.contactInfoType.options.${value}`), value: `${value}`, })) @@ -53,9 +53,8 @@ const ContactInfo = (props: Props): ReactElement => { } const Component = componentList[component] - const onTypeChange = (event: React.ChangeEvent, index: number) => { + const onTypeChange = (newType: string, index: number) => { if (onChange) { - const newType = event.currentTarget.value const currentContact = { ...data[index], type: newType } const newContacts = [...data] newContacts.splice(index, 1, currentContact) @@ -83,10 +82,10 @@ const ContactInfo = (props: Props): ReactElement => { onTypeChange(event, i)} + defaultSelected={typeOptions.filter(({ value }) => value === entry.type)} + onChange={(values) => onTypeChange(values[0], i)} + isEditable={isEditable} /> diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index eca1ea70a2..decafea491 100644 --- a/src/patients/GeneralInformation.tsx +++ b/src/patients/GeneralInformation.tsx @@ -4,7 +4,7 @@ import React, { ReactElement } from 'react' import { useTranslation } from 'react-i18next' import DatePickerWithLabelFormGroup from '../components/input/DatePickerWithLabelFormGroup' -import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup' import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' import { ContactInfoPiece } from '../model/ContactInformation' import Patient from '../model/Patient' @@ -59,6 +59,18 @@ const GeneralInformation = (props: Props): ReactElement => { onFieldChange('isApproximateDateOfBirth', checked) } + const sexOptions: Option[] = [ + { label: t('sex.male'), value: 'male' }, + { label: t('sex.female'), value: 'female' }, + { label: t('sex.other'), value: 'other' }, + { label: t('sex.unknown'), value: 'unknown' }, + ] + + const typeOptions: Option[] = [ + { label: t('patient.types.charity'), value: 'charity' }, + { label: t('patient.types.private'), value: 'private' }, + ] + return (
@@ -115,28 +127,20 @@ const GeneralInformation = (props: Props): ReactElement => { value === patient.sex)} + onChange={(values) => onFieldChange('sex', values[0])} isEditable={isEditable} - options={[ - { label: t('sex.male'), value: 'male' }, - { label: t('sex.female'), value: 'female' }, - { label: t('sex.other'), value: 'other' }, - { label: t('sex.unknown'), value: 'unknown' }, - ]} - onChange={(event) => onFieldChange('sex', event.currentTarget.value)} />
value === patient.type)} + onChange={(values) => onFieldChange('type', values[0])} isEditable={isEditable} - options={[ - { label: t('patient.types.charity'), value: 'charity' }, - { label: t('patient.types.private'), value: 'private' }, - ]} - onChange={(event) => onFieldChange('type', event.currentTarget.value)} />
diff --git a/src/patients/care-plans/CarePlanForm.tsx b/src/patients/care-plans/CarePlanForm.tsx index 6a5a24e7d9..be517b45c7 100644 --- a/src/patients/care-plans/CarePlanForm.tsx +++ b/src/patients/care-plans/CarePlanForm.tsx @@ -1,9 +1,9 @@ import { Alert, Column, Row } from '@hospitalrun/components' -import React from 'react' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import DatePickerWithLabelFormGroup from '../../components/input/DatePickerWithLabelFormGroup' -import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup' import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../model/CarePlan' @@ -32,6 +32,10 @@ const CarePlanForm = (props: Props) => { const { t } = useTranslation() const { patient, carePlan, carePlanError, disabled, onChange } = props + const [condition, setCondition] = useState(carePlan.diagnosisId) + const [status, setStatus] = useState(carePlan.status) + const [intent, setIntent] = useState(carePlan.intent) + const onFieldChange = (name: string, value: string | CarePlanStatus | CarePlanIntent) => { if (onChange) { const newCarePlan = { @@ -42,6 +46,13 @@ const CarePlanForm = (props: Props) => { } } + const conditionOptions: Option[] = + patient.diagnoses?.map((d) => ({ label: d.name, value: d.id })) || [] + + const statusOptions: Option[] = Object.values(CarePlanStatus).map((v) => ({ label: v, value: v })) + + const intentOptions: Option[] = Object.values(CarePlanIntent).map((v) => ({ label: v, value: v })) + return (
{carePlanError?.message && } @@ -75,44 +86,51 @@ const CarePlanForm = (props: Props) => { + {/* add feedback in next round */} value === condition)} + onChange={(values) => { + onFieldChange('diagnosisId', values[0]) + setCondition(values[0]) + }} isEditable={!disabled} - onChange={(event) => onFieldChange('diagnosisId', event.currentTarget.value)} - options={patient.diagnoses?.map((d) => ({ label: d.name, value: d.id })) || []} + isInvalid={!!carePlanError?.condition} /> value === status)} + onChange={(values) => { + onFieldChange('status', values[0]) + setStatus(values[0] as CarePlanStatus) + }} isEditable={!disabled} - options={Object.values(CarePlanStatus).map((v) => ({ label: v, value: v }))} - onChange={(event) => onFieldChange('status', event.currentTarget.value)} + isInvalid={!!carePlanError?.status} /> value === intent)} + onChange={(values) => { + onFieldChange('intent', values[0]) + setIntent(values[0] as CarePlanIntent) + }} isEditable={!disabled} - options={Object.values(CarePlanIntent).map((v) => ({ label: v, value: v }))} - onChange={(event) => onFieldChange('intent', event.currentTarget.value)} + isInvalid={!!carePlanError?.intent} /> diff --git a/src/scheduling/appointments/AppointmentDetailForm.tsx b/src/scheduling/appointments/AppointmentDetailForm.tsx index 612291ad3b..a43b591c47 100644 --- a/src/scheduling/appointments/AppointmentDetailForm.tsx +++ b/src/scheduling/appointments/AppointmentDetailForm.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next' import PatientRepository from '../../clients/db/PatientRepository' import DateTimePickerWithLabelFormGroup from '../../components/input/DateTimePickerWithLabelFormGroup' -import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup' import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' import Appointment from '../../model/Appointment' @@ -22,15 +22,20 @@ const AppointmentDetailForm = (props: Props) => { const { onFieldChange, appointment, patient, isEditable, error } = props const { t } = useTranslation() - const onSelectChange = (event: React.ChangeEvent, fieldName: string) => - onFieldChange && onFieldChange(fieldName, event.target.value) - const onDateChange = (date: Date, fieldName: string) => onFieldChange && onFieldChange(fieldName, date.toISOString()) const onInputElementChange = (event: React.ChangeEvent, fieldName: string) => onFieldChange && onFieldChange(fieldName, event.target.value) + const typeOptions: Option[] = [ + { label: t('scheduling.appointment.types.checkup'), value: 'checkup' }, + { label: t('scheduling.appointment.types.emergency'), value: 'emergency' }, + { label: t('scheduling.appointment.types.followUp'), value: 'follow up' }, + { label: t('scheduling.appointment.types.routine'), value: 'routine' }, + { label: t('scheduling.appointment.types.walkIn'), value: 'walk in' }, + ] + return ( <> {error?.message && } @@ -112,18 +117,10 @@ const AppointmentDetailForm = (props: Props) => { value === appointment.type)} + onChange={(values) => onFieldChange && onFieldChange('type', values[0])} isEditable={isEditable} - options={[ - { label: t('scheduling.appointment.types.checkup'), value: 'checkup' }, - { label: t('scheduling.appointment.types.emergency'), value: 'emergency' }, - { label: t('scheduling.appointment.types.followUp'), value: 'follow up' }, - { label: t('scheduling.appointment.types.routine'), value: 'routine' }, - { label: t('scheduling.appointment.types.walkIn'), value: 'walk in' }, - ]} - onChange={(event: React.ChangeEvent) => { - onSelectChange(event, 'type') - }} /> From b3f024180bfa8398381c0b08bef5f218f8a89016 Mon Sep 17 00:00:00 2001 From: kumikokashii Date: Tue, 23 Jun 2020 18:43:51 -0700 Subject: [PATCH 53/83] test: update tests for select after components update --- src/__tests__/components/Navbar.test.tsx | 10 ++--- .../components/PageComponent.test.tsx | 31 --------------- .../input/SelectWithLabelFormGroup.test.tsx | 39 +++---------------- .../incidents/list/ViewIncidents.test.tsx | 16 +------- src/__tests__/patients/ContactInfo.test.tsx | 25 ++---------- .../patients/GeneralInformation.test.tsx | 24 ++---------- .../patients/care-plans/CarePlanForm.test.tsx | 18 ++++----- .../AppointmentDetailForm.test.tsx | 14 +------ 8 files changed, 29 insertions(+), 148 deletions(-) delete mode 100644 src/__tests__/components/PageComponent.test.tsx diff --git a/src/__tests__/components/Navbar.test.tsx b/src/__tests__/components/Navbar.test.tsx index a7234502bf..b3faa97619 100644 --- a/src/__tests__/components/Navbar.test.tsx +++ b/src/__tests__/components/Navbar.test.tsx @@ -61,9 +61,9 @@ describe('Navbar', () => { const hamberger = hospitalRunNavbar.find('.nav-hamberger') const { children } = hamberger.first().props() as any - expect(children[0].props.children).toEqual('dashboard.label') - expect(children[1].props.children).toEqual('patients.newPatient') - expect(children[children.length - 1].props.children).toEqual('settings.label') + expect(children[0].props.children).toEqual([undefined, 'dashboard.label']) + expect(children[1].props.children).toEqual([undefined, 'patients.newPatient']) + expect(children[children.length - 1].props.children).toEqual([undefined, 'settings.label']) }) it('should not show an item if user does not have a permission', () => { @@ -144,7 +144,7 @@ describe('Navbar', () => { const addNew = hospitalRunNavbar.find('.nav-add-new') const { children } = addNew.first().props() as any - expect(children[0].props.children).toEqual('patients.newPatient') + expect(children[0].props.children).toEqual([undefined, 'patients.newPatient']) }) it('should not show a shortcut if user does not have a permission', () => { @@ -168,7 +168,7 @@ describe('Navbar', () => { const accountLinkList = hospitalRunNavbar.find('.nav-account') const { children } = accountLinkList.first().props() as any - expect(children[0].props.children).toEqual('settings.label') + expect(children[0].props.children).toEqual([undefined, 'settings.label']) }) it('should navigate to /settings when the list option is selected', () => { diff --git a/src/__tests__/components/PageComponent.test.tsx b/src/__tests__/components/PageComponent.test.tsx deleted file mode 100644 index fa1bf5a4ef..0000000000 --- a/src/__tests__/components/PageComponent.test.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import '../../__mocks__/matchMediaMock' -import { Button, Select } from '@hospitalrun/components' -import { mount } from 'enzyme' -import React from 'react' - -import PageComponent, { defaultPageSize } from '../../components/PageComponent' - -describe('PageComponenet test', () => { - it('should render PageComponent Component', () => { - const wrapper = mount( - , - ) - const buttons = wrapper.find(Button) - expect(buttons).toHaveLength(2) - expect(buttons.at(0).prop('disabled')).toBeTruthy() - expect(buttons.at(1).prop('disabled')).toBeTruthy() - - const select = wrapper.find(Select) - expect(select.prop('defaultValue')).toEqual(defaultPageSize.value?.toString()) - - const options = select.find('option') - expect(options).toHaveLength(5) - }) -}) diff --git a/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx b/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx index 96b04df022..50f1b9162a 100644 --- a/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx +++ b/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx @@ -15,7 +15,6 @@ describe('select with label form group', () => { options={[{ value: 'value1', label: 'label1' }]} name={expectedName} label="test" - value="" isEditable onChange={jest.fn()} />, @@ -27,30 +26,6 @@ describe('select with label form group', () => { expect(label.prop('text')).toEqual(expectedName) }) - it('should render a select with the proper options', () => { - const expectedName = 'test' - const wrapper = shallow( - , - ) - - const select = wrapper.find(Select) - expect(select).toHaveLength(1) - - const options = select.find('option') - expect(options).toHaveLength(2) - expect(options.at(0).prop('value')).toEqual('') - expect(options.at(0).text()).toEqual('-- Choose --') - expect(options.at(1).prop('value')).toEqual('value1') - expect(options.at(1).text()).toEqual('label1') - }) - it('should render disabled is isDisable disabled is true', () => { const expectedName = 'test' const wrapper = shallow( @@ -58,7 +33,6 @@ describe('select with label form group', () => { options={[{ value: 'value1', label: 'label1' }]} name={expectedName} label="test" - value="" isEditable={false} onChange={jest.fn()} />, @@ -71,13 +45,13 @@ describe('select with label form group', () => { it('should render the proper value', () => { const expectedName = 'test' - const expectedValue = 'expected value' + const expectedDefaultSelected = [{ value: 'value', label: 'label' }] const wrapper = shallow( , @@ -85,21 +59,18 @@ describe('select with label form group', () => { const select = wrapper.find(Select) expect(select).toHaveLength(1) - expect(select.prop('value')).toEqual(expectedValue) + expect(select.prop('defaultSelected')).toEqual(expectedDefaultSelected) }) }) describe('change handler', () => { it('should call the change handler on change', () => { - const expectedName = 'test' - const expectedValue = 'expected value' const handler = jest.fn() const wrapper = shallow( , diff --git a/src/__tests__/incidents/list/ViewIncidents.test.tsx b/src/__tests__/incidents/list/ViewIncidents.test.tsx index ab3dff4db2..aa541ca4b1 100644 --- a/src/__tests__/incidents/list/ViewIncidents.test.tsx +++ b/src/__tests__/incidents/list/ViewIncidents.test.tsx @@ -75,26 +75,12 @@ describe('View Incidents', () => { return wrapper } it('should filter incidents by status=reported on first load ', async () => { - const wrapper = await setup([Permissions.ViewIncidents]) - const filterSelect = wrapper.find('select') - expect(filterSelect.props().value).toBe(IncidentFilter.reported) + await setup([Permissions.ViewIncidents]) expect(IncidentRepository.search).toHaveBeenCalled() expect(IncidentRepository.search).toHaveBeenCalledWith({ status: IncidentFilter.reported }) }) - it('should call IncidentRepository after changing filter', async () => { - const wrapper = await setup([Permissions.ViewIncidents]) - const filterSelect = wrapper.find('select') - expect(IncidentRepository.findAll).not.toHaveBeenCalled() - - filterSelect.simulate('change', { target: { value: IncidentFilter.all } }) - expect(IncidentRepository.findAll).toHaveBeenCalled() - filterSelect.simulate('change', { target: { value: IncidentFilter.reported } }) - - expect(IncidentRepository.search).toHaveBeenCalledTimes(2) - expect(IncidentRepository.search).toHaveBeenLastCalledWith({ status: IncidentFilter.reported }) - }) describe('layout', () => { it('should set the title', async () => { await setup([Permissions.ViewIncidents]) diff --git a/src/__tests__/patients/ContactInfo.test.tsx b/src/__tests__/patients/ContactInfo.test.tsx index 207d946d72..885e89f407 100644 --- a/src/__tests__/patients/ContactInfo.test.tsx +++ b/src/__tests__/patients/ContactInfo.test.tsx @@ -86,14 +86,11 @@ describe('Contact Info in its Editable mode', () => { const wrapper = setup(data, errors) const feedbackWrappers = wrapper.find('.invalid-feedback') - expect(feedbackWrappers).toHaveLength(errors.length * 2) + expect(feedbackWrappers).toHaveLength(errors.length) - for (let i = 0; i < feedbackWrappers.length; i += 1) { - if (i % 2 === 1) { - const j = (i - 1) / 2 - expect(feedbackWrappers.at(i).text()).toEqual(errors[j]) - } - } + feedbackWrappers.forEach((_, i) => { + expect(feedbackWrappers.at(i).text()).toEqual(errors[i]) + }) }) it('should display the add button', () => { @@ -103,20 +100,6 @@ describe('Contact Info in its Editable mode', () => { expect(buttonWrapper.text().trim()).toEqual('actions.add') }) - it('should call the onChange callback if select is changed', () => { - const wrapper = setup(data) - const select = wrapper.findWhere((w: any) => w.prop('name') === `${name}Type0`).find('select') - select.getDOMNode().value = 'mobile' - select.simulate('change') - - const expectedNewData = [ - { id: '123', value: '123456', type: 'mobile' }, - { id: '456', value: '789012', type: undefined }, - ] - expect(onChange).toHaveBeenCalledTimes(1) - expect(onChange).toHaveBeenCalledWith(expectedNewData) - }) - it('should call the onChange callback if input is changed', () => { const wrapper = setup(data) const input = wrapper.findWhere((w: any) => w.prop('name') === `${name}0`).find('input') diff --git a/src/__tests__/patients/GeneralInformation.test.tsx b/src/__tests__/patients/GeneralInformation.test.tsx index dde42ec3b5..b9ed7c5dd6 100644 --- a/src/__tests__/patients/GeneralInformation.test.tsx +++ b/src/__tests__/patients/GeneralInformation.test.tsx @@ -129,7 +129,7 @@ describe('General Information, without isEditable', () => { it('should render the sex select', () => { const sexSelect = wrapper.findWhere((w: any) => w.prop('name') === 'sex') - expect(sexSelect.prop('value')).toEqual(patient.sex) + expect(sexSelect.prop('defaultSelected')[0].value).toEqual(patient.sex) expect(sexSelect.prop('label')).toEqual('patient.sex') expect(sexSelect.prop('isEditable')).toBeFalsy() expect(sexSelect.prop('options')).toHaveLength(4) @@ -145,7 +145,7 @@ describe('General Information, without isEditable', () => { it('should render the patient type select', () => { const typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type') - expect(typeSelect.prop('value')).toEqual(patient.type) + expect(typeSelect.prop('defaultSelected')[0].value).toEqual(patient.type) expect(typeSelect.prop('label')).toEqual('patient.type') expect(typeSelect.prop('isEditable')).toBeFalsy() expect(typeSelect.prop('options')).toHaveLength(2) @@ -268,8 +268,6 @@ describe('General Information, isEditable', () => { const expectedGivenName = 'expectedGivenName' const expectedFamilyName = 'expectedFamilyName' const expectedSuffix = 'expectedSuffix' - const expectedSex = 'unknown' - const expectedType = 'private' const expectedDateOfBirth = '1937-06-14T05:00:00.000Z' const expectedOccupation = 'expectedOccupation' const expectedPreferredLanguage = 'expectedPreferredLanguage' @@ -349,7 +347,7 @@ describe('General Information, isEditable', () => { it('should render the sex select', () => { const sexSelect = wrapper.findWhere((w: any) => w.prop('name') === 'sex') - expect(sexSelect.prop('value')).toEqual(patient.sex) + expect(sexSelect.prop('defaultSelected')[0].value).toEqual(patient.sex) expect(sexSelect.prop('label')).toEqual('patient.sex') expect(sexSelect.prop('isEditable')).toBeTruthy() expect(sexSelect.prop('options')).toHaveLength(4) @@ -362,19 +360,12 @@ describe('General Information, isEditable', () => { expect(sexSelect.prop('options')[2].value).toEqual('other') expect(sexSelect.prop('options')[3].label).toEqual('sex.unknown') expect(sexSelect.prop('options')[3].value).toEqual('unknown') - - const select = sexSelect.find('select') - select.getDOMNode().value = expectedSex - select.simulate('change') - - expect(onFieldChange).toHaveBeenCalledTimes(1) - expect(onFieldChange).toHaveBeenCalledWith({ ...patient, sex: expectedSex }) }) it('should render the patient type select', () => { const typeSelect = wrapper.findWhere((w: any) => w.prop('name') === 'type') - expect(typeSelect.prop('value')).toEqual(patient.type) + expect(typeSelect.prop('defaultSelected')[0].value).toEqual(patient.type) expect(typeSelect.prop('label')).toEqual('patient.type') expect(typeSelect.prop('isEditable')).toBeTruthy() @@ -383,13 +374,6 @@ describe('General Information, isEditable', () => { expect(typeSelect.prop('options')[0].value).toEqual('charity') expect(typeSelect.prop('options')[1].label).toEqual('patient.types.private') expect(typeSelect.prop('options')[1].value).toEqual('private') - - const select = typeSelect.find('select') - select.getDOMNode().value = expectedType - select.simulate('change') - - expect(onFieldChange).toHaveBeenCalledTimes(1) - expect(onFieldChange).toHaveBeenCalledWith({ ...patient, type: expectedType }) }) it('should render the date of the birth of the patient', () => { diff --git a/src/__tests__/patients/care-plans/CarePlanForm.test.tsx b/src/__tests__/patients/care-plans/CarePlanForm.test.tsx index d5441b4a36..c7bcbd6366 100644 --- a/src/__tests__/patients/care-plans/CarePlanForm.test.tsx +++ b/src/__tests__/patients/care-plans/CarePlanForm.test.tsx @@ -98,7 +98,7 @@ describe('Care Plan Form', () => { expect(conditionSelector).toHaveLength(1) expect(conditionSelector.prop('patient.carePlan.condition')) expect(conditionSelector.prop('isRequired')).toBeTruthy() - expect(conditionSelector.prop('value')).toEqual(carePlan.diagnosisId) + expect(conditionSelector.prop('defaultSelected')[0].value).toEqual(carePlan.diagnosisId) expect(conditionSelector.prop('options')).toEqual([ { value: diagnosis.id, label: diagnosis.name }, ]) @@ -110,7 +110,7 @@ describe('Care Plan Form', () => { act(() => { const conditionSelector = wrapper.findWhere((w) => w.prop('name') === 'condition') const onChange = conditionSelector.prop('onChange') as any - onChange({ currentTarget: { value: expectedNewCondition } }) + onChange([expectedNewCondition]) }) expect(onCarePlanChangeSpy).toHaveBeenCalledWith({ diagnosisId: expectedNewCondition }) @@ -124,7 +124,7 @@ describe('Care Plan Form', () => { expect(statusSelector).toHaveLength(1) expect(statusSelector.prop('patient.carePlan.status')) expect(statusSelector.prop('isRequired')).toBeTruthy() - expect(statusSelector.prop('value')).toEqual(carePlan.status) + expect(statusSelector.prop('defaultSelected')[0].value).toEqual(carePlan.status) expect(statusSelector.prop('options')).toEqual( Object.values(CarePlanStatus).map((v) => ({ label: v, value: v })), ) @@ -136,7 +136,7 @@ describe('Care Plan Form', () => { act(() => { const statusSelector = wrapper.findWhere((w) => w.prop('name') === 'status') const onChange = statusSelector.prop('onChange') as any - onChange({ currentTarget: { value: expectedNewStatus } }) + onChange([expectedNewStatus]) }) expect(onCarePlanChangeSpy).toHaveBeenCalledWith({ status: expectedNewStatus }) @@ -150,7 +150,7 @@ describe('Care Plan Form', () => { expect(intentSelector).toHaveLength(1) expect(intentSelector.prop('patient.carePlan.intent')) expect(intentSelector.prop('isRequired')).toBeTruthy() - expect(intentSelector.prop('value')).toEqual(carePlan.intent) + expect(intentSelector.prop('defaultSelected')[0].value).toEqual(carePlan.intent) expect(intentSelector.prop('options')).toEqual( Object.values(CarePlanIntent).map((v) => ({ label: v, value: v })), ) @@ -162,7 +162,7 @@ describe('Care Plan Form', () => { act(() => { const intentSelector = wrapper.findWhere((w) => w.prop('name') === 'intent') const onChange = intentSelector.prop('onChange') as any - onChange({ currentTarget: { value: newIntent } }) + onChange([newIntent]) }) expect(onCarePlanChangeSpy).toHaveBeenCalledWith({ intent: newIntent }) @@ -298,13 +298,13 @@ describe('Care Plan Form', () => { expect(descriptionInput.prop('feedback')).toEqual(expectedError.description) expect(conditionSelector.prop('isInvalid')).toBeTruthy() - expect(conditionSelector.prop('feedback')).toEqual(expectedError.condition) + // expect(conditionSelector.prop('feedback')).toEqual(expectedError.condition) expect(statusSelector.prop('isInvalid')).toBeTruthy() - expect(statusSelector.prop('feedback')).toEqual(expectedError.status) + // expect(statusSelector.prop('feedback')).toEqual(expectedError.status) expect(intentSelector.prop('isInvalid')).toBeTruthy() - expect(intentSelector.prop('feedback')).toEqual(expectedError.intent) + // expect(intentSelector.prop('feedback')).toEqual(expectedError.intent) expect(startDatePicker.prop('isInvalid')).toBeTruthy() expect(startDatePicker.prop('feedback')).toEqual(expectedError.startDate) diff --git a/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx b/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx index 03564619b1..f7bf50d98d 100644 --- a/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx +++ b/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx @@ -112,7 +112,7 @@ describe('AppointmentDetailForm', () => { expect(typeSelect.prop('options')[3].value).toEqual('routine') expect(typeSelect.prop('options')[4].label).toEqual('scheduling.appointment.types.walkIn') expect(typeSelect.prop('options')[4].value).toEqual('walk in') - expect(typeSelect.prop('value')).toEqual(expectedAppointment.type) + expect(typeSelect.prop('defaultSelected')[0].value).toEqual(expectedAppointment.type) }) it('should render a reason text field input', () => { @@ -263,18 +263,6 @@ describe('AppointmentDetailForm', () => { expect(onFieldChange).toHaveBeenLastCalledWith('location', expectedLocation) }) - it('should call onFieldChange when type changes', () => { - const expectedType = 'follow up' - - act(() => { - const typeSelect = wrapper.findWhere((w) => w.prop('name') === 'type') - typeSelect.prop('onChange')({ target: { value: expectedType } }) - }) - wrapper.update() - - expect(onFieldChange).toHaveBeenLastCalledWith('type', expectedType) - }) - it('should call onFieldChange when reason changes', () => { const expectedReason = 'reason' From 1cf657516e1249373c3e44247700d435473c7d59 Mon Sep 17 00:00:00 2001 From: kumikokashii Date: Tue, 23 Jun 2020 19:10:14 -0700 Subject: [PATCH 54/83] feat(navbar): add hamberger icon for mobile, and dividers --- src/components/Navbar.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 62ddca4548..86cb9a67bc 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -18,6 +18,14 @@ const Navbar = () => { history.push(location) } + const dividerAboveLabels = [ + 'patients.newPatient', + 'scheduling.appointments.new', + 'labs.requests.new', + 'incidents.reports.new', + 'settings.label', + ] + function getDropdownListOfPages(pages: Page[]) { return pages .filter((page) => !page.permission || permissions.includes(page.permission)) @@ -27,6 +35,7 @@ const Navbar = () => { onClick: () => { navigateTo(page.path) }, + dividerAbove: dividerAboveLabels.indexOf(page.label) > -1, })) } @@ -42,9 +51,11 @@ const Navbar = () => { variant="dark" navItems={[ { + name: 'menu', + size: 'lg', + type: 'link-list-icon', children: getDropdownListOfPages(hambergerPages), label: '', - type: 'link-list', className: 'nav-hamberger pr-4 d-md-none', }, { From 2f22386820d45e1b6f32667aec5731fc69c6216d Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Wed, 24 Jun 2020 09:17:19 +0200 Subject: [PATCH 55/83] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6926cd5e25..b38a891142 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "private": false, "license": "MIT", "dependencies": { - "@hospitalrun/components": "~1.14.1", + "@hospitalrun/components": "~1.14.2", "@reduxjs/toolkit": "~1.4.0", "@types/escape-string-regexp": "~2.0.1", "@types/pouchdb-find": "~6.3.4", From 2f260f491c73d4495378b6a7e1a2cfc1b896422a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 24 Jun 2020 17:52:31 +0000 Subject: [PATCH 56/83] build(deps-dev): bump @types/validator from 13.0.0 to 13.1.0 Bumps [@types/validator](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/validator) from 13.0.0 to 13.1.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/validator) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b38a891142..618c5e9540 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@types/redux-mock-store": "~1.0.1", "@types/shortid": "^0.0.29", "@types/uuid": "^8.0.0", - "@types/validator": "~13.0.0", + "@types/validator": "~13.1.0", "@typescript-eslint/eslint-plugin": "~3.4.0", "@typescript-eslint/parser": "~3.4.0", "chalk": "^4.0.0", From e618dcdcffd3ac660791ebe262f046191bdeb10c Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Wed, 24 Jun 2020 21:59:05 -0500 Subject: [PATCH 57/83] chore(lint): turn off @typescript-eslint/explicit-module-boundary-types --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index ef1ede40e0..9efd20b86f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -43,6 +43,7 @@ module.exports = { 'prettier/prettier': 'error', '@typescript-eslint/member-delimiter-style': 'off', '@typescript-eslint/explicit-function-return-type': 'off', + "@typescript-eslint/explicit-module-boundary-types": 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }], '@typescript-eslint/unified-signatures': 'error', From eb4dfa466fb081f1e045f442adde3f1b8637e6c3 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Thu, 25 Jun 2020 08:18:16 +0200 Subject: [PATCH 58/83] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c84f4a9782..80a963b6d1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,3 @@ -## Don't open the PR until it is ready for review. - Fixes #[replace brackets with the issue number that your pull request addresses]. **Changes proposed in this pull request:** From b5dba17ae1d37f1affdc7f0a3f2b824520bff367 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2020 12:46:56 +0000 Subject: [PATCH 59/83] build(deps): bump react-bootstrap-typeahead from 5.0.0 to 5.1.0 Bumps [react-bootstrap-typeahead](https://github.com/ericgio/react-bootstrap-typeahead) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/ericgio/react-bootstrap-typeahead/releases) - [Changelog](https://github.com/ericgio/react-bootstrap-typeahead/blob/master/CHANGELOG.md) - [Commits](https://github.com/ericgio/react-bootstrap-typeahead/compare/v5.0.0...v5.1.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 618c5e9540..d890a9fde3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "pouchdb-quick-search": "~1.3.0", "react": "~16.13.0", "react-bootstrap": "~1.0.0-beta.16", - "react-bootstrap-typeahead": "~5.0.0", + "react-bootstrap-typeahead": "~5.1.0", "react-dom": "~16.13.0", "react-i18next": "~11.7.0", "react-redux": "~7.2.0", From f39abd5769635f64871ffbd2287c11b9283e4f9b Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Fri, 26 Jun 2020 15:21:09 +0200 Subject: [PATCH 60/83] ci(action): remove autoupdater --- .github/workflows/pr-updater.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/pr-updater.yml diff --git a/.github/workflows/pr-updater.yml b/.github/workflows/pr-updater.yml deleted file mode 100644 index 26ebb922f6..0000000000 --- a/.github/workflows/pr-updater.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: PR update - -on: - push: - branches: - - master - -jobs: - autoupdate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: PR updater - uses: maxkomarychev/pr-updater-action@v1.0.0 - with: - token: ${{ secrets.GH_TOKEN }} From f3e9d47c2e49605125a0c48722f6ac2ddfd18a37 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Fri, 26 Jun 2020 15:22:21 +0200 Subject: [PATCH 61/83] chore(action) remove compressed size --- .github/workflows/compressed-size.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/compressed-size.yml diff --git a/.github/workflows/compressed-size.yml b/.github/workflows/compressed-size.yml deleted file mode 100644 index b3197c5cc4..0000000000 --- a/.github/workflows/compressed-size.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Compressed Size - -on: [pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - uses: preactjs/compressed-size-action@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" From c217199e9e1a27edc6710ff567f7f0338af94486 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Fri, 26 Jun 2020 16:51:52 +0200 Subject: [PATCH 62/83] chore(release): 2.0.0-alpha.4 --- CHANGELOG.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98c81376c6..9780d62c86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,67 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.0.0-alpha.4](https://github.com/HospitalRun/hospitalrun-frontend/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2020-06-26) + + +### Features + +* **navbar:** add hamberger icon for mobile, and dividers ([1cf6575](https://github.com/HospitalRun/hospitalrun-frontend/commit/1cf657516e1249373c3e44247700d435473c7d59)) +* apply select component changes ([c38004b](https://github.com/HospitalRun/hospitalrun-frontend/commit/c38004bf9285a6cc53c36150754bd659130e5998)) +* **add new script for checking missing translations:** translations ([9ca5232](https://github.com/HospitalRun/hospitalrun-frontend/commit/9ca5232632503fbefb5ffae4e4d23a10d44fc62c)), closes [#1919](https://github.com/HospitalRun/hospitalrun-frontend/issues/1919) +* **care plan:** fix internationalization ([72a5bed](https://github.com/HospitalRun/hospitalrun-frontend/commit/72a5bede7862c72eecb068c0c20141ef619a8f27)) +* **care-plan:** add care plan form and tests ([e96eb83](https://github.com/HospitalRun/hospitalrun-frontend/commit/e96eb835c37c0d4174ee8a8878286fbabda309c8)) +* **careplan:** adds ability to add a new care plan ([0aa0cf9](https://github.com/HospitalRun/hospitalrun-frontend/commit/0aa0cf93b3f9e3153592684ce05babee2e0c5379)) +* **checkmissingtranslations.ts:** add language in logs ([d20b9c7](https://github.com/HospitalRun/hospitalrun-frontend/commit/d20b9c718dcb3f72142cb3280d779d7ef74f973e)) +* **checkmissingtranslations.ts:** change type of searchingPath ([7ab8195](https://github.com/HospitalRun/hospitalrun-frontend/commit/7ab81957277eec5368d6daea5e38f003a7f03255)) +* **checkmissingtranslations.ts:** refactor ([75f9981](https://github.com/HospitalRun/hospitalrun-frontend/commit/75f998103cde809054d01b5d999dba557952bb09)) +* **checkmissintranlations.ts:** add colors to log ([ede7b2e](https://github.com/HospitalRun/hospitalrun-frontend/commit/ede7b2eca4046bc93dc47c43a73ef9007f2f1594)) +* **checkmissintranslations.ts:** run script before default ones ([5ef3f7e](https://github.com/HospitalRun/hospitalrun-frontend/commit/5ef3f7ec702331bb1bea14cd51a46e48a2a31ca2)) +* **datepicker:** add year selector dropdown ([#2060](https://github.com/HospitalRun/hospitalrun-frontend/issues/2060)) ([b159d7a](https://github.com/HospitalRun/hospitalrun-frontend/commit/b159d7ada730976583d416b0f44d38a186abe4cd)) +* **i18n:** add italian translation ([#2035](https://github.com/HospitalRun/hospitalrun-frontend/issues/2035)) ([44f15f3](https://github.com/HospitalRun/hospitalrun-frontend/commit/44f15f3a12b3a4252f70c745b37a1140c732d976)) +* **incident:** Added Report Incident button ([43cafa6](https://github.com/HospitalRun/hospitalrun-frontend/commit/43cafa6da8334bf41440588ce71a27b42b73ef9d)) +* **incidents:** add ability to view an incident ([5887859](https://github.com/HospitalRun/hospitalrun-frontend/commit/5887859542247573843fc5af980cd081f6cc6f25)) +* **incidents:** add incident related routing ([2e9e985](https://github.com/HospitalRun/hospitalrun-frontend/commit/2e9e985c877db2f095ba11fb6900fc177283d5cc)) +* **incidents:** adds ability to report incident ([4a4a682](https://github.com/HospitalRun/hospitalrun-frontend/commit/4a4a6821838982f51b94ff050ff5e614a95d8839)) +* **incidents:** adds ability to view all incidents ([f11d8e9](https://github.com/HospitalRun/hospitalrun-frontend/commit/f11d8e90fe2752eba35fa2108e188053b89e6e8f)) +* **incidents:** filter incidents ([#2087](https://github.com/HospitalRun/hospitalrun-frontend/issues/2087)) ([5309a85](https://github.com/HospitalRun/hospitalrun-frontend/commit/5309a859a4b19617f44183b1d70d0f36af6206d8)) +* **labs:** ability to filter by status on labs screen ([#2033](https://github.com/HospitalRun/hospitalrun-frontend/issues/2033)) ([2b5c789](https://github.com/HospitalRun/hospitalrun-frontend/commit/2b5c789bb6247c3fe62fad8818d7fa1a16034a5b)) +* **labs:** add lab code ([#2040](https://github.com/HospitalRun/hospitalrun-frontend/issues/2040)) ([b695ac8](https://github.com/HospitalRun/hospitalrun-frontend/commit/b695ac899ea73e7059a50ad633bea90932431ff8)) +* **navbar:** add shortcut icon to the create pages ([b1a8cdf](https://github.com/HospitalRun/hospitalrun-frontend/commit/b1a8cdf3e3288f6084592f583407ea89cebd5134)) +* **network-status:** Notify users when they're working offline ([#2109](https://github.com/HospitalRun/hospitalrun-frontend/issues/2109)) ([fa5bcb6](https://github.com/HospitalRun/hospitalrun-frontend/commit/fa5bcb6a86ae082de789aca84a938bc7f99a8ca7)) +* **newlabrequest:** add requestBy to model ([c791de3](https://github.com/HospitalRun/hospitalrun-frontend/commit/c791de39fa8c67d875f8fb1aa99baf164691b5eb)), closes [#2082](https://github.com/HospitalRun/hospitalrun-frontend/issues/2082) +* **pagecomponent:** user can change page size ([7411ad0](https://github.com/HospitalRun/hospitalrun-frontend/commit/7411ad09ee680e5a691fdd34f1ca33c452398f1b)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) +* **patient:** add input validation ([#2032](https://github.com/HospitalRun/hospitalrun-frontend/issues/2032)) ([bb02fa2](https://github.com/HospitalRun/hospitalrun-frontend/commit/bb02fa20a23eab285c88cfe6ef16d28783d24ec6)) +* **patient:** multiple contact info ([#2113](https://github.com/HospitalRun/hospitalrun-frontend/issues/2113)) ([ceb96a4](https://github.com/HospitalRun/hospitalrun-frontend/commit/ceb96a4af48d4108babb7ff4f5d3e75bf74ec1fb)) +* **settings:** add navbar dropdown and settings page ([#2096](https://github.com/HospitalRun/hospitalrun-frontend/issues/2096)) ([e5677fe](https://github.com/HospitalRun/hospitalrun-frontend/commit/e5677fe459fe07637b0c9b3a2445296a89d16ee1)) +* **viewpatient:** added labs tab to ViewPatient ([#1987](https://github.com/HospitalRun/hospitalrun-frontend/issues/1987)) ([4a1c7ed](https://github.com/HospitalRun/hospitalrun-frontend/commit/4a1c7ed4a80265e55020f8b86fbec1aedf366330)) +* **viewpatients:** add a new field 'index', paging in next direction ([d1c55e7](https://github.com/HospitalRun/hospitalrun-frontend/commit/d1c55e7ab0bdcbe9a851751a747a6fe71714dc6a)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) [#1967](https://github.com/HospitalRun/hospitalrun-frontend/issues/1967) +* **viewpatients:** add paging feature in ViewPatients component ([dff2b3e](https://github.com/HospitalRun/hospitalrun-frontend/commit/dff2b3e44ee076f8154290fe9183106d6fe3f231)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) +* **viewpatients:** add paging for search patients ([b96680f](https://github.com/HospitalRun/hospitalrun-frontend/commit/b96680fbe1329384ed6eefa9e414803c781897dd)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) +* **viewpatients:** add Tests, Fix bug ([671ad02](https://github.com/HospitalRun/hospitalrun-frontend/commit/671ad02d6992727f73c777f673a6c305fd57b1b2)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) +* **viewpatients:** enables to navigation to previous page ([52a59d3](https://github.com/HospitalRun/hospitalrun-frontend/commit/52a59d3865444d37a2c605d2799346172fec2904)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) +* **viewpatients:** refactor code as recommended ([5308f5f](https://github.com/HospitalRun/hospitalrun-frontend/commit/5308f5fc7fa358d13797dee5e6a78b724795f31b)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) +* add Sort request in ViewPatients ([c4109a4](https://github.com/HospitalRun/hospitalrun-frontend/commit/c4109a470290843b39023e656db68845930174d0)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) + + +### Bug Fixes + +* **datetime:** datetime pickers are bigger now ([#2056](https://github.com/HospitalRun/hospitalrun-frontend/issues/2056)) ([52d30a3](https://github.com/HospitalRun/hospitalrun-frontend/commit/52d30a3ec1cc27c2ee2ec8827dce331180203461)) +* **eslint:** fix pouchdb test error ([f19d276](https://github.com/HospitalRun/hospitalrun-frontend/commit/f19d276bff9fa8aaf906cf0b8f1f97dcfa362e4a)) +* **i18n:** fix build ([30bb158](https://github.com/HospitalRun/hospitalrun-frontend/commit/30bb1587125e1d208ffb68e6f8ec9d4aab09a291)) +* **incidents:** add loading during fetch phase ([#2085](https://github.com/HospitalRun/hospitalrun-frontend/issues/2085)) ([d1fb940](https://github.com/HospitalRun/hospitalrun-frontend/commit/d1fb94078494a048f9d8aae5ac1b803f429dc07e)) +* **navbar:** Make Navbar mobile-friendly ([#2118](https://github.com/HospitalRun/hospitalrun-frontend/issues/2118)) ([391271a](https://github.com/HospitalRun/hospitalrun-frontend/commit/391271a23a3cdd66f27911aafb729c4add10c171)) +* **patient:** make note not required in care plan ([#2158](https://github.com/HospitalRun/hospitalrun-frontend/issues/2158)) ([34e6041](https://github.com/HospitalRun/hospitalrun-frontend/commit/34e6041cd051aa8ce98bdf359cc6874da1244096)) +* **sidebar:** sidebar should only show links user has access to see ([66feda1](https://github.com/HospitalRun/hospitalrun-frontend/commit/66feda1eefba9f663598f4f1d8f3f0484dfe38eb)), closes [#2110](https://github.com/HospitalRun/hospitalrun-frontend/issues/2110) +* **sidebar:** sidebar should only show links user has access to see ([2f22ebd](https://github.com/HospitalRun/hospitalrun-frontend/commit/2f22ebdab707028d17a1417a995aa57b40422ad3)), closes [#2110](https://github.com/HospitalRun/hospitalrun-frontend/issues/2110) +* **toolchain:** extends scripts tsconfig.json from base one ([6532028](https://github.com/HospitalRun/hospitalrun-frontend/commit/653202870b4eafad6f960136b63ef76639ca005c)), closes [#2113](https://github.com/HospitalRun/hospitalrun-frontend/issues/2113) +* **toolchain:** fix broken deps and updates translate-check script ([d0c35db](https://github.com/HospitalRun/hospitalrun-frontend/commit/d0c35db60aef95d0892fe7650960635eeda25df8)) +* standardize mock store setup in tests ([#2075](https://github.com/HospitalRun/hospitalrun-frontend/issues/2075)) ([50f9e49](https://github.com/HospitalRun/hospitalrun-frontend/commit/50f9e49ec1edc3bfdb8c2bbaed98bb8ceeb27f92)) +* standardized react router imports in tests and source code ([#2067](https://github.com/HospitalRun/hospitalrun-frontend/issues/2067)) ([cb3cea5](https://github.com/HospitalRun/hospitalrun-frontend/commit/cb3cea5d6e1c3c568ecd6536c55d8aa5e6d6e62d)) +* styling the Navbar to make it Sticky ([#2057](https://github.com/HospitalRun/hospitalrun-frontend/issues/2057)) ([11e4de8](https://github.com/HospitalRun/hospitalrun-frontend/commit/11e4de80fc2d36d5fdeacdf24466db14de10eb30)) +* **viewpatients:** call PatientRepository.findAll() only once ([#2044](https://github.com/HospitalRun/hospitalrun-frontend/issues/2044)) ([9084411](https://github.com/HospitalRun/hospitalrun-frontend/commit/9084411bc459abfd5e7003460ff2f1574cbbc243)) +* **viewpatients.tsx:** add userPageRequest in dependency array ([11b6c8b](https://github.com/HospitalRun/hospitalrun-frontend/commit/11b6c8be0ee643bea6c33250c8adb36b8dafbf8f)), closes [#1969](https://github.com/HospitalRun/hospitalrun-frontend/issues/1969) + ## [2.0.0-alpha.3](https://github.com/HospitalRun/hospitalrun-frontend/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2020-05-02) diff --git a/package.json b/package.json index d890a9fde3..42586c102a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hospitalrun/frontend", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "React frontend for HospitalRun", "private": false, "license": "MIT", From 4cc418c14eecd7575f78039bb93dec44789eb55c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 27 Jun 2020 06:58:29 +0000 Subject: [PATCH 63/83] build(deps-dev): bump eslint-plugin-import from 2.21.2 to 2.22.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.21.2 to 2.22.0. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.21.2...v2.22.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42586c102a..c339edb154 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "eslint-config-airbnb": "~18.2.0", "eslint-config-prettier": "~6.11.0", "eslint-import-resolver-typescript": "~2.0.0", - "eslint-plugin-import": "~2.21.1", + "eslint-plugin-import": "~2.22.0", "eslint-plugin-jest": "~23.17.1", "eslint-plugin-jsx-a11y": "~6.3.0", "eslint-plugin-prettier": "~3.1.2", From c1ffd82f64eb44400d82815102b2efdbca19b433 Mon Sep 17 00:00:00 2001 From: Nischay Venkatram Date: Sat, 27 Jun 2020 15:59:31 -0500 Subject: [PATCH 64/83] fix(patient): add DOB to add related person search Co-authored-by: Matteo Vivona --- .../related-persons/AddRelatedPersonModal.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/patients/related-persons/AddRelatedPersonModal.tsx b/src/patients/related-persons/AddRelatedPersonModal.tsx index 3c1ccf906a..d5c844d58e 100644 --- a/src/patients/related-persons/AddRelatedPersonModal.tsx +++ b/src/patients/related-persons/AddRelatedPersonModal.tsx @@ -1,4 +1,5 @@ import { Modal, Alert, Typeahead, Label } from '@hospitalrun/components' +import format from 'date-fns/format' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' @@ -42,6 +43,11 @@ const AddRelatedPersonModal = (props: Props) => { setRelatedPerson({ ...relatedPerson, patientId: p[0].id }) } + const onSearch = async (query: string) => { + const patients: Patient[] = await PatientRepository.search(query) + return patients.filter((p: Patient) => p.id !== patient.id) + } + const body = ( {relatedPersonError?.message && ( @@ -57,14 +63,12 @@ const AddRelatedPersonModal = (props: Props) => { placeholder={t('patient.relatedPerson')} onChange={onPatientSelect} isInvalid={!!relatedPersonError?.relatedPerson} - onSearch={async (query: string) => PatientRepository.search(query)} - renderMenuItemChildren={(p: Patient) => { - if (patient.id === p.id) { - return
- } - - return
{`${p.fullName} (${p.code})`}
- }} + onSearch={onSearch} + renderMenuItemChildren={(p: Patient) => ( +
+ {`${p.fullName} - ${format(new Date(p.dateOfBirth), 'yyyy-MM-dd')} (${p.code})`} +
+ )} /> {relatedPersonError?.relatedPerson && (
From ef15ed391b86359d67e2706fbf86323c8de90a05 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sat, 27 Jun 2020 17:36:40 -0500 Subject: [PATCH 65/83] chore: better folder structure and cleanup mocks (#2180) --- .eslintrc.js | 2 +- check-translations/tsconfig.json | 13 ------ package.json | 8 ++-- {check-translations => scripts}/.eslintrc.js | 0 .../check-translations}/index.ts | 2 +- scripts/tsconfig.json | 2 +- src/App.tsx | 2 +- src/HospitalRun.tsx | 14 +++--- src/__tests__/App.test.tsx | 2 - src/__tests__/HospitalRun.test.tsx | 10 ++-- src/__tests__/incidents/Incidents.test.tsx | 10 ++-- .../incidents/incident-slice.test.ts | 10 ++-- .../incidents/incidents-slice.test.ts | 6 +-- .../incidents/list/ViewIncidents.test.tsx | 16 +++---- .../incidents/report/ReportIncident.test.tsx | 16 +++---- .../incidents/view/ViewIncident.test.tsx | 16 +++---- src/__tests__/labs/Labs.test.tsx | 14 +++--- src/__tests__/labs/ViewLab.test.tsx | 20 ++++---- src/__tests__/labs/ViewLabs.test.tsx | 14 +++--- src/__tests__/labs/lab-slice.test.ts | 10 ++-- src/__tests__/labs/labs.slice.test.ts | 6 +-- .../labs/requests/NewLabRequest.test.tsx | 18 ++++--- .../breadcrumbs/Breadcrumbs.test.tsx | 7 ++- .../breadcrumbs/breadcrumbs-slice.test.ts | 7 +-- .../breadcrumbs/useAddBreadcrumbs.test.tsx | 6 +-- .../ButtonBarProvider.test.tsx | 4 +- .../ButtonToolBar.test.tsx | 6 +-- .../{ => title}/title-slice.test.ts | 2 +- .../page-header/{ => title}/useTitle.test.tsx | 6 +-- src/__tests__/patients/ContactInfo.test.tsx | 7 ++- .../patients/GeneralInformation.test.tsx | 44 +++++++++--------- src/__tests__/patients/Patients.test.tsx | 12 ++--- .../patients/allergies/Allergies.test.tsx | 12 ++--- .../allergies/NewAllergyModal.test.tsx | 10 ++-- .../appointments/AppointmentsList.test.tsx | 10 ++-- .../care-plans/AddCarePlanModal.test.tsx | 9 ++-- .../patients/care-plans/CarePlanForm.test.tsx | 7 ++- .../patients/care-plans/CarePlanTab.test.tsx | 5 +- .../care-plans/CarePlanTable.test.tsx | 7 ++- .../patients/care-plans/ViewCarePlan.test.tsx | 5 +- .../diagnoses/AddDiagnosisModal.test.tsx | 14 +++--- .../patients/diagnoses/Diagnoses.test.tsx | 12 ++--- .../patients/edit/EditPatient.test.tsx | 16 +++---- src/__tests__/patients/labs/LabsTab.test.tsx | 11 ++--- .../patients/list/ViewPatients.test.tsx | 8 ++-- .../patients/new/NewPatient.test.tsx | 10 ++-- .../patients/notes/NewNoteModal.test.tsx | 10 ++-- .../patients/notes/NotesTab.test.tsx | 12 ++--- src/__tests__/patients/patient-slice.test.ts | 18 ++++--- src/__tests__/patients/patients-slice.test.ts | 6 +-- .../AddRelatedPersonModal.test.tsx | 10 ++-- .../related-persons/RelatedPersons.test.tsx | 12 ++--- .../patients/util/patient-name-util.test.ts | 2 +- .../patients/view/ViewPatient.test.tsx | 14 +++--- .../AppointmentDetailForm.test.tsx | 8 ++-- .../appointments/Appointments.test.tsx | 16 +++---- .../appointments/ViewAppointments.test.tsx | 16 +++---- .../appointments/appointment-slice.test.ts | 10 ++-- .../appointments/appointments-slice.test.ts | 4 +- .../edit/EditAppointment.test.tsx | 14 +++--- .../appointments/new/NewAppointment.test.tsx | 16 +++---- .../util/scheduling-appointment.util.test.ts | 2 +- .../view/ViewAppointment.test.tsx | 18 ++++--- src/__tests__/settings/Settings.test.tsx | 6 +-- .../{ => shared}/components/Sidebar.test.tsx | 8 ++-- .../DatePickerWithLabelFormGroup.test.tsx | 4 +- .../DateTimePickerWithLabelFormGroup.test.tsx | 4 +- .../input/SelectWithLabelFormGroup.test.tsx | 4 +- .../TestInputWithLabelFormGroup.test.tsx | 4 +- .../TextFieldWithLabelFormGroup.test.tsx | 4 +- .../components/navbar}/Navbar.test.tsx | 8 ++-- .../NetworkStatusMessage.test.tsx | 8 ++-- .../db/AppointmentRepository.test.ts | 6 +-- .../db/LabRepository.test.ts | 8 ++-- .../db/PatientRepository.test.ts | 6 +-- .../hooks/useDebounce.test.ts} | 2 +- .../hooks/useUpdateEffect.test.ts | 2 +- .../{ => shared}/utils/generateCode.test.ts | 2 +- src/__tests__/user/user-slice.test.ts | 6 +-- src/dashboard/Dashboard.tsx | 2 +- src/incidents/Incidents.tsx | 8 ++-- src/incidents/incident-slice.ts | 6 +-- src/incidents/incidents-slice.ts | 6 +-- src/incidents/list/ViewIncidents.tsx | 12 +++-- src/incidents/report/ReportIncident.tsx | 14 +++--- src/incidents/view/ViewIncident.tsx | 10 ++-- src/index.tsx | 2 +- src/labs/Labs.tsx | 8 ++-- src/labs/ViewLab.tsx | 14 +++--- src/labs/ViewLabs.tsx | 18 +++---- src/labs/lab-slice.ts | 10 ++-- src/labs/labs-slice.ts | 8 ++-- src/labs/requests/NewLabRequest.tsx | 16 +++---- src/login/Login.tsx | 8 ++-- .../breadcrumbs/Breadcrumbs.tsx | 2 +- .../breadcrumbs/breadcrumbs-slice.ts | 2 +- .../breadcrumbs/useAddBreadcrumbs.ts | 2 +- .../ButtonBarProvider.tsx | 0 .../{ => button-toolbar}/ButtonToolBar.tsx | 0 src/page-header/{ => title}/title-slice.ts | 2 +- src/page-header/{ => title}/useTitle.tsx | 0 src/patients/ContactInfo.tsx | 12 +++-- src/patients/GeneralInformation.tsx | 12 +++-- src/patients/Patients.tsx | 6 +-- src/patients/allergies/Allergies.tsx | 10 ++-- src/patients/allergies/NewAllergyModal.tsx | 6 +-- .../appointments/AppointmentsList.tsx | 4 +- src/patients/care-plans/AddCarePlanModal.tsx | 4 +- src/patients/care-plans/CarePlanForm.tsx | 14 +++--- src/patients/care-plans/CarePlanTab.tsx | 4 +- src/patients/care-plans/CarePlanTable.tsx | 4 +- src/patients/care-plans/ViewCarePlan.tsx | 4 +- src/patients/diagnoses/AddDiagnosisModal.tsx | 8 ++-- src/patients/diagnoses/Diagnoses.tsx | 10 ++-- src/patients/edit/EditPatient.tsx | 8 ++-- src/patients/labs/LabsTab.tsx | 4 +- src/patients/list/ViewPatients.tsx | 14 +++--- src/patients/new/NewPatient.tsx | 8 ++-- src/patients/notes/NewNoteModal.tsx | 6 +-- src/patients/notes/NoteTab.tsx | 8 ++-- src/patients/patient-slice.ts | 18 +++---- src/patients/patients-slice.ts | 8 ++-- .../related-persons/AddRelatedPersonModal.tsx | 10 ++-- .../related-persons/RelatedPersonTab.tsx | 10 ++-- src/patients/util/patient-name-util.ts | 2 +- src/patients/util/set-patient-helper.ts | 2 +- src/patients/view/ViewPatient.tsx | 12 ++--- .../appointments/AppointmentDetailForm.tsx | 16 ++++--- src/scheduling/appointments/Appointments.tsx | 6 +-- .../appointments/ViewAppointments.tsx | 10 ++-- .../appointments/appointment-slice.ts | 10 ++-- .../appointments/appointments-slice.ts | 8 ++-- .../appointments/edit/EditAppointment.tsx | 8 ++-- .../appointments/new/NewAppointment.tsx | 8 ++-- .../util/scheduling-appointment.util.ts | 2 +- .../appointments/view/ViewAppointment.tsx | 10 ++-- src/settings/Settings.tsx | 4 +- src/setupTests.js | 4 ++ src/{ => shared}/components/PageComponent.tsx | 0 src/{ => shared}/components/PrivateRoute.tsx | 0 src/{ => shared}/components/Sidebar.tsx | 0 .../components/component-slice.ts | 0 .../input/DatePickerWithLabelFormGroup.tsx | 0 .../DateTimePickerWithLabelFormGroup.tsx | 0 .../components/input/LanguageSelector.tsx | 2 +- .../input/SelectWithLableFormGroup.tsx | 0 .../input/TextFieldWithLabelFormGroup.tsx | 0 .../input/TextInputWithLabelFormGroup.tsx | 0 .../components/navbar}/Navbar.tsx | 6 +-- .../components/navbar}/pageMap.tsx | 2 +- .../network-status/NetworkStatusMessage.tsx | 0 .../components/network-status/index.ts | 0 .../components/network-status/types.ts | 0 .../network-status/useNetworkStatus.ts | 0 src/{ => shared/config}/i18n.ts | 2 +- src/{ => shared}/config/pouchdb.ts | 0 .../db/AppointmentRepository.ts | 4 +- .../db/IncidentRepository.ts | 4 +- src/{clients => shared}/db/LabRepository.ts | 6 +-- src/{clients => shared/db}/Page.ts | 2 +- src/{clients => shared}/db/PageRequest.ts | 0 .../db/PatientRepository.ts | 10 ++-- src/{clients => shared}/db/Repository.ts | 4 +- src/{clients => shared}/db/Search.ts | 0 src/{clients => shared/db}/Sort.ts | 0 src/{clients => shared}/db/SortRequest.ts | 2 +- .../hooks/useDebounce.ts} | 0 src/{ => shared}/hooks/useUpdateEffect.ts | 0 src/{ => shared}/locales/README.md | 0 .../locales/ar/translations/actions/index.ts | 0 .../ar/translations/dashboard/index.ts | 0 .../locales/ar/translations/index.ts | 0 .../locales/ar/translations/labs/index.ts | 0 .../locales/ar/translations/patient/index.ts | 0 .../locales/ar/translations/patients/index.ts | 0 .../locales/ar/translations/settings/index.ts | 0 .../locales/de/translations/actions/index.ts | 0 .../de/translations/dashboard/index.ts | 0 .../de/translations/incidents/index.ts | 0 .../locales/de/translations/index.ts | 0 .../locales/de/translations/labs/index.ts | 0 .../locales/de/translations/patient/index.ts | 0 .../locales/de/translations/patients/index.ts | 0 .../de/translations/scheduling/index.ts | 0 .../locales/de/translations/settings/index.ts | 0 .../locales/de/translations/sex/index.ts | 0 .../locales/de/translations/states/index.ts | 0 .../enUs/translations/actions/index.ts | 0 .../enUs/translations/dashboard/index.ts | 0 .../enUs/translations/incidents/index.ts | 0 .../locales/enUs/translations/index.ts | 0 .../locales/enUs/translations/labs/index.ts | 0 .../enUs/translations/network-status/index.ts | 0 .../enUs/translations/patient/index.ts | 0 .../enUs/translations/patients/index.ts | 0 .../enUs/translations/scheduling/index.ts | 0 .../enUs/translations/settings/index.ts | 0 .../locales/enUs/translations/sex/index.ts | 0 .../locales/enUs/translations/states/index.ts | 0 .../locales/es/translations/actions/index.ts | 0 .../es/translations/dashboard/index.ts | 0 .../locales/es/translations/index.ts | 0 .../locales/es/translations/labs/index.ts | 0 .../locales/es/translations/patient/index.ts | 0 .../locales/es/translations/patients/index.ts | 0 .../locales/es/translations/settings/index.ts | 0 .../locales/fr/translations/actions/index.ts | 0 .../fr/translations/dashboard/index.ts | 0 .../locales/fr/translations/index.ts | 0 .../locales/fr/translations/labs/index.ts | 0 .../locales/fr/translations/patient/index.ts | 0 .../locales/fr/translations/patients/index.ts | 0 .../fr/translations/scheduling/index.ts | 0 .../locales/fr/translations/settings/index.ts | 0 .../locales/fr/translations/sex/index.ts | 0 .../locales/fr/translations/states/index.ts | 0 .../locales/id/translations/actions/index.ts | 0 .../id/translations/dashboard/index.ts | 0 .../locales/id/translations/index.ts | 0 .../locales/id/translations/labs/index.ts | 0 .../locales/id/translations/patient/index.ts | 0 .../locales/id/translations/patients/index.ts | 0 .../locales/id/translations/settings/index.ts | 0 src/{ => shared}/locales/index.ts | 0 .../locales/it/translations/actions/index.ts | 0 .../it/translations/dashboard/index.ts | 0 .../locales/it/translations/index.ts | 0 .../locales/it/translations/labs/index.ts | 0 .../locales/it/translations/patient/index.ts | 0 .../locales/it/translations/patients/index.ts | 0 .../it/translations/scheduling/index.ts | 0 .../locales/it/translations/settings/index.ts | 0 .../locales/it/translations/sex/index.ts | 0 .../locales/it/translations/states/index.ts | 0 .../locales/ja/translations/actions/index.ts | 0 .../ja/translations/dashboard/index.ts | 0 .../locales/ja/translations/index.ts | 0 .../locales/ja/translations/labs/index.ts | 0 .../locales/ja/translations/patient/index.ts | 0 .../locales/ja/translations/patients/index.ts | 0 .../locales/ja/translations/settings/index.ts | 0 .../ptBr/translations/actions/index.ts | 0 .../ptBr/translations/dashboard/index.ts | 0 .../locales/ptBr/translations/index.ts | 0 .../locales/ptBr/translations/labs/index.ts | 0 .../ptBr/translations/patient/index.ts | 0 .../ptBr/translations/patients/index.ts | 0 .../ptBr/translations/scheduling/index.ts | 0 .../ptBr/translations/settings/index.ts | 0 .../locales/ptBr/translations/sex/index.ts | 0 .../locales/ptBr/translations/states/index.ts | 0 .../locales/ru/translations/actions/index.ts | 0 .../ru/translations/dashboard/index.ts | 0 .../locales/ru/translations/index.ts | 0 .../locales/ru/translations/labs/index.ts | 0 .../locales/ru/translations/patient/index.ts | 0 .../locales/ru/translations/patients/index.ts | 0 .../locales/ru/translations/settings/index.ts | 0 .../zhCN/translations/actions/index.ts | 0 .../zhCN/translations/dashboard/index.ts | 0 .../locales/zhCN/translations/index.ts | 0 .../locales/zhCN/translations/labs/index.ts | 0 .../zhCN/translations/patient/index.ts | 0 .../zhCN/translations/patients/index.ts | 0 .../zhCN/translations/settings/index.ts | 0 src/{ => shared}/model/AbstractDBModel.ts | 0 src/{ => shared}/model/Allergy.ts | 0 src/{ => shared}/model/Appointment.ts | 0 src/{ => shared}/model/Breadcrumb.ts | 0 src/{ => shared}/model/CarePlan.ts | 0 src/{ => shared}/model/ContactInformation.ts | 0 src/{ => shared}/model/Diagnosis.ts | 0 src/{ => shared}/model/Incident.ts | 0 src/{ => shared}/model/Lab.ts | 0 src/{ => shared}/model/Name.ts | 0 src/{ => shared}/model/Note.ts | 0 src/{ => shared}/model/Patient.ts | 0 src/{ => shared}/model/Permissions.ts | 0 src/{ => shared}/model/RelatedPerson.ts | 0 src/{ => shared}/model/User.ts | 0 .../static}/images/logo-on-transparent.png | Bin src/{ => shared}/store/index.ts | 22 ++++----- src/{ => shared}/util/generateCode.ts | 0 src/{ => shared}/util/uuid.ts | 0 src/user/user-slice.ts | 8 ++-- 285 files changed, 572 insertions(+), 664 deletions(-) delete mode 100644 check-translations/tsconfig.json rename {check-translations => scripts}/.eslintrc.js (100%) rename {check-translations => scripts/check-translations}/index.ts (97%) rename src/__tests__/{ => page-header}/breadcrumbs/Breadcrumbs.test.tsx (89%) rename src/__tests__/{ => page-header}/breadcrumbs/breadcrumbs-slice.test.ts (94%) rename src/__tests__/{ => page-header}/breadcrumbs/useAddBreadcrumbs.test.tsx (90%) rename src/__tests__/page-header/{ => button-toolbar}/ButtonBarProvider.test.tsx (90%) rename src/__tests__/page-header/{ => button-toolbar}/ButtonToolBar.test.tsx (85%) rename src/__tests__/page-header/{ => title}/title-slice.test.ts (91%) rename src/__tests__/page-header/{ => title}/useTitle.test.tsx (80%) rename src/__tests__/{ => shared}/components/Sidebar.test.tsx (98%) rename src/__tests__/{ => shared}/components/input/DatePickerWithLabelFormGroup.test.tsx (95%) rename src/__tests__/{ => shared}/components/input/DateTimePickerWithLabelFormGroup.test.tsx (94%) rename src/__tests__/{ => shared}/components/input/SelectWithLabelFormGroup.test.tsx (94%) rename src/__tests__/{ => shared}/components/input/TestInputWithLabelFormGroup.test.tsx (94%) rename src/__tests__/{ => shared}/components/input/TextFieldWithLabelFormGroup.test.tsx (95%) rename src/__tests__/{components => shared/components/navbar}/Navbar.test.tsx (97%) rename src/__tests__/{ => shared}/components/network-status/NetworkStatusMessage.test.tsx (82%) rename src/__tests__/{clients => shared}/db/AppointmentRepository.test.ts (91%) rename src/__tests__/{clients => shared}/db/LabRepository.test.ts (96%) rename src/__tests__/{clients => shared}/db/PatientRepository.test.ts (97%) rename src/__tests__/{hooks/debounce.test.ts => shared/hooks/useDebounce.test.ts} (95%) rename src/__tests__/{ => shared}/hooks/useUpdateEffect.test.ts (85%) rename src/__tests__/{ => shared}/utils/generateCode.test.ts (69%) rename src/{ => page-header}/breadcrumbs/Breadcrumbs.tsx (95%) rename src/{ => page-header}/breadcrumbs/breadcrumbs-slice.ts (94%) rename src/{ => page-header}/breadcrumbs/useAddBreadcrumbs.ts (92%) rename src/page-header/{ => button-toolbar}/ButtonBarProvider.tsx (100%) rename src/page-header/{ => button-toolbar}/ButtonToolBar.tsx (100%) rename src/page-header/{ => title}/title-slice.ts (92%) rename src/page-header/{ => title}/useTitle.tsx (100%) rename src/{ => shared}/components/PageComponent.tsx (100%) rename src/{ => shared}/components/PrivateRoute.tsx (100%) rename src/{ => shared}/components/Sidebar.tsx (100%) rename src/{ => shared}/components/component-slice.ts (100%) rename src/{ => shared}/components/input/DatePickerWithLabelFormGroup.tsx (100%) rename src/{ => shared}/components/input/DateTimePickerWithLabelFormGroup.tsx (100%) rename src/{ => shared}/components/input/LanguageSelector.tsx (94%) rename src/{ => shared}/components/input/SelectWithLableFormGroup.tsx (100%) rename src/{ => shared}/components/input/TextFieldWithLabelFormGroup.tsx (100%) rename src/{ => shared}/components/input/TextInputWithLabelFormGroup.tsx (100%) rename src/{components => shared/components/navbar}/Navbar.tsx (97%) rename src/{ => shared/components/navbar}/pageMap.tsx (96%) rename src/{ => shared}/components/network-status/NetworkStatusMessage.tsx (100%) rename src/{ => shared}/components/network-status/index.ts (100%) rename src/{ => shared}/components/network-status/types.ts (100%) rename src/{ => shared}/components/network-status/useNetworkStatus.ts (100%) rename src/{ => shared/config}/i18n.ts (95%) rename src/{ => shared}/config/pouchdb.ts (100%) rename src/{clients => shared}/db/AppointmentRepository.ts (92%) rename src/{clients => shared}/db/IncidentRepository.ts (88%) rename src/{clients => shared}/db/LabRepository.ts (90%) rename src/{clients => shared/db}/Page.ts (82%) rename src/{clients => shared}/db/PageRequest.ts (100%) rename src/{clients => shared}/db/PatientRepository.ts (85%) rename src/{clients => shared}/db/Repository.ts (98%) rename src/{clients => shared}/db/Search.ts (100%) rename src/{clients => shared/db}/Sort.ts (100%) rename src/{clients => shared}/db/SortRequest.ts (80%) rename src/{hooks/debounce.ts => shared/hooks/useDebounce.ts} (100%) rename src/{ => shared}/hooks/useUpdateEffect.ts (100%) rename src/{ => shared}/locales/README.md (100%) rename src/{ => shared}/locales/ar/translations/actions/index.ts (100%) rename src/{ => shared}/locales/ar/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/ar/translations/index.ts (100%) rename src/{ => shared}/locales/ar/translations/labs/index.ts (100%) rename src/{ => shared}/locales/ar/translations/patient/index.ts (100%) rename src/{ => shared}/locales/ar/translations/patients/index.ts (100%) rename src/{ => shared}/locales/ar/translations/settings/index.ts (100%) rename src/{ => shared}/locales/de/translations/actions/index.ts (100%) rename src/{ => shared}/locales/de/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/de/translations/incidents/index.ts (100%) rename src/{ => shared}/locales/de/translations/index.ts (100%) rename src/{ => shared}/locales/de/translations/labs/index.ts (100%) rename src/{ => shared}/locales/de/translations/patient/index.ts (100%) rename src/{ => shared}/locales/de/translations/patients/index.ts (100%) rename src/{ => shared}/locales/de/translations/scheduling/index.ts (100%) rename src/{ => shared}/locales/de/translations/settings/index.ts (100%) rename src/{ => shared}/locales/de/translations/sex/index.ts (100%) rename src/{ => shared}/locales/de/translations/states/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/actions/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/incidents/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/labs/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/network-status/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/patient/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/patients/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/scheduling/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/settings/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/sex/index.ts (100%) rename src/{ => shared}/locales/enUs/translations/states/index.ts (100%) rename src/{ => shared}/locales/es/translations/actions/index.ts (100%) rename src/{ => shared}/locales/es/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/es/translations/index.ts (100%) rename src/{ => shared}/locales/es/translations/labs/index.ts (100%) rename src/{ => shared}/locales/es/translations/patient/index.ts (100%) rename src/{ => shared}/locales/es/translations/patients/index.ts (100%) rename src/{ => shared}/locales/es/translations/settings/index.ts (100%) rename src/{ => shared}/locales/fr/translations/actions/index.ts (100%) rename src/{ => shared}/locales/fr/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/fr/translations/index.ts (100%) rename src/{ => shared}/locales/fr/translations/labs/index.ts (100%) rename src/{ => shared}/locales/fr/translations/patient/index.ts (100%) rename src/{ => shared}/locales/fr/translations/patients/index.ts (100%) rename src/{ => shared}/locales/fr/translations/scheduling/index.ts (100%) rename src/{ => shared}/locales/fr/translations/settings/index.ts (100%) rename src/{ => shared}/locales/fr/translations/sex/index.ts (100%) rename src/{ => shared}/locales/fr/translations/states/index.ts (100%) rename src/{ => shared}/locales/id/translations/actions/index.ts (100%) rename src/{ => shared}/locales/id/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/id/translations/index.ts (100%) rename src/{ => shared}/locales/id/translations/labs/index.ts (100%) rename src/{ => shared}/locales/id/translations/patient/index.ts (100%) rename src/{ => shared}/locales/id/translations/patients/index.ts (100%) rename src/{ => shared}/locales/id/translations/settings/index.ts (100%) rename src/{ => shared}/locales/index.ts (100%) rename src/{ => shared}/locales/it/translations/actions/index.ts (100%) rename src/{ => shared}/locales/it/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/it/translations/index.ts (100%) rename src/{ => shared}/locales/it/translations/labs/index.ts (100%) rename src/{ => shared}/locales/it/translations/patient/index.ts (100%) rename src/{ => shared}/locales/it/translations/patients/index.ts (100%) rename src/{ => shared}/locales/it/translations/scheduling/index.ts (100%) rename src/{ => shared}/locales/it/translations/settings/index.ts (100%) rename src/{ => shared}/locales/it/translations/sex/index.ts (100%) rename src/{ => shared}/locales/it/translations/states/index.ts (100%) rename src/{ => shared}/locales/ja/translations/actions/index.ts (100%) rename src/{ => shared}/locales/ja/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/ja/translations/index.ts (100%) rename src/{ => shared}/locales/ja/translations/labs/index.ts (100%) rename src/{ => shared}/locales/ja/translations/patient/index.ts (100%) rename src/{ => shared}/locales/ja/translations/patients/index.ts (100%) rename src/{ => shared}/locales/ja/translations/settings/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/actions/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/labs/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/patient/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/patients/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/scheduling/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/settings/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/sex/index.ts (100%) rename src/{ => shared}/locales/ptBr/translations/states/index.ts (100%) rename src/{ => shared}/locales/ru/translations/actions/index.ts (100%) rename src/{ => shared}/locales/ru/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/ru/translations/index.ts (100%) rename src/{ => shared}/locales/ru/translations/labs/index.ts (100%) rename src/{ => shared}/locales/ru/translations/patient/index.ts (100%) rename src/{ => shared}/locales/ru/translations/patients/index.ts (100%) rename src/{ => shared}/locales/ru/translations/settings/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/actions/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/dashboard/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/labs/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/patient/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/patients/index.ts (100%) rename src/{ => shared}/locales/zhCN/translations/settings/index.ts (100%) rename src/{ => shared}/model/AbstractDBModel.ts (100%) rename src/{ => shared}/model/Allergy.ts (100%) rename src/{ => shared}/model/Appointment.ts (100%) rename src/{ => shared}/model/Breadcrumb.ts (100%) rename src/{ => shared}/model/CarePlan.ts (100%) rename src/{ => shared}/model/ContactInformation.ts (100%) rename src/{ => shared}/model/Diagnosis.ts (100%) rename src/{ => shared}/model/Incident.ts (100%) rename src/{ => shared}/model/Lab.ts (100%) rename src/{ => shared}/model/Name.ts (100%) rename src/{ => shared}/model/Note.ts (100%) rename src/{ => shared}/model/Patient.ts (100%) rename src/{ => shared}/model/Permissions.ts (100%) rename src/{ => shared}/model/RelatedPerson.ts (100%) rename src/{ => shared}/model/User.ts (100%) rename src/{ => shared/static}/images/logo-on-transparent.png (100%) rename src/{ => shared}/store/index.ts (50%) rename src/{ => shared}/util/generateCode.ts (100%) rename src/{ => shared}/util/uuid.ts (100%) diff --git a/.eslintrc.js b/.eslintrc.js index 9efd20b86f..684e13342b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,7 +21,7 @@ module.exports = { }, parser: '@typescript-eslint/parser', parserOptions: { - project: ['./tsconfig.json', './check-translations/tsconfig.json'], + project: ['./tsconfig.json', './scripts/tsconfig.json'], tsconfigRootDir: './', }, settings: { diff --git a/check-translations/tsconfig.json b/check-translations/tsconfig.json deleted file mode 100644 index aa1518f5d2..0000000000 --- a/check-translations/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [ - "./index.ts" - ], - "compilerOptions": { - "module": "commonjs", - "outDir": "compiled", - "target": "es5", - "sourceMap": false, - "noEmit": false - } -} diff --git a/package.json b/package.json index c339edb154..b58c890b37 100644 --- a/package.json +++ b/package.json @@ -116,14 +116,14 @@ "prepublishOnly": "npm run build", "test": "npm run translation:check && react-scripts test --detectOpenHandles", "test:ci": "cross-env CI=true react-scripts test --passWithNoTests", - "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"check-translations/**/*.{js,ts}\"", - "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"check-translations/**/*.{js,ts}\" --fix", + "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/check-translations/**/*.{js,ts}\"", + "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"scripts/check-translations/**/*.{js,ts}\" --fix", "lint-staged": "lint-staged", "commitlint": "commitlint", "coveralls": "npm run test:ci -- --coverage --watchAll=false && cat ./coverage/lcov.info", - "remove-compiled-translations": "rimraf ./check-translations/compiled", + "remove-compiled-translations": "rimraf ./bin/scripts/check-translations", "pretranslation:check": "npm run remove-compiled-translations", - "translation:check": "tsc -p ./check-translations/tsconfig.json && node ./check-translations/compiled/check-translations/index.js", + "translation:check": "tsc -p scripts/tsconfig.json && node ./bin/scripts/check-translations/index.js", "posttranslation:check": "npm run remove-compiled-translations" }, "browserslist": { diff --git a/check-translations/.eslintrc.js b/scripts/.eslintrc.js similarity index 100% rename from check-translations/.eslintrc.js rename to scripts/.eslintrc.js diff --git a/check-translations/index.ts b/scripts/check-translations/index.ts similarity index 97% rename from check-translations/index.ts rename to scripts/check-translations/index.ts index 222131cb65..dbca8fb590 100644 --- a/check-translations/index.ts +++ b/scripts/check-translations/index.ts @@ -1,7 +1,7 @@ import chalk from 'chalk' import { ResourceKey } from 'i18next' -import resources from '../src/locales' +import resources from '../../src/shared/locales' const error = chalk.bold.red const warning = chalk.keyword('orange') diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 0b401bd5b3..55e2b73017 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["./checkMissingTranslations.ts"], + "include": ["./**/*.ts"], "compilerOptions": { "module": "commonjs", "outDir": "../bin", diff --git a/src/App.tsx b/src/App.tsx index 9d93d08033..61ffb3a15a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,7 @@ import { BrowserRouter, Route, Switch } from 'react-router-dom' import HospitalRun from './HospitalRun' import Login from './login/Login' -import store from './store' +import store from './shared/store' const App: React.FC = () => (
diff --git a/src/HospitalRun.tsx b/src/HospitalRun.tsx index cc3043f907..6e9a9b406c 100644 --- a/src/HospitalRun.tsx +++ b/src/HospitalRun.tsx @@ -3,19 +3,19 @@ import React from 'react' import { useSelector } from 'react-redux' import { Redirect, Route, Switch } from 'react-router-dom' -import Breadcrumbs from './breadcrumbs/Breadcrumbs' -import Navbar from './components/Navbar' -import { NetworkStatusMessage } from './components/network-status' -import Sidebar from './components/Sidebar' import Dashboard from './dashboard/Dashboard' import Incidents from './incidents/Incidents' import Labs from './labs/Labs' -import { ButtonBarProvider } from './page-header/ButtonBarProvider' -import ButtonToolBar from './page-header/ButtonToolBar' +import Breadcrumbs from './page-header/breadcrumbs/Breadcrumbs' +import { ButtonBarProvider } from './page-header/button-toolbar/ButtonBarProvider' +import ButtonToolBar from './page-header/button-toolbar/ButtonToolBar' import Patients from './patients/Patients' import Appointments from './scheduling/appointments/Appointments' import Settings from './settings/Settings' -import { RootState } from './store' +import Navbar from './shared/components/navbar/Navbar' +import { NetworkStatusMessage } from './shared/components/network-status' +import Sidebar from './shared/components/Sidebar' +import { RootState } from './shared/store' const HospitalRun = () => { const { title } = useSelector((state: RootState) => state.title) diff --git a/src/__tests__/App.test.tsx b/src/__tests__/App.test.tsx index 6ce7d690a6..e726884bbd 100644 --- a/src/__tests__/App.test.tsx +++ b/src/__tests__/App.test.tsx @@ -1,5 +1,3 @@ -import '../__mocks__/matchMediaMock' - import { shallow } from 'enzyme' import React from 'react' diff --git a/src/__tests__/HospitalRun.test.tsx b/src/__tests__/HospitalRun.test.tsx index 0984fce25b..ef18ef3bb2 100644 --- a/src/__tests__/HospitalRun.test.tsx +++ b/src/__tests__/HospitalRun.test.tsx @@ -1,5 +1,3 @@ -import '../__mocks__/matchMediaMock' - import { Toaster } from '@hospitalrun/components' import { mount } from 'enzyme' import React from 'react' @@ -9,16 +7,16 @@ import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { addBreadcrumbs } from '../breadcrumbs/breadcrumbs-slice' -import LabRepository from '../clients/db/LabRepository' import Dashboard from '../dashboard/Dashboard' import HospitalRun from '../HospitalRun' import Incidents from '../incidents/Incidents' import ViewLabs from '../labs/ViewLabs' -import Permissions from '../model/Permissions' +import { addBreadcrumbs } from '../page-header/breadcrumbs/breadcrumbs-slice' import Appointments from '../scheduling/appointments/Appointments' import Settings from '../settings/Settings' -import { RootState } from '../store' +import LabRepository from '../shared/db/LabRepository' +import Permissions from '../shared/model/Permissions' +import { RootState } from '../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/Incidents.test.tsx b/src/__tests__/incidents/Incidents.test.tsx index ecc4626461..7474948481 100644 --- a/src/__tests__/incidents/Incidents.test.tsx +++ b/src/__tests__/incidents/Incidents.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { act } from '@testing-library/react' import { mount } from 'enzyme' import React from 'react' @@ -8,13 +6,13 @@ import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import IncidentRepository from '../../clients/db/IncidentRepository' import Incidents from '../../incidents/Incidents' import ReportIncident from '../../incidents/report/ReportIncident' import ViewIncident from '../../incidents/view/ViewIncident' -import Incident from '../../model/Incident' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import IncidentRepository from '../../shared/db/IncidentRepository' +import Incident from '../../shared/model/Incident' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/incident-slice.test.ts b/src/__tests__/incidents/incident-slice.test.ts index 103462c9e3..416208e30e 100644 --- a/src/__tests__/incidents/incident-slice.test.ts +++ b/src/__tests__/incidents/incident-slice.test.ts @@ -4,7 +4,6 @@ import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import shortid from 'shortid' -import IncidentRepository from '../../clients/db/IncidentRepository' import incident, { reportIncidentStart, reportIncidentSuccess, @@ -14,10 +13,11 @@ import incident, { fetchIncidentSuccess, fetchIncident, } from '../../incidents/incident-slice' -import Incident from '../../model/Incident' -import Permissions from '../../model/Permissions' -import User from '../../model/User' -import { RootState } from '../../store' +import IncidentRepository from '../../shared/db/IncidentRepository' +import Incident from '../../shared/model/Incident' +import Permissions from '../../shared/model/Permissions' +import User from '../../shared/model/User' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/incidents-slice.test.ts b/src/__tests__/incidents/incidents-slice.test.ts index 47dd1b4656..031aa32f49 100644 --- a/src/__tests__/incidents/incidents-slice.test.ts +++ b/src/__tests__/incidents/incidents-slice.test.ts @@ -2,15 +2,15 @@ import { AnyAction } from 'redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import IncidentRepository from '../../clients/db/IncidentRepository' import IncidentFilter from '../../incidents/IncidentFilter' import incidents, { fetchIncidentsStart, fetchIncidentsSuccess, searchIncidents, } from '../../incidents/incidents-slice' -import Incident from '../../model/Incident' -import { RootState } from '../../store' +import IncidentRepository from '../../shared/db/IncidentRepository' +import Incident from '../../shared/model/Incident' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/list/ViewIncidents.test.tsx b/src/__tests__/incidents/list/ViewIncidents.test.tsx index aa541ca4b1..3ce82b1364 100644 --- a/src/__tests__/incidents/list/ViewIncidents.test.tsx +++ b/src/__tests__/incidents/list/ViewIncidents.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -9,15 +7,15 @@ import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' -import IncidentRepository from '../../../clients/db/IncidentRepository' import IncidentFilter from '../../../incidents/IncidentFilter' import ViewIncidents from '../../../incidents/list/ViewIncidents' -import Incident from '../../../model/Incident' -import Permissions from '../../../model/Permissions' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' -import * as titleUtil from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import * as breadcrumbUtil from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../../page-header/title/useTitle' +import IncidentRepository from '../../../shared/db/IncidentRepository' +import Incident from '../../../shared/model/Incident' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/report/ReportIncident.test.tsx b/src/__tests__/incidents/report/ReportIncident.test.tsx index 6812c7b6fe..12b8c6f4ee 100644 --- a/src/__tests__/incidents/report/ReportIncident.test.tsx +++ b/src/__tests__/incidents/report/ReportIncident.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Button } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount, ReactWrapper } from 'enzyme' @@ -10,14 +8,14 @@ import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' -import IncidentRepository from '../../../clients/db/IncidentRepository' import ReportIncident from '../../../incidents/report/ReportIncident' -import Incident from '../../../model/Incident' -import Permissions from '../../../model/Permissions' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' -import * as titleUtil from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import * as breadcrumbUtil from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../../page-header/title/useTitle' +import IncidentRepository from '../../../shared/db/IncidentRepository' +import Incident from '../../../shared/model/Incident' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/incidents/view/ViewIncident.test.tsx b/src/__tests__/incidents/view/ViewIncident.test.tsx index d8bdeae1aa..9b2d77798d 100644 --- a/src/__tests__/incidents/view/ViewIncident.test.tsx +++ b/src/__tests__/incidents/view/ViewIncident.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -9,14 +7,14 @@ import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' -import IncidentRepository from '../../../clients/db/IncidentRepository' import ViewIncident from '../../../incidents/view/ViewIncident' -import Incident from '../../../model/Incident' -import Permissions from '../../../model/Permissions' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' -import * as titleUtil from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import * as breadcrumbUtil from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../../page-header/title/useTitle' +import IncidentRepository from '../../../shared/db/IncidentRepository' +import Incident from '../../../shared/model/Incident' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/Labs.test.tsx b/src/__tests__/labs/Labs.test.tsx index 9489b30f8c..2dde1714c5 100644 --- a/src/__tests__/labs/Labs.test.tsx +++ b/src/__tests__/labs/Labs.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { act } from '@testing-library/react' import { mount } from 'enzyme' import React from 'react' @@ -8,15 +6,15 @@ import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import LabRepository from '../../clients/db/LabRepository' -import PatientRepository from '../../clients/db/PatientRepository' import Labs from '../../labs/Labs' import NewLabRequest from '../../labs/requests/NewLabRequest' import ViewLab from '../../labs/ViewLab' -import Lab from '../../model/Lab' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import LabRepository from '../../shared/db/LabRepository' +import PatientRepository from '../../shared/db/PatientRepository' +import Lab from '../../shared/model/Lab' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/ViewLab.test.tsx b/src/__tests__/labs/ViewLab.test.tsx index 59516ffbf0..a8968a897c 100644 --- a/src/__tests__/labs/ViewLab.test.tsx +++ b/src/__tests__/labs/ViewLab.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { Badge, Button, Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' import format from 'date-fns/format' @@ -11,16 +9,16 @@ import { Router, Route } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import LabRepository from '../../clients/db/LabRepository' -import PatientRepository from '../../clients/db/PatientRepository' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' import ViewLab from '../../labs/ViewLab' -import Lab from '../../model/Lab' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import * as ButtonBarProvider from '../../page-header/ButtonBarProvider' -import * as titleUtil from '../../page-header/useTitle' -import { RootState } from '../../store' +import * as ButtonBarProvider from '../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../page-header/title/useTitle' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import LabRepository from '../../shared/db/LabRepository' +import PatientRepository from '../../shared/db/PatientRepository' +import Lab from '../../shared/model/Lab' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/ViewLabs.test.tsx b/src/__tests__/labs/ViewLabs.test.tsx index 2c3eae5a1b..5220bb7244 100644 --- a/src/__tests__/labs/ViewLabs.test.tsx +++ b/src/__tests__/labs/ViewLabs.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { TextInput, Select } from '@hospitalrun/components' import { act } from '@testing-library/react' import format from 'date-fns/format' @@ -11,14 +9,14 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import LabRepository from '../../clients/db/LabRepository' import * as labsSlice from '../../labs/labs-slice' import ViewLabs from '../../labs/ViewLabs' -import Lab from '../../model/Lab' -import Permissions from '../../model/Permissions' -import * as ButtonBarProvider from '../../page-header/ButtonBarProvider' -import * as titleUtil from '../../page-header/useTitle' -import { RootState } from '../../store' +import * as ButtonBarProvider from '../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../page-header/title/useTitle' +import LabRepository from '../../shared/db/LabRepository' +import Lab from '../../shared/model/Lab' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/lab-slice.test.ts b/src/__tests__/labs/lab-slice.test.ts index 39a6342087..45449b3aea 100644 --- a/src/__tests__/labs/lab-slice.test.ts +++ b/src/__tests__/labs/lab-slice.test.ts @@ -1,8 +1,6 @@ import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import LabRepository from '../../clients/db/LabRepository' -import PatientRepository from '../../clients/db/PatientRepository' import labSlice, { requestLab, fetchLabStart, @@ -22,9 +20,11 @@ import labSlice, { requestLabError, updateLab, } from '../../labs/lab-slice' -import Lab from '../../model/Lab' -import Patient from '../../model/Patient' -import { RootState } from '../../store' +import LabRepository from '../../shared/db/LabRepository' +import PatientRepository from '../../shared/db/PatientRepository' +import Lab from '../../shared/model/Lab' +import Patient from '../../shared/model/Patient' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/labs/labs.slice.test.ts b/src/__tests__/labs/labs.slice.test.ts index d02dbca38b..5e05eb15fb 100644 --- a/src/__tests__/labs/labs.slice.test.ts +++ b/src/__tests__/labs/labs.slice.test.ts @@ -1,10 +1,10 @@ import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' -import LabRepository from '../../clients/db/LabRepository' -import SortRequest from '../../clients/db/SortRequest' import labs, { fetchLabsStart, fetchLabsSuccess, searchLabs } from '../../labs/labs-slice' -import Lab from '../../model/Lab' +import LabRepository from '../../shared/db/LabRepository' +import SortRequest from '../../shared/db/SortRequest' +import Lab from '../../shared/model/Lab' interface SearchContainer { text: string diff --git a/src/__tests__/labs/requests/NewLabRequest.test.tsx b/src/__tests__/labs/requests/NewLabRequest.test.tsx index bf06d74775..01d1392ffd 100644 --- a/src/__tests__/labs/requests/NewLabRequest.test.tsx +++ b/src/__tests__/labs/requests/NewLabRequest.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Button, Typeahead, Label, Alert } from '@hospitalrun/components' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' @@ -10,15 +8,15 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import LabRepository from '../../../clients/db/LabRepository' -import PatientRepository from '../../../clients/db/PatientRepository' -import TextFieldWithLabelFormGroup from '../../../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' import NewLabRequest from '../../../labs/requests/NewLabRequest' -import Lab from '../../../model/Lab' -import Patient from '../../../model/Patient' -import * as titleUtil from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import * as titleUtil from '../../../page-header/title/useTitle' +import TextFieldWithLabelFormGroup from '../../../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup' +import LabRepository from '../../../shared/db/LabRepository' +import PatientRepository from '../../../shared/db/PatientRepository' +import Lab from '../../../shared/model/Lab' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx b/src/__tests__/page-header/breadcrumbs/Breadcrumbs.test.tsx similarity index 89% rename from src/__tests__/breadcrumbs/Breadcrumbs.test.tsx rename to src/__tests__/page-header/breadcrumbs/Breadcrumbs.test.tsx index 664af2a3bd..397630ffc9 100644 --- a/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx +++ b/src/__tests__/page-header/breadcrumbs/Breadcrumbs.test.tsx @@ -1,4 +1,3 @@ -import '../../__mocks__/matchMediaMock' import { Breadcrumb as HRBreadcrumb, BreadcrumbItem as HRBreadcrumbItem, @@ -11,9 +10,9 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Breadcrumbs from '../../breadcrumbs/Breadcrumbs' -import Breadcrumb from '../../model/Breadcrumb' -import { RootState } from '../../store' +import Breadcrumbs from '../../../page-header/breadcrumbs/Breadcrumbs' +import Breadcrumb from '../../../shared/model/Breadcrumb' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts b/src/__tests__/page-header/breadcrumbs/breadcrumbs-slice.test.ts similarity index 94% rename from src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts rename to src/__tests__/page-header/breadcrumbs/breadcrumbs-slice.test.ts index a3b46992b1..f65dc97a8e 100644 --- a/src/__tests__/breadcrumbs/breadcrumbs-slice.test.ts +++ b/src/__tests__/page-header/breadcrumbs/breadcrumbs-slice.test.ts @@ -1,8 +1,9 @@ -import '../../__mocks__/matchMediaMock' - import { AnyAction } from 'redux' -import breadcrumbs, { addBreadcrumbs, removeBreadcrumbs } from '../../breadcrumbs/breadcrumbs-slice' +import breadcrumbs, { + addBreadcrumbs, + removeBreadcrumbs, +} from '../../../page-header/breadcrumbs/breadcrumbs-slice' describe('breadcrumbs slice', () => { describe('breadcrumbs reducer', () => { diff --git a/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx b/src/__tests__/page-header/breadcrumbs/useAddBreadcrumbs.test.tsx similarity index 90% rename from src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx rename to src/__tests__/page-header/breadcrumbs/useAddBreadcrumbs.test.tsx index f67b9fd22f..50732bc28d 100644 --- a/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx +++ b/src/__tests__/page-header/breadcrumbs/useAddBreadcrumbs.test.tsx @@ -4,9 +4,9 @@ import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import * as breadcrumbsSlice from '../../breadcrumbs/breadcrumbs-slice' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import { RootState } from '../../store' +import * as breadcrumbsSlice from '../../../page-header/breadcrumbs/breadcrumbs-slice' +import useAddBreadcrumbs from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/page-header/ButtonBarProvider.test.tsx b/src/__tests__/page-header/button-toolbar/ButtonBarProvider.test.tsx similarity index 90% rename from src/__tests__/page-header/ButtonBarProvider.test.tsx rename to src/__tests__/page-header/button-toolbar/ButtonBarProvider.test.tsx index 70e8f95713..b8310667c3 100644 --- a/src/__tests__/page-header/ButtonBarProvider.test.tsx +++ b/src/__tests__/page-header/button-toolbar/ButtonBarProvider.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { Button } from '@hospitalrun/components' import { renderHook } from '@testing-library/react-hooks' import React, { useEffect } from 'react' @@ -8,7 +6,7 @@ import { ButtonBarProvider, useButtons, useButtonToolbarSetter, -} from '../../page-header/ButtonBarProvider' +} from '../../../page-header/button-toolbar/ButtonBarProvider' describe('Button Bar Provider', () => { it('should update and fetch data from the button bar provider', () => { diff --git a/src/__tests__/page-header/ButtonToolBar.test.tsx b/src/__tests__/page-header/button-toolbar/ButtonToolBar.test.tsx similarity index 85% rename from src/__tests__/page-header/ButtonToolBar.test.tsx rename to src/__tests__/page-header/button-toolbar/ButtonToolBar.test.tsx index f5ac62fe16..e451f75c58 100644 --- a/src/__tests__/page-header/ButtonToolBar.test.tsx +++ b/src/__tests__/page-header/button-toolbar/ButtonToolBar.test.tsx @@ -1,12 +1,10 @@ -import '../../__mocks__/matchMediaMock' - import { Button } from '@hospitalrun/components' import { mount } from 'enzyme' import React from 'react' import { mocked } from 'ts-jest/utils' -import * as ButtonBarProvider from '../../page-header/ButtonBarProvider' -import ButtonToolBar from '../../page-header/ButtonToolBar' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' +import ButtonToolBar from '../../../page-header/button-toolbar/ButtonToolBar' describe('Button Tool Bar', () => { beforeEach(() => { diff --git a/src/__tests__/page-header/title-slice.test.ts b/src/__tests__/page-header/title/title-slice.test.ts similarity index 91% rename from src/__tests__/page-header/title-slice.test.ts rename to src/__tests__/page-header/title/title-slice.test.ts index 0c56a92fe3..8684ed6513 100644 --- a/src/__tests__/page-header/title-slice.test.ts +++ b/src/__tests__/page-header/title/title-slice.test.ts @@ -1,6 +1,6 @@ import { AnyAction } from 'redux' -import title, { updateTitle, changeTitle } from '../../page-header/title-slice' +import title, { updateTitle, changeTitle } from '../../../page-header/title/title-slice' describe('title slice', () => { describe('title reducer', () => { diff --git a/src/__tests__/page-header/useTitle.test.tsx b/src/__tests__/page-header/title/useTitle.test.tsx similarity index 80% rename from src/__tests__/page-header/useTitle.test.tsx rename to src/__tests__/page-header/title/useTitle.test.tsx index 1534ca2b58..8155df39c3 100644 --- a/src/__tests__/page-header/useTitle.test.tsx +++ b/src/__tests__/page-header/title/useTitle.test.tsx @@ -4,9 +4,9 @@ import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import * as titleSlice from '../../page-header/title-slice' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import * as titleSlice from '../../../page-header/title/title-slice' +import useTitle from '../../../page-header/title/useTitle' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/ContactInfo.test.tsx b/src/__tests__/patients/ContactInfo.test.tsx index 885e89f407..debfb82cdd 100644 --- a/src/__tests__/patients/ContactInfo.test.tsx +++ b/src/__tests__/patients/ContactInfo.test.tsx @@ -1,4 +1,3 @@ -import '../../__mocks__/matchMediaMock' import { Column, Spinner } from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -6,10 +5,10 @@ import React from 'react' import { act } from 'react-dom/test-utils' import { Router } from 'react-router-dom' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import { ContactInfoPiece } from '../../model/ContactInformation' import ContactInfo from '../../patients/ContactInfo' -import * as uuid from '../../util/uuid' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import { ContactInfoPiece } from '../../shared/model/ContactInformation' +import * as uuid from '../../shared/util/uuid' describe('Contact Info in its Editable mode', () => { const data = [ diff --git a/src/__tests__/patients/GeneralInformation.test.tsx b/src/__tests__/patients/GeneralInformation.test.tsx index b9ed7c5dd6..ecd1d1cc0d 100644 --- a/src/__tests__/patients/GeneralInformation.test.tsx +++ b/src/__tests__/patients/GeneralInformation.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' import { startOfDay, subYears } from 'date-fns' @@ -8,8 +6,8 @@ import { createMemoryHistory, MemoryHistory } from 'history' import React from 'react' import { Router } from 'react-router-dom' -import Patient from '../../model/Patient' import GeneralInformation from '../../patients/GeneralInformation' +import Patient from '../../shared/model/Patient' describe('Error handling', () => { it('should display errors', () => { @@ -25,8 +23,8 @@ describe('Error handling', () => { { occupation: 'occupation', preferredLanguage: 'preferredLanguage', phoneNumbers: [ - { value: '123456', type: undefined }, - { value: '789012', type: undefined }, + { value: '123456', type: undefined, id: '123' }, + { value: '789012', type: undefined, id: '456' }, ], emails: [ - { value: 'abc@email.com', type: undefined }, - { value: 'xyz@email.com', type: undefined }, + { value: 'abc@email.com', type: undefined, id: '789' }, + { value: 'xyz@email.com', type: undefined, id: '987' }, ], addresses: [ - { value: 'address A', type: undefined }, - { value: 'address B', type: undefined }, + { value: 'address A', type: undefined, id: '654' }, + { value: 'address B', type: undefined, id: '321' }, ], code: 'P00001', } as Patient @@ -238,16 +236,16 @@ describe('General Information, isEditable', () => { occupation: 'occupation', preferredLanguage: 'preferredLanguage', phoneNumbers: [ - { value: '123456', type: undefined }, - { value: '789012', type: undefined }, + { value: '123456', type: undefined, id: '123' }, + { value: '789012', type: undefined, id: '456' }, ], emails: [ - { value: 'abc@email.com', type: undefined }, - { value: 'xyz@email.com', type: undefined }, + { value: 'abc@email.com', type: undefined, id: '789' }, + { value: 'xyz@email.com', type: undefined, id: '987' }, ], addresses: [ - { value: 'address A', type: undefined }, - { value: 'address B', type: undefined }, + { value: 'address A', type: undefined, id: '654' }, + { value: 'address B', type: undefined, id: '321' }, ], code: 'P00001', } as Patient @@ -272,16 +270,16 @@ describe('General Information, isEditable', () => { const expectedOccupation = 'expectedOccupation' const expectedPreferredLanguage = 'expectedPreferredLanguage' const expectedPhoneNumbers = [ - { value: '111111', type: undefined }, - { value: '222222', type: undefined }, + { value: '111111', type: undefined, id: '123' }, + { value: '222222', type: undefined, id: '456' }, ] const expectedEmails = [ - { value: 'def@email.com', type: undefined }, - { value: 'uvw@email.com', type: undefined }, + { value: 'def@email.com', type: undefined, id: '789' }, + { value: 'uvw@email.com', type: undefined, id: '987' }, ] const expectedAddresses = [ - { value: 'address C', type: undefined }, - { value: 'address D', type: undefined }, + { value: 'address C', type: undefined, id: '654' }, + { value: 'address D', type: undefined, id: '321' }, ] it('should render the prefix', () => { diff --git a/src/__tests__/patients/Patients.test.tsx b/src/__tests__/patients/Patients.test.tsx index 60d929d74d..8214eb15bf 100644 --- a/src/__tests__/patients/Patients.test.tsx +++ b/src/__tests__/patients/Patients.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { mount } from 'enzyme' import React from 'react' import { act } from 'react-dom/test-utils' @@ -8,16 +6,16 @@ import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { addBreadcrumbs } from '../../breadcrumbs/breadcrumbs-slice' -import PatientRepository from '../../clients/db/PatientRepository' import Dashboard from '../../dashboard/Dashboard' import HospitalRun from '../../HospitalRun' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' +import { addBreadcrumbs } from '../../page-header/breadcrumbs/breadcrumbs-slice' import EditPatient from '../../patients/edit/EditPatient' import NewPatient from '../../patients/new/NewPatient' import ViewPatient from '../../patients/view/ViewPatient' -import { RootState } from '../../store' +import PatientRepository from '../../shared/db/PatientRepository' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/allergies/Allergies.test.tsx b/src/__tests__/patients/allergies/Allergies.test.tsx index 87ef0dd253..ef3fbf692f 100644 --- a/src/__tests__/patients/allergies/Allergies.test.tsx +++ b/src/__tests__/patients/allergies/Allergies.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -10,12 +8,12 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Allergy from '../../../model/Allergy' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' import Allergies from '../../../patients/allergies/Allergies' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Allergy from '../../../shared/model/Allergy' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) const history = createMemoryHistory() diff --git a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx index 6492bc0b8c..15cba448c2 100644 --- a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx +++ b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Modal, Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -8,12 +6,12 @@ import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' -import Patient from '../../../model/Patient' import NewAllergyModal from '../../../patients/allergies/NewAllergyModal' import * as patientSlice from '../../../patients/patient-slice' -import { RootState } from '../../../store' +import TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/appointments/AppointmentsList.test.tsx b/src/__tests__/patients/appointments/AppointmentsList.test.tsx index 90e9ed8c22..938b92361e 100644 --- a/src/__tests__/patients/appointments/AppointmentsList.test.tsx +++ b/src/__tests__/patients/appointments/AppointmentsList.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' @@ -10,11 +8,11 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Appointment from '../../../model/Appointment' -import Patient from '../../../model/Patient' import AppointmentsList from '../../../patients/appointments/AppointmentsList' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Appointment from '../../../shared/model/Appointment' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const expectedPatient = { id: '123', diff --git a/src/__tests__/patients/care-plans/AddCarePlanModal.test.tsx b/src/__tests__/patients/care-plans/AddCarePlanModal.test.tsx index 340fdbcb60..ba9998606e 100644 --- a/src/__tests__/patients/care-plans/AddCarePlanModal.test.tsx +++ b/src/__tests__/patients/care-plans/AddCarePlanModal.test.tsx @@ -1,4 +1,3 @@ -import '../../../__mocks__/matchMediaMock' import { Modal } from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -9,13 +8,13 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import { CarePlanIntent, CarePlanStatus } from '../../../model/CarePlan' -import Patient from '../../../model/Patient' import AddCarePlanModal from '../../../patients/care-plans/AddCarePlanModal' import CarePlanForm from '../../../patients/care-plans/CarePlanForm' import * as patientSlice from '../../../patients/patient-slice' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import { CarePlanIntent, CarePlanStatus } from '../../../shared/model/CarePlan' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/care-plans/CarePlanForm.test.tsx b/src/__tests__/patients/care-plans/CarePlanForm.test.tsx index c7bcbd6366..8a92683677 100644 --- a/src/__tests__/patients/care-plans/CarePlanForm.test.tsx +++ b/src/__tests__/patients/care-plans/CarePlanForm.test.tsx @@ -1,14 +1,13 @@ -import '../../../__mocks__/matchMediaMock' import { Alert } from '@hospitalrun/components' import { addDays } from 'date-fns' import { mount } from 'enzyme' import React from 'react' import { act } from 'react-dom/test-utils' -import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../../model/CarePlan' -import Diagnosis from '../../../model/Diagnosis' -import Patient from '../../../model/Patient' import CarePlanForm from '../../../patients/care-plans/CarePlanForm' +import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../../shared/model/CarePlan' +import Diagnosis from '../../../shared/model/Diagnosis' +import Patient from '../../../shared/model/Patient' describe('Care Plan Form', () => { let onCarePlanChangeSpy: any diff --git a/src/__tests__/patients/care-plans/CarePlanTab.test.tsx b/src/__tests__/patients/care-plans/CarePlanTab.test.tsx index 3b26cc4c0b..ba024db7ac 100644 --- a/src/__tests__/patients/care-plans/CarePlanTab.test.tsx +++ b/src/__tests__/patients/care-plans/CarePlanTab.test.tsx @@ -1,4 +1,3 @@ -import '../../../__mocks__/matchMediaMock' import { Button } from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -9,12 +8,12 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Permissions from '../../../model/Permissions' import AddCarePlanModal from '../../../patients/care-plans/AddCarePlanModal' import CarePlanTab from '../../../patients/care-plans/CarePlanTab' import CarePlanTable from '../../../patients/care-plans/CarePlanTable' import ViewCarePlan from '../../../patients/care-plans/ViewCarePlan' -import { RootState } from '../../../store' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/care-plans/CarePlanTable.test.tsx b/src/__tests__/patients/care-plans/CarePlanTable.test.tsx index ce705f2a59..53ceff95a4 100644 --- a/src/__tests__/patients/care-plans/CarePlanTable.test.tsx +++ b/src/__tests__/patients/care-plans/CarePlanTable.test.tsx @@ -1,4 +1,3 @@ -import '../../../__mocks__/matchMediaMock' import { Button } from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -9,10 +8,10 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../../model/CarePlan' -import Patient from '../../../model/Patient' import CarePlanTable from '../../../patients/care-plans/CarePlanTable' -import { RootState } from '../../../store' +import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../../shared/model/CarePlan' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/care-plans/ViewCarePlan.test.tsx b/src/__tests__/patients/care-plans/ViewCarePlan.test.tsx index 4f85dd47bb..67481533ec 100644 --- a/src/__tests__/patients/care-plans/ViewCarePlan.test.tsx +++ b/src/__tests__/patients/care-plans/ViewCarePlan.test.tsx @@ -1,4 +1,3 @@ -import '../../../__mocks__/matchMediaMock' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' import React from 'react' @@ -7,10 +6,10 @@ import { Route, Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Patient from '../../../model/Patient' import CarePlanForm from '../../../patients/care-plans/CarePlanForm' import ViewCarePlan from '../../../patients/care-plans/ViewCarePlan' -import { RootState } from '../../../store' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx b/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx index c31be04acd..19707ce111 100644 --- a/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx +++ b/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Modal, Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -8,14 +6,14 @@ import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import DatePickerWithLabelFormGroup from '../../../components/input/DatePickerWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' -import Diagnosis from '../../../model/Diagnosis' -import Patient from '../../../model/Patient' import AddDiagnosisModal from '../../../patients/diagnoses/AddDiagnosisModal' import * as patientSlice from '../../../patients/patient-slice' -import { RootState } from '../../../store' +import DatePickerWithLabelFormGroup from '../../../shared/components/input/DatePickerWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup' +import PatientRepository from '../../../shared/db/PatientRepository' +import Diagnosis from '../../../shared/model/Diagnosis' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx index f53e29c021..453bb50cb2 100644 --- a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx +++ b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -10,12 +8,12 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Diagnosis from '../../../model/Diagnosis' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' import Diagnoses from '../../../patients/diagnoses/Diagnoses' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Diagnosis from '../../../shared/model/Diagnosis' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const expectedPatient = { id: '123', diff --git a/src/__tests__/patients/edit/EditPatient.test.tsx b/src/__tests__/patients/edit/EditPatient.test.tsx index 671d2bc446..da394a5c40 100644 --- a/src/__tests__/patients/edit/EditPatient.test.tsx +++ b/src/__tests__/patients/edit/EditPatient.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { subDays } from 'date-fns' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -10,13 +8,13 @@ import { Router, Route } from 'react-router-dom' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Patient from '../../../model/Patient' -import * as titleUtil from '../../../page-header/useTitle' +import * as titleUtil from '../../../page-header/title/useTitle' import EditPatient from '../../../patients/edit/EditPatient' import GeneralInformation from '../../../patients/GeneralInformation' import * as patientSlice from '../../../patients/patient-slice' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) @@ -32,9 +30,9 @@ describe('Edit Patient', () => { type: 'charity', occupation: 'occupation', preferredLanguage: 'preferredLanguage', - phoneNumbers: [{ value: '123456789' }], - emails: [{ value: 'email@email.com' }], - addresses: [{ value: 'address' }], + phoneNumbers: [{ value: '123456789', id: '789' }], + emails: [{ value: 'email@email.com', id: '456' }], + addresses: [{ value: 'address', id: '123' }], code: 'P00001', dateOfBirth: subDays(new Date(), 2).toISOString(), index: 'givenName familyName suffixP00001', diff --git a/src/__tests__/patients/labs/LabsTab.test.tsx b/src/__tests__/patients/labs/LabsTab.test.tsx index 70ad173f76..6e3e42288c 100644 --- a/src/__tests__/patients/labs/LabsTab.test.tsx +++ b/src/__tests__/patients/labs/LabsTab.test.tsx @@ -1,4 +1,3 @@ -import '../../../__mocks__/matchMediaMock' import * as components from '@hospitalrun/components' import format from 'date-fns/format' import { mount, ReactWrapper } from 'enzyme' @@ -10,12 +9,12 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Lab from '../../../model/Lab' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' import LabsTab from '../../../patients/labs/LabsTab' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Lab from '../../../shared/model/Lab' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const expectedPatient = { id: '123', diff --git a/src/__tests__/patients/list/ViewPatients.test.tsx b/src/__tests__/patients/list/ViewPatients.test.tsx index 3a70c36855..7d81983be5 100644 --- a/src/__tests__/patients/list/ViewPatients.test.tsx +++ b/src/__tests__/patients/list/ViewPatients.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { TextInput, Spinner } from '@hospitalrun/components' import format from 'date-fns/format' import { mount } from 'enzyme' @@ -11,11 +9,11 @@ import configureStore from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import { UnpagedRequest } from '../../../clients/db/PageRequest' -import PatientRepository from '../../../clients/db/PatientRepository' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' import ViewPatients from '../../../patients/list/ViewPatients' import * as patientSlice from '../../../patients/patients-slice' +import { UnpagedRequest } from '../../../shared/db/PageRequest' +import PatientRepository from '../../../shared/db/PatientRepository' const middlewares = [thunk] const mockStore = configureStore(middlewares) diff --git a/src/__tests__/patients/new/NewPatient.test.tsx b/src/__tests__/patients/new/NewPatient.test.tsx index 947c00e882..61ea79d945 100644 --- a/src/__tests__/patients/new/NewPatient.test.tsx +++ b/src/__tests__/patients/new/NewPatient.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -11,13 +9,13 @@ import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import PatientRepository from '../../../clients/db/PatientRepository' -import Patient from '../../../model/Patient' -import * as titleUtil from '../../../page-header/useTitle' +import * as titleUtil from '../../../page-header/title/useTitle' import GeneralInformation from '../../../patients/GeneralInformation' import NewPatient from '../../../patients/new/NewPatient' import * as patientSlice from '../../../patients/patient-slice' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/notes/NewNoteModal.test.tsx b/src/__tests__/patients/notes/NewNoteModal.test.tsx index ba9a4abd7d..e71cf5f5ca 100644 --- a/src/__tests__/patients/notes/NewNoteModal.test.tsx +++ b/src/__tests__/patients/notes/NewNoteModal.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Alert, Modal } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -8,12 +6,12 @@ import { Provider } from 'react-redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import TextFieldWithLabelFormGroup from '../../../components/input/TextFieldWithLabelFormGroup' -import Patient from '../../../model/Patient' import NewNoteModal from '../../../patients/notes/NewNoteModal' import * as patientSlice from '../../../patients/patient-slice' -import { RootState } from '../../../store' +import TextFieldWithLabelFormGroup from '../../../shared/components/input/TextFieldWithLabelFormGroup' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/notes/NotesTab.test.tsx b/src/__tests__/patients/notes/NotesTab.test.tsx index b4191e03ae..1f4cda1b77 100644 --- a/src/__tests__/patients/notes/NotesTab.test.tsx +++ b/src/__tests__/patients/notes/NotesTab.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -10,12 +8,12 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Note from '../../../model/Note' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' import NoteTab from '../../../patients/notes/NoteTab' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Note from '../../../shared/model/Note' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const expectedPatient = { id: '123', diff --git a/src/__tests__/patients/patient-slice.test.ts b/src/__tests__/patients/patient-slice.test.ts index 53a7c2da5d..4ce21fd54a 100644 --- a/src/__tests__/patients/patient-slice.test.ts +++ b/src/__tests__/patients/patient-slice.test.ts @@ -1,16 +1,8 @@ -import '../../__mocks__/matchMediaMock' - import { addDays, subDays } from 'date-fns' import { AnyAction } from 'redux' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../clients/db/PatientRepository' -import Allergy from '../../model/Allergy' -import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../model/CarePlan' -import Diagnosis from '../../model/Diagnosis' -import Patient from '../../model/Patient' -import RelatedPerson from '../../model/RelatedPerson' import patient, { addAllergy, addAllergyError, @@ -33,8 +25,14 @@ import patient, { updatePatientSuccess, addCarePlanError, } from '../../patients/patient-slice' -import { RootState } from '../../store' -import * as uuid from '../../util/uuid' +import PatientRepository from '../../shared/db/PatientRepository' +import Allergy from '../../shared/model/Allergy' +import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../shared/model/CarePlan' +import Diagnosis from '../../shared/model/Diagnosis' +import Patient from '../../shared/model/Patient' +import RelatedPerson from '../../shared/model/RelatedPerson' +import { RootState } from '../../shared/store' +import * as uuid from '../../shared/util/uuid' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/patients-slice.test.ts b/src/__tests__/patients/patients-slice.test.ts index b0dd750927..84565aedd2 100644 --- a/src/__tests__/patients/patients-slice.test.ts +++ b/src/__tests__/patients/patients-slice.test.ts @@ -1,14 +1,12 @@ -import '../../__mocks__/matchMediaMock' - import { AnyAction } from 'redux' -import PatientRepository from '../../clients/db/PatientRepository' -import Patient from '../../model/Patient' import patients, { fetchPatientsStart, fetchPatientsSuccess, searchPatients, } from '../../patients/patients-slice' +import PatientRepository from '../../shared/db/PatientRepository' +import Patient from '../../shared/model/Patient' describe('patients slice', () => { const expectedPatients = [ diff --git a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx index 37f65a319f..bbf919c155 100644 --- a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx +++ b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Modal, Alert, Typeahead } from '@hospitalrun/components' import { act } from '@testing-library/react' import { ReactWrapper, mount } from 'enzyme' @@ -8,12 +6,12 @@ import { Provider } from 'react-redux' import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' -import Patient from '../../../model/Patient' import * as patientSlice from '../../../patients/patient-slice' import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' -import { RootState } from '../../../store' +import TextInputWithLabelFormGroup from '../../../shared/components/input/TextInputWithLabelFormGroup' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx index 73d22f3b89..5b48ec6d23 100644 --- a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -10,14 +8,14 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import PatientRepository from '../../../clients/db/PatientRepository' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' -import RelatedPerson from '../../../model/RelatedPerson' import * as patientSlice from '../../../patients/patient-slice' import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' import RelatedPersonTab from '../../../patients/related-persons/RelatedPersonTab' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import RelatedPerson from '../../../shared/model/RelatedPerson' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/patients/util/patient-name-util.test.ts b/src/__tests__/patients/util/patient-name-util.test.ts index ef668c36fd..f0fd700634 100644 --- a/src/__tests__/patients/util/patient-name-util.test.ts +++ b/src/__tests__/patients/util/patient-name-util.test.ts @@ -1,5 +1,5 @@ -import Patient from '../../../model/Patient' import { getPatientFullName, getPatientName } from '../../../patients/util/patient-name-util' +import Patient from '../../../shared/model/Patient' describe('patient name util', () => { describe('getPatientName', () => { diff --git a/src/__tests__/patients/view/ViewPatient.test.tsx b/src/__tests__/patients/view/ViewPatient.test.tsx index dde83c4e12..1bd7d808a2 100644 --- a/src/__tests__/patients/view/ViewPatient.test.tsx +++ b/src/__tests__/patients/view/ViewPatient.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { TabsHeader, Tab } from '@hospitalrun/components' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' @@ -11,11 +9,8 @@ import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import PatientRepository from '../../../clients/db/PatientRepository' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' -import * as titleUtil from '../../../page-header/useTitle' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../../page-header/title/useTitle' import Allergies from '../../../patients/allergies/Allergies' import AppointmentsList from '../../../patients/appointments/AppointmentsList' import CarePlanTab from '../../../patients/care-plans/CarePlanTab' @@ -26,7 +21,10 @@ import NotesTab from '../../../patients/notes/NoteTab' import * as patientSlice from '../../../patients/patient-slice' import RelatedPersonTab from '../../../patients/related-persons/RelatedPersonTab' import ViewPatient from '../../../patients/view/ViewPatient' -import { RootState } from '../../../store' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx b/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx index f7bf50d98d..7d810ac8d9 100644 --- a/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx +++ b/src/__tests__/scheduling/appointments/AppointmentDetailForm.test.tsx @@ -1,15 +1,13 @@ -import '../../../__mocks__/matchMediaMock' - import { Typeahead, Alert } from '@hospitalrun/components' import { act } from '@testing-library/react' import { roundToNearestMinutes, addMinutes } from 'date-fns' import { mount, ReactWrapper } from 'enzyme' import React from 'react' -import PatientRepository from '../../../clients/db/PatientRepository' -import Appointment from '../../../model/Appointment' -import Patient from '../../../model/Patient' import AppointmentDetailForm from '../../../scheduling/appointments/AppointmentDetailForm' +import PatientRepository from '../../../shared/db/PatientRepository' +import Appointment from '../../../shared/model/Appointment' +import Patient from '../../../shared/model/Patient' describe('AppointmentDetailForm', () => { describe('Error handling', () => { diff --git a/src/__tests__/scheduling/appointments/Appointments.test.tsx b/src/__tests__/scheduling/appointments/Appointments.test.tsx index 6dd93f0fa3..2de4c800d8 100644 --- a/src/__tests__/scheduling/appointments/Appointments.test.tsx +++ b/src/__tests__/scheduling/appointments/Appointments.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { mount } from 'enzyme' import React from 'react' import { act } from 'react-dom/test-utils' @@ -8,19 +6,19 @@ import { MemoryRouter } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { addBreadcrumbs } from '../../../breadcrumbs/breadcrumbs-slice' -import AppointmentRepository from '../../../clients/db/AppointmentRepository' -import PatientRepository from '../../../clients/db/PatientRepository' import Dashboard from '../../../dashboard/Dashboard' import HospitalRun from '../../../HospitalRun' -import Appointment from '../../../model/Appointment' -import Patient from '../../../model/Patient' -import Permissions from '../../../model/Permissions' +import { addBreadcrumbs } from '../../../page-header/breadcrumbs/breadcrumbs-slice' import Appointments from '../../../scheduling/appointments/Appointments' import EditAppointment from '../../../scheduling/appointments/edit/EditAppointment' import NewAppointment from '../../../scheduling/appointments/new/NewAppointment' import ViewAppointments from '../../../scheduling/appointments/ViewAppointments' -import { RootState } from '../../../store' +import AppointmentRepository from '../../../shared/db/AppointmentRepository' +import PatientRepository from '../../../shared/db/PatientRepository' +import Appointment from '../../../shared/model/Appointment' +import Patient from '../../../shared/model/Patient' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx b/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx index 5accb763ec..d1f7590fd7 100644 --- a/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx +++ b/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx @@ -1,5 +1,3 @@ -import '../../../__mocks__/matchMediaMock' - import { Calendar } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -10,14 +8,14 @@ import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import AppointmentRepository from '../../../clients/db/AppointmentRepository' -import PatientRepository from '../../../clients/db/PatientRepository' -import Appointment from '../../../model/Appointment' -import Patient from '../../../model/Patient' -import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' -import * as titleUtil from '../../../page-header/useTitle' +import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../../page-header/title/useTitle' import ViewAppointments from '../../../scheduling/appointments/ViewAppointments' -import { RootState } from '../../../store' +import AppointmentRepository from '../../../shared/db/AppointmentRepository' +import PatientRepository from '../../../shared/db/PatientRepository' +import Appointment from '../../../shared/model/Appointment' +import Patient from '../../../shared/model/Patient' +import { RootState } from '../../../shared/store' describe('ViewAppointments', () => { const expectedAppointments = [ diff --git a/src/__tests__/scheduling/appointments/appointment-slice.test.ts b/src/__tests__/scheduling/appointments/appointment-slice.test.ts index 0f81a5a30d..ef37235a47 100644 --- a/src/__tests__/scheduling/appointments/appointment-slice.test.ts +++ b/src/__tests__/scheduling/appointments/appointment-slice.test.ts @@ -1,13 +1,7 @@ -import '../../../__mocks__/matchMediaMock' - import { subDays } from 'date-fns' import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' -import AppointmentRepository from '../../../clients/db/AppointmentRepository' -import PatientRepository from '../../../clients/db/PatientRepository' -import Appointment from '../../../model/Appointment' -import Patient from '../../../model/Patient' import appointment, { fetchAppointmentStart, fetchAppointmentSuccess, @@ -24,6 +18,10 @@ import appointment, { deleteAppointmentStart, deleteAppointmentSuccess, } from '../../../scheduling/appointments/appointment-slice' +import AppointmentRepository from '../../../shared/db/AppointmentRepository' +import PatientRepository from '../../../shared/db/PatientRepository' +import Appointment from '../../../shared/model/Appointment' +import Patient from '../../../shared/model/Patient' describe('appointment slice', () => { describe('appointment reducer', () => { diff --git a/src/__tests__/scheduling/appointments/appointments-slice.test.ts b/src/__tests__/scheduling/appointments/appointments-slice.test.ts index 0b1b91ad02..656fbd79a3 100644 --- a/src/__tests__/scheduling/appointments/appointments-slice.test.ts +++ b/src/__tests__/scheduling/appointments/appointments-slice.test.ts @@ -1,13 +1,13 @@ import { AnyAction } from 'redux' import { mocked } from 'ts-jest/utils' -import AppointmentRepository from '../../../clients/db/AppointmentRepository' -import Appointment from '../../../model/Appointment' import appointments, { fetchAppointmentsStart, fetchAppointmentsSuccess, fetchAppointments, } from '../../../scheduling/appointments/appointments-slice' +import AppointmentRepository from '../../../shared/db/AppointmentRepository' +import Appointment from '../../../shared/model/Appointment' describe('appointments slice', () => { describe('appointments reducer', () => { diff --git a/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx b/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx index 1be2f541b6..5745e2dc14 100644 --- a/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx @@ -1,5 +1,3 @@ -import '../../../../__mocks__/matchMediaMock' - import { Button } from '@hospitalrun/components' import { roundToNearestMinutes, addMinutes } from 'date-fns' import { mount } from 'enzyme' @@ -12,15 +10,15 @@ import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import AppointmentRepository from '../../../../clients/db/AppointmentRepository' -import PatientRepository from '../../../../clients/db/PatientRepository' -import Appointment from '../../../../model/Appointment' -import Patient from '../../../../model/Patient' -import * as titleUtil from '../../../../page-header/useTitle' +import * as titleUtil from '../../../../page-header/title/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' import EditAppointment from '../../../../scheduling/appointments/edit/EditAppointment' -import { RootState } from '../../../../store' +import AppointmentRepository from '../../../../shared/db/AppointmentRepository' +import PatientRepository from '../../../../shared/db/PatientRepository' +import Appointment from '../../../../shared/model/Appointment' +import Patient from '../../../../shared/model/Patient' +import { RootState } from '../../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx b/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx index 8301462bb9..2f81a3b7dd 100644 --- a/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx @@ -1,5 +1,3 @@ -import '../../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { act } from '@testing-library/react' import { roundToNearestMinutes, addMinutes } from 'date-fns' @@ -12,16 +10,16 @@ import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import AppointmentRepository from '../../../../clients/db/AppointmentRepository' -import LabRepository from '../../../../clients/db/LabRepository' -import Appointment from '../../../../model/Appointment' -import Lab from '../../../../model/Lab' -import Patient from '../../../../model/Patient' -import * as titleUtil from '../../../../page-header/useTitle' +import * as titleUtil from '../../../../page-header/title/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' import NewAppointment from '../../../../scheduling/appointments/new/NewAppointment' -import { RootState } from '../../../../store' +import AppointmentRepository from '../../../../shared/db/AppointmentRepository' +import LabRepository from '../../../../shared/db/LabRepository' +import Appointment from '../../../../shared/model/Appointment' +import Lab from '../../../../shared/model/Lab' +import Patient from '../../../../shared/model/Patient' +import { RootState } from '../../../../shared/store' const mockStore = createMockStore([thunk]) const mockedComponents = mocked(components, true) diff --git a/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts b/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts index 9f248451f1..0a3b963b54 100644 --- a/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts +++ b/src/__tests__/scheduling/appointments/util/scheduling-appointment.util.test.ts @@ -1,5 +1,5 @@ -import Appointment from '../../../../model/Appointment' import { getAppointmentLabel } from '../../../../scheduling/appointments/util/scheduling-appointment.util' +import Appointment from '../../../../shared/model/Appointment' describe('scheduling appointment util', () => { describe('getAppointmentLabel', () => { diff --git a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx index 24d10612c1..3490f28e18 100644 --- a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx @@ -1,5 +1,3 @@ -import '../../../../__mocks__/matchMediaMock' - import * as components from '@hospitalrun/components' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' @@ -11,17 +9,17 @@ import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { mocked } from 'ts-jest/utils' -import AppointmentRepository from '../../../../clients/db/AppointmentRepository' -import PatientRepository from '../../../../clients/db/PatientRepository' -import Appointment from '../../../../model/Appointment' -import Patient from '../../../../model/Patient' -import Permissions from '../../../../model/Permissions' -import * as ButtonBarProvider from '../../../../page-header/ButtonBarProvider' -import * as titleUtil from '../../../../page-header/useTitle' +import * as ButtonBarProvider from '../../../../page-header/button-toolbar/ButtonBarProvider' +import * as titleUtil from '../../../../page-header/title/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' import AppointmentDetailForm from '../../../../scheduling/appointments/AppointmentDetailForm' import ViewAppointment from '../../../../scheduling/appointments/view/ViewAppointment' -import { RootState } from '../../../../store' +import AppointmentRepository from '../../../../shared/db/AppointmentRepository' +import PatientRepository from '../../../../shared/db/PatientRepository' +import Appointment from '../../../../shared/model/Appointment' +import Patient from '../../../../shared/model/Patient' +import Permissions from '../../../../shared/model/Permissions' +import { RootState } from '../../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/settings/Settings.test.tsx b/src/__tests__/settings/Settings.test.tsx index d4820d513b..18ad6a78f4 100644 --- a/src/__tests__/settings/Settings.test.tsx +++ b/src/__tests__/settings/Settings.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { mount } from 'enzyme' import { createMemoryHistory } from 'history' import React from 'react' @@ -8,9 +6,9 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import * as titleUtil from '../../page-header/useTitle' +import * as titleUtil from '../../page-header/title/useTitle' import Settings from '../../settings/Settings' -import { RootState } from '../../store' +import { RootState } from '../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/components/Sidebar.test.tsx b/src/__tests__/shared/components/Sidebar.test.tsx similarity index 98% rename from src/__tests__/components/Sidebar.test.tsx rename to src/__tests__/shared/components/Sidebar.test.tsx index a9f3548202..34e78818fd 100644 --- a/src/__tests__/components/Sidebar.test.tsx +++ b/src/__tests__/shared/components/Sidebar.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { ListItem } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' @@ -10,9 +8,9 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Sidebar from '../../components/Sidebar' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import Sidebar from '../../../shared/components/Sidebar' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx b/src/__tests__/shared/components/input/DatePickerWithLabelFormGroup.test.tsx similarity index 95% rename from src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx rename to src/__tests__/shared/components/input/DatePickerWithLabelFormGroup.test.tsx index ee3c169a82..0f50874ba5 100644 --- a/src/__tests__/components/input/DatePickerWithLabelFormGroup.test.tsx +++ b/src/__tests__/shared/components/input/DatePickerWithLabelFormGroup.test.tsx @@ -1,10 +1,8 @@ -import '../../../__mocks__/matchMediaMock' - import { DateTimePicker, Label } from '@hospitalrun/components' import { shallow } from 'enzyme' import React, { ChangeEvent } from 'react' -import DatePickerWithLabelFormGroup from '../../../components/input/DatePickerWithLabelFormGroup' +import DatePickerWithLabelFormGroup from '../../../../shared/components/input/DatePickerWithLabelFormGroup' describe('date picker with label form group', () => { describe('layout', () => { diff --git a/src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx b/src/__tests__/shared/components/input/DateTimePickerWithLabelFormGroup.test.tsx similarity index 94% rename from src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx rename to src/__tests__/shared/components/input/DateTimePickerWithLabelFormGroup.test.tsx index 9052cd0fe9..80b4e8ad42 100644 --- a/src/__tests__/components/input/DateTimePickerWithLabelFormGroup.test.tsx +++ b/src/__tests__/shared/components/input/DateTimePickerWithLabelFormGroup.test.tsx @@ -1,10 +1,8 @@ -import '../../../__mocks__/matchMediaMock' - import { DateTimePicker, Label } from '@hospitalrun/components' import { shallow } from 'enzyme' import React, { ChangeEvent } from 'react' -import DateTimePickerWithLabelFormGroup from '../../../components/input/DateTimePickerWithLabelFormGroup' +import DateTimePickerWithLabelFormGroup from '../../../../shared/components/input/DateTimePickerWithLabelFormGroup' describe('date picker with label form group', () => { describe('layout', () => { diff --git a/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx b/src/__tests__/shared/components/input/SelectWithLabelFormGroup.test.tsx similarity index 94% rename from src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx rename to src/__tests__/shared/components/input/SelectWithLabelFormGroup.test.tsx index 50f1b9162a..d4cf9cc75a 100644 --- a/src/__tests__/components/input/SelectWithLabelFormGroup.test.tsx +++ b/src/__tests__/shared/components/input/SelectWithLabelFormGroup.test.tsx @@ -1,10 +1,8 @@ -import '../../../__mocks__/matchMediaMock' - import { Label, Select } from '@hospitalrun/components' import { shallow } from 'enzyme' import React from 'react' -import SelectWithLabelFormGroup from '../../../components/input/SelectWithLableFormGroup' +import SelectWithLabelFormGroup from '../../../../shared/components/input/SelectWithLableFormGroup' describe('select with label form group', () => { describe('layout', () => { diff --git a/src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx b/src/__tests__/shared/components/input/TestInputWithLabelFormGroup.test.tsx similarity index 94% rename from src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx rename to src/__tests__/shared/components/input/TestInputWithLabelFormGroup.test.tsx index 4dd9841647..9b448fab06 100644 --- a/src/__tests__/components/input/TestInputWithLabelFormGroup.test.tsx +++ b/src/__tests__/shared/components/input/TestInputWithLabelFormGroup.test.tsx @@ -1,10 +1,8 @@ -import '../../../__mocks__/matchMediaMock' - import { Label, TextInput } from '@hospitalrun/components' import { shallow } from 'enzyme' import React from 'react' -import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../../../shared/components/input/TextInputWithLabelFormGroup' describe('text input with label form group', () => { describe('layout', () => { diff --git a/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx b/src/__tests__/shared/components/input/TextFieldWithLabelFormGroup.test.tsx similarity index 95% rename from src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx rename to src/__tests__/shared/components/input/TextFieldWithLabelFormGroup.test.tsx index 5e033bb987..9980a076b6 100644 --- a/src/__tests__/components/input/TextFieldWithLabelFormGroup.test.tsx +++ b/src/__tests__/shared/components/input/TextFieldWithLabelFormGroup.test.tsx @@ -1,10 +1,8 @@ -import '../../../__mocks__/matchMediaMock' - import { Label, TextField } from '@hospitalrun/components' import { shallow } from 'enzyme' import React from 'react' -import TextFieldWithLabelFormGroup from '../../../components/input/TextFieldWithLabelFormGroup' +import TextFieldWithLabelFormGroup from '../../../../shared/components/input/TextFieldWithLabelFormGroup' describe('text field with label form group', () => { describe('layout', () => { diff --git a/src/__tests__/components/Navbar.test.tsx b/src/__tests__/shared/components/navbar/Navbar.test.tsx similarity index 97% rename from src/__tests__/components/Navbar.test.tsx rename to src/__tests__/shared/components/navbar/Navbar.test.tsx index b3faa97619..36d7487247 100644 --- a/src/__tests__/components/Navbar.test.tsx +++ b/src/__tests__/shared/components/navbar/Navbar.test.tsx @@ -1,5 +1,3 @@ -import '../../__mocks__/matchMediaMock' - import { Navbar as HospitalRunNavbar } from '@hospitalrun/components' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -11,9 +9,9 @@ import { Router } from 'react-router-dom' import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import Navbar from '../../components/Navbar' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import Navbar from '../../../../shared/components/navbar/Navbar' +import Permissions from '../../../../shared/model/Permissions' +import { RootState } from '../../../../shared/store' const mockStore = createMockStore([thunk]) diff --git a/src/__tests__/components/network-status/NetworkStatusMessage.test.tsx b/src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx similarity index 82% rename from src/__tests__/components/network-status/NetworkStatusMessage.test.tsx rename to src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx index cbd144510c..87cf13246a 100644 --- a/src/__tests__/components/network-status/NetworkStatusMessage.test.tsx +++ b/src/__tests__/shared/components/network-status/NetworkStatusMessage.test.tsx @@ -1,11 +1,11 @@ import { render, shallow } from 'enzyme' import React from 'react' -import { useTranslation } from '../../../__mocks__/react-i18next' -import { NetworkStatusMessage } from '../../../components/network-status' -import { useNetworkStatus } from '../../../components/network-status/useNetworkStatus' +import { useTranslation } from '../../../../__mocks__/react-i18next' +import { NetworkStatusMessage } from '../../../../shared/components/network-status' +import { useNetworkStatus } from '../../../../shared/components/network-status/useNetworkStatus' -jest.mock('../../../components/network-status/useNetworkStatus') +jest.mock('../../../../shared/components/network-status/useNetworkStatus') const useNetworkStatusMock = (useNetworkStatus as unknown) as jest.MockInstance< ReturnType, any diff --git a/src/__tests__/clients/db/AppointmentRepository.test.ts b/src/__tests__/shared/db/AppointmentRepository.test.ts similarity index 91% rename from src/__tests__/clients/db/AppointmentRepository.test.ts rename to src/__tests__/shared/db/AppointmentRepository.test.ts index 268fb97cdd..e5cb51a852 100644 --- a/src/__tests__/clients/db/AppointmentRepository.test.ts +++ b/src/__tests__/shared/db/AppointmentRepository.test.ts @@ -1,6 +1,6 @@ -import AppointmentRepository from '../../../clients/db/AppointmentRepository' -import { relationalDb } from '../../../config/pouchdb' -import Appointment from '../../../model/Appointment' +import { relationalDb } from '../../../shared/config/pouchdb' +import AppointmentRepository from '../../../shared/db/AppointmentRepository' +import Appointment from '../../../shared/model/Appointment' const uuidV4Regex = /^[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i diff --git a/src/__tests__/clients/db/LabRepository.test.ts b/src/__tests__/shared/db/LabRepository.test.ts similarity index 96% rename from src/__tests__/clients/db/LabRepository.test.ts rename to src/__tests__/shared/db/LabRepository.test.ts index a42549db0c..c0e87333e0 100644 --- a/src/__tests__/clients/db/LabRepository.test.ts +++ b/src/__tests__/shared/db/LabRepository.test.ts @@ -1,9 +1,9 @@ import shortid from 'shortid' -import LabRepository from '../../../clients/db/LabRepository' -import SortRequest from '../../../clients/db/SortRequest' -import { relationalDb } from '../../../config/pouchdb' -import Lab from '../../../model/Lab' +import { relationalDb } from '../../../shared/config/pouchdb' +import LabRepository from '../../../shared/db/LabRepository' +import SortRequest from '../../../shared/db/SortRequest' +import Lab from '../../../shared/model/Lab' interface SearchContainer { text: string diff --git a/src/__tests__/clients/db/PatientRepository.test.ts b/src/__tests__/shared/db/PatientRepository.test.ts similarity index 97% rename from src/__tests__/clients/db/PatientRepository.test.ts rename to src/__tests__/shared/db/PatientRepository.test.ts index 20f3be772b..d58d7d593f 100644 --- a/src/__tests__/clients/db/PatientRepository.test.ts +++ b/src/__tests__/shared/db/PatientRepository.test.ts @@ -1,9 +1,9 @@ import { getTime, isAfter } from 'date-fns' import shortid from 'shortid' -import PatientRepository from '../../../clients/db/PatientRepository' -import { relationalDb } from '../../../config/pouchdb' -import Patient from '../../../model/Patient' +import { relationalDb } from '../../../shared/config/pouchdb' +import PatientRepository from '../../../shared/db/PatientRepository' +import Patient from '../../../shared/model/Patient' const uuidV4Regex = /^[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i diff --git a/src/__tests__/hooks/debounce.test.ts b/src/__tests__/shared/hooks/useDebounce.test.ts similarity index 95% rename from src/__tests__/hooks/debounce.test.ts rename to src/__tests__/shared/hooks/useDebounce.test.ts index d4ced8c57d..f4b2ab94b5 100644 --- a/src/__tests__/hooks/debounce.test.ts +++ b/src/__tests__/shared/hooks/useDebounce.test.ts @@ -1,6 +1,6 @@ import { renderHook, act } from '@testing-library/react-hooks' -import useDebounce from '../../hooks/debounce' +import useDebounce from '../../../shared/hooks/useDebounce' describe('useDebounce', () => { beforeAll(() => jest.useFakeTimers()) diff --git a/src/__tests__/hooks/useUpdateEffect.test.ts b/src/__tests__/shared/hooks/useUpdateEffect.test.ts similarity index 85% rename from src/__tests__/hooks/useUpdateEffect.test.ts rename to src/__tests__/shared/hooks/useUpdateEffect.test.ts index 06b044f946..f89ae78a63 100644 --- a/src/__tests__/hooks/useUpdateEffect.test.ts +++ b/src/__tests__/shared/hooks/useUpdateEffect.test.ts @@ -1,6 +1,6 @@ import { renderHook } from '@testing-library/react-hooks' -import useUpdateEffect from '../../hooks/useUpdateEffect' +import useUpdateEffect from '../../../shared/hooks/useUpdateEffect' describe('useUpdateEffect', () => { it('should call the function after udpate', () => { diff --git a/src/__tests__/utils/generateCode.test.ts b/src/__tests__/shared/utils/generateCode.test.ts similarity index 69% rename from src/__tests__/utils/generateCode.test.ts rename to src/__tests__/shared/utils/generateCode.test.ts index 22a44dd2a5..cf6d887128 100644 --- a/src/__tests__/utils/generateCode.test.ts +++ b/src/__tests__/shared/utils/generateCode.test.ts @@ -1,4 +1,4 @@ -import generateCode from '../../util/generateCode' +import generateCode from '../../../shared/util/generateCode' it('should generate a code with prefix A-', () => { const generatedCode = generateCode('A') diff --git a/src/__tests__/user/user-slice.test.ts b/src/__tests__/user/user-slice.test.ts index 12fcc4f3bf..4c388ef92d 100644 --- a/src/__tests__/user/user-slice.test.ts +++ b/src/__tests__/user/user-slice.test.ts @@ -1,9 +1,9 @@ import configureMockStore from 'redux-mock-store' import thunk from 'redux-thunk' -import { remoteDb } from '../../config/pouchdb' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import { remoteDb } from '../../shared/config/pouchdb' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import user, { fetchPermissions, getCurrentSession, diff --git a/src/dashboard/Dashboard.tsx b/src/dashboard/Dashboard.tsx index 8a26e4df9e..8cfefb9325 100644 --- a/src/dashboard/Dashboard.tsx +++ b/src/dashboard/Dashboard.tsx @@ -1,7 +1,7 @@ import React from 'react' import { useTranslation } from 'react-i18next' -import useTitle from '../page-header/useTitle' +import useTitle from '../page-header/title/useTitle' const Dashboard: React.FC = () => { const { t } = useTranslation() diff --git a/src/incidents/Incidents.tsx b/src/incidents/Incidents.tsx index 59d3a9cd0b..7b19355a56 100644 --- a/src/incidents/Incidents.tsx +++ b/src/incidents/Incidents.tsx @@ -2,10 +2,10 @@ import React from 'react' import { useSelector } from 'react-redux' import { Switch } from 'react-router-dom' -import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' -import PrivateRoute from '../components/PrivateRoute' -import Permissions from '../model/Permissions' -import { RootState } from '../store' +import useAddBreadcrumbs from '../page-header/breadcrumbs/useAddBreadcrumbs' +import PrivateRoute from '../shared/components/PrivateRoute' +import Permissions from '../shared/model/Permissions' +import { RootState } from '../shared/store' import ViewIncidents from './list/ViewIncidents' import ReportIncident from './report/ReportIncident' import ViewIncident from './view/ViewIncident' diff --git a/src/incidents/incident-slice.ts b/src/incidents/incident-slice.ts index 05a8bc6eee..11a319ebe9 100644 --- a/src/incidents/incident-slice.ts +++ b/src/incidents/incident-slice.ts @@ -3,9 +3,9 @@ import { isAfter } from 'date-fns' import { isEmpty } from 'lodash' import shortid from 'shortid' -import IncidentRepository from '../clients/db/IncidentRepository' -import Incident from '../model/Incident' -import { AppThunk } from '../store' +import IncidentRepository from '../shared/db/IncidentRepository' +import Incident from '../shared/model/Incident' +import { AppThunk } from '../shared/store' interface Error { date?: string diff --git a/src/incidents/incidents-slice.ts b/src/incidents/incidents-slice.ts index 1d35600312..96e69dcd9d 100644 --- a/src/incidents/incidents-slice.ts +++ b/src/incidents/incidents-slice.ts @@ -1,8 +1,8 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import IncidentRepository from '../clients/db/IncidentRepository' -import Incident from '../model/Incident' -import { AppThunk } from '../store' +import IncidentRepository from '../shared/db/IncidentRepository' +import Incident from '../shared/model/Incident' +import { AppThunk } from '../shared/store' import IncidentFilter from './IncidentFilter' interface IncidentsState { diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx index 4fe6d09a5f..35dc9c4f01 100644 --- a/src/incidents/list/ViewIncidents.tsx +++ b/src/incidents/list/ViewIncidents.tsx @@ -5,11 +5,13 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup' -import Incident from '../../model/Incident' -import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import { useButtonToolbarSetter } from '../../page-header/button-toolbar/ButtonBarProvider' +import useTitle from '../../page-header/title/useTitle' +import SelectWithLabelFormGroup, { + Option, +} from '../../shared/components/input/SelectWithLableFormGroup' +import Incident from '../../shared/model/Incident' +import { RootState } from '../../shared/store' import IncidentFilter from '../IncidentFilter' import { searchIncidents } from '../incidents-slice' diff --git a/src/incidents/report/ReportIncident.tsx b/src/incidents/report/ReportIncident.tsx index d7eeb35f45..b270cc7222 100644 --- a/src/incidents/report/ReportIncident.tsx +++ b/src/incidents/report/ReportIncident.tsx @@ -4,13 +4,13 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import DateTimePickerWithLabelFormGroup from '../../components/input/DateTimePickerWithLabelFormGroup' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import Incident from '../../model/Incident' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../page-header/title/useTitle' +import DateTimePickerWithLabelFormGroup from '../../shared/components/input/DateTimePickerWithLabelFormGroup' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import Incident from '../../shared/model/Incident' +import { RootState } from '../../shared/store' import { reportIncident } from '../incident-slice' const ReportIncident = () => { diff --git a/src/incidents/view/ViewIncident.tsx b/src/incidents/view/ViewIncident.tsx index e68436cf26..a4797cb7c5 100644 --- a/src/incidents/view/ViewIncident.tsx +++ b/src/incidents/view/ViewIncident.tsx @@ -5,11 +5,11 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useParams } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../page-header/title/useTitle' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import { RootState } from '../../shared/store' import { fetchIncident } from '../incident-slice' const ViewIncident = () => { diff --git a/src/index.tsx b/src/index.tsx index 48c2f883cd..9fc7aaacc0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,7 +6,7 @@ import './index.css' import App from './App' import * as serviceWorker from './serviceWorker' -import './i18n' +import './shared/config/i18n' ReactDOM.render(, document.getElementById('root')) diff --git a/src/labs/Labs.tsx b/src/labs/Labs.tsx index 11252b0383..fadf4e4335 100644 --- a/src/labs/Labs.tsx +++ b/src/labs/Labs.tsx @@ -2,10 +2,10 @@ import React from 'react' import { useSelector } from 'react-redux' import { Switch } from 'react-router-dom' -import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' -import PrivateRoute from '../components/PrivateRoute' -import Permissions from '../model/Permissions' -import { RootState } from '../store' +import useAddBreadcrumbs from '../page-header/breadcrumbs/useAddBreadcrumbs' +import PrivateRoute from '../shared/components/PrivateRoute' +import Permissions from '../shared/model/Permissions' +import { RootState } from '../shared/store' import NewLabRequest from './requests/NewLabRequest' import ViewLab from './ViewLab' import LabRequests from './ViewLabs' diff --git a/src/labs/ViewLab.tsx b/src/labs/ViewLab.tsx index 0f654a0dde..b8328de69d 100644 --- a/src/labs/ViewLab.tsx +++ b/src/labs/ViewLab.tsx @@ -5,13 +5,13 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useParams, useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../breadcrumbs/useAddBreadcrumbs' -import TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup' -import Lab from '../model/Lab' -import Patient from '../model/Patient' -import Permissions from '../model/Permissions' -import useTitle from '../page-header/useTitle' -import { RootState } from '../store' +import useAddBreadcrumbs from '../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../page-header/title/useTitle' +import TextFieldWithLabelFormGroup from '../shared/components/input/TextFieldWithLabelFormGroup' +import Lab from '../shared/model/Lab' +import Patient from '../shared/model/Patient' +import Permissions from '../shared/model/Permissions' +import { RootState } from '../shared/store' import { cancelLab, completeLab, updateLab, fetchLab } from './lab-slice' const getTitle = (patient: Patient | undefined, lab: Lab | undefined) => diff --git a/src/labs/ViewLabs.tsx b/src/labs/ViewLabs.tsx index c8a724d240..2cca3daf05 100644 --- a/src/labs/ViewLabs.tsx +++ b/src/labs/ViewLabs.tsx @@ -5,14 +5,16 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup' -import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' -import useDebounce from '../hooks/debounce' -import Lab from '../model/Lab' -import Permissions from '../model/Permissions' -import { useButtonToolbarSetter } from '../page-header/ButtonBarProvider' -import useTitle from '../page-header/useTitle' -import { RootState } from '../store' +import { useButtonToolbarSetter } from '../page-header/button-toolbar/ButtonBarProvider' +import useTitle from '../page-header/title/useTitle' +import SelectWithLabelFormGroup, { + Option, +} from '../shared/components/input/SelectWithLableFormGroup' +import TextInputWithLabelFormGroup from '../shared/components/input/TextInputWithLabelFormGroup' +import useDebounce from '../shared/hooks/useDebounce' +import Lab from '../shared/model/Lab' +import Permissions from '../shared/model/Permissions' +import { RootState } from '../shared/store' import { searchLabs } from './labs-slice' type LabFilter = 'requested' | 'completed' | 'canceled' | 'all' diff --git a/src/labs/lab-slice.ts b/src/labs/lab-slice.ts index 231bf016a2..c57ea7b165 100644 --- a/src/labs/lab-slice.ts +++ b/src/labs/lab-slice.ts @@ -1,10 +1,10 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import LabRepository from '../clients/db/LabRepository' -import PatientRepository from '../clients/db/PatientRepository' -import Lab from '../model/Lab' -import Patient from '../model/Patient' -import { AppThunk } from '../store' +import LabRepository from '../shared/db/LabRepository' +import PatientRepository from '../shared/db/PatientRepository' +import Lab from '../shared/model/Lab' +import Patient from '../shared/model/Patient' +import { AppThunk } from '../shared/store' interface Error { result?: string diff --git a/src/labs/labs-slice.ts b/src/labs/labs-slice.ts index 2951d739b6..0acd4c8a50 100644 --- a/src/labs/labs-slice.ts +++ b/src/labs/labs-slice.ts @@ -1,9 +1,9 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import LabRepository from '../clients/db/LabRepository' -import SortRequest from '../clients/db/SortRequest' -import Lab from '../model/Lab' -import { AppThunk } from '../store' +import LabRepository from '../shared/db/LabRepository' +import SortRequest from '../shared/db/SortRequest' +import Lab from '../shared/model/Lab' +import { AppThunk } from '../shared/store' interface LabsState { isLoading: boolean diff --git a/src/labs/requests/NewLabRequest.tsx b/src/labs/requests/NewLabRequest.tsx index 829730424e..08fe49b664 100644 --- a/src/labs/requests/NewLabRequest.tsx +++ b/src/labs/requests/NewLabRequest.tsx @@ -4,14 +4,14 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import PatientRepository from '../../clients/db/PatientRepository' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import Lab from '../../model/Lab' -import Patient from '../../model/Patient' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../page-header/title/useTitle' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import PatientRepository from '../../shared/db/PatientRepository' +import Lab from '../../shared/model/Lab' +import Patient from '../../shared/model/Patient' +import { RootState } from '../../shared/store' import { requestLab } from '../lab-slice' const NewLabRequest = () => { diff --git a/src/login/Login.tsx b/src/login/Login.tsx index ac726159a2..a7cf37aacc 100644 --- a/src/login/Login.tsx +++ b/src/login/Login.tsx @@ -4,10 +4,10 @@ import Button from 'react-bootstrap/Button' import { useDispatch, useSelector } from 'react-redux' import { Redirect } from 'react-router-dom' -import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' -import { remoteDb } from '../config/pouchdb' -import logo from '../images/logo-on-transparent.png' -import { RootState } from '../store' +import TextInputWithLabelFormGroup from '../shared/components/input/TextInputWithLabelFormGroup' +import { remoteDb } from '../shared/config/pouchdb' +import logo from '../shared/static/images/logo-on-transparent.png' +import { RootState } from '../shared/store' import { getCurrentSession, login } from '../user/user-slice' const Login = () => { diff --git a/src/breadcrumbs/Breadcrumbs.tsx b/src/page-header/breadcrumbs/Breadcrumbs.tsx similarity index 95% rename from src/breadcrumbs/Breadcrumbs.tsx rename to src/page-header/breadcrumbs/Breadcrumbs.tsx index 665c13fc5f..720126e4c9 100644 --- a/src/breadcrumbs/Breadcrumbs.tsx +++ b/src/page-header/breadcrumbs/Breadcrumbs.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import { RootState } from '../store' +import { RootState } from '../../shared/store' const Breadcrumbs = () => { const history = useHistory() diff --git a/src/breadcrumbs/breadcrumbs-slice.ts b/src/page-header/breadcrumbs/breadcrumbs-slice.ts similarity index 94% rename from src/breadcrumbs/breadcrumbs-slice.ts rename to src/page-header/breadcrumbs/breadcrumbs-slice.ts index 5785326efd..a0e29d3bc2 100644 --- a/src/breadcrumbs/breadcrumbs-slice.ts +++ b/src/page-header/breadcrumbs/breadcrumbs-slice.ts @@ -1,6 +1,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import Breadcrumb from '../model/Breadcrumb' +import Breadcrumb from '../../shared/model/Breadcrumb' interface BreadcrumbsState { breadcrumbs: Breadcrumb[] diff --git a/src/breadcrumbs/useAddBreadcrumbs.ts b/src/page-header/breadcrumbs/useAddBreadcrumbs.ts similarity index 92% rename from src/breadcrumbs/useAddBreadcrumbs.ts rename to src/page-header/breadcrumbs/useAddBreadcrumbs.ts index f3822cecf1..7a1b62ae8c 100644 --- a/src/breadcrumbs/useAddBreadcrumbs.ts +++ b/src/page-header/breadcrumbs/useAddBreadcrumbs.ts @@ -1,7 +1,7 @@ import { useEffect } from 'react' import { useDispatch } from 'react-redux' -import Breadcrumb from '../model/Breadcrumb' +import Breadcrumb from '../../shared/model/Breadcrumb' import { addBreadcrumbs, removeBreadcrumbs } from './breadcrumbs-slice' export default function useAddBreadcrumbs(breadcrumbs: Breadcrumb[], withDashboard = false): void { diff --git a/src/page-header/ButtonBarProvider.tsx b/src/page-header/button-toolbar/ButtonBarProvider.tsx similarity index 100% rename from src/page-header/ButtonBarProvider.tsx rename to src/page-header/button-toolbar/ButtonBarProvider.tsx diff --git a/src/page-header/ButtonToolBar.tsx b/src/page-header/button-toolbar/ButtonToolBar.tsx similarity index 100% rename from src/page-header/ButtonToolBar.tsx rename to src/page-header/button-toolbar/ButtonToolBar.tsx diff --git a/src/page-header/title-slice.ts b/src/page-header/title/title-slice.ts similarity index 92% rename from src/page-header/title-slice.ts rename to src/page-header/title/title-slice.ts index 1025ed4456..3b3bc3339b 100644 --- a/src/page-header/title-slice.ts +++ b/src/page-header/title/title-slice.ts @@ -1,6 +1,6 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { AppThunk } from '../store' +import { AppThunk } from '../../shared/store' interface TitleState { title: string diff --git a/src/page-header/useTitle.tsx b/src/page-header/title/useTitle.tsx similarity index 100% rename from src/page-header/useTitle.tsx rename to src/page-header/title/useTitle.tsx diff --git a/src/patients/ContactInfo.tsx b/src/patients/ContactInfo.tsx index 7d3a9be3de..8a5939f220 100644 --- a/src/patients/ContactInfo.tsx +++ b/src/patients/ContactInfo.tsx @@ -2,11 +2,13 @@ import { Spinner, Row, Column, Icon } from '@hospitalrun/components' import React, { useEffect, ReactElement } from 'react' import { useTranslation } from 'react-i18next' -import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup' -import TextFieldWithLabelFormGroup from '../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' -import { ContactInfoPiece } from '../model/ContactInformation' -import { uuid } from '../util/uuid' +import SelectWithLabelFormGroup, { + Option, +} from '../shared/components/input/SelectWithLableFormGroup' +import TextFieldWithLabelFormGroup from '../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../shared/components/input/TextInputWithLabelFormGroup' +import { ContactInfoPiece } from '../shared/model/ContactInformation' +import { uuid } from '../shared/util/uuid' import ContactInfoTypes from './ContactInfoTypes' interface Props { diff --git a/src/patients/GeneralInformation.tsx b/src/patients/GeneralInformation.tsx index decafea491..5830d650ac 100644 --- a/src/patients/GeneralInformation.tsx +++ b/src/patients/GeneralInformation.tsx @@ -3,11 +3,13 @@ import { startOfDay, subYears, differenceInYears } from 'date-fns' import React, { ReactElement } from 'react' import { useTranslation } from 'react-i18next' -import DatePickerWithLabelFormGroup from '../components/input/DatePickerWithLabelFormGroup' -import SelectWithLabelFormGroup, { Option } from '../components/input/SelectWithLableFormGroup' -import TextInputWithLabelFormGroup from '../components/input/TextInputWithLabelFormGroup' -import { ContactInfoPiece } from '../model/ContactInformation' -import Patient from '../model/Patient' +import DatePickerWithLabelFormGroup from '../shared/components/input/DatePickerWithLabelFormGroup' +import SelectWithLabelFormGroup, { + Option, +} from '../shared/components/input/SelectWithLableFormGroup' +import TextInputWithLabelFormGroup from '../shared/components/input/TextInputWithLabelFormGroup' +import { ContactInfoPiece } from '../shared/model/ContactInformation' +import Patient from '../shared/model/Patient' import ContactInfo from './ContactInfo' interface Error { diff --git a/src/patients/Patients.tsx b/src/patients/Patients.tsx index be40c699df..92e0995b59 100644 --- a/src/patients/Patients.tsx +++ b/src/patients/Patients.tsx @@ -2,9 +2,9 @@ import React from 'react' import { useSelector } from 'react-redux' import { Switch } from 'react-router-dom' -import PrivateRoute from '../components/PrivateRoute' -import Permissions from '../model/Permissions' -import { RootState } from '../store' +import PrivateRoute from '../shared/components/PrivateRoute' +import Permissions from '../shared/model/Permissions' +import { RootState } from '../shared/store' import EditPatient from './edit/EditPatient' import ViewPatients from './list/ViewPatients' import NewPatient from './new/NewPatient' diff --git a/src/patients/allergies/Allergies.tsx b/src/patients/allergies/Allergies.tsx index 9a8d9d5cc6..f39ffaa60a 100644 --- a/src/patients/allergies/Allergies.tsx +++ b/src/patients/allergies/Allergies.tsx @@ -3,11 +3,11 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import Allergy from '../../model/Allergy' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import Allergy from '../../shared/model/Allergy' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import NewAllergyModal from './NewAllergyModal' interface AllergiesProps { diff --git a/src/patients/allergies/NewAllergyModal.tsx b/src/patients/allergies/NewAllergyModal.tsx index 9ea5374bf3..9a5383df24 100644 --- a/src/patients/allergies/NewAllergyModal.tsx +++ b/src/patients/allergies/NewAllergyModal.tsx @@ -3,9 +3,9 @@ import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import Allergy from '../../model/Allergy' -import { RootState } from '../../store' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import Allergy from '../../shared/model/Allergy' +import { RootState } from '../../shared/store' import { addAllergy } from '../patient-slice' interface NewAllergyModalProps { diff --git a/src/patients/appointments/AppointmentsList.tsx b/src/patients/appointments/AppointmentsList.tsx index e8669fd7f8..93ee38e70d 100644 --- a/src/patients/appointments/AppointmentsList.tsx +++ b/src/patients/appointments/AppointmentsList.tsx @@ -4,9 +4,9 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' import { fetchPatientAppointments } from '../../scheduling/appointments/appointments-slice' -import { RootState } from '../../store' +import { RootState } from '../../shared/store' interface Props { patientId: string diff --git a/src/patients/care-plans/AddCarePlanModal.tsx b/src/patients/care-plans/AddCarePlanModal.tsx index 923652775b..7ecb0a4938 100644 --- a/src/patients/care-plans/AddCarePlanModal.tsx +++ b/src/patients/care-plans/AddCarePlanModal.tsx @@ -4,8 +4,8 @@ import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import CarePlan from '../../model/CarePlan' -import { RootState } from '../../store' +import CarePlan from '../../shared/model/CarePlan' +import { RootState } from '../../shared/store' import { addCarePlan } from '../patient-slice' import CarePlanForm from './CarePlanForm' diff --git a/src/patients/care-plans/CarePlanForm.tsx b/src/patients/care-plans/CarePlanForm.tsx index be517b45c7..b658d9dd99 100644 --- a/src/patients/care-plans/CarePlanForm.tsx +++ b/src/patients/care-plans/CarePlanForm.tsx @@ -2,12 +2,14 @@ import { Alert, Column, Row } from '@hospitalrun/components' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import DatePickerWithLabelFormGroup from '../../components/input/DatePickerWithLabelFormGroup' -import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../model/CarePlan' -import Patient from '../../model/Patient' +import DatePickerWithLabelFormGroup from '../../shared/components/input/DatePickerWithLabelFormGroup' +import SelectWithLabelFormGroup, { + Option, +} from '../../shared/components/input/SelectWithLableFormGroup' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import CarePlan, { CarePlanIntent, CarePlanStatus } from '../../shared/model/CarePlan' +import Patient from '../../shared/model/Patient' interface Error { message?: string diff --git a/src/patients/care-plans/CarePlanTab.tsx b/src/patients/care-plans/CarePlanTab.tsx index ecd6d11cc0..e52aca0142 100644 --- a/src/patients/care-plans/CarePlanTab.tsx +++ b/src/patients/care-plans/CarePlanTab.tsx @@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { Route, Switch } from 'react-router-dom' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import AddCarePlanModal from './AddCarePlanModal' import CarePlanTable from './CarePlanTable' import ViewCarePlan from './ViewCarePlan' diff --git a/src/patients/care-plans/CarePlanTable.tsx b/src/patients/care-plans/CarePlanTable.tsx index d621315078..44c40128a1 100644 --- a/src/patients/care-plans/CarePlanTable.tsx +++ b/src/patients/care-plans/CarePlanTable.tsx @@ -5,8 +5,8 @@ import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import CarePlan from '../../model/CarePlan' -import { RootState } from '../../store' +import CarePlan from '../../shared/model/CarePlan' +import { RootState } from '../../shared/store' const CarePlanTable = () => { const history = useHistory() diff --git a/src/patients/care-plans/ViewCarePlan.tsx b/src/patients/care-plans/ViewCarePlan.tsx index 0e098e3bd2..c24f9b0bd5 100644 --- a/src/patients/care-plans/ViewCarePlan.tsx +++ b/src/patients/care-plans/ViewCarePlan.tsx @@ -3,8 +3,8 @@ import React, { useEffect, useState } from 'react' import { useSelector } from 'react-redux' import { useParams } from 'react-router-dom' -import CarePlan from '../../model/CarePlan' -import { RootState } from '../../store' +import CarePlan from '../../shared/model/CarePlan' +import { RootState } from '../../shared/store' import CarePlanForm from './CarePlanForm' const ViewCarePlan = () => { diff --git a/src/patients/diagnoses/AddDiagnosisModal.tsx b/src/patients/diagnoses/AddDiagnosisModal.tsx index 110dab5f68..c42bbf5da5 100644 --- a/src/patients/diagnoses/AddDiagnosisModal.tsx +++ b/src/patients/diagnoses/AddDiagnosisModal.tsx @@ -3,10 +3,10 @@ import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import DatePickerWithLabelFormGroup from '../../components/input/DatePickerWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import Diagnosis from '../../model/Diagnosis' -import { RootState } from '../../store' +import DatePickerWithLabelFormGroup from '../../shared/components/input/DatePickerWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import Diagnosis from '../../shared/model/Diagnosis' +import { RootState } from '../../shared/store' import { addDiagnosis } from '../patient-slice' interface Props { diff --git a/src/patients/diagnoses/Diagnoses.tsx b/src/patients/diagnoses/Diagnoses.tsx index 78dd595e44..24465461af 100644 --- a/src/patients/diagnoses/Diagnoses.tsx +++ b/src/patients/diagnoses/Diagnoses.tsx @@ -3,11 +3,11 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import Diagnosis from '../../model/Diagnosis' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import Diagnosis from '../../shared/model/Diagnosis' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import AddDiagnosisModal from './AddDiagnosisModal' interface Props { diff --git a/src/patients/edit/EditPatient.tsx b/src/patients/edit/EditPatient.tsx index 292a827cfa..8eccc03c9e 100644 --- a/src/patients/edit/EditPatient.tsx +++ b/src/patients/edit/EditPatient.tsx @@ -4,10 +4,10 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory, useParams } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import Patient from '../../model/Patient' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../page-header/title/useTitle' +import Patient from '../../shared/model/Patient' +import { RootState } from '../../shared/store' import GeneralInformation from '../GeneralInformation' import { updatePatient, fetchPatient } from '../patient-slice' import { getPatientFullName } from '../util/patient-name-util' diff --git a/src/patients/labs/LabsTab.tsx b/src/patients/labs/LabsTab.tsx index 4d552c3f9b..03ec2a2a71 100644 --- a/src/patients/labs/LabsTab.tsx +++ b/src/patients/labs/LabsTab.tsx @@ -4,8 +4,8 @@ import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { useHistory } from 'react-router-dom' -import PatientRepository from '../../clients/db/PatientRepository' -import Lab from '../../model/Lab' +import PatientRepository from '../../shared/db/PatientRepository' +import Lab from '../../shared/model/Lab' interface Props { patientId: string diff --git a/src/patients/list/ViewPatients.tsx b/src/patients/list/ViewPatients.tsx index d310ae2f53..6729694332 100644 --- a/src/patients/list/ViewPatients.tsx +++ b/src/patients/list/ViewPatients.tsx @@ -5,13 +5,13 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import SortRequest from '../../clients/db/SortRequest' -import useDebounce from '../../hooks/debounce' -import useUpdateEffect from '../../hooks/useUpdateEffect' -import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import { useButtonToolbarSetter } from '../../page-header/button-toolbar/ButtonBarProvider' +import useTitle from '../../page-header/title/useTitle' +import SortRequest from '../../shared/db/SortRequest' +import useDebounce from '../../shared/hooks/useDebounce' +import useUpdateEffect from '../../shared/hooks/useUpdateEffect' +import { RootState } from '../../shared/store' import { searchPatients } from '../patients-slice' const breadcrumbs = [{ i18nKey: 'patients.label', location: '/patients' }] diff --git a/src/patients/new/NewPatient.tsx b/src/patients/new/NewPatient.tsx index a15a0b4ad5..3dbdb120dd 100644 --- a/src/patients/new/NewPatient.tsx +++ b/src/patients/new/NewPatient.tsx @@ -4,10 +4,10 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import Patient from '../../model/Patient' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../page-header/title/useTitle' +import Patient from '../../shared/model/Patient' +import { RootState } from '../../shared/store' import GeneralInformation from '../GeneralInformation' import { createPatient } from '../patient-slice' diff --git a/src/patients/notes/NewNoteModal.tsx b/src/patients/notes/NewNoteModal.tsx index 4363d45ee3..913e9a9ad4 100644 --- a/src/patients/notes/NewNoteModal.tsx +++ b/src/patients/notes/NewNoteModal.tsx @@ -3,9 +3,9 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' -import Note from '../../model/Note' -import { RootState } from '../../store' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import Note from '../../shared/model/Note' +import { RootState } from '../../shared/store' import { addNote } from '../patient-slice' interface Props { diff --git a/src/patients/notes/NoteTab.tsx b/src/patients/notes/NoteTab.tsx index ead93598fc..b91970ddf1 100644 --- a/src/patients/notes/NoteTab.tsx +++ b/src/patients/notes/NoteTab.tsx @@ -3,10 +3,10 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import Note from '../../model/Note' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import Note from '../../shared/model/Note' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import NewNoteModal from './NewNoteModal' interface Props { diff --git a/src/patients/patient-slice.ts b/src/patients/patient-slice.ts index 2f57aa67f9..b0a3b21292 100644 --- a/src/patients/patient-slice.ts +++ b/src/patients/patient-slice.ts @@ -3,15 +3,15 @@ import { isAfter, isBefore, parseISO } from 'date-fns' import { isEmpty } from 'lodash' import validator from 'validator' -import PatientRepository from '../clients/db/PatientRepository' -import Allergy from '../model/Allergy' -import CarePlan from '../model/CarePlan' -import Diagnosis from '../model/Diagnosis' -import Note from '../model/Note' -import Patient from '../model/Patient' -import RelatedPerson from '../model/RelatedPerson' -import { AppThunk } from '../store' -import { uuid } from '../util/uuid' +import PatientRepository from '../shared/db/PatientRepository' +import Allergy from '../shared/model/Allergy' +import CarePlan from '../shared/model/CarePlan' +import Diagnosis from '../shared/model/Diagnosis' +import Note from '../shared/model/Note' +import Patient from '../shared/model/Patient' +import RelatedPerson from '../shared/model/RelatedPerson' +import { AppThunk } from '../shared/store' +import { uuid } from '../shared/util/uuid' import { cleanupPatient } from './util/set-patient-helper' interface PatientState { diff --git a/src/patients/patients-slice.ts b/src/patients/patients-slice.ts index 2a42bc3c61..e3daa42d56 100644 --- a/src/patients/patients-slice.ts +++ b/src/patients/patients-slice.ts @@ -1,9 +1,9 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import PatientRepository from '../clients/db/PatientRepository' -import SortRequest, { Unsorted } from '../clients/db/SortRequest' -import Patient from '../model/Patient' -import { AppThunk } from '../store' +import PatientRepository from '../shared/db/PatientRepository' +import SortRequest, { Unsorted } from '../shared/db/SortRequest' +import Patient from '../shared/model/Patient' +import { AppThunk } from '../shared/store' interface PatientsState { isLoading: boolean diff --git a/src/patients/related-persons/AddRelatedPersonModal.tsx b/src/patients/related-persons/AddRelatedPersonModal.tsx index d5c844d58e..e3bca43c37 100644 --- a/src/patients/related-persons/AddRelatedPersonModal.tsx +++ b/src/patients/related-persons/AddRelatedPersonModal.tsx @@ -4,11 +4,11 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' -import PatientRepository from '../../clients/db/PatientRepository' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import Patient from '../../model/Patient' -import RelatedPerson from '../../model/RelatedPerson' -import { RootState } from '../../store' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import PatientRepository from '../../shared/db/PatientRepository' +import Patient from '../../shared/model/Patient' +import RelatedPerson from '../../shared/model/RelatedPerson' +import { RootState } from '../../shared/store' import { addRelatedPerson } from '../patient-slice' interface Props { diff --git a/src/patients/related-persons/RelatedPersonTab.tsx b/src/patients/related-persons/RelatedPersonTab.tsx index 526abe4097..81dfef9967 100644 --- a/src/patients/related-persons/RelatedPersonTab.tsx +++ b/src/patients/related-persons/RelatedPersonTab.tsx @@ -4,11 +4,11 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import PatientRepository from '../../clients/db/PatientRepository' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import PatientRepository from '../../shared/db/PatientRepository' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import { removeRelatedPerson } from '../patient-slice' import AddRelatedPersonModal from './AddRelatedPersonModal' diff --git a/src/patients/util/patient-name-util.ts b/src/patients/util/patient-name-util.ts index 3b6b8b86c5..e4dee31524 100644 --- a/src/patients/util/patient-name-util.ts +++ b/src/patients/util/patient-name-util.ts @@ -1,4 +1,4 @@ -import Patient from '../../model/Patient' +import Patient from '../../shared/model/Patient' const getNamePartString = (namePart: string | undefined) => { if (!namePart) { diff --git a/src/patients/util/set-patient-helper.ts b/src/patients/util/set-patient-helper.ts index 641ef8c013..87af353bd8 100644 --- a/src/patients/util/set-patient-helper.ts +++ b/src/patients/util/set-patient-helper.ts @@ -1,4 +1,4 @@ -import Patient from '../../model/Patient' +import Patient from '../../shared/model/Patient' import { getPatientName } from './patient-name-util' /** diff --git a/src/patients/view/ViewPatient.tsx b/src/patients/view/ViewPatient.tsx index a998212e88..0f26ebe03a 100644 --- a/src/patients/view/ViewPatient.tsx +++ b/src/patients/view/ViewPatient.tsx @@ -11,12 +11,12 @@ import { useRouteMatch, } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import Patient from '../../model/Patient' -import Permissions from '../../model/Permissions' -import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import { useButtonToolbarSetter } from '../../page-header/button-toolbar/ButtonBarProvider' +import useTitle from '../../page-header/title/useTitle' +import Patient from '../../shared/model/Patient' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import Allergies from '../allergies/Allergies' import AppointmentsList from '../appointments/AppointmentsList' import CarePlanTab from '../care-plans/CarePlanTab' diff --git a/src/scheduling/appointments/AppointmentDetailForm.tsx b/src/scheduling/appointments/AppointmentDetailForm.tsx index a43b591c47..e8f4139b4f 100644 --- a/src/scheduling/appointments/AppointmentDetailForm.tsx +++ b/src/scheduling/appointments/AppointmentDetailForm.tsx @@ -2,13 +2,15 @@ import { Typeahead, Label, Alert } from '@hospitalrun/components' import React from 'react' import { useTranslation } from 'react-i18next' -import PatientRepository from '../../clients/db/PatientRepository' -import DateTimePickerWithLabelFormGroup from '../../components/input/DateTimePickerWithLabelFormGroup' -import SelectWithLabelFormGroup, { Option } from '../../components/input/SelectWithLableFormGroup' -import TextFieldWithLabelFormGroup from '../../components/input/TextFieldWithLabelFormGroup' -import TextInputWithLabelFormGroup from '../../components/input/TextInputWithLabelFormGroup' -import Appointment from '../../model/Appointment' -import Patient from '../../model/Patient' +import DateTimePickerWithLabelFormGroup from '../../shared/components/input/DateTimePickerWithLabelFormGroup' +import SelectWithLabelFormGroup, { + Option, +} from '../../shared/components/input/SelectWithLableFormGroup' +import TextFieldWithLabelFormGroup from '../../shared/components/input/TextFieldWithLabelFormGroup' +import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup' +import PatientRepository from '../../shared/db/PatientRepository' +import Appointment from '../../shared/model/Appointment' +import Patient from '../../shared/model/Patient' interface Props { appointment: Appointment diff --git a/src/scheduling/appointments/Appointments.tsx b/src/scheduling/appointments/Appointments.tsx index 2166722519..b90ec73d19 100644 --- a/src/scheduling/appointments/Appointments.tsx +++ b/src/scheduling/appointments/Appointments.tsx @@ -2,9 +2,9 @@ import React from 'react' import { useSelector } from 'react-redux' import { Switch } from 'react-router-dom' -import PrivateRoute from '../../components/PrivateRoute' -import Permissions from '../../model/Permissions' -import { RootState } from '../../store' +import PrivateRoute from '../../shared/components/PrivateRoute' +import Permissions from '../../shared/model/Permissions' +import { RootState } from '../../shared/store' import EditAppointment from './edit/EditAppointment' import NewAppointment from './new/NewAppointment' import ViewAppointment from './view/ViewAppointment' diff --git a/src/scheduling/appointments/ViewAppointments.tsx b/src/scheduling/appointments/ViewAppointments.tsx index 21dcd129de..df60389573 100644 --- a/src/scheduling/appointments/ViewAppointments.tsx +++ b/src/scheduling/appointments/ViewAppointments.tsx @@ -4,11 +4,11 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' -import PatientRepository from '../../clients/db/PatientRepository' -import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider' -import useTitle from '../../page-header/useTitle' -import { RootState } from '../../store' +import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs' +import { useButtonToolbarSetter } from '../../page-header/button-toolbar/ButtonBarProvider' +import useTitle from '../../page-header/title/useTitle' +import PatientRepository from '../../shared/db/PatientRepository' +import { RootState } from '../../shared/store' import { fetchAppointments } from './appointments-slice' interface Event { diff --git a/src/scheduling/appointments/appointment-slice.ts b/src/scheduling/appointments/appointment-slice.ts index 2f6e1e8e07..413c8820f6 100644 --- a/src/scheduling/appointments/appointment-slice.ts +++ b/src/scheduling/appointments/appointment-slice.ts @@ -2,11 +2,11 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { isBefore } from 'date-fns' import _ from 'lodash' -import AppointmentRepository from '../../clients/db/AppointmentRepository' -import PatientRepository from '../../clients/db/PatientRepository' -import Appointment from '../../model/Appointment' -import Patient from '../../model/Patient' -import { AppThunk } from '../../store' +import AppointmentRepository from '../../shared/db/AppointmentRepository' +import PatientRepository from '../../shared/db/PatientRepository' +import Appointment from '../../shared/model/Appointment' +import Patient from '../../shared/model/Patient' +import { AppThunk } from '../../shared/store' function validateAppointment(appointment: Appointment) { const err: Error = {} diff --git a/src/scheduling/appointments/appointments-slice.ts b/src/scheduling/appointments/appointments-slice.ts index 5d7bc8513b..edf21ece5c 100644 --- a/src/scheduling/appointments/appointments-slice.ts +++ b/src/scheduling/appointments/appointments-slice.ts @@ -1,9 +1,9 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import AppointmentRepository from '../../clients/db/AppointmentRepository' -import PatientRepository from '../../clients/db/PatientRepository' -import Appointment from '../../model/Appointment' -import { AppThunk } from '../../store' +import AppointmentRepository from '../../shared/db/AppointmentRepository' +import PatientRepository from '../../shared/db/PatientRepository' +import Appointment from '../../shared/model/Appointment' +import { AppThunk } from '../../shared/store' interface AppointmentsState { isLoading: boolean diff --git a/src/scheduling/appointments/edit/EditAppointment.tsx b/src/scheduling/appointments/edit/EditAppointment.tsx index 765700f8f5..94280e1ddd 100644 --- a/src/scheduling/appointments/edit/EditAppointment.tsx +++ b/src/scheduling/appointments/edit/EditAppointment.tsx @@ -4,10 +4,10 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory, useParams } from 'react-router-dom' -import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' -import Appointment from '../../../model/Appointment' -import useTitle from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import useAddBreadcrumbs from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../../page-header/title/useTitle' +import Appointment from '../../../shared/model/Appointment' +import { RootState } from '../../../shared/store' import { updateAppointment, fetchAppointment } from '../appointment-slice' import AppointmentDetailForm from '../AppointmentDetailForm' import { getAppointmentLabel } from '../util/scheduling-appointment.util' diff --git a/src/scheduling/appointments/new/NewAppointment.tsx b/src/scheduling/appointments/new/NewAppointment.tsx index 778e74b970..49c2687896 100644 --- a/src/scheduling/appointments/new/NewAppointment.tsx +++ b/src/scheduling/appointments/new/NewAppointment.tsx @@ -6,10 +6,10 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' -import Appointment from '../../../model/Appointment' -import useTitle from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import useAddBreadcrumbs from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import useTitle from '../../../page-header/title/useTitle' +import Appointment from '../../../shared/model/Appointment' +import { RootState } from '../../../shared/store' import { createAppointment } from '../appointment-slice' import AppointmentDetailForm from '../AppointmentDetailForm' diff --git a/src/scheduling/appointments/util/scheduling-appointment.util.ts b/src/scheduling/appointments/util/scheduling-appointment.util.ts index eb1d28bdd8..32604500a6 100644 --- a/src/scheduling/appointments/util/scheduling-appointment.util.ts +++ b/src/scheduling/appointments/util/scheduling-appointment.util.ts @@ -1,4 +1,4 @@ -import Appointment from '../../../model/Appointment' +import Appointment from '../../../shared/model/Appointment' const options = { year: 'numeric', diff --git a/src/scheduling/appointments/view/ViewAppointment.tsx b/src/scheduling/appointments/view/ViewAppointment.tsx index cf3782ee93..221fe0d868 100644 --- a/src/scheduling/appointments/view/ViewAppointment.tsx +++ b/src/scheduling/appointments/view/ViewAppointment.tsx @@ -4,11 +4,11 @@ import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import { useParams, useHistory } from 'react-router-dom' -import useAddBreadcrumbs from '../../../breadcrumbs/useAddBreadcrumbs' -import Permissions from '../../../model/Permissions' -import { useButtonToolbarSetter } from '../../../page-header/ButtonBarProvider' -import useTitle from '../../../page-header/useTitle' -import { RootState } from '../../../store' +import useAddBreadcrumbs from '../../../page-header/breadcrumbs/useAddBreadcrumbs' +import { useButtonToolbarSetter } from '../../../page-header/button-toolbar/ButtonBarProvider' +import useTitle from '../../../page-header/title/useTitle' +import Permissions from '../../../shared/model/Permissions' +import { RootState } from '../../../shared/store' import { fetchAppointment, deleteAppointment } from '../appointment-slice' import AppointmentDetailForm from '../AppointmentDetailForm' import { getAppointmentLabel } from '../util/scheduling-appointment.util' diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 74df245d45..d3fe2dc91f 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -2,8 +2,8 @@ import { Row, Column } from '@hospitalrun/components' import React from 'react' import { useTranslation } from 'react-i18next' -import LanguageSelector from '../components/input/LanguageSelector' -import useTitle from '../page-header/useTitle' +import useTitle from '../page-header/title/useTitle' +import LanguageSelector from '../shared/components/input/LanguageSelector' const Settings = () => { const { t } = useTranslation() diff --git a/src/setupTests.js b/src/setupTests.js index df94f8bf90..c4dd3d9893 100644 --- a/src/setupTests.js +++ b/src/setupTests.js @@ -2,4 +2,8 @@ import Enzyme from 'enzyme' import Adapter from 'enzyme-adapter-react-16' +import './__mocks__/i18next' +import './__mocks__/matchMediaMock' +import './__mocks__/react-i18next' + Enzyme.configure({ adapter: new Adapter() }) diff --git a/src/components/PageComponent.tsx b/src/shared/components/PageComponent.tsx similarity index 100% rename from src/components/PageComponent.tsx rename to src/shared/components/PageComponent.tsx diff --git a/src/components/PrivateRoute.tsx b/src/shared/components/PrivateRoute.tsx similarity index 100% rename from src/components/PrivateRoute.tsx rename to src/shared/components/PrivateRoute.tsx diff --git a/src/components/Sidebar.tsx b/src/shared/components/Sidebar.tsx similarity index 100% rename from src/components/Sidebar.tsx rename to src/shared/components/Sidebar.tsx diff --git a/src/components/component-slice.ts b/src/shared/components/component-slice.ts similarity index 100% rename from src/components/component-slice.ts rename to src/shared/components/component-slice.ts diff --git a/src/components/input/DatePickerWithLabelFormGroup.tsx b/src/shared/components/input/DatePickerWithLabelFormGroup.tsx similarity index 100% rename from src/components/input/DatePickerWithLabelFormGroup.tsx rename to src/shared/components/input/DatePickerWithLabelFormGroup.tsx diff --git a/src/components/input/DateTimePickerWithLabelFormGroup.tsx b/src/shared/components/input/DateTimePickerWithLabelFormGroup.tsx similarity index 100% rename from src/components/input/DateTimePickerWithLabelFormGroup.tsx rename to src/shared/components/input/DateTimePickerWithLabelFormGroup.tsx diff --git a/src/components/input/LanguageSelector.tsx b/src/shared/components/input/LanguageSelector.tsx similarity index 94% rename from src/components/input/LanguageSelector.tsx rename to src/shared/components/input/LanguageSelector.tsx index c6f55e05d6..349df6ba04 100644 --- a/src/components/input/LanguageSelector.tsx +++ b/src/shared/components/input/LanguageSelector.tsx @@ -2,7 +2,7 @@ import { sortBy } from 'lodash' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import i18n, { resources } from '../../i18n' +import i18n, { resources } from '../../config/i18n' import SelectWithLabelFormGroup, { Option } from './SelectWithLableFormGroup' const LanguageSelector = () => { diff --git a/src/components/input/SelectWithLableFormGroup.tsx b/src/shared/components/input/SelectWithLableFormGroup.tsx similarity index 100% rename from src/components/input/SelectWithLableFormGroup.tsx rename to src/shared/components/input/SelectWithLableFormGroup.tsx diff --git a/src/components/input/TextFieldWithLabelFormGroup.tsx b/src/shared/components/input/TextFieldWithLabelFormGroup.tsx similarity index 100% rename from src/components/input/TextFieldWithLabelFormGroup.tsx rename to src/shared/components/input/TextFieldWithLabelFormGroup.tsx diff --git a/src/components/input/TextInputWithLabelFormGroup.tsx b/src/shared/components/input/TextInputWithLabelFormGroup.tsx similarity index 100% rename from src/components/input/TextInputWithLabelFormGroup.tsx rename to src/shared/components/input/TextInputWithLabelFormGroup.tsx diff --git a/src/components/Navbar.tsx b/src/shared/components/navbar/Navbar.tsx similarity index 97% rename from src/components/Navbar.tsx rename to src/shared/components/navbar/Navbar.tsx index 86cb9a67bc..fd47e8eb8b 100644 --- a/src/components/Navbar.tsx +++ b/src/shared/components/navbar/Navbar.tsx @@ -4,9 +4,9 @@ import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import pageMap, { Page } from '../pageMap' -import { RootState } from '../store' -import { logout } from '../user/user-slice' +import { logout } from '../../../user/user-slice' +import { RootState } from '../../store' +import pageMap, { Page } from './pageMap' const Navbar = () => { const dispatch = useDispatch() diff --git a/src/pageMap.tsx b/src/shared/components/navbar/pageMap.tsx similarity index 96% rename from src/pageMap.tsx rename to src/shared/components/navbar/pageMap.tsx index 235c71b9d2..37c889edeb 100644 --- a/src/pageMap.tsx +++ b/src/shared/components/navbar/pageMap.tsx @@ -1,4 +1,4 @@ -import Permissions from './model/Permissions' +import Permissions from '../../model/Permissions' type Page = { permission: Permissions | null; label: string; path: string } diff --git a/src/components/network-status/NetworkStatusMessage.tsx b/src/shared/components/network-status/NetworkStatusMessage.tsx similarity index 100% rename from src/components/network-status/NetworkStatusMessage.tsx rename to src/shared/components/network-status/NetworkStatusMessage.tsx diff --git a/src/components/network-status/index.ts b/src/shared/components/network-status/index.ts similarity index 100% rename from src/components/network-status/index.ts rename to src/shared/components/network-status/index.ts diff --git a/src/components/network-status/types.ts b/src/shared/components/network-status/types.ts similarity index 100% rename from src/components/network-status/types.ts rename to src/shared/components/network-status/types.ts diff --git a/src/components/network-status/useNetworkStatus.ts b/src/shared/components/network-status/useNetworkStatus.ts similarity index 100% rename from src/components/network-status/useNetworkStatus.ts rename to src/shared/components/network-status/useNetworkStatus.ts diff --git a/src/i18n.ts b/src/shared/config/i18n.ts similarity index 95% rename from src/i18n.ts rename to src/shared/config/i18n.ts index eb1abeff60..7adc8d765b 100644 --- a/src/i18n.ts +++ b/src/shared/config/i18n.ts @@ -2,7 +2,7 @@ import i18n from 'i18next' import LanguageDetector from 'i18next-browser-languagedetector' import { initReactI18next } from 'react-i18next' -import resources from './locales' +import resources from '../locales' i18n // load translation using xhr -> see /public/locales diff --git a/src/config/pouchdb.ts b/src/shared/config/pouchdb.ts similarity index 100% rename from src/config/pouchdb.ts rename to src/shared/config/pouchdb.ts diff --git a/src/clients/db/AppointmentRepository.ts b/src/shared/db/AppointmentRepository.ts similarity index 92% rename from src/clients/db/AppointmentRepository.ts rename to src/shared/db/AppointmentRepository.ts index f08ea60456..36adcea156 100644 --- a/src/clients/db/AppointmentRepository.ts +++ b/src/shared/db/AppointmentRepository.ts @@ -1,7 +1,7 @@ import escapeStringRegexp from 'escape-string-regexp' -import { relationalDb } from '../../config/pouchdb' -import Appointment from '../../model/Appointment' +import { relationalDb } from '../config/pouchdb' +import Appointment from '../model/Appointment' import Repository from './Repository' class AppointmentRepository extends Repository { diff --git a/src/clients/db/IncidentRepository.ts b/src/shared/db/IncidentRepository.ts similarity index 88% rename from src/clients/db/IncidentRepository.ts rename to src/shared/db/IncidentRepository.ts index 384a73b1e6..262c493f80 100644 --- a/src/clients/db/IncidentRepository.ts +++ b/src/shared/db/IncidentRepository.ts @@ -1,6 +1,6 @@ -import { relationalDb } from '../../config/pouchdb' import IncidentFilter from '../../incidents/IncidentFilter' -import Incident from '../../model/Incident' +import { relationalDb } from '../config/pouchdb' +import Incident from '../model/Incident' import Repository from './Repository' interface SearchOptions { diff --git a/src/clients/db/LabRepository.ts b/src/shared/db/LabRepository.ts similarity index 90% rename from src/clients/db/LabRepository.ts rename to src/shared/db/LabRepository.ts index 4db49abb93..c7cf9e5cc8 100644 --- a/src/clients/db/LabRepository.ts +++ b/src/shared/db/LabRepository.ts @@ -1,6 +1,6 @@ -import { relationalDb } from '../../config/pouchdb' -import Lab from '../../model/Lab' -import generateCode from '../../util/generateCode' +import { relationalDb } from '../config/pouchdb' +import Lab from '../model/Lab' +import generateCode from '../util/generateCode' import Repository from './Repository' import SortRequest from './SortRequest' diff --git a/src/clients/Page.ts b/src/shared/db/Page.ts similarity index 82% rename from src/clients/Page.ts rename to src/shared/db/Page.ts index ec830a1f14..d2ad55263b 100644 --- a/src/clients/Page.ts +++ b/src/shared/db/Page.ts @@ -1,5 +1,5 @@ import AbstractDBModel from '../model/AbstractDBModel' -import PageRequest from './db/PageRequest' +import PageRequest from './PageRequest' export default interface Page { content: T[] diff --git a/src/clients/db/PageRequest.ts b/src/shared/db/PageRequest.ts similarity index 100% rename from src/clients/db/PageRequest.ts rename to src/shared/db/PageRequest.ts diff --git a/src/clients/db/PatientRepository.ts b/src/shared/db/PatientRepository.ts similarity index 85% rename from src/clients/db/PatientRepository.ts rename to src/shared/db/PatientRepository.ts index 1406996d1f..81ca68d356 100644 --- a/src/clients/db/PatientRepository.ts +++ b/src/shared/db/PatientRepository.ts @@ -1,10 +1,10 @@ import escapeStringRegexp from 'escape-string-regexp' -import { relationalDb } from '../../config/pouchdb' -import Appointment from '../../model/Appointment' -import Lab from '../../model/Lab' -import Patient from '../../model/Patient' -import generateCode from '../../util/generateCode' +import { relationalDb } from '../config/pouchdb' +import Appointment from '../model/Appointment' +import Lab from '../model/Lab' +import Patient from '../model/Patient' +import generateCode from '../util/generateCode' import Repository from './Repository' class PatientRepository extends Repository { diff --git a/src/clients/db/Repository.ts b/src/shared/db/Repository.ts similarity index 98% rename from src/clients/db/Repository.ts rename to src/shared/db/Repository.ts index 4c942b4eb2..d19e3c12cf 100644 --- a/src/clients/db/Repository.ts +++ b/src/shared/db/Repository.ts @@ -1,7 +1,7 @@ import { v4 as uuidv4 } from 'uuid' -import { schema } from '../../config/pouchdb' -import AbstractDBModel from '../../model/AbstractDBModel' +import { schema } from '../config/pouchdb' +import AbstractDBModel from '../model/AbstractDBModel' import SortRequest, { Unsorted } from './SortRequest' export default class Repository { diff --git a/src/clients/db/Search.ts b/src/shared/db/Search.ts similarity index 100% rename from src/clients/db/Search.ts rename to src/shared/db/Search.ts diff --git a/src/clients/Sort.ts b/src/shared/db/Sort.ts similarity index 100% rename from src/clients/Sort.ts rename to src/shared/db/Sort.ts diff --git a/src/clients/db/SortRequest.ts b/src/shared/db/SortRequest.ts similarity index 80% rename from src/clients/db/SortRequest.ts rename to src/shared/db/SortRequest.ts index fde109b2cd..2e0ebdb486 100644 --- a/src/clients/db/SortRequest.ts +++ b/src/shared/db/SortRequest.ts @@ -1,4 +1,4 @@ -import Sort from '../Sort' +import Sort from './Sort' export default interface SortRequest { sorts: Sort[] diff --git a/src/hooks/debounce.ts b/src/shared/hooks/useDebounce.ts similarity index 100% rename from src/hooks/debounce.ts rename to src/shared/hooks/useDebounce.ts diff --git a/src/hooks/useUpdateEffect.ts b/src/shared/hooks/useUpdateEffect.ts similarity index 100% rename from src/hooks/useUpdateEffect.ts rename to src/shared/hooks/useUpdateEffect.ts diff --git a/src/locales/README.md b/src/shared/locales/README.md similarity index 100% rename from src/locales/README.md rename to src/shared/locales/README.md diff --git a/src/locales/ar/translations/actions/index.ts b/src/shared/locales/ar/translations/actions/index.ts similarity index 100% rename from src/locales/ar/translations/actions/index.ts rename to src/shared/locales/ar/translations/actions/index.ts diff --git a/src/locales/ar/translations/dashboard/index.ts b/src/shared/locales/ar/translations/dashboard/index.ts similarity index 100% rename from src/locales/ar/translations/dashboard/index.ts rename to src/shared/locales/ar/translations/dashboard/index.ts diff --git a/src/locales/ar/translations/index.ts b/src/shared/locales/ar/translations/index.ts similarity index 100% rename from src/locales/ar/translations/index.ts rename to src/shared/locales/ar/translations/index.ts diff --git a/src/locales/ar/translations/labs/index.ts b/src/shared/locales/ar/translations/labs/index.ts similarity index 100% rename from src/locales/ar/translations/labs/index.ts rename to src/shared/locales/ar/translations/labs/index.ts diff --git a/src/locales/ar/translations/patient/index.ts b/src/shared/locales/ar/translations/patient/index.ts similarity index 100% rename from src/locales/ar/translations/patient/index.ts rename to src/shared/locales/ar/translations/patient/index.ts diff --git a/src/locales/ar/translations/patients/index.ts b/src/shared/locales/ar/translations/patients/index.ts similarity index 100% rename from src/locales/ar/translations/patients/index.ts rename to src/shared/locales/ar/translations/patients/index.ts diff --git a/src/locales/ar/translations/settings/index.ts b/src/shared/locales/ar/translations/settings/index.ts similarity index 100% rename from src/locales/ar/translations/settings/index.ts rename to src/shared/locales/ar/translations/settings/index.ts diff --git a/src/locales/de/translations/actions/index.ts b/src/shared/locales/de/translations/actions/index.ts similarity index 100% rename from src/locales/de/translations/actions/index.ts rename to src/shared/locales/de/translations/actions/index.ts diff --git a/src/locales/de/translations/dashboard/index.ts b/src/shared/locales/de/translations/dashboard/index.ts similarity index 100% rename from src/locales/de/translations/dashboard/index.ts rename to src/shared/locales/de/translations/dashboard/index.ts diff --git a/src/locales/de/translations/incidents/index.ts b/src/shared/locales/de/translations/incidents/index.ts similarity index 100% rename from src/locales/de/translations/incidents/index.ts rename to src/shared/locales/de/translations/incidents/index.ts diff --git a/src/locales/de/translations/index.ts b/src/shared/locales/de/translations/index.ts similarity index 100% rename from src/locales/de/translations/index.ts rename to src/shared/locales/de/translations/index.ts diff --git a/src/locales/de/translations/labs/index.ts b/src/shared/locales/de/translations/labs/index.ts similarity index 100% rename from src/locales/de/translations/labs/index.ts rename to src/shared/locales/de/translations/labs/index.ts diff --git a/src/locales/de/translations/patient/index.ts b/src/shared/locales/de/translations/patient/index.ts similarity index 100% rename from src/locales/de/translations/patient/index.ts rename to src/shared/locales/de/translations/patient/index.ts diff --git a/src/locales/de/translations/patients/index.ts b/src/shared/locales/de/translations/patients/index.ts similarity index 100% rename from src/locales/de/translations/patients/index.ts rename to src/shared/locales/de/translations/patients/index.ts diff --git a/src/locales/de/translations/scheduling/index.ts b/src/shared/locales/de/translations/scheduling/index.ts similarity index 100% rename from src/locales/de/translations/scheduling/index.ts rename to src/shared/locales/de/translations/scheduling/index.ts diff --git a/src/locales/de/translations/settings/index.ts b/src/shared/locales/de/translations/settings/index.ts similarity index 100% rename from src/locales/de/translations/settings/index.ts rename to src/shared/locales/de/translations/settings/index.ts diff --git a/src/locales/de/translations/sex/index.ts b/src/shared/locales/de/translations/sex/index.ts similarity index 100% rename from src/locales/de/translations/sex/index.ts rename to src/shared/locales/de/translations/sex/index.ts diff --git a/src/locales/de/translations/states/index.ts b/src/shared/locales/de/translations/states/index.ts similarity index 100% rename from src/locales/de/translations/states/index.ts rename to src/shared/locales/de/translations/states/index.ts diff --git a/src/locales/enUs/translations/actions/index.ts b/src/shared/locales/enUs/translations/actions/index.ts similarity index 100% rename from src/locales/enUs/translations/actions/index.ts rename to src/shared/locales/enUs/translations/actions/index.ts diff --git a/src/locales/enUs/translations/dashboard/index.ts b/src/shared/locales/enUs/translations/dashboard/index.ts similarity index 100% rename from src/locales/enUs/translations/dashboard/index.ts rename to src/shared/locales/enUs/translations/dashboard/index.ts diff --git a/src/locales/enUs/translations/incidents/index.ts b/src/shared/locales/enUs/translations/incidents/index.ts similarity index 100% rename from src/locales/enUs/translations/incidents/index.ts rename to src/shared/locales/enUs/translations/incidents/index.ts diff --git a/src/locales/enUs/translations/index.ts b/src/shared/locales/enUs/translations/index.ts similarity index 100% rename from src/locales/enUs/translations/index.ts rename to src/shared/locales/enUs/translations/index.ts diff --git a/src/locales/enUs/translations/labs/index.ts b/src/shared/locales/enUs/translations/labs/index.ts similarity index 100% rename from src/locales/enUs/translations/labs/index.ts rename to src/shared/locales/enUs/translations/labs/index.ts diff --git a/src/locales/enUs/translations/network-status/index.ts b/src/shared/locales/enUs/translations/network-status/index.ts similarity index 100% rename from src/locales/enUs/translations/network-status/index.ts rename to src/shared/locales/enUs/translations/network-status/index.ts diff --git a/src/locales/enUs/translations/patient/index.ts b/src/shared/locales/enUs/translations/patient/index.ts similarity index 100% rename from src/locales/enUs/translations/patient/index.ts rename to src/shared/locales/enUs/translations/patient/index.ts diff --git a/src/locales/enUs/translations/patients/index.ts b/src/shared/locales/enUs/translations/patients/index.ts similarity index 100% rename from src/locales/enUs/translations/patients/index.ts rename to src/shared/locales/enUs/translations/patients/index.ts diff --git a/src/locales/enUs/translations/scheduling/index.ts b/src/shared/locales/enUs/translations/scheduling/index.ts similarity index 100% rename from src/locales/enUs/translations/scheduling/index.ts rename to src/shared/locales/enUs/translations/scheduling/index.ts diff --git a/src/locales/enUs/translations/settings/index.ts b/src/shared/locales/enUs/translations/settings/index.ts similarity index 100% rename from src/locales/enUs/translations/settings/index.ts rename to src/shared/locales/enUs/translations/settings/index.ts diff --git a/src/locales/enUs/translations/sex/index.ts b/src/shared/locales/enUs/translations/sex/index.ts similarity index 100% rename from src/locales/enUs/translations/sex/index.ts rename to src/shared/locales/enUs/translations/sex/index.ts diff --git a/src/locales/enUs/translations/states/index.ts b/src/shared/locales/enUs/translations/states/index.ts similarity index 100% rename from src/locales/enUs/translations/states/index.ts rename to src/shared/locales/enUs/translations/states/index.ts diff --git a/src/locales/es/translations/actions/index.ts b/src/shared/locales/es/translations/actions/index.ts similarity index 100% rename from src/locales/es/translations/actions/index.ts rename to src/shared/locales/es/translations/actions/index.ts diff --git a/src/locales/es/translations/dashboard/index.ts b/src/shared/locales/es/translations/dashboard/index.ts similarity index 100% rename from src/locales/es/translations/dashboard/index.ts rename to src/shared/locales/es/translations/dashboard/index.ts diff --git a/src/locales/es/translations/index.ts b/src/shared/locales/es/translations/index.ts similarity index 100% rename from src/locales/es/translations/index.ts rename to src/shared/locales/es/translations/index.ts diff --git a/src/locales/es/translations/labs/index.ts b/src/shared/locales/es/translations/labs/index.ts similarity index 100% rename from src/locales/es/translations/labs/index.ts rename to src/shared/locales/es/translations/labs/index.ts diff --git a/src/locales/es/translations/patient/index.ts b/src/shared/locales/es/translations/patient/index.ts similarity index 100% rename from src/locales/es/translations/patient/index.ts rename to src/shared/locales/es/translations/patient/index.ts diff --git a/src/locales/es/translations/patients/index.ts b/src/shared/locales/es/translations/patients/index.ts similarity index 100% rename from src/locales/es/translations/patients/index.ts rename to src/shared/locales/es/translations/patients/index.ts diff --git a/src/locales/es/translations/settings/index.ts b/src/shared/locales/es/translations/settings/index.ts similarity index 100% rename from src/locales/es/translations/settings/index.ts rename to src/shared/locales/es/translations/settings/index.ts diff --git a/src/locales/fr/translations/actions/index.ts b/src/shared/locales/fr/translations/actions/index.ts similarity index 100% rename from src/locales/fr/translations/actions/index.ts rename to src/shared/locales/fr/translations/actions/index.ts diff --git a/src/locales/fr/translations/dashboard/index.ts b/src/shared/locales/fr/translations/dashboard/index.ts similarity index 100% rename from src/locales/fr/translations/dashboard/index.ts rename to src/shared/locales/fr/translations/dashboard/index.ts diff --git a/src/locales/fr/translations/index.ts b/src/shared/locales/fr/translations/index.ts similarity index 100% rename from src/locales/fr/translations/index.ts rename to src/shared/locales/fr/translations/index.ts diff --git a/src/locales/fr/translations/labs/index.ts b/src/shared/locales/fr/translations/labs/index.ts similarity index 100% rename from src/locales/fr/translations/labs/index.ts rename to src/shared/locales/fr/translations/labs/index.ts diff --git a/src/locales/fr/translations/patient/index.ts b/src/shared/locales/fr/translations/patient/index.ts similarity index 100% rename from src/locales/fr/translations/patient/index.ts rename to src/shared/locales/fr/translations/patient/index.ts diff --git a/src/locales/fr/translations/patients/index.ts b/src/shared/locales/fr/translations/patients/index.ts similarity index 100% rename from src/locales/fr/translations/patients/index.ts rename to src/shared/locales/fr/translations/patients/index.ts diff --git a/src/locales/fr/translations/scheduling/index.ts b/src/shared/locales/fr/translations/scheduling/index.ts similarity index 100% rename from src/locales/fr/translations/scheduling/index.ts rename to src/shared/locales/fr/translations/scheduling/index.ts diff --git a/src/locales/fr/translations/settings/index.ts b/src/shared/locales/fr/translations/settings/index.ts similarity index 100% rename from src/locales/fr/translations/settings/index.ts rename to src/shared/locales/fr/translations/settings/index.ts diff --git a/src/locales/fr/translations/sex/index.ts b/src/shared/locales/fr/translations/sex/index.ts similarity index 100% rename from src/locales/fr/translations/sex/index.ts rename to src/shared/locales/fr/translations/sex/index.ts diff --git a/src/locales/fr/translations/states/index.ts b/src/shared/locales/fr/translations/states/index.ts similarity index 100% rename from src/locales/fr/translations/states/index.ts rename to src/shared/locales/fr/translations/states/index.ts diff --git a/src/locales/id/translations/actions/index.ts b/src/shared/locales/id/translations/actions/index.ts similarity index 100% rename from src/locales/id/translations/actions/index.ts rename to src/shared/locales/id/translations/actions/index.ts diff --git a/src/locales/id/translations/dashboard/index.ts b/src/shared/locales/id/translations/dashboard/index.ts similarity index 100% rename from src/locales/id/translations/dashboard/index.ts rename to src/shared/locales/id/translations/dashboard/index.ts diff --git a/src/locales/id/translations/index.ts b/src/shared/locales/id/translations/index.ts similarity index 100% rename from src/locales/id/translations/index.ts rename to src/shared/locales/id/translations/index.ts diff --git a/src/locales/id/translations/labs/index.ts b/src/shared/locales/id/translations/labs/index.ts similarity index 100% rename from src/locales/id/translations/labs/index.ts rename to src/shared/locales/id/translations/labs/index.ts diff --git a/src/locales/id/translations/patient/index.ts b/src/shared/locales/id/translations/patient/index.ts similarity index 100% rename from src/locales/id/translations/patient/index.ts rename to src/shared/locales/id/translations/patient/index.ts diff --git a/src/locales/id/translations/patients/index.ts b/src/shared/locales/id/translations/patients/index.ts similarity index 100% rename from src/locales/id/translations/patients/index.ts rename to src/shared/locales/id/translations/patients/index.ts diff --git a/src/locales/id/translations/settings/index.ts b/src/shared/locales/id/translations/settings/index.ts similarity index 100% rename from src/locales/id/translations/settings/index.ts rename to src/shared/locales/id/translations/settings/index.ts diff --git a/src/locales/index.ts b/src/shared/locales/index.ts similarity index 100% rename from src/locales/index.ts rename to src/shared/locales/index.ts diff --git a/src/locales/it/translations/actions/index.ts b/src/shared/locales/it/translations/actions/index.ts similarity index 100% rename from src/locales/it/translations/actions/index.ts rename to src/shared/locales/it/translations/actions/index.ts diff --git a/src/locales/it/translations/dashboard/index.ts b/src/shared/locales/it/translations/dashboard/index.ts similarity index 100% rename from src/locales/it/translations/dashboard/index.ts rename to src/shared/locales/it/translations/dashboard/index.ts diff --git a/src/locales/it/translations/index.ts b/src/shared/locales/it/translations/index.ts similarity index 100% rename from src/locales/it/translations/index.ts rename to src/shared/locales/it/translations/index.ts diff --git a/src/locales/it/translations/labs/index.ts b/src/shared/locales/it/translations/labs/index.ts similarity index 100% rename from src/locales/it/translations/labs/index.ts rename to src/shared/locales/it/translations/labs/index.ts diff --git a/src/locales/it/translations/patient/index.ts b/src/shared/locales/it/translations/patient/index.ts similarity index 100% rename from src/locales/it/translations/patient/index.ts rename to src/shared/locales/it/translations/patient/index.ts diff --git a/src/locales/it/translations/patients/index.ts b/src/shared/locales/it/translations/patients/index.ts similarity index 100% rename from src/locales/it/translations/patients/index.ts rename to src/shared/locales/it/translations/patients/index.ts diff --git a/src/locales/it/translations/scheduling/index.ts b/src/shared/locales/it/translations/scheduling/index.ts similarity index 100% rename from src/locales/it/translations/scheduling/index.ts rename to src/shared/locales/it/translations/scheduling/index.ts diff --git a/src/locales/it/translations/settings/index.ts b/src/shared/locales/it/translations/settings/index.ts similarity index 100% rename from src/locales/it/translations/settings/index.ts rename to src/shared/locales/it/translations/settings/index.ts diff --git a/src/locales/it/translations/sex/index.ts b/src/shared/locales/it/translations/sex/index.ts similarity index 100% rename from src/locales/it/translations/sex/index.ts rename to src/shared/locales/it/translations/sex/index.ts diff --git a/src/locales/it/translations/states/index.ts b/src/shared/locales/it/translations/states/index.ts similarity index 100% rename from src/locales/it/translations/states/index.ts rename to src/shared/locales/it/translations/states/index.ts diff --git a/src/locales/ja/translations/actions/index.ts b/src/shared/locales/ja/translations/actions/index.ts similarity index 100% rename from src/locales/ja/translations/actions/index.ts rename to src/shared/locales/ja/translations/actions/index.ts diff --git a/src/locales/ja/translations/dashboard/index.ts b/src/shared/locales/ja/translations/dashboard/index.ts similarity index 100% rename from src/locales/ja/translations/dashboard/index.ts rename to src/shared/locales/ja/translations/dashboard/index.ts diff --git a/src/locales/ja/translations/index.ts b/src/shared/locales/ja/translations/index.ts similarity index 100% rename from src/locales/ja/translations/index.ts rename to src/shared/locales/ja/translations/index.ts diff --git a/src/locales/ja/translations/labs/index.ts b/src/shared/locales/ja/translations/labs/index.ts similarity index 100% rename from src/locales/ja/translations/labs/index.ts rename to src/shared/locales/ja/translations/labs/index.ts diff --git a/src/locales/ja/translations/patient/index.ts b/src/shared/locales/ja/translations/patient/index.ts similarity index 100% rename from src/locales/ja/translations/patient/index.ts rename to src/shared/locales/ja/translations/patient/index.ts diff --git a/src/locales/ja/translations/patients/index.ts b/src/shared/locales/ja/translations/patients/index.ts similarity index 100% rename from src/locales/ja/translations/patients/index.ts rename to src/shared/locales/ja/translations/patients/index.ts diff --git a/src/locales/ja/translations/settings/index.ts b/src/shared/locales/ja/translations/settings/index.ts similarity index 100% rename from src/locales/ja/translations/settings/index.ts rename to src/shared/locales/ja/translations/settings/index.ts diff --git a/src/locales/ptBr/translations/actions/index.ts b/src/shared/locales/ptBr/translations/actions/index.ts similarity index 100% rename from src/locales/ptBr/translations/actions/index.ts rename to src/shared/locales/ptBr/translations/actions/index.ts diff --git a/src/locales/ptBr/translations/dashboard/index.ts b/src/shared/locales/ptBr/translations/dashboard/index.ts similarity index 100% rename from src/locales/ptBr/translations/dashboard/index.ts rename to src/shared/locales/ptBr/translations/dashboard/index.ts diff --git a/src/locales/ptBr/translations/index.ts b/src/shared/locales/ptBr/translations/index.ts similarity index 100% rename from src/locales/ptBr/translations/index.ts rename to src/shared/locales/ptBr/translations/index.ts diff --git a/src/locales/ptBr/translations/labs/index.ts b/src/shared/locales/ptBr/translations/labs/index.ts similarity index 100% rename from src/locales/ptBr/translations/labs/index.ts rename to src/shared/locales/ptBr/translations/labs/index.ts diff --git a/src/locales/ptBr/translations/patient/index.ts b/src/shared/locales/ptBr/translations/patient/index.ts similarity index 100% rename from src/locales/ptBr/translations/patient/index.ts rename to src/shared/locales/ptBr/translations/patient/index.ts diff --git a/src/locales/ptBr/translations/patients/index.ts b/src/shared/locales/ptBr/translations/patients/index.ts similarity index 100% rename from src/locales/ptBr/translations/patients/index.ts rename to src/shared/locales/ptBr/translations/patients/index.ts diff --git a/src/locales/ptBr/translations/scheduling/index.ts b/src/shared/locales/ptBr/translations/scheduling/index.ts similarity index 100% rename from src/locales/ptBr/translations/scheduling/index.ts rename to src/shared/locales/ptBr/translations/scheduling/index.ts diff --git a/src/locales/ptBr/translations/settings/index.ts b/src/shared/locales/ptBr/translations/settings/index.ts similarity index 100% rename from src/locales/ptBr/translations/settings/index.ts rename to src/shared/locales/ptBr/translations/settings/index.ts diff --git a/src/locales/ptBr/translations/sex/index.ts b/src/shared/locales/ptBr/translations/sex/index.ts similarity index 100% rename from src/locales/ptBr/translations/sex/index.ts rename to src/shared/locales/ptBr/translations/sex/index.ts diff --git a/src/locales/ptBr/translations/states/index.ts b/src/shared/locales/ptBr/translations/states/index.ts similarity index 100% rename from src/locales/ptBr/translations/states/index.ts rename to src/shared/locales/ptBr/translations/states/index.ts diff --git a/src/locales/ru/translations/actions/index.ts b/src/shared/locales/ru/translations/actions/index.ts similarity index 100% rename from src/locales/ru/translations/actions/index.ts rename to src/shared/locales/ru/translations/actions/index.ts diff --git a/src/locales/ru/translations/dashboard/index.ts b/src/shared/locales/ru/translations/dashboard/index.ts similarity index 100% rename from src/locales/ru/translations/dashboard/index.ts rename to src/shared/locales/ru/translations/dashboard/index.ts diff --git a/src/locales/ru/translations/index.ts b/src/shared/locales/ru/translations/index.ts similarity index 100% rename from src/locales/ru/translations/index.ts rename to src/shared/locales/ru/translations/index.ts diff --git a/src/locales/ru/translations/labs/index.ts b/src/shared/locales/ru/translations/labs/index.ts similarity index 100% rename from src/locales/ru/translations/labs/index.ts rename to src/shared/locales/ru/translations/labs/index.ts diff --git a/src/locales/ru/translations/patient/index.ts b/src/shared/locales/ru/translations/patient/index.ts similarity index 100% rename from src/locales/ru/translations/patient/index.ts rename to src/shared/locales/ru/translations/patient/index.ts diff --git a/src/locales/ru/translations/patients/index.ts b/src/shared/locales/ru/translations/patients/index.ts similarity index 100% rename from src/locales/ru/translations/patients/index.ts rename to src/shared/locales/ru/translations/patients/index.ts diff --git a/src/locales/ru/translations/settings/index.ts b/src/shared/locales/ru/translations/settings/index.ts similarity index 100% rename from src/locales/ru/translations/settings/index.ts rename to src/shared/locales/ru/translations/settings/index.ts diff --git a/src/locales/zhCN/translations/actions/index.ts b/src/shared/locales/zhCN/translations/actions/index.ts similarity index 100% rename from src/locales/zhCN/translations/actions/index.ts rename to src/shared/locales/zhCN/translations/actions/index.ts diff --git a/src/locales/zhCN/translations/dashboard/index.ts b/src/shared/locales/zhCN/translations/dashboard/index.ts similarity index 100% rename from src/locales/zhCN/translations/dashboard/index.ts rename to src/shared/locales/zhCN/translations/dashboard/index.ts diff --git a/src/locales/zhCN/translations/index.ts b/src/shared/locales/zhCN/translations/index.ts similarity index 100% rename from src/locales/zhCN/translations/index.ts rename to src/shared/locales/zhCN/translations/index.ts diff --git a/src/locales/zhCN/translations/labs/index.ts b/src/shared/locales/zhCN/translations/labs/index.ts similarity index 100% rename from src/locales/zhCN/translations/labs/index.ts rename to src/shared/locales/zhCN/translations/labs/index.ts diff --git a/src/locales/zhCN/translations/patient/index.ts b/src/shared/locales/zhCN/translations/patient/index.ts similarity index 100% rename from src/locales/zhCN/translations/patient/index.ts rename to src/shared/locales/zhCN/translations/patient/index.ts diff --git a/src/locales/zhCN/translations/patients/index.ts b/src/shared/locales/zhCN/translations/patients/index.ts similarity index 100% rename from src/locales/zhCN/translations/patients/index.ts rename to src/shared/locales/zhCN/translations/patients/index.ts diff --git a/src/locales/zhCN/translations/settings/index.ts b/src/shared/locales/zhCN/translations/settings/index.ts similarity index 100% rename from src/locales/zhCN/translations/settings/index.ts rename to src/shared/locales/zhCN/translations/settings/index.ts diff --git a/src/model/AbstractDBModel.ts b/src/shared/model/AbstractDBModel.ts similarity index 100% rename from src/model/AbstractDBModel.ts rename to src/shared/model/AbstractDBModel.ts diff --git a/src/model/Allergy.ts b/src/shared/model/Allergy.ts similarity index 100% rename from src/model/Allergy.ts rename to src/shared/model/Allergy.ts diff --git a/src/model/Appointment.ts b/src/shared/model/Appointment.ts similarity index 100% rename from src/model/Appointment.ts rename to src/shared/model/Appointment.ts diff --git a/src/model/Breadcrumb.ts b/src/shared/model/Breadcrumb.ts similarity index 100% rename from src/model/Breadcrumb.ts rename to src/shared/model/Breadcrumb.ts diff --git a/src/model/CarePlan.ts b/src/shared/model/CarePlan.ts similarity index 100% rename from src/model/CarePlan.ts rename to src/shared/model/CarePlan.ts diff --git a/src/model/ContactInformation.ts b/src/shared/model/ContactInformation.ts similarity index 100% rename from src/model/ContactInformation.ts rename to src/shared/model/ContactInformation.ts diff --git a/src/model/Diagnosis.ts b/src/shared/model/Diagnosis.ts similarity index 100% rename from src/model/Diagnosis.ts rename to src/shared/model/Diagnosis.ts diff --git a/src/model/Incident.ts b/src/shared/model/Incident.ts similarity index 100% rename from src/model/Incident.ts rename to src/shared/model/Incident.ts diff --git a/src/model/Lab.ts b/src/shared/model/Lab.ts similarity index 100% rename from src/model/Lab.ts rename to src/shared/model/Lab.ts diff --git a/src/model/Name.ts b/src/shared/model/Name.ts similarity index 100% rename from src/model/Name.ts rename to src/shared/model/Name.ts diff --git a/src/model/Note.ts b/src/shared/model/Note.ts similarity index 100% rename from src/model/Note.ts rename to src/shared/model/Note.ts diff --git a/src/model/Patient.ts b/src/shared/model/Patient.ts similarity index 100% rename from src/model/Patient.ts rename to src/shared/model/Patient.ts diff --git a/src/model/Permissions.ts b/src/shared/model/Permissions.ts similarity index 100% rename from src/model/Permissions.ts rename to src/shared/model/Permissions.ts diff --git a/src/model/RelatedPerson.ts b/src/shared/model/RelatedPerson.ts similarity index 100% rename from src/model/RelatedPerson.ts rename to src/shared/model/RelatedPerson.ts diff --git a/src/model/User.ts b/src/shared/model/User.ts similarity index 100% rename from src/model/User.ts rename to src/shared/model/User.ts diff --git a/src/images/logo-on-transparent.png b/src/shared/static/images/logo-on-transparent.png similarity index 100% rename from src/images/logo-on-transparent.png rename to src/shared/static/images/logo-on-transparent.png diff --git a/src/store/index.ts b/src/shared/store/index.ts similarity index 50% rename from src/store/index.ts rename to src/shared/store/index.ts index e105cd7ad8..4ac0fa9576 100644 --- a/src/store/index.ts +++ b/src/shared/store/index.ts @@ -1,18 +1,18 @@ import { configureStore, combineReducers, Action } from '@reduxjs/toolkit' import ReduxThunk, { ThunkAction } from 'redux-thunk' -import breadcrumbs from '../breadcrumbs/breadcrumbs-slice' +import incident from '../../incidents/incident-slice' +import incidents from '../../incidents/incidents-slice' +import lab from '../../labs/lab-slice' +import labs from '../../labs/labs-slice' +import breadcrumbs from '../../page-header/breadcrumbs/breadcrumbs-slice' +import title from '../../page-header/title/title-slice' +import patient from '../../patients/patient-slice' +import patients from '../../patients/patients-slice' +import appointment from '../../scheduling/appointments/appointment-slice' +import appointments from '../../scheduling/appointments/appointments-slice' +import user from '../../user/user-slice' import components from '../components/component-slice' -import incident from '../incidents/incident-slice' -import incidents from '../incidents/incidents-slice' -import lab from '../labs/lab-slice' -import labs from '../labs/labs-slice' -import title from '../page-header/title-slice' -import patient from '../patients/patient-slice' -import patients from '../patients/patients-slice' -import appointment from '../scheduling/appointments/appointment-slice' -import appointments from '../scheduling/appointments/appointments-slice' -import user from '../user/user-slice' const reducer = combineReducers({ patient, diff --git a/src/util/generateCode.ts b/src/shared/util/generateCode.ts similarity index 100% rename from src/util/generateCode.ts rename to src/shared/util/generateCode.ts diff --git a/src/util/uuid.ts b/src/shared/util/uuid.ts similarity index 100% rename from src/util/uuid.ts rename to src/shared/util/uuid.ts diff --git a/src/user/user-slice.ts b/src/user/user-slice.ts index c4e9c8d155..ab924be092 100644 --- a/src/user/user-slice.ts +++ b/src/user/user-slice.ts @@ -1,10 +1,10 @@ /* eslint-disable no-underscore-dangle */ import { createSlice, PayloadAction } from '@reduxjs/toolkit' -import { remoteDb } from '../config/pouchdb' -import Permissions from '../model/Permissions' -import User from '../model/User' -import { AppThunk } from '../store' +import { remoteDb } from '../shared/config/pouchdb' +import Permissions from '../shared/model/Permissions' +import User from '../shared/model/User' +import { AppThunk } from '../shared/store' interface UserState { permissions: (Permissions | null)[] From cbb9487efcd261d96ba8f62ae5025c96651a85d4 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 21:43:34 -0500 Subject: [PATCH 66/83] refactor(patients): refactor patient table to use Table component --- .../patients/list/ViewPatients.test.tsx | 38 ++++++++-------- src/patients/list/ViewPatients.tsx | 43 +++++++++---------- .../enUs/translations/actions/index.ts | 1 + 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/src/__tests__/patients/list/ViewPatients.test.tsx b/src/__tests__/patients/list/ViewPatients.test.tsx index 7d81983be5..35a8afdcae 100644 --- a/src/__tests__/patients/list/ViewPatients.test.tsx +++ b/src/__tests__/patients/list/ViewPatients.test.tsx @@ -1,5 +1,4 @@ -import { TextInput, Spinner } from '@hospitalrun/components' -import format from 'date-fns/format' +import { TextInput, Spinner, Table } from '@hospitalrun/components' import { mount } from 'enzyme' import React from 'react' import { act } from 'react-dom/test-utils' @@ -84,26 +83,27 @@ describe('Patients', () => { it('should render a table of patients', () => { const wrapper = setup() - const table = wrapper.find('table') - const tableHeaders = table.find('th') - const tableColumns = table.find('td') + const table = wrapper.find(Table) + const columns = table.prop('columns') + const actions = table.prop('actions') as any expect(table).toHaveLength(1) - expect(tableHeaders).toHaveLength(5) - expect(tableColumns).toHaveLength(5) - expect(tableHeaders.at(0).text()).toEqual('patient.code') - expect(tableHeaders.at(1).text()).toEqual('patient.givenName') - expect(tableHeaders.at(2).text()).toEqual('patient.familyName') - expect(tableHeaders.at(3).text()).toEqual('patient.sex') - expect(tableHeaders.at(4).text()).toEqual('patient.dateOfBirth') - - expect(tableColumns.at(0).text()).toEqual(patients[0].code) - expect(tableColumns.at(1).text()).toEqual(patients[0].givenName) - expect(tableColumns.at(2).text()).toEqual(patients[0].familyName) - expect(tableColumns.at(3).text()).toEqual(patients[0].sex) - expect(tableColumns.at(4).text()).toEqual( - format(new Date(patients[0].dateOfBirth), 'yyyy-MM-dd'), + + expect(columns[0]).toEqual(expect.objectContaining({ label: 'patient.code', key: 'code' })) + expect(columns[1]).toEqual( + expect.objectContaining({ label: 'patient.givenName', key: 'givenName' }), + ) + expect(columns[2]).toEqual( + expect.objectContaining({ label: 'patient.familyName', key: 'familyName' }), ) + expect(columns[3]).toEqual(expect.objectContaining({ label: 'patient.sex', key: 'sex' })) + expect(columns[4]).toEqual( + expect.objectContaining({ label: 'patient.dateOfBirth', key: 'dateOfBirth' }), + ) + + expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' })) + expect(table.prop('data')).toEqual(patients) + expect(table.prop('actionsHeaderText')).toEqual('actions.label') }) it('should add a "New Patient" button to the button tool bar', () => { diff --git a/src/patients/list/ViewPatients.tsx b/src/patients/list/ViewPatients.tsx index 6729694332..80a093f3d5 100644 --- a/src/patients/list/ViewPatients.tsx +++ b/src/patients/list/ViewPatients.tsx @@ -1,4 +1,4 @@ -import { Spinner, Button, Container, Row, TextInput, Column } from '@hospitalrun/components' +import { Spinner, Button, Container, Row, TextInput, Column, Table } from '@hospitalrun/components' import format from 'date-fns/format' import React, { useEffect, useState, useRef } from 'react' import { useTranslation } from 'react-i18next' @@ -67,28 +67,25 @@ const ViewPatients = () => { const loadingIndicator = const table = ( - - - - - - - - - - - - {patients.map((p) => ( - history.push(`/patients/${p.id}`)}> - - - - - - - ))} - -
{t('patient.code')}{t('patient.givenName')}{t('patient.familyName')}{t('patient.sex')}{t('patient.dateOfBirth')}
{p.code}{p.givenName}{p.familyName}{p.sex}{p.dateOfBirth ? format(new Date(p.dateOfBirth), 'yyyy-MM-dd') : ''}
+ row.id} + columns={[ + { label: t('patient.code'), key: 'code' }, + { label: t('patient.givenName'), key: 'givenName' }, + { label: t('patient.familyName'), key: 'familyName' }, + { label: t('patient.sex'), key: 'sex' }, + { + label: t('patient.dateOfBirth'), + key: 'dateOfBirth', + formatter: (row) => + row.dateOfBirth ? format(new Date(row.dateOfBirth), 'yyyy-MM-dd') : '', + }, + ]} + actionsHeaderText={t('actions.label')} + actions={[{ label: t('actions.view'), action: (row) => history.push(`/patients/${row.id}`) }]} + /> ) const onSearchBoxChange = (event: React.ChangeEvent) => { diff --git a/src/shared/locales/enUs/translations/actions/index.ts b/src/shared/locales/enUs/translations/actions/index.ts index 58113ee8d0..28993c21d8 100644 --- a/src/shared/locales/enUs/translations/actions/index.ts +++ b/src/shared/locales/enUs/translations/actions/index.ts @@ -15,5 +15,6 @@ export default { previous: 'Previous', page: 'Page', add: 'Add', + view: 'View', }, } From 0c06f609c1ef7c7d1aa2ca841a905035a40bdee0 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 22:00:27 -0500 Subject: [PATCH 67/83] refactor(incidents): refactor incidents table to use Table component --- .../incidents/list/ViewIncidents.test.tsx | 49 ++++++++-------- src/incidents/list/ViewIncidents.tsx | 56 ++++++++----------- 2 files changed, 49 insertions(+), 56 deletions(-) diff --git a/src/__tests__/incidents/list/ViewIncidents.test.tsx b/src/__tests__/incidents/list/ViewIncidents.test.tsx index 3ce82b1364..99d2808265 100644 --- a/src/__tests__/incidents/list/ViewIncidents.test.tsx +++ b/src/__tests__/incidents/list/ViewIncidents.test.tsx @@ -1,5 +1,6 @@ +import { Table } from '@hospitalrun/components' import { act } from '@testing-library/react' -import { mount } from 'enzyme' +import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' import React from 'react' import { Provider } from 'react-redux' @@ -70,7 +71,7 @@ describe('View Incidents', () => { ) }) wrapper.update() - return wrapper + return wrapper as ReactWrapper } it('should filter incidents by status=reported on first load ', async () => { await setup([Permissions.ViewIncidents]) @@ -88,36 +89,40 @@ describe('View Incidents', () => { it('should render a table with the incidents', async () => { const wrapper = await setup([Permissions.ViewIncidents]) + const table = wrapper.find(Table) + const columns = table.prop('columns') + const actions = table.prop('actions') as any + expect(columns[0]).toEqual( + expect.objectContaining({ label: 'incidents.reports.code', key: 'code' }), + ) + expect(columns[1]).toEqual( + expect.objectContaining({ label: 'incidents.reports.dateOfIncident', key: 'date' }), + ) + expect(columns[2]).toEqual( + expect.objectContaining({ label: 'incidents.reports.reportedBy', key: 'reportedBy' }), + ) + expect(columns[3]).toEqual( + expect.objectContaining({ label: 'incidents.reports.reportedOn', key: 'reportedOn' }), + ) + expect(columns[4]).toEqual( + expect.objectContaining({ label: 'incidents.reports.status', key: 'status' }), + ) - const table = wrapper.find('table') - const tableHeader = table.find('thead') - const tableBody = table.find('tbody') - const tableHeaders = tableHeader.find('th') - const tableColumns = tableBody.find('td') - - expect(tableHeaders.at(0).text()).toEqual('incidents.reports.code') - expect(tableHeaders.at(1).text()).toEqual('incidents.reports.dateOfIncident') - expect(tableHeaders.at(2).text()).toEqual('incidents.reports.reportedBy') - expect(tableHeaders.at(3).text()).toEqual('incidents.reports.reportedOn') - expect(tableHeaders.at(4).text()).toEqual('incidents.reports.status') - - expect(tableColumns.at(0).text()).toEqual(expectedIncidents[0].code) - expect(tableColumns.at(1).text()).toEqual('2020-06-03 07:48 PM') - expect(tableColumns.at(2).text()).toEqual(expectedIncidents[0].reportedBy) - expect(tableColumns.at(3).text()).toEqual('2020-06-03 07:48 PM') - expect(tableColumns.at(4).text()).toEqual(expectedIncidents[0].status) + expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' })) + expect(table.prop('actionsHeaderText')).toEqual('actions.label') + expect(table.prop('data')).toEqual(expectedIncidents) }) }) - describe('on table row click', () => { + describe('on view button click', () => { it('should navigate to the incident when the table row is clicked', async () => { const wrapper = await setup([Permissions.ViewIncidents]) const tr = wrapper.find('tr').at(1) act(() => { - const onClick = tr.prop('onClick') - onClick() + const onClick = tr.find('button').prop('onClick') as any + onClick({ stopPropagation: jest.fn() }) }) expect(history.location.pathname).toEqual(`/incidents/${expectedIncidents[0].id}`) diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx index 35dc9c4f01..9f59d9dd99 100644 --- a/src/incidents/list/ViewIncidents.tsx +++ b/src/incidents/list/ViewIncidents.tsx @@ -1,4 +1,4 @@ -import { Button } from '@hospitalrun/components' +import { Button, Table } from '@hospitalrun/components' import format from 'date-fns/format' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -10,7 +10,6 @@ import useTitle from '../../page-header/title/useTitle' import SelectWithLabelFormGroup, { Option, } from '../../shared/components/input/SelectWithLableFormGroup' -import Incident from '../../shared/model/Incident' import { RootState } from '../../shared/store' import IncidentFilter from '../IncidentFilter' import { searchIncidents } from '../incidents-slice' @@ -46,10 +45,6 @@ const ViewIncidents = () => { dispatch(searchIncidents(searchFilter)) }, [dispatch, searchFilter]) - const onTableRowClick = (incident: Incident) => { - history.push(`incidents/${incident.id}`) - } - const filterOptions: Option[] = Object.values(IncidentFilter).map((filter) => ({ label: t(`incidents.status.${filter}`), value: `${filter}`, @@ -70,34 +65,27 @@ const ViewIncidents = () => {
-
- - - - - - - - - - - {incidents.map((incident: Incident) => ( - onTableRowClick(incident)} key={incident.id}> - - - - - - - ))} - -
{t('incidents.reports.code')}{t('incidents.reports.dateOfIncident')}{t('incidents.reports.reportedBy')}{t('incidents.reports.reportedOn')}{t('incidents.reports.status')}
{incident.code} - {incident.date ? format(new Date(incident.date), 'yyyy-MM-dd hh:mm a') : ''} - {incident.reportedBy} - {incident.reportedOn - ? format(new Date(incident.reportedOn), 'yyyy-MM-dd hh:mm a') - : ''} - {incident.status}
+ row.id} + data={incidents} + columns={[ + { label: t('incidents.reports.code'), key: 'code' }, + { + label: t('incidents.reports.dateOfIncident'), + key: 'date', + formatter: (row) => + row.date ? format(new Date(row.date), 'yyyy-MM-dd hh:mm a') : '', + }, + { label: t('incidents.reports.reportedBy'), key: 'reportedBy' }, + { label: t('incidents.reports.reportedOn'), key: 'reportedOn' }, + { label: t('incidents.reports.status'), key: 'status' }, + ]} + actionsHeaderText={t('actions.label')} + actions={[ + { label: t('actions.view'), action: (row) => history.push(`incidents/${row.id}`) }, + ]} + /> ) From 25504671ef5b0950c29e8759f2d84e048eba5026 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 22:12:28 -0500 Subject: [PATCH 68/83] refactor(care plans): refactor care plans table to use Table component --- .../care-plans/CarePlanTable.test.tsx | 48 +++++++-------- src/patients/care-plans/CarePlanTable.tsx | 59 +++++++++---------- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/src/__tests__/patients/care-plans/CarePlanTable.test.tsx b/src/__tests__/patients/care-plans/CarePlanTable.test.tsx index 53ceff95a4..713197fa80 100644 --- a/src/__tests__/patients/care-plans/CarePlanTable.test.tsx +++ b/src/__tests__/patients/care-plans/CarePlanTable.test.tsx @@ -1,5 +1,5 @@ -import { Button } from '@hospitalrun/components' -import { mount } from 'enzyme' +import { Table } from '@hospitalrun/components' +import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' import React from 'react' import { act } from 'react-dom/test-utils' @@ -46,41 +46,41 @@ describe('Care Plan Table', () => { , ) - return { wrapper, history } + return { wrapper: wrapper as ReactWrapper, history } } it('should render a table', () => { const { wrapper } = setup() - const table = wrapper.find('table') - const tableHeader = table.find('thead') - const headers = tableHeader.find('th') - const body = table.find('tbody') - const columns = body.find('tr').find('td') - - expect(headers.at(0).text()).toEqual('patient.carePlan.title') - expect(headers.at(1).text()).toEqual('patient.carePlan.startDate') - expect(headers.at(2).text()).toEqual('patient.carePlan.endDate') - expect(headers.at(3).text()).toEqual('patient.carePlan.status') - expect(headers.at(4).text()).toEqual('actions.label') + const table = wrapper.find(Table) + const columns = table.prop('columns') + const actions = table.prop('actions') as any + expect(columns[0]).toEqual( + expect.objectContaining({ label: 'patient.carePlan.title', key: 'title' }), + ) + expect(columns[1]).toEqual( + expect.objectContaining({ label: 'patient.carePlan.startDate', key: 'startDate' }), + ) + expect(columns[2]).toEqual( + expect.objectContaining({ label: 'patient.carePlan.endDate', key: 'endDate' }), + ) + expect(columns[3]).toEqual( + expect.objectContaining({ label: 'patient.carePlan.status', key: 'status' }), + ) - expect(columns.at(0).text()).toEqual(carePlan.title) - expect(columns.at(1).text()).toEqual('2020-07-03') - expect(columns.at(2).text()).toEqual('2020-07-05') - expect(columns.at(3).text()).toEqual(carePlan.status) - expect(columns.at(4).find('button')).toHaveLength(1) + expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' })) + expect(table.prop('actionsHeaderText')).toEqual('actions.label') + expect(table.prop('data')).toEqual(patient.carePlans) }) it('should navigate to the care plan view when the view details button is clicked', () => { const { wrapper, history } = setup() - const table = wrapper.find('table') - const body = table.find('tbody') - const columns = body.find('tr').find('td') + const tr = wrapper.find('tr').at(1) act(() => { - const onClick = columns.at(4).find(Button).prop('onClick') as any - onClick() + const onClick = tr.find('button').prop('onClick') as any + onClick({ stopPropagation: jest.fn() }) }) expect(history.location.pathname).toEqual(`/patients/${patient.id}/care-plans/${carePlan.id}`) diff --git a/src/patients/care-plans/CarePlanTable.tsx b/src/patients/care-plans/CarePlanTable.tsx index 44c40128a1..8c0bb2da82 100644 --- a/src/patients/care-plans/CarePlanTable.tsx +++ b/src/patients/care-plans/CarePlanTable.tsx @@ -1,11 +1,10 @@ -import { Button } from '@hospitalrun/components' +import { Table } from '@hospitalrun/components' import format from 'date-fns/format' import React from 'react' import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' import { useHistory } from 'react-router-dom' -import CarePlan from '../../shared/model/CarePlan' import { RootState } from '../../shared/store' const CarePlanTable = () => { @@ -13,37 +12,33 @@ const CarePlanTable = () => { const { t } = useTranslation() const { patient } = useSelector((state: RootState) => state.patient) - const onViewClick = (carePlan: CarePlan) => { - history.push(`/patients/${patient.id}/care-plans/${carePlan.id}`) - } - return ( -
- - - - - - - - - - - {patient.carePlans?.map((carePlan) => ( - - - - - - - - ))} - -
{t('patient.carePlan.title')}{t('patient.carePlan.startDate')}{t('patient.carePlan.endDate')}{t('patient.carePlan.status')}{t('actions.label')}
{carePlan.title}{format(new Date(carePlan.startDate), 'yyyy-MM-dd')}{format(new Date(carePlan.endDate), 'yyyy-MM-dd')}{carePlan.status} - -
+ row.id} + data={patient.carePlans} + columns={[ + { label: t('patient.carePlan.title'), key: 'title' }, + { + label: t('patient.carePlan.startDate'), + key: 'startDate', + formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'), + }, + { + label: t('patient.carePlan.endDate'), + key: 'endDate', + formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'), + }, + { label: t('patient.carePlan.status'), key: 'status' }, + ]} + actionsHeaderText={t('actions.label')} + actions={[ + { + label: 'actions.view', + action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`), + }, + ]} + /> ) } From 25d0902fa4c7ee89b7e5e02932272ad6a6bd809c Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 22:29:54 -0500 Subject: [PATCH 69/83] refactor(relatedpersons): refactor to use Table component --- ...ns.test.tsx => RelatedPersonsTab.test.tsx} | 67 +++++++++---------- .../related-persons/RelatedPersonTab.tsx | 58 ++++++---------- 2 files changed, 52 insertions(+), 73 deletions(-) rename src/__tests__/patients/related-persons/{RelatedPersons.test.tsx => RelatedPersonsTab.test.tsx} (76%) diff --git a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx b/src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx similarity index 76% rename from src/__tests__/patients/related-persons/RelatedPersons.test.tsx rename to src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx index 5b48ec6d23..2fce3faaa8 100644 --- a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx @@ -1,4 +1,5 @@ import * as components from '@hospitalrun/components' +import { Table } from '@hospitalrun/components' import { act } from '@testing-library/react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -14,7 +15,6 @@ import RelatedPersonTab from '../../../patients/related-persons/RelatedPersonTab import PatientRepository from '../../../shared/db/PatientRepository' import Patient from '../../../shared/model/Patient' import Permissions from '../../../shared/model/Permissions' -import RelatedPerson from '../../../shared/model/RelatedPerson' import { RootState } from '../../../shared/store' const mockStore = createMockStore([thunk]) @@ -110,6 +110,7 @@ describe('Related Persons Tab', () => { familyName: 'test', fullName: 'test test', id: '123001', + type: 'type', } as Patient const user = { @@ -133,51 +134,45 @@ describe('Related Persons Tab', () => { }) it('should render a list of related persons with their full name being displayed', () => { - const table = wrapper.find('table') - const tableHeader = wrapper.find('thead') - const tableHeaders = wrapper.find('th') - const tableBody = wrapper.find('tbody') - const tableData = wrapper.find('td') - const deleteButton = tableData.at(3).find(components.Button) - expect(table).toHaveLength(1) - expect(tableHeader).toHaveLength(1) - expect(tableBody).toHaveLength(1) - expect(tableHeaders.at(0).text()).toEqual('patient.givenName') - expect(tableHeaders.at(1).text()).toEqual('patient.familyName') - expect(tableHeaders.at(2).text()).toEqual('patient.relatedPersons.relationshipType') - expect(tableHeaders.at(3).text()).toEqual('actions.label') - expect(tableData.at(0).text()).toEqual(expectedRelatedPerson.givenName) - expect(tableData.at(1).text()).toEqual(expectedRelatedPerson.familyName) - expect(tableData.at(2).text()).toEqual((patient.relatedPersons as RelatedPerson[])[0].type) - expect(deleteButton).toHaveLength(1) - expect(deleteButton.text().trim()).toEqual('actions.delete') - expect(deleteButton.prop('color')).toEqual('danger') + const table = wrapper.find(Table) + const columns = table.prop('columns') + const actions = table.prop('actions') as any + expect(columns[0]).toEqual( + expect.objectContaining({ label: 'patient.givenName', key: 'givenName' }), + ) + expect(columns[1]).toEqual( + expect.objectContaining({ label: 'patient.familyName', key: 'familyName' }), + ) + expect(columns[2]).toEqual( + expect.objectContaining({ + label: 'patient.relatedPersons.relationshipType', + key: 'type', + }), + ) + + expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' })) + expect(actions[1]).toEqual(expect.objectContaining({ label: 'actions.delete' })) + expect(table.prop('actionsHeaderText')).toEqual('actions.label') + expect(table.prop('data')).toEqual([expectedRelatedPerson]) }) it('should remove the related person when the delete button is clicked', async () => { const removeRelatedPersonSpy = jest.spyOn(patientSlice, 'removeRelatedPerson') - const eventPropagationSpy = jest.fn() + const tr = wrapper.find('tr').at(1) - const table = wrapper.find('table') - const tableBody = table.find('tbody') - const tableData = tableBody.find('td') - const deleteButton = tableData.at(3).find(components.Button) - - await act(async () => { - const onClick = deleteButton.prop('onClick') - await onClick({ stopPropagation: eventPropagationSpy }) + act(() => { + const onClick = tr.find('button').at(1).prop('onClick') as any + onClick({ stopPropagation: jest.fn() }) }) - expect(removeRelatedPersonSpy).toHaveBeenCalledWith(patient.id, expectedRelatedPerson.id) }) it('should navigate to related person patient profile on related person click', async () => { - const table = wrapper.find('table') - const tableBody = table.find('tbody') - const row = tableBody.find('tr') - await act(async () => { - const onClick = row.prop('onClick') - await onClick() + const tr = wrapper.find('tr').at(1) + + act(() => { + const onClick = tr.find('button').at(0).prop('onClick') as any + onClick({ stopPropagation: jest.fn() }) }) expect(history.location.pathname).toEqual('/patients/123001') diff --git a/src/patients/related-persons/RelatedPersonTab.tsx b/src/patients/related-persons/RelatedPersonTab.tsx index 81dfef9967..e445518ba2 100644 --- a/src/patients/related-persons/RelatedPersonTab.tsx +++ b/src/patients/related-persons/RelatedPersonTab.tsx @@ -1,4 +1,4 @@ -import { Button, Alert, Spinner } from '@hospitalrun/components' +import { Button, Alert, Spinner, Table } from '@hospitalrun/components' import React, { useState, useEffect } from 'react' import { useTranslation } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' @@ -59,18 +59,11 @@ const RelatedPersonTab = (props: Props) => { setShowRelatedPersonModal(true) } - const onRelatedPersonClick = (id: string) => { - navigateTo(`/patients/${id}`) - } const closeNewRelatedPersonModal = () => { setShowRelatedPersonModal(false) } - const onRelatedPersonDelete = ( - event: React.MouseEvent, - relatedPerson: Patient, - ) => { - event.stopPropagation() + const onRelatedPersonDelete = (relatedPerson: Patient) => { dispatch(removeRelatedPerson(patient.id, relatedPerson.id)) } @@ -96,34 +89,25 @@ const RelatedPersonTab = (props: Props) => {
{relatedPersons ? ( relatedPersons.length > 0 ? ( -
- - - - - - - - - - {relatedPersons.map((r) => ( - onRelatedPersonClick(r.id)}> - - - - - - ))} - -
{t('patient.givenName')}{t('patient.familyName')}{t('patient.relatedPersons.relationshipType')}{t('actions.label')}
{r.givenName}{r.familyName}{r.type} - -
+ row.id} + data={relatedPersons} + columns={[ + { label: t('patient.givenName'), key: 'givenName' }, + { label: t('patient.familyName'), key: 'familyName' }, + { label: t('patient.relatedPersons.relationshipType'), key: 'type' }, + ]} + actionsHeaderText={t('actions.label')} + actions={[ + { label: t('actions.view'), action: (row) => navigateTo(`/patients/${row.id}`) }, + { + label: t('actions.delete'), + action: (row) => onRelatedPersonDelete(row as Patient), + buttonColor: 'danger', + }, + ]} + /> ) : ( Date: Sun, 28 Jun 2020 22:58:43 -0500 Subject: [PATCH 70/83] fix(care plans): fix undefined care plans behavior --- src/patients/care-plans/CarePlanTable.tsx | 59 ++++++++++++----------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/patients/care-plans/CarePlanTable.tsx b/src/patients/care-plans/CarePlanTable.tsx index 8c0bb2da82..f1f42e3a4c 100644 --- a/src/patients/care-plans/CarePlanTable.tsx +++ b/src/patients/care-plans/CarePlanTable.tsx @@ -12,34 +12,37 @@ const CarePlanTable = () => { const { t } = useTranslation() const { patient } = useSelector((state: RootState) => state.patient) - return ( -
row.id} - data={patient.carePlans} - columns={[ - { label: t('patient.carePlan.title'), key: 'title' }, - { - label: t('patient.carePlan.startDate'), - key: 'startDate', - formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'), - }, - { - label: t('patient.carePlan.endDate'), - key: 'endDate', - formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'), - }, - { label: t('patient.carePlan.status'), key: 'status' }, - ]} - actionsHeaderText={t('actions.label')} - actions={[ - { - label: 'actions.view', - action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`), - }, - ]} - /> - ) + if (patient.carePlans !== undefined) { + return ( +
row.id} + data={patient.carePlans} + columns={[ + { label: t('patient.carePlan.title'), key: 'title' }, + { + label: t('patient.carePlan.startDate'), + key: 'startDate', + formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'), + }, + { + label: t('patient.carePlan.endDate'), + key: 'endDate', + formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'), + }, + { label: t('patient.carePlan.status'), key: 'status' }, + ]} + actionsHeaderText={t('actions.label')} + actions={[ + { + label: 'actions.view', + action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`), + }, + ]} + /> + ) + } + return <> } export default CarePlanTable From 922d7675bc9c7f51cacd100be0becbd5ee6087e1 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 22:59:28 -0500 Subject: [PATCH 71/83] fix: fix find all + sort request behavior --- src/shared/db/Repository.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shared/db/Repository.ts b/src/shared/db/Repository.ts index d19e3c12cf..a77ad08d72 100644 --- a/src/shared/db/Repository.ts +++ b/src/shared/db/Repository.ts @@ -31,7 +31,7 @@ export default class Repository { } sort.sorts.forEach((s) => { - selector[s.field] = { $gt: null } + selector[`data.${s.field}`] = { $gt: null } }) // Adds an index to each of the fields coming from the sorting object @@ -42,7 +42,7 @@ export default class Repository { async (s): Promise => { await this.db.createIndex({ index: { - fields: [s.field], + fields: [`data.${s.field}`], }, }) @@ -53,7 +53,10 @@ export default class Repository { const result = await this.db.find({ selector, - sort: sort.sorts.length > 0 ? sort.sorts.map((s) => ({ [s.field]: s.direction })) : undefined, + sort: + sort.sorts.length > 0 + ? sort.sorts.map((s) => ({ [`data.${s.field}`]: s.direction })) + : undefined, }) const relDocs = await this.db.rel.parseRelDocs(this.type, result.docs) return relDocs[this.pluralType] From 279d64914ca0fab541ade4f64d9569f27000ddae Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 23:00:27 -0500 Subject: [PATCH 72/83] fix: undefined care plan behavior --- src/patients/care-plans/CarePlanTable.tsx | 59 +++++++++++------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/src/patients/care-plans/CarePlanTable.tsx b/src/patients/care-plans/CarePlanTable.tsx index f1f42e3a4c..3b8fd48535 100644 --- a/src/patients/care-plans/CarePlanTable.tsx +++ b/src/patients/care-plans/CarePlanTable.tsx @@ -12,37 +12,34 @@ const CarePlanTable = () => { const { t } = useTranslation() const { patient } = useSelector((state: RootState) => state.patient) - if (patient.carePlans !== undefined) { - return ( -
row.id} - data={patient.carePlans} - columns={[ - { label: t('patient.carePlan.title'), key: 'title' }, - { - label: t('patient.carePlan.startDate'), - key: 'startDate', - formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'), - }, - { - label: t('patient.carePlan.endDate'), - key: 'endDate', - formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'), - }, - { label: t('patient.carePlan.status'), key: 'status' }, - ]} - actionsHeaderText={t('actions.label')} - actions={[ - { - label: 'actions.view', - action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`), - }, - ]} - /> - ) - } - return <> + return ( +
row.id} + data={patient.carePlans || []} + columns={[ + { label: t('patient.carePlan.title'), key: 'title' }, + { + label: t('patient.carePlan.startDate'), + key: 'startDate', + formatter: (row) => format(new Date(row.startDate), 'yyyy-MM-dd'), + }, + { + label: t('patient.carePlan.endDate'), + key: 'endDate', + formatter: (row) => format(new Date(row.endDate), 'yyyy-MM-dd'), + }, + { label: t('patient.carePlan.status'), key: 'status' }, + ]} + actionsHeaderText={t('actions.label')} + actions={[ + { + label: 'actions.view', + action: (row) => history.push(`/patients/${patient.id}/care-plans/${row.id}`), + }, + ]} + /> + ) } export default CarePlanTable From 88a7c0863c0a7752b99683e864d461209fe16b5d Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 23:01:07 -0500 Subject: [PATCH 73/83] feat(labs): labs tab should use Table component --- src/__tests__/patients/labs/LabsTab.test.tsx | 34 ++++++++--------- src/patients/labs/LabsTab.tsx | 40 +++++++++----------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/__tests__/patients/labs/LabsTab.test.tsx b/src/__tests__/patients/labs/LabsTab.test.tsx index 6e3e42288c..bd7d7fa884 100644 --- a/src/__tests__/patients/labs/LabsTab.test.tsx +++ b/src/__tests__/patients/labs/LabsTab.test.tsx @@ -1,5 +1,5 @@ import * as components from '@hospitalrun/components' -import format from 'date-fns/format' +import { Table } from '@hospitalrun/components' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' import React from 'react' @@ -61,23 +61,23 @@ describe('Labs Tab', () => { it('should list the patients labs', async () => { const { wrapper } = await setup() - const table = wrapper.find('table') - const tableHeader = wrapper.find('thead') - const tableHeaders = wrapper.find('th') - const tableBody = wrapper.find('tbody') - const tableData = wrapper.find('td') - - expect(table).toHaveLength(1) - expect(tableHeader).toHaveLength(1) - expect(tableBody).toHaveLength(1) - expect(tableHeaders.at(0).text()).toEqual('labs.lab.type') - expect(tableHeaders.at(1).text()).toEqual('labs.lab.requestedOn') - expect(tableHeaders.at(2).text()).toEqual('labs.lab.status') - expect(tableData.at(0).text()).toEqual(expectedLabs[0].type) - expect(tableData.at(1).text()).toEqual( - format(new Date(expectedLabs[0].requestedOn), 'yyyy-MM-dd hh:mm a'), + const table = wrapper.find(Table) + const columns = table.prop('columns') + const actions = table.prop('actions') as any + expect(columns[0]).toEqual(expect.objectContaining({ label: 'labs.lab.type', key: 'type' })) + expect(columns[1]).toEqual( + expect.objectContaining({ label: 'labs.lab.requestedOn', key: 'requestedOn' }), + ) + expect(columns[2]).toEqual( + expect.objectContaining({ + label: 'labs.lab.status', + key: 'status', + }), ) - expect(tableData.at(2).text()).toEqual(expectedLabs[0].status) + + expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' })) + expect(table.prop('actionsHeaderText')).toEqual('actions.label') + expect(table.prop('data')).toEqual(expectedLabs) }) it('should render a warning message if the patient does not have any labs', async () => { diff --git a/src/patients/labs/LabsTab.tsx b/src/patients/labs/LabsTab.tsx index 03ec2a2a71..5461183ac1 100644 --- a/src/patients/labs/LabsTab.tsx +++ b/src/patients/labs/LabsTab.tsx @@ -1,4 +1,4 @@ -import { Alert } from '@hospitalrun/components' +import { Alert, Table } from '@hospitalrun/components' import format from 'date-fns/format' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -27,10 +27,6 @@ const LabsTab = (props: Props) => { fetch() }, [patientId]) - const onTableRowClick = (lab: Lab) => { - history.push(`/labs/${lab.id}`) - } - return (
{(!labs || labs.length === 0) && ( @@ -41,24 +37,22 @@ const LabsTab = (props: Props) => { /> )} {labs && labs.length > 0 && ( -
- - - - - - - - - {labs.map((lab) => ( - onTableRowClick(lab)} key={lab.id}> - - - - - ))} - -
{t('labs.lab.type')}{t('labs.lab.requestedOn')}{t('labs.lab.status')}
{lab.type}{format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a')}{lab.status}
+ row.id} + data={labs} + columns={[ + { label: t('labs.lab.type'), key: 'type' }, + { + label: t('labs.lab.requestedOn'), + key: 'requestedOn', + formatter: (row) => format(new Date(row.requestedOn), 'yyyy-MM-dd hh:mm a'), + }, + { label: t('labs.lab.status'), key: 'status' }, + ]} + actions={[{ label: t('actions.view'), action: (row) => history.push(`/labs/${row.id}`) }]} + /> )} ) From 978788e540db6553fbc5e4fd928b44d47285be01 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 23:11:31 -0500 Subject: [PATCH 74/83] refactor(labs): labs should use Table component --- src/__tests__/labs/ViewLabs.test.tsx | 58 ++++++++++------------------ src/labs/ViewLabs.tsx | 50 ++++++++++-------------- 2 files changed, 42 insertions(+), 66 deletions(-) diff --git a/src/__tests__/labs/ViewLabs.test.tsx b/src/__tests__/labs/ViewLabs.test.tsx index 5220bb7244..fefdea666f 100644 --- a/src/__tests__/labs/ViewLabs.test.tsx +++ b/src/__tests__/labs/ViewLabs.test.tsx @@ -1,6 +1,5 @@ -import { TextInput, Select } from '@hospitalrun/components' +import { TextInput, Select, Table } from '@hospitalrun/components' import { act } from '@testing-library/react' -import format from 'date-fns/format' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' import React from 'react' @@ -102,7 +101,7 @@ describe('View Labs', () => { code: 'L-1234', id: '1234', type: 'lab type', - patientId: 'patientId', + patient: 'patientId', status: 'requested', requestedOn: '2020-03-30T04:43:20.102Z', } as Lab @@ -130,45 +129,30 @@ describe('View Labs', () => { }) it('should render a table with data', () => { - const table = wrapper.find('table') - const tableHeader = table.find('thead') - const tableBody = table.find('tbody') - - const tableColumnHeaders = tableHeader.find('th') - const tableDataColumns = tableBody.find('td') - - expect(table).toBeDefined() - expect(tableHeader).toBeDefined() - expect(tableBody).toBeDefined() - expect(tableColumnHeaders.at(0).text().trim()).toEqual('labs.lab.code') - - expect(tableColumnHeaders.at(1).text().trim()).toEqual('labs.lab.type') - - expect(tableColumnHeaders.at(2).text().trim()).toEqual('labs.lab.requestedOn') - - expect(tableColumnHeaders.at(3).text().trim()).toEqual('labs.lab.status') - - expect(tableDataColumns.at(0).text().trim()).toEqual(expectedLab.code) - - expect(tableDataColumns.at(1).text().trim()).toEqual(expectedLab.type) - - expect(tableDataColumns.at(2).text().trim()).toEqual( - format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'), + const table = wrapper.find(Table) + const columns = table.prop('columns') + const actions = table.prop('actions') as any + expect(columns[0]).toEqual(expect.objectContaining({ label: 'labs.lab.code', key: 'code' })) + expect(columns[1]).toEqual(expect.objectContaining({ label: 'labs.lab.type', key: 'type' })) + expect(columns[2]).toEqual( + expect.objectContaining({ label: 'labs.lab.requestedOn', key: 'requestedOn' }), + ) + expect(columns[3]).toEqual( + expect.objectContaining({ label: 'labs.lab.status', key: 'status' }), ) - expect(tableDataColumns.at(3).text().trim()).toEqual(expectedLab.status) + expect(actions[0]).toEqual(expect.objectContaining({ label: 'actions.view' })) + expect(table.prop('actionsHeaderText')).toEqual('actions.label') + expect(table.prop('data')).toEqual([expectedLab]) }) - it('should navigate to the lab when the row is clicked', () => { - const table = wrapper.find('table') - const tableBody = table.find('tbody') - const tableRow = tableBody.find('tr').at(0) + it('should navigate to the lab when the view button is clicked', () => { + const tr = wrapper.find('tr').at(1) act(() => { - const onClick = tableRow.prop('onClick') as any - onClick() + const onClick = tr.find('button').prop('onClick') as any + onClick({ stopPropagation: jest.fn() }) }) - expect(history.location.pathname).toEqual(`/labs/${expectedLab.id}`) }) }) @@ -181,7 +165,7 @@ describe('View Labs', () => { const expectedLab = { id: '1234', type: 'lab type', - patientId: 'patientId', + patient: 'patientId', status: 'requested', requestedOn: '2020-03-30T04:43:20.102Z', } as Lab @@ -234,7 +218,7 @@ describe('View Labs', () => { const expectedLab = { id: '1234', type: 'lab type', - patientId: 'patientId', + patient: 'patientId', status: 'requested', requestedOn: '2020-03-30T04:43:20.102Z', } as Lab diff --git a/src/labs/ViewLabs.tsx b/src/labs/ViewLabs.tsx index 2cca3daf05..3f99fe242f 100644 --- a/src/labs/ViewLabs.tsx +++ b/src/labs/ViewLabs.tsx @@ -1,4 +1,4 @@ -import { Spinner, Button } from '@hospitalrun/components' +import { Button, Table } from '@hospitalrun/components' import format from 'date-fns/format' import React, { useState, useEffect, useCallback } from 'react' import { useTranslation } from 'react-i18next' @@ -27,7 +27,7 @@ const ViewLabs = () => { const { permissions } = useSelector((state: RootState) => state.user) const dispatch = useDispatch() - const { labs, isLoading } = useSelector((state: RootState) => state.labs) + const { labs } = useSelector((state: RootState) => state.labs) const [searchFilter, setSearchFilter] = useState('all') const [searchText, setSearchText] = useState('') const debouncedSearchText = useDebounce(searchText, 500) @@ -63,9 +63,7 @@ const ViewLabs = () => { } }, [dispatch, getButtons, setButtons]) - const loadingIndicator = - - const onTableRowClick = (lab: Lab) => { + const onViewClick = (lab: Lab) => { history.push(`/labs/${lab.id}`) } @@ -80,19 +78,6 @@ const ViewLabs = () => { { label: t('labs.filter.all'), value: 'all' }, ] - const listBody = ( - - {labs.map((lab) => ( - onTableRowClick(lab)} key={lab.id}> - - - - - - ))} - - ) - return ( <>
@@ -118,17 +103,24 @@ const ViewLabs = () => {
-
{lab.code}{lab.type}{lab.requestedOn ? format(new Date(lab.requestedOn), 'yyyy-MM-dd hh:mm a') : ''}{lab.status}
- - - - - - - - - {isLoading ? loadingIndicator : listBody} -
{t('labs.lab.code')}{t('labs.lab.type')}{t('labs.lab.requestedOn')}{t('labs.lab.status')}
+ row.id} + columns={[ + { label: t('labs.lab.code'), key: 'code' }, + { label: t('labs.lab.type'), key: 'type' }, + { + label: t('labs.lab.requestedOn'), + key: 'requestedOn', + formatter: (row) => + row.requestedOn ? format(new Date(row.requestedOn), 'yyyy-MM-dd hh:mm a') : '', + }, + { label: t('labs.lab.status'), key: 'status' }, + ]} + data={labs} + actionsHeaderText={t('actions.label')} + actions={[{ label: t('actions.view'), action: (row) => onViewClick(row as Lab) }]} + /> ) From aabd33e2651246ac8eaadc1c6b260b1f3b6e7591 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 28 Jun 2020 23:17:42 -0500 Subject: [PATCH 75/83] fix(incidents): fix find all incidents --- src/shared/db/IncidentRepository.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/db/IncidentRepository.ts b/src/shared/db/IncidentRepository.ts index 262c493f80..867954b36c 100644 --- a/src/shared/db/IncidentRepository.ts +++ b/src/shared/db/IncidentRepository.ts @@ -16,7 +16,8 @@ class IncidentRepository extends Repository { } private static getSearchCriteria(options: SearchOptions): any { - const statusFilter = options.status !== IncidentFilter.all ? [{ status: options.status }] : [] + const statusFilter = + options.status !== IncidentFilter.all ? [{ 'data.status': options.status }] : [] const selector = { $and: statusFilter, } From 0b8d10878b00f9957357988d9b80823d125eef0f Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Mon, 29 Jun 2020 17:18:37 +0200 Subject: [PATCH 76/83] docs(readme): add login indications --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4c6095bde5..8d48abf70d 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ React frontend for [HospitalRun](http://hospitalrun.io/): free software for deve +# Staging area + +You can follow developments by visiting the dedicated [staging environment](https://staging.hospitalrun.io). Use `username` / `password` as credentials to access. + # Contributing Contributions are always welcome. Before contributing please read our [contributor guide](https://github.com/HospitalRun/hospitalrun-frontend/blob/master/.github/CONTRIBUTING.md). From 7f3d8ee6f7f195c1589becebf268b7ca43081f64 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Mon, 29 Jun 2020 22:23:53 +0200 Subject: [PATCH 77/83] chore(ci): update lint script --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24cae26305..d1b1152a51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: npm install - name: Lint code run: | - npm run lint + npm run lint:fix - name: Build if: always() run: | From 92c6ac8caea1f84fc0d52cff2f496907a5867196 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 29 Jun 2020 20:50:12 +0000 Subject: [PATCH 78/83] build(deps-dev): bump @typescript-eslint/parser from 3.4.0 to 3.5.0 Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v3.5.0/packages/parser) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b58c890b37..3784fbb5f5 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@types/uuid": "^8.0.0", "@types/validator": "~13.1.0", "@typescript-eslint/eslint-plugin": "~3.4.0", - "@typescript-eslint/parser": "~3.4.0", + "@typescript-eslint/parser": "~3.5.0", "chalk": "^4.0.0", "commitizen": "~4.1.2", "commitlint-config-cz": "~0.13.0", From 3136c155628d7febfc81ad28a4e0e7948ce4ff57 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Mon, 29 Jun 2020 16:46:14 -0500 Subject: [PATCH 79/83] style: warn on react default props --- .eslintrc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 684e13342b..07674dd3f8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -74,5 +74,7 @@ module.exports = { }, ], curly: ['error', 'all'], + 'react/require-default-props': ['warn'], + 'react/default-props-match-prop-types': ['warn'] }, } From d5505d269d298fc45997f4b7c69fbedf131d50f2 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Mon, 29 Jun 2020 16:50:07 -0500 Subject: [PATCH 80/83] style: remove unused prop --- src/shared/components/input/TextFieldWithLabelFormGroup.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/shared/components/input/TextFieldWithLabelFormGroup.tsx b/src/shared/components/input/TextFieldWithLabelFormGroup.tsx index 10a92de726..857034706e 100644 --- a/src/shared/components/input/TextFieldWithLabelFormGroup.tsx +++ b/src/shared/components/input/TextFieldWithLabelFormGroup.tsx @@ -6,7 +6,6 @@ interface Props { label?: string name: string isEditable?: boolean - placeholder?: string onChange?: (event: React.ChangeEvent) => void isRequired?: boolean feedback?: string From faea7bae3e00d3c471802a875bcce7e719f9b277 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Mon, 29 Jun 2020 16:51:56 -0500 Subject: [PATCH 81/83] fix: remove duplicate prop --- src/incidents/list/ViewIncidents.tsx | 1 - src/labs/ViewLabs.tsx | 1 - src/patients/care-plans/CarePlanTable.tsx | 1 - src/patients/labs/LabsTab.tsx | 1 - src/patients/list/ViewPatients.tsx | 1 - src/patients/related-persons/RelatedPersonTab.tsx | 1 - 6 files changed, 6 deletions(-) diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx index 9f59d9dd99..88c72fdf35 100644 --- a/src/incidents/list/ViewIncidents.tsx +++ b/src/incidents/list/ViewIncidents.tsx @@ -66,7 +66,6 @@ const ViewIncidents = () => {
row.id} data={incidents} columns={[ diff --git a/src/labs/ViewLabs.tsx b/src/labs/ViewLabs.tsx index 3f99fe242f..36ab36c7c8 100644 --- a/src/labs/ViewLabs.tsx +++ b/src/labs/ViewLabs.tsx @@ -104,7 +104,6 @@ const ViewLabs = () => {
row.id} columns={[ { label: t('labs.lab.code'), key: 'code' }, diff --git a/src/patients/care-plans/CarePlanTable.tsx b/src/patients/care-plans/CarePlanTable.tsx index 3b8fd48535..e25280a7af 100644 --- a/src/patients/care-plans/CarePlanTable.tsx +++ b/src/patients/care-plans/CarePlanTable.tsx @@ -14,7 +14,6 @@ const CarePlanTable = () => { return (
row.id} data={patient.carePlans || []} columns={[ diff --git a/src/patients/labs/LabsTab.tsx b/src/patients/labs/LabsTab.tsx index 5461183ac1..2fd8c80db1 100644 --- a/src/patients/labs/LabsTab.tsx +++ b/src/patients/labs/LabsTab.tsx @@ -38,7 +38,6 @@ const LabsTab = (props: Props) => { )} {labs && labs.length > 0 && (
row.id} data={labs} diff --git a/src/patients/list/ViewPatients.tsx b/src/patients/list/ViewPatients.tsx index 80a093f3d5..51aaa381e2 100644 --- a/src/patients/list/ViewPatients.tsx +++ b/src/patients/list/ViewPatients.tsx @@ -68,7 +68,6 @@ const ViewPatients = () => { const loadingIndicator = const table = (
row.id} columns={[ diff --git a/src/patients/related-persons/RelatedPersonTab.tsx b/src/patients/related-persons/RelatedPersonTab.tsx index e445518ba2..a2247f91d6 100644 --- a/src/patients/related-persons/RelatedPersonTab.tsx +++ b/src/patients/related-persons/RelatedPersonTab.tsx @@ -90,7 +90,6 @@ const RelatedPersonTab = (props: Props) => { {relatedPersons ? ( relatedPersons.length > 0 ? (
row.id} data={relatedPersons} columns={[ From b7680aa7129ac6637fc445321a46a819f01229e5 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 30 Jun 2020 07:57:50 +0200 Subject: [PATCH 82/83] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3784fbb5f5..2762c90f73 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@types/shortid": "^0.0.29", "@types/uuid": "^8.0.0", "@types/validator": "~13.1.0", - "@typescript-eslint/eslint-plugin": "~3.4.0", + "@typescript-eslint/eslint-plugin": "~3.5.0", "@typescript-eslint/parser": "~3.5.0", "chalk": "^4.0.0", "commitizen": "~4.1.2", From 10057a8a8f9320bae8ae33529e974960974e52f2 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Tue, 30 Jun 2020 06:01:01 -0500 Subject: [PATCH 83/83] docs: add note about making hospitalrun a public database --- .github/CONTRIBUTING.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e5fae60c0a..1074e42bff 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -36,13 +36,19 @@ The following directions will be for running CouchDB via Docker Compose. This should launch a new CouchDB instance on `http://localhost:5984`, create system database, configure CouchDB as Single Node, enable CORS, create `hospitalrun` database, create a default admin with a username of `admin` and password of 'password' -4. Create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137) +4. Make the `hospitalrun` database a public database by removing its member permissions: + + ``` + curl -X PUT http://admin:password@localhost:5984/hospitalrun/_security -d '{"members": {}, "admins": {"roles": ["_admin"] }}' + ``` + +5. Create a sample user with a username of `username` and password of 'password' to use new login page [#2137](https://github.com/HospitalRun/hospitalrun-frontend/pull/2137) ``` curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:username -H "Accept: application/json" -H "Content-Type: application/json" -d '{"name": "username", "password": "password", "metadata": { "givenName": "John", "familyName": "Doe"}, "roles": [], "type": "user"}' ``` -5. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks. +6. Launch `http://localhost:5984/_utils` to view Fauxton and perform administrative tasks. **_Cleanup_** To delete the development database, go to the root of the project and run `docker-compose down -v --rmi all --remove-orphans`