From 553a2d1324bf540f4795aaecf750121bfd66b652 Mon Sep 17 00:00:00 2001 From: Artem Blazhko Date: Tue, 3 Dec 2024 13:50:41 +0200 Subject: [PATCH] UIU-3290: Fix issue with `Proxy borrower` field value (#2817) --- CHANGELOG.md | 1 + src/views/LoanDetails/LoanProxyDetails.js | 5 ++++- src/views/LoanDetails/LoanProxyDetails.test.js | 10 ++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4109487f2..1c670d3e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * `useUserTenantRoles` supplies `tenantId` in all its queries. Refs UIU-3279. * Leverage API supported sorting of columns on pre-registrations records list. Refs UIU-3249. * Add permission to access users-keycloak delete method. Refs UIU-3282. +* Fix issue with `Proxy borrower` field value. Refs UIU-3290. ## [11.0.7](https://github.com/folio-org/ui-users/tree/v11.0.7) (2024-11-30) [Full Changelog](https://github.com/folio-org/ui-users/compare/v11.0.6...v11.0.7) diff --git a/src/views/LoanDetails/LoanProxyDetails.js b/src/views/LoanDetails/LoanProxyDetails.js index de6c20bff..c8970cb55 100644 --- a/src/views/LoanDetails/LoanProxyDetails.js +++ b/src/views/LoanDetails/LoanProxyDetails.js @@ -22,11 +22,13 @@ class LoanProxyDetails extends React.Component { resources: PropTypes.shape({ proxy: PropTypes.shape({ records: PropTypes.arrayOf(PropTypes.object), + hasLoaded: PropTypes.bool, }), }), mutator: PropTypes.shape({ proxy: PropTypes.shape({ GET: PropTypes.func.isRequired, + reset: PropTypes.func.isRequired, }).isRequired, }).isRequired, showErrorCallout: PropTypes.func.isRequired, @@ -34,6 +36,7 @@ class LoanProxyDetails extends React.Component { componentDidMount() { if (this.props.id) { + this.props.mutator.proxy.reset(); this.props.mutator.proxy.GET() .catch(() => { this.props.showErrorCallout('ui-users.errors.proxyBorrowerNotFound'); @@ -51,7 +54,7 @@ class LoanProxyDetails extends React.Component { } render() { - if (this.props.id) { + if (this.props.id && this.props.resources.proxy.hasLoaded) { return } value={this.getUserFullName()} diff --git a/src/views/LoanDetails/LoanProxyDetails.test.js b/src/views/LoanDetails/LoanProxyDetails.test.js index 63b76c35e..dc6ec6180 100644 --- a/src/views/LoanDetails/LoanProxyDetails.test.js +++ b/src/views/LoanDetails/LoanProxyDetails.test.js @@ -21,12 +21,14 @@ const props = (propID, proxyID) => { id: propID, resources: { proxy: { - records: [{ id: proxyID }] + records: [{ id: proxyID }], + hasLoaded: true, } }, mutator: { proxy: { GET: jest.fn().mockResolvedValueOnce(proxyData), + reset: jest.fn(), }, }, showErrorCallout: showErrorMock, @@ -56,11 +58,15 @@ describe('Render LoanProxyDetails component', () => { const newprops = { id: 'test', resources: { - proxy: null + proxy: { + records: null, + hasLoaded: true, + }, }, mutator: { proxy: { GET: jest.fn().mockRejectedValueOnce(), + reset: jest.fn(), }, }, showErrorCallout: showErrorMock,