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(AppointmentsList): add an appointments tab to the patient view #1823
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
deee00e
feat(appointmentslist): add an appointments tab to the patient view
1c86717
Merge branch 'master' into patient-appointment-list
matteovivona b715358
adress review comments
a0ac600
Merge branch 'patient-appointment-list' of https://github.com/igeagon…
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
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,71 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { useSelector, useDispatch } from 'react-redux' | ||
import { useHistory } from 'react-router' | ||
import { useTranslation } from 'react-i18next' | ||
import { TextInput, Button, List, ListItem, Container, Row } from '@hospitalrun/components' | ||
import { RootState } from '../../store' | ||
import { fetchPatientAppointments } from '../../scheduling/appointments/appointments-slice' | ||
|
||
interface Props { | ||
patientId: string | ||
} | ||
|
||
const AppointmentsList = (props: Props) => { | ||
const dispatch = useDispatch() | ||
const history = useHistory() | ||
const { t } = useTranslation() | ||
|
||
const { patientId } = props | ||
const { appointments } = useSelector((state: RootState) => state.appointments) | ||
const [searchText, setSearchText] = useState<string>('') | ||
|
||
useEffect(() => { | ||
dispatch(fetchPatientAppointments(patientId)) | ||
}, [dispatch, patientId]) | ||
|
||
const list = ( | ||
// inline style added to pick up on newlines for string literal | ||
<ul style={{ whiteSpace: 'pre-line' }}> | ||
{appointments.map((a) => ( | ||
<ListItem action key={a.id} onClick={() => history.push(`/appointments/${a.id}`)}> | ||
{new Date(a.startDateTime).toLocaleString()} | ||
</ListItem> | ||
))} | ||
</ul> | ||
) | ||
|
||
const onSearchBoxChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setSearchText(event.target.value) | ||
} | ||
|
||
const onSearchFormSubmit = (event: React.FormEvent | React.MouseEvent) => { | ||
event.preventDefault() | ||
dispatch(fetchPatientAppointments(patientId, searchText)) | ||
} | ||
|
||
return ( | ||
<Container> | ||
<form className="form-inline" onSubmit={onSearchFormSubmit}> | ||
<div className="input-group" style={{ width: '100%' }}> | ||
<TextInput | ||
size="lg" | ||
value={searchText} | ||
placeholder={t('actions.search')} | ||
onChange={onSearchBoxChange} | ||
/> | ||
<div className="input-group-append"> | ||
<Button onClick={onSearchFormSubmit}>{t('actions.search')}</Button> | ||
</div> | ||
Comment on lines
+50
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we have two search boxes, we should consider abstracting that to a component in the |
||
</div> | ||
</form> | ||
|
||
<Row> | ||
<List layout="flush" style={{ width: '100%', marginTop: '10px', marginLeft: '-25px' }}> | ||
{list} | ||
</List> | ||
</Row> | ||
</Container> | ||
) | ||
} | ||
|
||
export default AppointmentsList |
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.
Searching this list is not something that I had previously considered. I think that this is a really neat idea!
@fox1t @tehkapa @lauggh @StefanoMiC,
What does everyone thing the requirements should be here? I see a really cool opportunity for having filter buttons for the different appointment types.
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 can leave it like this for now. We need to open a new feature issue to search about this. We really want a multi-field fuzzy search on almost every entity.