-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(allergies): ability to click on allergy and view an allergy #2224
Conversation
…tail on separate route feat HospitalRun#2215
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/hospitalrun/hospitalrun-frontend/df3zxkmb3 |
@@ -0,0 +1,41 @@ | |||
import findLast from 'lodash/findLast' |
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.
convention for file naming is PascalCase
.
So for this file, src/patients/allergies/ViewAllergy.tsx
src/patients/allergies/Allergies.tsx
Outdated
<List> | ||
{patient.allergies?.map((a: Allergy) => ( | ||
<ListItem | ||
key={a.id} | ||
onClick={() => history.push(`/patients/${patient.id}/allergies/${a.id}`)} | ||
> | ||
{a.name} | ||
</ListItem> | ||
))} | ||
</List> |
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 should extract this to its own component
|
||
useEffect(() => { | ||
if (patient && allergyId) { | ||
const currentAllergy = findLast(patient.allergies, (a: Allergy) => a.id === allergyId) |
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.
Rather than using findLast
we can use Arrays.find
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find.
@@ -29,9 +29,14 @@ const expectedPatient = { | |||
let user: any | |||
let store: any | |||
|
|||
const setup = (patient = expectedPatient, permissions = [Permissions.AddAllergy]) => { | |||
const setup = ( |
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.
there should be a test that ensures the functionality of clicking on a list element navigates to the allergy.
src/patients/allergies/Allergies.tsx
Outdated
<Route exact path="/patients/:id/allergies"> | ||
<List> | ||
{patient.allergies?.map((a: Allergy) => ( | ||
<ListItem |
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 should indicate that the list item is clickable. We can do this by adding action
as a prop to ListItem
…t component and tests re HospitalRun#2215
…alrun-frontend into feat/view-allergy
@jackcmeyer PR is ready for review |
// console.log('===========================>') | ||
// console.log(patient) | ||
return ( |
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.
remove commented out code
fixes #2215
Changes proposed in this pull request: