diff --git a/packages/fhir-care-team/src/components/CreateEditCareTeam/Form.tsx b/packages/fhir-care-team/src/components/CreateEditCareTeam/Form.tsx index 4dd3001c5..d17e38ffc 100644 --- a/packages/fhir-care-team/src/components/CreateEditCareTeam/Form.tsx +++ b/packages/fhir-care-team/src/components/CreateEditCareTeam/Form.tsx @@ -101,8 +101,7 @@ const CareTeamForm: React.FC = (props: CareTeamFormProps) => .then(() => { history.push(URL_CARE_TEAM); }) - .catch((err) => { - console.log({ err }); + .catch(() => { if (initialValues.id) { sendErrorNotification(t('There was a problem updating the Care Team')); } else { @@ -155,7 +154,7 @@ const CareTeamForm: React.FC = (props: CareTeamFormProps) => mode="multiple" allowClear getFullOptionOnChange={practitionerChangeHandler} - discoverUnknownOptions={practitionerPreloadExistingOptions as any} + discoverUnknownOptions={practitionerPreloadExistingOptions} /> @@ -175,7 +174,7 @@ const CareTeamForm: React.FC = (props: CareTeamFormProps) => placeholder={t('Select a managing Organization')} disabled={disabled?.includes(managingOrganizations)} getFullOptionOnChange={organizationChangeHandler} - discoverUnknownOptions={organizationPreloadExistingOptions as any} + discoverUnknownOptions={organizationPreloadExistingOptions} /> diff --git a/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/form.test.tsx b/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/form.test.tsx index 6b9770456..036b74952 100644 --- a/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/form.test.tsx +++ b/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/form.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { CareTeamForm } from '../Form'; import { defaultInitialValues, getCareTeamFormFields } from '../utils'; -import { cleanup, fireEvent, waitFor, render, screen, prettyDOM } from '@testing-library/react'; +import { cleanup, fireEvent, waitFor, render, screen } from '@testing-library/react'; import userEvents from '@testing-library/user-event'; import * as notifications from '@opensrp/notifications'; import nock from 'nock'; diff --git a/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/index.test.tsx b/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/index.test.tsx index 48db82812..403dc4865 100644 --- a/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/index.test.tsx +++ b/packages/fhir-care-team/src/components/CreateEditCareTeam/tests/index.test.tsx @@ -24,7 +24,6 @@ import { import { screen, render } from '@testing-library/react'; import userEvents from '@testing-library/user-event'; import { careTeam1, careTeam4201Edited, organizations } from './fixtures'; -import flushPromises from 'flush-promises'; import { RoleContext } from '@opensrp/rbac'; import { superUserRole } from '@opensrp/react-utils'; import * as notifications from '@opensrp/notifications'; @@ -38,7 +37,6 @@ jest.mock('@opensrp/notifications', () => ({ ...Object.assign({}, jest.requireActual('@opensrp/notifications')), })); - const mockId = '0b3a3311-6f5a-40dd-95e5-008001acebe1'; jest.mock('uuid', () => { @@ -208,9 +206,8 @@ test('#1016 - does not create malformed request body', async () => { const history = createMemoryHistory(); const successNoticeMock = jest - .spyOn(notifications, 'sendSuccessNotification') - .mockImplementation(() => undefined); - + .spyOn(notifications, 'sendSuccessNotification') + .mockImplementation(() => undefined); const careTeamId = fixtures.careTeam4201.id; history.push(`/add/${careTeamId}`); @@ -266,8 +263,8 @@ test('#1016 - does not create malformed request body', async () => { }); await waitFor(() => { - expect(successNoticeMock).toHaveBeenCalledWith("Successfully updated CareTeams") - }) + expect(successNoticeMock).toHaveBeenCalledWith('Successfully updated CareTeams'); + }); }); test('data loading problem', async () => { diff --git a/packages/fhir-care-team/src/components/CreateEditCareTeam/utils.tsx b/packages/fhir-care-team/src/components/CreateEditCareTeam/utils.tsx index b5c7d6de5..5e747725f 100644 --- a/packages/fhir-care-team/src/components/CreateEditCareTeam/utils.tsx +++ b/packages/fhir-care-team/src/components/CreateEditCareTeam/utils.tsx @@ -1,4 +1,3 @@ -import { history } from '@onaio/connected-reducer-registry'; import { v4 } from 'uuid'; import { FHIRServiceClass, @@ -9,7 +8,7 @@ import { SelectOption, TransformOptions, } from '@opensrp/react-utils'; -import { sendErrorNotification, sendSuccessNotification } from '@opensrp/notifications'; +import { sendSuccessNotification } from '@opensrp/notifications'; import { FHIR_CARE_TEAM, id, @@ -17,7 +16,6 @@ import { organizationResourceType, practitionerParticipants, practitionerResourceType, - URL_CARE_TEAM, uuid, name, status, @@ -265,11 +263,12 @@ export function preloadExistingOptionsFactory( url: fhirBaseUrl, }) .then((response) => { - return getResourcesFromBundle(response as IBundle).map(optionsPreprocessor); + return getResourcesFromBundle(response as IBundle).map( + optionsPreprocessor + ) as SelectOption[]; }) - .catch((err) => { - console.log({ err }); - return []; + .catch(() => { + return [] as SelectOption[]; }); }; } diff --git a/packages/react-utils/src/components/AsyncSelect/PaginatedAsyncSelect/index.tsx b/packages/react-utils/src/components/AsyncSelect/PaginatedAsyncSelect/index.tsx index 175178411..4a35ae4d9 100644 --- a/packages/react-utils/src/components/AsyncSelect/PaginatedAsyncSelect/index.tsx +++ b/packages/react-utils/src/components/AsyncSelect/PaginatedAsyncSelect/index.tsx @@ -1,7 +1,7 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { URLParams } from '@opensrp/server-service'; import { IBundle } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/IBundle'; -import { useInfiniteQuery, useQueries, useQuery } from 'react-query'; +import { useInfiniteQuery, useQuery } from 'react-query'; import { VerticalAlignBottomOutlined } from '@ant-design/icons'; import { Button, Divider, Select, Empty, Space, Spin, Alert } from 'antd'; import type { SelectProps } from 'antd'; @@ -128,7 +128,7 @@ export function PaginatedAsyncSelect( const missingValues: string[] = []; for (const value of poolValuesToCheck) { if (typeof value === 'string') { - if (optionsByValue[value] === undefined) { + if (!optionsByValue[value]) { missingValues.push(value); } else { // TODO - YAGNI - case when value is labelledValue @@ -172,8 +172,6 @@ export function PaginatedAsyncSelect( const totalPossibleRecords = getTotalRecordsOnApi(pages); const remainingRecords = totalPossibleRecords - recordsFetchedNum; - console.log({ error }); - const propsToSelect = { style: { minWidth: '200px' }, ...restProps,