-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/hospitalrun/hospitalrun-frontend/an1yuurn8 |
src/patients/GeneralInformation.tsx
Outdated
)} | ||
</form> | ||
</Panel> | ||
{isEditable ? ( |
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.
Looks like some of the stylings may have accidentally changed here.
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.
Github thinks this file is NewPatientForm.tsx (which didn't have panels) renamed to GeneralInformation.tsx, when in fact I deleted NewPatientForm.tsx, so that's why it thinks I put panels in.
src/patients/edit/EditPatient.tsx
Outdated
const dispatch = useDispatch() | ||
|
||
const [patient, setPatient] = useState({} as Patient) | ||
const { patient: reduxPatient } = useSelector((state: RootState) => state.patient) |
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 think that we could add isLoading
to this restructured object so that we can use it for displaying the loading spinner.
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.
done
src/patients/edit/EditPatient.tsx
Outdated
} | ||
|
||
// see comment in ViewPatient | ||
if (!reduxPatient) { |
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.
We could change this check to something like isLoading || !reduxPatient.id
so that the loading spinner properly appears
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.
isLoading
makes sense to me, but what does the check for !reduxPatient.id
add? or should it be !id
, like if there's no parameter? but that seems like it would be handled separately with an error or something
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.
so far I've just used isLoading
which seems to work. Now, you actually see the loading icon when you change patients, etc.
src/patients/view/ViewPatient.tsx
Outdated
@@ -34,6 +37,8 @@ const ViewPatient = () => { | |||
} | |||
}, [dispatch, id]) | |||
|
|||
// this check doesn't work as an empty object isn't falsy. would it be more correct to display | |||
// the spinner when the Redux patient state isLoading is true? | |||
if (!patient) { |
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 think that we can change this check to something like isLoading || !patient.id
when we display the loading spinner.
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.
in this one, test fails unless you use isLoading || !patient
since it uses patient.id to render the tabs
@@ -130,6 +237,7 @@ describe('patients slice', () => { | |||
}) | |||
}) | |||
|
|||
// should check for the Toast |
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.
Does a test still need to be written to check for the Toast?
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.
yeah. I added a toast for updating a Patient and made it redirect history to /patients/${newPatient.id}
, since saving on Edit Patient ought to redirect to that. as a side effect of that, adding a new Related Person now moves you off the Related Persons tab and back onto the General Information tab, but I'm not sure if should do anything else about that now.
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.
added this test
@@ -39,11 +39,11 @@ export default class Repository<T extends AbstractDBModel> { | |||
} | |||
|
|||
async findAll(): Promise<T[]> { | |||
const allPatients = await this.db.allDocs({ | |||
const allDocs = await this.db.allDocs({ |
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.
thanks for renaming these :)
@@ -3,12 +3,13 @@ import { useDispatch, useSelector } from 'react-redux' | |||
import { useParams, withRouter, Route, useHistory, useLocation } from 'react-router-dom' | |||
import { Panel, Spinner, TabsHeader, Tab } from '@hospitalrun/components' | |||
import { useTranslation } from 'react-i18next' | |||
|
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.
extra whitespace here?
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.
just thought it helped to separate the types of imports
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 really like separating type of imports:external deps -> 1 empty line -> internal deps
:)
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 think there's an eslint setting for this, that's why I instinctively did it.
const wrapper = setup() | ||
|
||
const dateOfBirthInput = wrapper.findWhere((w) => w.prop('name') === 'address') | ||
const dateOfBirthInput = wrapper.findWhere((w: any) => w.prop('name') === 'address') |
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 think this variable name should be addressTextField
. This is probably my bad, copy paste :(
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.
done
const wrapper = setup() | ||
|
||
const dateOfBirthInput = wrapper.findWhere((w) => w.prop('name') === 'occupation') | ||
const dateOfBirthInput = wrapper.findWhere((w: any) => w.prop('name') === 'occupation') |
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 should probably be occupationInput
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.
done
const wrapper = setup() | ||
|
||
const dateOfBirthInput = wrapper.findWhere((w) => w.prop('name') === 'preferredLanguage') | ||
const dateOfBirthInput = wrapper.findWhere((w: any) => w.prop('name') === 'preferredLanguage') |
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.
preferredLanguageInput
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.
done
const wrapper = setup() | ||
|
||
const dateOfBirthInput = wrapper.findWhere((w) => w.prop('name') === 'phoneNumber') | ||
const dateOfBirthInput = wrapper.findWhere((w: any) => w.prop('name') === 'phoneNumber') |
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.
phoneNumberInput
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.
done
<PrivateRoute | ||
isAuthenticated={ | ||
permissions.includes(Permissions.WritePatients) && | ||
permissions.includes(Permissions.ReadPatients) | ||
} | ||
exact | ||
path="/patients/edit/:id" | ||
component={EditPatient} | ||
/> |
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 think that we need some tests in HospitalRun.test.tsx
surrounding this new route, especially for permissions.
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.
Added these
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.
UI Styling comment:
Edit button should be in the top right corner, outlined success variant, and a pencil icon.
Add tests into GeneralInformation that were in the now-deleted NewPatientForm
Still need to add tests for the new route in HospitalRun component, and the actual tests for EditPatient. |
{isEditable && ( | ||
<div className="row float-right"> | ||
<div className="btn-group btn-group-lg"> | ||
<Button className="mr-2" color="success" onClick={onSaveButtonClick}> | ||
{t('actions.save')} | ||
</Button> | ||
<Button color="danger" onClick={() => onCancel()}> | ||
{t('actions.cancel')} | ||
</Button> | ||
</div> |
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 think we want to keep these buttons
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.
that's where the buttons were in NewPatientForm, the entire file is deleted but Github thinks I renamed it to GeneralInformation and deleted GeneralInformation. The buttons are still there, they're just slightly further down. GeneralInformation has a different layout than NewPatientForm because it has the panels.
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.
ok, I restored the previous style of buttons
Added tests for EditPatient component and the |
@MatthewDorner this afternoon we fixed an annoying bug with husky/lint. Could you Resolve conflicts and errors? thank you! |
onChange={ | ||
(event: React.ChangeEvent<HTMLTextAreaElement>) => | ||
onFieldChange && onFieldChange('address', event.currentTarget.value) | ||
// eslint-disable-next-line react/jsx-curly-newline | ||
} |
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.
Can't get eslint to accept this any way I can think to format it, or via the eslint automatic fix. There must be two conflicting rules.
Instead of conditionally rendering buttons in GeneralInformation, render them in their parent components (New/View/Edit Patient).
|
Tests passing now. Looks like I should add some more tests, although I was thinking of going through the tests more thoroughly after this gets merged anyway. |
@@ -3,12 +3,13 @@ import { useDispatch, useSelector } from 'react-redux' | |||
import { useParams, withRouter, Route, useHistory, useLocation } from 'react-router-dom' | |||
import { Panel, Spinner, TabsHeader, Tab } from '@hospitalrun/components' | |||
import { useTranslation } from 'react-i18next' | |||
|
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 really like separating type of imports:external deps -> 1 empty line -> internal deps
:)
@MatthewDorner Great PR! |
LGTM |
Fixes #1765
GeneralInformation
form.isEditable
prop in input components to make it false by default, as this seems to make more sense for booleancreatePatient
into patient slice instead of patientsRight now the tests should all pass but I still need to add the tests for Edit Patient and improve some other tests. I think I also need to add error handling back into the new form since I lost it when I deleted
NewPatientForm
.