Skip to content

Commit

Permalink
UIU-1404: Fix bug with wrong displaying of address type
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav-Velytskyi authored and zburke committed Jan 6, 2020
1 parent 90888d4 commit bd2002d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Add default settings for user status and preferred contact in new user creation. Refs UIU-1385.
* Display correct user block on the edit form. Fixes UIU-1397.
* Clear previous item data when open a new fee/fine form page. Fixes UIU-1410.
* Add record last updated and created back to manual patron block. Fixes UIU-1420.
* Go back to user's accounts when clicking on cancel or `x` from fee/fine form. Fixes UIU-1412.
* Reset patronBlocks before refetching. Fixes UIU-1430 and UIU-1431.
* Fix bug with wrong displaying of address type. Refs UIU-1404

## [2.26.0](https://github.com/folio-org/ui-users/tree/v2.26.0) (2019-12-05)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v2.25.3...v2.26.0)
Expand Down
21 changes: 18 additions & 3 deletions src/views/UserDetail/UserDetail.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import get from 'lodash/get';
import cloneDeep from 'lodash/cloneDeep';
import {
get,
keyBy,
cloneDeep,
} from 'lodash';
import { FormattedMessage } from 'react-intl';
import {
AppIcon,
Expand Down Expand Up @@ -331,6 +334,17 @@ class UserDetail extends React.Component {
}
]

getAddressesList(addresses, addressTypes) {
const addressTypesById = keyBy(addressTypes, 'id');

return addresses.map(address => {
const addressTypeOption = addressTypesById[address.addressType];
const addressType = get(addressTypeOption, ['addressType']);

return { ...address, addressType };
});
}

render() {
const {
resources,
Expand All @@ -351,6 +365,7 @@ class UserDetail extends React.Component {

const addressTypes = (resources.addressTypes || {}).records || [];
const addresses = getFormAddressList(get(user, 'personal.addresses', []));
const addressesList = this.getAddressesList(addresses, addressTypes);
const permissions = (resources.permissions || {}).records || [];
const settings = (resources.settings || {}).records || [];
const sponsors = this.props.getSponsors();
Expand Down Expand Up @@ -464,7 +479,7 @@ class UserDetail extends React.Component {
accordionId="contactInfoSection"
stripes={stripes}
user={user}
addresses={addresses}
addresses={addressesList}
addressTypes={addressTypes}
expanded={sections.contactInfoSection}
onToggle={this.handleSectionToggle}
Expand Down
3 changes: 0 additions & 3 deletions test/bigtest/interactors/user-form-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import {
triggerable,
scoped,
collection,
findAll,
value,
selectable,
property,
action,
focusable,
} from '@bigtest/interactor';

Expand Down

0 comments on commit bd2002d

Please sign in to comment.