Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixup in the patient list modal #29

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Minor fixup
  • Loading branch information
vasharma05 committed Jul 28, 2021
commit 4a7bfe8bc92e576a636fca91c65a8ed265b01658
10 changes: 5 additions & 5 deletions packages/esm-patient-list-app/src/AddPatientToList/index.tsx
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@ const AddPatient: React.FC<AddPatientProps> = ({ closeModal, patientUuid }) => {
const [searchValue, setSearchValue] = useState('');
const userId = useSessionUser()?.user.uuid;
const { loading, data } = usePatientListData(userId);
const [page, setPage] = useState(1);
const [patientListsObj, setPatientListsObj] = useState<PatientListObj | null>(null);

useEffect(() => {
@@ -95,7 +94,6 @@ const AddPatient: React.FC<AddPatientProps> = ({ closeModal, patientUuid }) => {
if (data && patientListsObj) {
if (searchValue && searchValue.trim() !== '') {
const search = searchValue.toLowerCase();
setPage(1);
return data.filter(
(patientList) =>
patientListsObj[patientList.id]?.visible && patientList.display.toLowerCase().includes(search),
@@ -110,8 +108,10 @@ const AddPatient: React.FC<AddPatientProps> = ({ closeModal, patientUuid }) => {
const { results, goTo, currentPage, paginated } = usePagination(searchResults, 5);

useEffect(() => {
goTo(page);
}, [page]);
if (currentPage !== 1) {
goTo(1);
}
}, [searchValue]);

return (
<div className={styles.modalContent}>
@@ -169,7 +169,7 @@ const AddPatient: React.FC<AddPatientProps> = ({ closeModal, patientUuid }) => {
pageSize={5}
pageSizes={[5]}
totalItems={searchResults.length}
onChange={({ page }) => setPage(page)}
onChange={({ page }) => goTo(page)}
/>
</div>
)}