From 8d275ffb9b1598bea916f3a3669175925fc34d32 Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Wed, 20 Apr 2022 23:28:51 +0300 Subject: [PATCH] (refactor) Replace deprecated `useSessionUser` with `useSession` (#177) --- .../patient-queue-header/patient-queue-header.component.tsx | 4 ++-- .../src/add-patient/add-patient.component.tsx | 4 ++-- .../offline-patient-table/offline-patient-table.component.tsx | 4 ++-- .../src/patient-list-list/patient-list-list.component.tsx | 4 ++-- .../src/patient-list-list/patient-list-table.component.tsx | 4 ++-- .../create-edit-patient-list/create-edit-list.component.tsx | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/esm-outpatient-app/src/patient-queue-header/patient-queue-header.component.tsx b/packages/esm-outpatient-app/src/patient-queue-header/patient-queue-header.component.tsx index 2fd41c37b..8331576b7 100644 --- a/packages/esm-outpatient-app/src/patient-queue-header/patient-queue-header.component.tsx +++ b/packages/esm-outpatient-app/src/patient-queue-header/patient-queue-header.component.tsx @@ -3,13 +3,13 @@ import { useTranslation } from 'react-i18next'; import Calendar16 from '@carbon/icons-react/es/calendar/16'; import Location16 from '@carbon/icons-react/es/location/16'; import { Dropdown } from 'carbon-components-react'; -import { formatDate, useSessionUser } from '@openmrs/esm-framework'; +import { formatDate, useSession } from '@openmrs/esm-framework'; import PatientQueueIllustration from './patient-queue-illustration.component'; import styles from './patient-queue-header.scss'; const PatientQueueHeader: React.FC<{ title: string }> = ({ title }) => { const { t } = useTranslation(); - const userSession = useSessionUser(); + const userSession = useSession(); const userLocation = userSession?.sessionLocation?.display; const careTypes = [ { diff --git a/packages/esm-patient-list-app/src/add-patient/add-patient.component.tsx b/packages/esm-patient-list-app/src/add-patient/add-patient.component.tsx index 35b919959..46f405029 100644 --- a/packages/esm-patient-list-app/src/add-patient/add-patient.component.tsx +++ b/packages/esm-patient-list-app/src/add-patient/add-patient.component.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useMemo, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; -import { toOmrsIsoString, showToast, usePagination, useSessionUser } from '@openmrs/esm-framework'; +import { toOmrsIsoString, showToast, usePagination, useSession } from '@openmrs/esm-framework'; import { Button, Checkbox, Pagination, Search, SkeletonText } from 'carbon-components-react'; import styles from './add-patient.scss'; import { addPatientToLocalOrRemotePatientList } from '../api/api'; @@ -22,7 +22,7 @@ type PatientListObj = Record; const AddPatient: React.FC = ({ closeModal, patientUuid }) => { const { t } = useTranslation(); const [searchValue, setSearchValue] = useState(''); - const userId = useSessionUser()?.user.uuid; + const userId = useSession()?.user.uuid; const { data, isValidating } = useAllPatientListsWhichDoNotIncludeGivenPatient(userId, patientUuid); const [patientListsObj, setPatientListsObj] = useState(null); diff --git a/packages/esm-patient-list-app/src/offline-patient-table/offline-patient-table.component.tsx b/packages/esm-patient-list-app/src/offline-patient-table/offline-patient-table.component.tsx index 9bfeefdcc..9e2eb860e 100644 --- a/packages/esm-patient-list-app/src/offline-patient-table/offline-patient-table.component.tsx +++ b/packages/esm-patient-list-app/src/offline-patient-table/offline-patient-table.component.tsx @@ -20,7 +20,7 @@ import { import { useStore, getOfflinePatientDataStore, - useSessionUser, + useSession, age, useLayoutType, syncOfflinePatientData, @@ -43,7 +43,7 @@ export interface OfflinePatientTableProps { const OfflinePatientTable: React.FC = ({ isInteractive, showHeader }) => { const { t } = useTranslation(); const store = useStore(getOfflinePatientDataStore()); - const userId = useSessionUser()?.user.uuid; + const userId = useSession()?.user.uuid; const layout = useLayoutType(); const { isValidating, data: patients, mutate } = useAllPatientsFromOfflinePatientList(userId); const toolbarItemSize = layout === 'desktop' ? 'sm' : undefined; diff --git a/packages/esm-patient-list-app/src/patient-list-list/patient-list-list.component.tsx b/packages/esm-patient-list-app/src/patient-list-list/patient-list-list.component.tsx index 116f9abee..449c0e1ad 100755 --- a/packages/esm-patient-list-app/src/patient-list-list/patient-list-list.component.tsx +++ b/packages/esm-patient-list-app/src/patient-list-list/patient-list-list.component.tsx @@ -4,7 +4,7 @@ import { Button, DataTableHeader, Tab, Tabs } from 'carbon-components-react'; import PatientListTable from './patient-list-table.component'; import CreateNewList from '../ui-components/create-edit-patient-list/create-edit-list.component'; import { useTranslation } from 'react-i18next'; -import { ExtensionSlot, useSessionUser } from '@openmrs/esm-framework'; +import { ExtensionSlot, useSession } from '@openmrs/esm-framework'; import styles from './patient-list-list.scss'; import { useAllPatientLists } from '../api/hooks'; import { PatientList, PatientListFilter, PatientListType } from '../api/types'; @@ -78,7 +78,7 @@ const PatientListList: React.FC = () => { const [selectedTab, setSelectedTab] = useState(TabTypes.STARRED); const [searchString, setSearchString] = useState(''); const patientListFilter = usePatientListFilterForCurrentTab(selectedTab, searchString); - const userId = useSessionUser()?.user.uuid; + const userId = useSession()?.user.uuid; const customHeaders = useAppropriateTableHeadersForSelectedTab(selectedTab); const patientListQuery = useAllPatientLists(userId, patientListFilter); diff --git a/packages/esm-patient-list-app/src/patient-list-list/patient-list-table.component.tsx b/packages/esm-patient-list-app/src/patient-list-list/patient-list-table.component.tsx index 3951af178..24daa7985 100755 --- a/packages/esm-patient-list-app/src/patient-list-list/patient-list-table.component.tsx +++ b/packages/esm-patient-list-app/src/patient-list-list/patient-list-table.component.tsx @@ -17,7 +17,7 @@ import { } from 'carbon-components-react'; import Star16 from '@carbon/icons-react/es/star/16'; import StarFilled16 from '@carbon/icons-react/es/star--filled/16'; -import { useSessionUser, ConfigurableLink, useLayoutType } from '@openmrs/esm-framework'; +import { useSession, ConfigurableLink, useLayoutType } from '@openmrs/esm-framework'; import styles from './patient-list-list.scss'; import debounce from 'lodash-es/debounce'; import { updateLocalOrRemotePatientList } from '../api/api'; @@ -54,7 +54,7 @@ const PatientListTable: React.FC = ({ refetch, search, }) => { - const userId = useSessionUser()?.user.uuid; + const userId = useSession()?.user.uuid; const isDesktop = useLayoutType() === 'desktop'; const handleSearch = useMemo(() => debounce((searchTerm) => search.onSearch(searchTerm), 300), []); diff --git a/packages/esm-patient-list-app/src/ui-components/create-edit-patient-list/create-edit-list.component.tsx b/packages/esm-patient-list-app/src/ui-components/create-edit-patient-list/create-edit-list.component.tsx index 74ce84e8f..a113f43dc 100644 --- a/packages/esm-patient-list-app/src/ui-components/create-edit-patient-list/create-edit-list.component.tsx +++ b/packages/esm-patient-list-app/src/ui-components/create-edit-patient-list/create-edit-list.component.tsx @@ -3,7 +3,7 @@ import { Button, Dropdown, OnChangeData, TextArea, TextInput } from 'carbon-comp import Overlay from '../../overlay.component'; import { useTranslation } from 'react-i18next'; import styles from './create-edit-patient-list.scss'; -import { useLayoutType, showToast, useSessionUser } from '@openmrs/esm-framework'; +import { useLayoutType, showToast, useSession } from '@openmrs/esm-framework'; import { createPatientList, editPatientList } from '../../api/api-remote'; import { useCohortTypes } from '../../api/hooks'; import { OpenmrsCohort, NewCohortData } from '../../api/types'; @@ -29,7 +29,7 @@ const CreateEditPatientList: React.FC = ({ location: '', }); const isDesktop = useLayoutType() === 'desktop'; - const user = useSessionUser(); + const user = useSession(); const { data: cohortTypes } = useCohortTypes(); useEffect(() => {