Skip to content

Commit

Permalink
fix: Add initial selected item in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
harshthakkr committed Jan 9, 2025
1 parent bccb20a commit ac35818
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ function ClinicMetrics() {
const { activeVisitsCount, isLoading: loading } = useActiveVisits();
const { waitTime } = useAverageWaitTime(currentService?.serviceUuid, '');

const defaultServiceItem = {
display: `${t('all', 'All')}`,
uuid: '',
};

const serviceItems = [defaultServiceItem, ...(services ?? [])];

const handleServiceChange = ({ selectedItem }) => {
updateSelectedService(selectedItem.uuid, selectedItem.display);
if (selectedItem.uuid == undefined) {
Expand Down Expand Up @@ -63,11 +70,12 @@ function ClinicMetrics() {
locationUuid={currentQueueLocation}>
<Dropdown
id="inline"
items={[{ display: `${t('all', 'All')}` }, ...(services ?? [])]}
initialSelectedItem={defaultServiceItem}
items={serviceItems}
itemToString={(item) =>
item ? `${item.display} ${item.location?.display ? `- ${item.location.display}` : ''}` : ''
}
label={t('all', 'All')}
label=""
onChange={handleServiceChange}
size={isDesktop(layout) ? 'sm' : 'lg'}
titleText=""
Expand Down

0 comments on commit ac35818

Please sign in to comment.