Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIDATIMP-1440, UIDATIMP-1439, UIDATIMP-1438: Multiple holdings/items #1447

Merged
merged 17 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b04ad92
UIDATIMP-1440: Update Log JSON screen to support multiple items (#1438)
mariia-aloshyna Jul 13, 2023
4d960aa
UIDATIMP-1439: Update Log JSON screen to support multiple holdings (R…
mariia-aloshyna Jul 13, 2023
f519eb6
UIDATIMP-1438: Update Log details screen to support multiple holdings…
OleksandrHladchenko1 Jul 13, 2023
e360d19
UIDATIMP-1443: Improve mapping profile for Holdings for handling mult…
mariia-aloshyna Jul 13, 2023
8c14ce8
multiple-feature: Fix error in records table
OleksandrHladchenko1 Jul 25, 2023
150134b
multiple-feature: add no value if no record found
OleksandrHladchenko1 Jul 25, 2023
a35097c
Fixes for map
OleksandrHladchenko1 Jul 26, 2023
35f2f03
multiple-feature: Adjust RecordsTable component
OleksandrHladchenko1 Aug 1, 2023
5bd6911
Revert "UIDATIMP-1443: Improve mapping profile for Holdings for handl…
mariia-aloshyna Aug 4, 2023
8c218c2
multiple-feature: Add general items error displaying
OleksandrHladchenko1 Aug 7, 2023
8e7aa9b
Merge branch 'multiple-feature' of https://github.com/folio-org/ui-da…
OleksandrHladchenko1 Aug 7, 2023
d842e75
Merge branch 'master' into multiple-feature
OleksandrHladchenko1 Aug 7, 2023
5aefcd5
multiple-feature: Replace Error with No action
OleksandrHladchenko1 Aug 7, 2023
426fe01
Merge branch 'multiple-feature' of https://github.com/folio-org/ui-da…
OleksandrHladchenko1 Aug 7, 2023
474789f
multiple-feature: refactor code
OleksandrHladchenko1 Aug 7, 2023
991788c
multiple-feature: fix code smells
OleksandrHladchenko1 Aug 7, 2023
dcc5f46
multiple-feature: fixes after review
OleksandrHladchenko1 Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* Invoice field mapping: Add info icon to the Acq unit field (UIDATIMP-1427)
* View all: Create hotlink from job profile name in log to the job profile details (UIDATIMP-1428)
* Fix warnings in unit tests (part 2) (UIDATIMP-1437)
* Update Log details screen to support multiple holdings & items (UIDATIMP-1438)
* Update Log JSON screen to support multiple holdings (UIDATIMP-1439)
* Update Log JSON screen to support multiple items (UIDATIMP-1440)
* Improve mapping profile for Holdings for handling multiple Holdings mapping (UIDATIMP-1443)
* DI Log: change Discarded to No action (UIDATIMP-1446)
* DI Log: Make some changes to the Log header (UIDATIMP-1447)
* DI Job profiles: Redirect when job profile was deleted (UIDATIMP-1450)
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from './useInventoryItemsByIdQuery';
export * from './useInvoiceLineByIdQuery';
export * from './useInvoicesByIdQuery';
export * from './useJobLogRecordsQuery';
export * from './useLocationsQuery';
export * from './useOrderByIdQuery';
export * from './usePOLinesByIdQuery';
export * from './useSRSRecordQuery';
31 changes: 31 additions & 0 deletions src/hooks/tests/useLocationsQuery.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { renderHook } from '@testing-library/react-hooks';

import '../../../test/jest/__mock__';

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

import { useLocationsQuery } from '../useLocationsQuery';
import { queryClientWrapper } from '../../../test/jest/helpers';

const mockLocationsRecord = [{ id: 'locationId1' }, { id: 'locationId2' }];

describe('useLocationsQuery', () => {
beforeEach(() => {
useOkapiKy.mockClear().mockReturnValue({
get: () => {
return ({
json: () => Promise.resolve({ locations: mockLocationsRecord })
});
},
});
});

it('should fetch locations', async () => {
const { result, waitFor } = renderHook(() => useLocationsQuery(), { wrapper: queryClientWrapper });

await waitFor(() => !result.current.isLoading);

expect(result.current.data).toEqual(mockLocationsRecord);
});
});
21 changes: 21 additions & 0 deletions src/hooks/useLocationsQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useQuery } from 'react-query';

import {
useOkapiKy,
useNamespace,
} from '@folio/stripes/core';

export const useLocationsQuery = () => {
const ky = useOkapiKy();
const [namespace] = useNamespace({ key: 'locations' });

const query = useQuery({
queryKey: [namespace],
queryFn: () => ky.get('locations').json(),
});

return ({
...query,
data: query.data?.locations,
});
};
7 changes: 7 additions & 0 deletions src/routes/JobSummary/JobSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ JobSummaryComponent.manifest = Object.freeze({
path: 'change-manager/jobExecutions/:{id}',
throwErrors: false,
},
locations: {
throwErrors: false,
type: 'okapi',
records: 'locations',
path: 'locations?limit=1000&query=cql.allRecords=1 sortby name',
OleksandrHladchenko1 marked this conversation as resolved.
Show resolved Hide resolved
}
});

JobSummaryComponent.propTypes = {
Expand All @@ -307,6 +313,7 @@ JobSummaryComponent.propTypes = {
}),
jobLogEntries: PropTypes.shape({ records: PropTypes.arrayOf(PropTypes.object).isRequired }),
jobLog: PropTypes.shape({ records: PropTypes.arrayOf(PropTypes.object).isRequired }),
locations: PropTypes.shape({ records: PropTypes.arrayOf(PropTypes.object).isRequired }),
}).isRequired,
location: PropTypes.oneOfType([
PropTypes.shape({
Expand Down
Loading
Loading