Skip to content

Commit

Permalink
Reset proxy data before fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-blazhko committed Nov 29, 2024
1 parent e070325 commit 7d77a3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/views/LoanDetails/LoanProxyDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class LoanProxyDetails extends React.Component {
mutator: PropTypes.shape({
proxy: PropTypes.shape({
GET: PropTypes.func.isRequired,
reset: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
showErrorCallout: PropTypes.func.isRequired,
}

componentDidMount() {
if (this.props.id) {
this.props.mutator.proxy.reset();
this.props.mutator.proxy.GET()
.catch(() => {
this.props.showErrorCallout('ui-users.errors.proxyBorrowerNotFound');
Expand All @@ -43,6 +45,7 @@ class LoanProxyDetails extends React.Component {

getUserFullName() {
const proxy = (this.props.resources.proxy || {}).records || [];
console.log('proxy.length: ', proxy.length);

Check warning on line 48 in src/views/LoanDetails/LoanProxyDetails.js

View workflow job for this annotation

GitHub Actions / build-npm

Unexpected console statement

Check warning on line 48 in src/views/LoanDetails/LoanProxyDetails.js

View workflow job for this annotation

GitHub Actions / build-npm

Unexpected console statement
if (proxy.length === 1 && proxy[0].id === this.props.id) {
return <Link to={`/users/view/${this.props.id}`}>{getFullName(proxy[0])}</Link>;
}
Expand Down
1 change: 1 addition & 0 deletions src/views/LoanDetails/LoanProxyDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const props = (propID, proxyID) => {
mutator: {
proxy: {
GET: jest.fn().mockResolvedValueOnce(proxyData),
reset: jest.fn(),
},
},
showErrorCallout: showErrorMock,
Expand Down

0 comments on commit 7d77a3d

Please sign in to comment.