Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Aug 26, 2024
1 parent 945cbf7 commit 7898670
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ const CareTeamForm: React.FC<CareTeamFormProps> = (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 {
Expand Down Expand Up @@ -155,7 +154,7 @@ const CareTeamForm: React.FC<CareTeamFormProps> = (props: CareTeamFormProps) =>
mode="multiple"
allowClear
getFullOptionOnChange={practitionerChangeHandler}
discoverUnknownOptions={practitionerPreloadExistingOptions as any}
discoverUnknownOptions={practitionerPreloadExistingOptions}
/>
</Form.Item>

Expand All @@ -175,7 +174,7 @@ const CareTeamForm: React.FC<CareTeamFormProps> = (props: CareTeamFormProps) =>
placeholder={t('Select a managing Organization')}
disabled={disabled?.includes(managingOrganizations)}
getFullOptionOnChange={organizationChangeHandler}
discoverUnknownOptions={organizationPreloadExistingOptions as any}
discoverUnknownOptions={organizationPreloadExistingOptions}
/>
</Form.Item>

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -38,7 +37,6 @@ jest.mock('@opensrp/notifications', () => ({
...Object.assign({}, jest.requireActual('@opensrp/notifications')),
}));


const mockId = '0b3a3311-6f5a-40dd-95e5-008001acebe1';

jest.mock('uuid', () => {
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { history } from '@onaio/connected-reducer-registry';
import { v4 } from 'uuid';
import {
FHIRServiceClass,
Expand All @@ -9,15 +8,14 @@ import {
SelectOption,
TransformOptions,
} from '@opensrp/react-utils';
import { sendErrorNotification, sendSuccessNotification } from '@opensrp/notifications';
import { sendSuccessNotification } from '@opensrp/notifications';
import {
FHIR_CARE_TEAM,
id,
organizationParticipants,
organizationResourceType,
practitionerParticipants,
practitionerResourceType,
URL_CARE_TEAM,
uuid,
name,
status,
Expand Down Expand Up @@ -265,11 +263,12 @@ export function preloadExistingOptionsFactory<ResourceT extends IResource>(
url: fhirBaseUrl,
})
.then((response) => {
return getResourcesFromBundle<ResourceT>(response as IBundle).map(optionsPreprocessor);
return getResourcesFromBundle<ResourceT>(response as IBundle).map(
optionsPreprocessor
) as SelectOption<ResourceT>[];
})
.catch((err) => {
console.log({ err });
return [];
.catch(() => {
return [] as SelectOption<ResourceT>[];
});
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -128,7 +128,7 @@ export function PaginatedAsyncSelect<ResourceT extends IResource>(
const missingValues: string[] = [];
for (const value of poolValuesToCheck) {
if (typeof value === 'string') {
if (optionsByValue[value] === undefined) {
if (!optionsByValue[value]) {

Check failure on line 131 in packages/react-utils/src/components/AsyncSelect/PaginatedAsyncSelect/index.tsx

View workflow job for this annotation

GitHub Actions / test (22.x, ubuntu-latest)

Unnecessary conditional, value is always falsy
missingValues.push(value);
} else {
// TODO - YAGNI - case when value is labelledValue
Expand Down Expand Up @@ -172,8 +172,6 @@ export function PaginatedAsyncSelect<ResourceT extends IResource>(
const totalPossibleRecords = getTotalRecordsOnApi(pages);
const remainingRecords = totalPossibleRecords - recordsFetchedNum;

console.log({ error });

const propsToSelect = {
style: { minWidth: '200px' },
...restProps,
Expand Down

0 comments on commit 7898670

Please sign in to comment.