Skip to content

Commit a2bf4fe

Browse files
authored
UISACQCOMP-238 Support 'CLAIMS' export type in the 'useIntegrationConfigs' hook (#842)
* UISACQCOMP-238 Support 'CLAIMS' export type in the 'useIntegrationConfigs' hook * update test
1 parent 76fa627 commit a2bf4fe

File tree

8 files changed

+49
-12
lines changed

8 files changed

+49
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Move reusable helper function to support version history functionality. Refs UISACQCOMP-232.
88
* Move reusable version history hook useVersionHistoryValueResolvers to the ACQ lib. Refs UISACQCOMP-235.
99
* Move reusable claiming code from `ui-receiving` to the shared library. Refs UISACQCOMP-236.
10+
* Support `CLAIMS` export type in the `useIntegrationConfigs` hook. Refs UISACQCOMP-238.
1011

1112
## [6.0.2](https://github.com/folio-org/stripes-acq-components/tree/v6.0.2) (2024-12-04)
1213
[Full Changelog](https://github.com/folio-org/stripes-acq-components/compare/v6.0.1...v6.0.2)

lib/constants/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const CONSORTIUM_INSTITUTIONS_API = 'search/consortium/institutions';
1515
export const CONSORTIUM_LIBRARIES_API = 'search/consortium/libraries';
1616
export const CONSORTIUM_LOCATIONS_API = 'search/consortium/locations';
1717
export const CONTRIBUTOR_NAME_TYPES_API = 'contributor-name-types';
18+
export const DATA_EXPORT_CONFIGS_API = 'data-export-spring/configs';
1819
export const EXCHANGE_RATE_API = 'finance/exchange-rate';
1920
export const EXPENSE_CLASSES_API = 'finance/expense-classes';
2021
export const FUNDS_API = 'finance/funds';

lib/constants/constants.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,3 @@ export const CENTRAL_ORDERING_DEFAULT_RECEIVING_SEARCH = {
3939
centralDefault: 'Central default',
4040
activeAffiliationDefault: 'Active affiliation default',
4141
};
42-
43-
export const ALL_RECORDS_CQL = 'cql.allRecords=1';

lib/constants/cql.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const ALL_RECORDS_CQL = 'cql.allRecords=1';
2+
export const CQL_OR_OPERATOR = 'or';
3+
export const CQL_AND_OPERATOR = 'and';

lib/constants/export.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const FOLIO_EXPORT_TYPE = {
2+
CIRCULATION_LOG: 'CIRCULATION_LOG',
3+
BURSAR_FEES_FINES: 'BURSAR_FEES_FINES',
4+
BATCH_VOUCHER_EXPORT: 'BATCH_VOUCHER_EXPORT',
5+
EDIFACT_ORDERS_EXPORT: 'EDIFACT_ORDERS_EXPORT',
6+
CLAIMS: 'CLAIMS',
7+
ORDERS_EXPORT: 'ORDERS_EXPORT',
8+
INVOICE_EXPORT: 'INVOICE_EXPORT',
9+
BULK_EDIT_IDENTIFIERS: 'BULK_EDIT_IDENTIFIERS',
10+
BULK_EDIT_QUERY: 'BULK_EDIT_QUERY',
11+
BULK_EDIT_UPDATE: 'BULK_EDIT_UPDATE',
12+
E_HOLDINGS: 'E_HOLDINGS',
13+
AUTH_HEADINGS_UPDATES: 'AUTH_HEADINGS_UPDATES',
14+
FAILED_LINKED_BIB_UPDATES: 'FAILED_LINKED_BIB_UPDATES',
15+
};
16+
17+
export const ORGANIZATION_INTEGRATION_EXPORT_TYPES = [
18+
FOLIO_EXPORT_TYPE.CLAIMS,
19+
FOLIO_EXPORT_TYPE.EDIFACT_ORDERS_EXPORT,
20+
];

lib/constants/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ export * from './acqCommands';
22
export * from './api';
33
export * from './constants';
44
export * from './countries';
5+
export * from './cql';
56
export * from './customFields';
67
export * from './events';
8+
export * from './export';
79
export * from './invoice';
810
export * from './item';
911
export * from './languages';

lib/hooks/useIntegrationConfigs/useIntegrationConfigs.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,40 @@ import {
55
useOkapiKy,
66
} from '@folio/stripes/core';
77

8-
import { LIMIT_MAX } from '../../constants';
8+
import {
9+
CQL_OR_OPERATOR,
10+
DATA_EXPORT_CONFIGS_API,
11+
LIMIT_MAX,
12+
ORGANIZATION_INTEGRATION_EXPORT_TYPES,
13+
} from '../../constants';
14+
15+
const buildQuery = (organizationId) => {
16+
const configName = ORGANIZATION_INTEGRATION_EXPORT_TYPES
17+
.map(type => `"${type}_${organizationId}*"`)
18+
.join(` ${CQL_OR_OPERATOR} `);
19+
20+
return `configName==(${configName})`;
21+
};
22+
23+
const DEFAULT_DATA = [];
924

1025
export const useIntegrationConfigs = ({ organizationId }) => {
1126
const ky = useOkapiKy();
1227
const [namespace] = useNamespace({ key: 'organization-integrations' });
1328

1429
const searchParams = {
15-
query: `configName==EDIFACT_ORDERS_EXPORT_${organizationId}*`,
30+
query: buildQuery(organizationId),
1631
limit: LIMIT_MAX,
1732
};
1833

1934
const { isFetching, data = {} } = useQuery(
2035
[namespace, organizationId],
21-
() => ky.get('data-export-spring/configs', { searchParams }).json(),
36+
({ signal }) => ky.get(DATA_EXPORT_CONFIGS_API, { searchParams, signal }).json(),
2237
{ enabled: Boolean(organizationId) },
2338
);
2439

2540
return ({
26-
integrationConfigs: data.configs || [],
41+
integrationConfigs: data.configs || DEFAULT_DATA,
2742
isFetching,
2843
});
2944
};

lib/hooks/useIntegrationConfigs/useIntegrationConfigs.test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import React from 'react';
1+
import { renderHook } from '@testing-library/react-hooks';
22
import {
33
QueryClient,
44
QueryClientProvider,
55
} from 'react-query';
6-
import { renderHook } from '@testing-library/react-hooks';
76

87
import { useOkapiKy } from '@folio/stripes/core';
98

109
import { LIMIT_MAX } from '../../constants';
11-
1210
import { useIntegrationConfigs } from './useIntegrationConfigs';
1311

1412
const queryClient = new QueryClient();
15-
16-
// eslint-disable-next-line react/prop-types
1713
const wrapper = ({ children }) => (
1814
<QueryClientProvider client={queryClient}>
1915
{children}
@@ -54,9 +50,10 @@ describe('useIntegrationConfigs', () => {
5450
'data-export-spring/configs',
5551
{
5652
searchParams: {
57-
query: `configName==EDIFACT_ORDERS_EXPORT_${organizationId}*`,
53+
query: `configName==("CLAIMS_${organizationId}*" or "EDIFACT_ORDERS_EXPORT_${organizationId}*")`,
5854
limit: LIMIT_MAX,
5955
},
56+
signal: expect.any(AbortSignal),
6057
},
6158
);
6259
});

0 commit comments

Comments
 (0)