This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(patients): add no patients exist #2235
Merged
jackcmeyer
merged 8 commits into
HospitalRun:master
from
Fibii:feat(patients)-implement-noPatients
Aug 5, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9ada8f0
feat(patients): add no patients exist
Fibii 0b5701c
add missing useEffect dependency
Fibii 86ca0f9
Merge branch 'master' into feat(patients)-implement-noPatients
matteovivona a65f44c
Merge branch 'master' into feat(patients)-implement-noPatients
matteovivona 09a9066
feat(patients): add proposed changes in PR #2235
Fibii 69e689b
Merge branch 'master' into feat(patients)-implement-noPatients
matteovivona 3aff81e
feat(patients): add proposed changes in PR
Fibii fbd94b4
Merge branch 'master' into feat(patients)-implement-noPatients
matteovivona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Icon, Typography, Button } from '@hospitalrun/components' | ||
import { mount } from 'enzyme' | ||
import React from 'react' | ||
|
||
import NoPatientsExist from '../../../patients/view/NoPatientsExist' | ||
|
||
describe('NoPatientsExist', () => { | ||
const setup = () => mount(<NoPatientsExist />) | ||
|
||
it('should render an icon and a button with typography', () => { | ||
const wrapper = setup() | ||
|
||
const addNewPatient = wrapper.find(NoPatientsExist) | ||
expect(addNewPatient).toHaveLength(1) | ||
|
||
const icon = wrapper.find(Icon).first() | ||
const typography = wrapper.find(Typography) | ||
const button = wrapper.find(Button) | ||
const iconType = icon.prop('icon') | ||
const iconSize = icon.prop('size') | ||
const typographyText = typography.prop('children') | ||
const typographyVariant = typography.prop('variant') | ||
const buttonIcon = button.prop('icon') | ||
const buttonText = button.prop('children') | ||
|
||
expect(iconType).toEqual('patients') | ||
expect(iconSize).toEqual('6x') | ||
expect(typographyText).toEqual('patients.noPatients') | ||
expect(typographyVariant).toEqual('h5') | ||
expect(buttonIcon).toEqual('patient-add') | ||
expect(buttonText).toEqual('patients.newPatient') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Button, Icon, Typography } from '@hospitalrun/components' | ||
import React from 'react' | ||
import { useHistory } from 'react-router-dom' | ||
|
||
import useTranslator from '../../shared/hooks/useTranslator' | ||
|
||
const NoPatientsExist = () => { | ||
const history = useHistory() | ||
const { t } = useTranslator() | ||
|
||
return ( | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<div style={{ display: 'flex', flexDirection: 'column' }}> | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<Icon icon="patients" outline={false} size="6x" /> | ||
</div> | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<div style={{ textAlign: 'center', width: '60%', margin: 16 }}> | ||
<Typography variant="h5">{t('patients.noPatients')}</Typography> | ||
</div> | ||
</div> | ||
<div style={{ display: 'flex', justifyContent: 'center' }}> | ||
<Button | ||
key="newPatientButton" | ||
outlined | ||
color="primary" | ||
icon="patient-add" | ||
onClick={() => history.push('/patients/new')} | ||
> | ||
{t('patients.newPatient')} | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default NoPatientsExist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
patients
variable represents the current patients in state.This could be the default page of patients or a search result. When searching for patients and my search results return 0, I would not expect the new icon to appear.
I think that we should implement a new function called
count
inRepository
that returns the number of documents that are available for a type.Then here, we use that
count
function to determine if the new icon should display or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i get it, what i don't get is why do we need to implement
count
?it seems like
PatientRepository.findAll()
returns all the existing patients in the db, we can use it as:count
addNewPations
component, else show the tablebut it seems that implementing a
count
inRepository
seems like a better solution here, since it makesRepository
more flexible for future issues/enhancements