@openmrs/esm-appointments-app 9.1.2-pre.6596 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import dayjs from 'dayjs';
2
3
  import { useTranslation } from 'react-i18next';
3
4
  import {
4
5
  InlineLoading,
@@ -11,12 +12,11 @@ import {
11
12
  StructuredListWrapper,
12
13
  } from '@carbon/react';
13
14
  import { formatDate, parseDate, showSnackbar, type Visit } from '@openmrs/esm-framework';
14
- import { changeAppointmentStatus, usePatientAppointments } from './patient-appointments.resource';
15
15
  import { ErrorState } from '@openmrs/esm-patient-common-lib';
16
- import styles from './patient-upcoming-appointments-card.scss';
17
- import dayjs from 'dayjs';
16
+ import { changeAppointmentStatus, usePatientAppointments } from './patient-appointments.resource';
18
17
  import { type Appointment } from '../types';
19
18
  import { useMutateAppointments } from '../form/appointments-form.resource';
19
+ import styles from './patient-upcoming-appointments-card.scss';
20
20
 
21
21
  interface VisitFormCallbacks {
22
22
  onVisitCreatedOrUpdated: (visit: Visit) => Promise<any>;
@@ -44,7 +44,7 @@ const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps
44
44
  patientChartConfig,
45
45
  }) => {
46
46
  const { t } = useTranslation();
47
- const startDate = dayjs(new Date().toISOString()).subtract(6, 'month').toISOString();
47
+ const startDate = useMemo(() => dayjs().subtract(6, 'month').toISOString(), []);
48
48
  const headerTitle = t('upcomingAppointments', 'Upcoming appointments');
49
49
  const [selectedAppointment, setSelectedAppointment] = useState<Appointment>(null);
50
50
  const { mutateAppointments } = useMutateAppointments();
@@ -102,12 +102,13 @@ const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps
102
102
  };
103
103
 
104
104
  if (!patientChartConfig.showUpcomingAppointments) {
105
- return <></>;
105
+ return null;
106
106
  }
107
107
 
108
108
  if (error) {
109
109
  return <ErrorState headerTitle={headerTitle} error={error} />;
110
110
  }
111
+
111
112
  if (isLoading) {
112
113
  return (
113
114
  <span>
@@ -159,11 +160,11 @@ const PatientUpcomingAppointmentsCard: React.FC<PatientUpcomingAppointmentsProps
159
160
 
160
161
  return (
161
162
  <InlineNotification
162
- kind={'info'}
163
- lowContrast
164
163
  className={styles.inlineNotification}
165
- title={t('upcomingAppointments', 'Upcoming appointments')}
164
+ kind="info"
165
+ lowContrast
166
166
  subtitle={t('noUpcomingAppointments', 'No upcoming appointments found')}
167
+ title={t('upcomingAppointments', 'Upcoming appointments')}
167
168
  />
168
169
  );
169
170
  };
@@ -149,6 +149,7 @@
149
149
  "todays": "Today's",
150
150
  "TUE": "TUE",
151
151
  "type": "Type",
152
+ "unknownError": "An unknown error occurred",
152
153
  "unscheduled": "Unscheduled",
153
154
  "unscheduledAppointments": "Unscheduled appointments",
154
155
  "unscheduledAppointments_lower": "unscheduled appointments",