-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Refactor) : Removed patient bills filter and fixed patient search cs…
…s issue (#309) * initial work on patient bills * fix: override button height for patient search extension * refactor: use carbon spacing for tile padding * fix: applied changes from code-review
- Loading branch information
1 parent
ff99bb3
commit 7752c71
Showing
6 changed files
with
111 additions
and
78 deletions.
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
79 changes: 66 additions & 13 deletions
79
...sm-billing-app/src/past-patient-bills/patient-bills-dashboard/patient-bills-dashboard.tsx
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 |
---|---|---|
@@ -1,34 +1,87 @@ | ||
import React, { useState } from 'react'; | ||
import styles from './patient-bills-dashboard.scss'; | ||
import { ExtensionSlot } from '@openmrs/esm-framework'; | ||
import PastPatientBills from '../filtered-patient-bills.component'; | ||
import { ErrorState, ExtensionSlot } from '@openmrs/esm-framework'; | ||
import { useBills } from '../../billing.resource'; | ||
import { Dropdown } from '@carbon/react'; | ||
|
||
const filterItems = [ | ||
{ id: 'PENDING', text: 'Pending bills' }, | ||
{ id: 'POSTED', text: 'Posted bills' }, | ||
]; | ||
import { useTranslation } from 'react-i18next'; | ||
import { DataTableSkeleton } from '@carbon/react'; | ||
import { patientBillsHeaders, PatientBills } from '../patient-bills.component'; | ||
import { EmptyState } from '@openmrs/esm-patient-common-lib'; | ||
|
||
const PatientBillsScreen: React.FC = () => { | ||
const [patientUuid, setPatientUuid] = React.useState<string>(''); | ||
const { bills } = useBills(patientUuid); | ||
const filterBills = bills.filter((bill) => bill.status !== 'PAID' && patientUuid === bill.patientUuid) ?? []; | ||
const [patientUuid, setPatientUuid] = useState<string | undefined>(); | ||
|
||
return ( | ||
<main className={styles.container}> | ||
<ExtensionSlot | ||
name="patient-search-bar-slot" | ||
state={{ | ||
selectPatientAction: (patientUuid) => setPatientUuid(patientUuid), | ||
selectPatientAction: (patientUuid: string) => setPatientUuid(patientUuid), | ||
buttonProps: { | ||
kind: 'primary', | ||
}, | ||
}} | ||
/> | ||
<PastPatientBills patientUuid={patientUuid} bills={filterBills} setPatientUuid={setPatientUuid} /> | ||
<PatientBillsWrapper patientUUID={patientUuid} /> | ||
</main> | ||
); | ||
}; | ||
|
||
const PatientBillsWrapper = ({ patientUUID }: { patientUUID?: string }) => { | ||
const { bills, isLoading, error } = useBills(patientUUID); | ||
|
||
const { t } = useTranslation(); | ||
|
||
if (!patientUUID) { | ||
return ( | ||
<div className={styles.emptyStateContainer}> | ||
<EmptyState | ||
displayText={t('notSearchedState', 'Please search for a patient in the input above')} | ||
headerTitle="Not Searched" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (isLoading) { | ||
return ( | ||
<div className={styles.loadingContainer}> | ||
<DataTableSkeleton | ||
headers={patientBillsHeaders} | ||
aria-label="patient bills table" | ||
showToolbar={false} | ||
showHeader={false} | ||
rowCount={3} | ||
zebra | ||
columnCount={3} | ||
className={styles.dataTableSkeleton} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<div className={styles.errorStateContainer}> | ||
<ErrorState | ||
error={t('anErrorOccurredLoadingPatientBills', 'An error occurred loading patient bills')} | ||
headerTitle={t('errorLoadingPatientBills', 'Error loading patient bills')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (bills.length === 0) { | ||
return ( | ||
<div className={styles.emptyStateContainer}> | ||
<EmptyState | ||
headerTitle={t('noBillsState', 'No Patient Bills Found')} | ||
displayText={t('noBillsFoundToDisplay', 'No bills to dipsplay')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
return <PatientBills bills={bills} />; | ||
}; | ||
|
||
export default PatientBillsScreen; |
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