Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen committed Jan 13, 2025
1 parent f0cd18a commit b7b1b57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,50 @@ import { updateSelectedService, useSelectedService, useSelectedQueueLocationUuid
import { useActiveVisits, useAverageWaitTime } from './clinic-metrics.resource';
import { useServiceMetricsCount } from './queue-metrics.resource';
import { useQueueEntries } from '../hooks/useQueueEntries';
import useQueueServices from '../hooks/useQueueService';
import { type Concept } from '../types';
import MetricsCard from './metrics-card.component';
import MetricsHeader from './metrics-header.component';
import useQueueServices from '../hooks/useQueueService';
import styles from './clinic-metrics.scss';
import { type Concept } from '../types';

export interface Service {
uuid: string;
display: string;
uuid?: string;
}

type ServiceListItem = Service | Concept;

function ClinicMetrics() {
const { t } = useTranslation();
const layout = useLayoutType();

const currentQueueLocation = useSelectedQueueLocationUuid();
const { services } = useQueueServices();
const currentService = useSelectedService();

const { services } = useQueueServices();
const { serviceCount } = useServiceMetricsCount(currentService?.serviceUuid, currentQueueLocation);

const [initialSelectedItem, setInitialSelectItem] = useState(() => {
return !currentService?.serviceDisplay || !currentService?.serviceUuid;
});

const { totalCount } = useQueueEntries({
service: currentService?.serviceUuid,
location: currentQueueLocation,
isEnded: false,
});

const { activeVisitsCount, isLoading: loading } = useActiveVisits();
const { waitTime } = useAverageWaitTime(currentService?.serviceUuid, '');

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

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

const handleServiceChange = ({ selectedItem }) => {
updateSelectedService(selectedItem.uuid, selectedItem.display);
if (selectedItem.uuid == undefined) {
if (selectedItem.uuid === undefined) {
setInitialSelectItem(true);
} else {
setInitialSelectItem(false);
Expand All @@ -59,18 +61,18 @@ function ClinicMetrics() {
<MetricsHeader />
<div className={styles.cardContainer} data-testid="clinic-metrics">
<MetricsCard
label={t('patients', 'Patients')}
value={loading ? '--' : activeVisitsCount}
headerLabel={t('checkedInPatients', 'Checked in patients')}
label={t('patients', 'Patients')}
service="scheduled"
value={loading ? '--' : activeVisitsCount}
/>
<MetricsCard
headerLabel=""
label={t('patients', 'Patients')}
value={initialSelectedItem ? totalCount ?? '--' : serviceCount}
headerLabel={`${t('waitingFor', 'Waiting for')}:`}
locationUuid={currentQueueLocation}
service={currentService?.serviceDisplay}
serviceUuid={currentService?.serviceUuid}
locationUuid={currentQueueLocation}>
value={initialSelectedItem ? totalCount ?? '--' : serviceCount}>
<Dropdown
id="inline"
initialSelectedItem={defaultServiceItem}
Expand All @@ -81,15 +83,15 @@ function ClinicMetrics() {
label=""
onChange={handleServiceChange}
size={isDesktop(layout) ? 'sm' : 'lg'}
titleText=""
titleText={`${t('waitingFor', 'Waiting for')}:`}
type="inline"
/>
</MetricsCard>
<MetricsCard
label={t('minutes', 'Minutes')}
value={waitTime ? waitTime.averageWaitTime : '--'}
headerLabel={t('averageWaitTime', 'Average wait time today')}
service="waitTime"
value={waitTime ? waitTime.averageWaitTime : '--'}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@
.headerLabelContainer {
display: flex;
height: layout.$spacing-07;
align-items: center;

:global(.cds--dropdown__wrapper--inline) {
gap: 0;
margin-top: -(layout.$spacing-04);

label {
@include type.type-style('heading-compact-01');
color: $text-02;
margin-right: layout.$spacing-03;
}
}

:global(.cds--list-box__menu-icon) {
Expand Down

0 comments on commit b7b1b57

Please sign in to comment.