Skip to content

Commit f8ffbb4

Browse files
committed
chore(react): fix profile updates
1 parent 2fc5947 commit f8ffbb4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

packages/react/src/components/presentation/UserDropdown/BaseUserDropdown.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,20 @@ export const BaseUserDropdown: FC<BaseUserDropdownProps> = ({
180180
picture: ['profile', 'profileUrl'],
181181
firstName: 'givenName',
182182
lastName: 'familyName',
183+
email: 'emails',
183184
};
184185

185186
const mergedMappings = {...defaultAttributeMappings, ...attributeMapping};
186187

187-
const getMappedValue = (key: string) => {
188-
const mappedKey = mergedMappings[key];
189-
return mappedKey ? user[mappedKey] : user[key];
190-
};
191-
192188
const getDisplayName = () => {
193-
const firstName = getMappedValue('firstName');
194-
const lastName = getMappedValue('lastName');
189+
const firstName = getMappedUserProfileValue('firstName', mergedMappings, user);
190+
const lastName = getMappedUserProfileValue('lastName', mergedMappings, user);
195191

196192
if (firstName && lastName) {
197193
return `${firstName} ${lastName}`;
198194
}
199195

200-
return getMappedValue('username') || '';
196+
return getMappedUserProfileValue('username', mergedMappings, user) || '';
201197
};
202198

203199
if (!user) {
@@ -242,11 +238,15 @@ export const BaseUserDropdown: FC<BaseUserDropdownProps> = ({
242238
<span className={withVendorCSSClassPrefix('user-dropdown-header-name')} style={styles.headerName}>
243239
{getDisplayName()}
244240
</span>
245-
{getMappedValue('email') !== getDisplayName() && getMappedValue('email') && (
246-
<span className={withVendorCSSClassPrefix('user-dropdown-header-email')} style={styles.headerEmail}>
247-
{getMappedValue('email')}
248-
</span>
249-
)}
241+
{getMappedUserProfileValue('email', mergedMappings, user) !== getDisplayName() &&
242+
getMappedUserProfileValue('email', mergedMappings, user) && (
243+
<span
244+
className={withVendorCSSClassPrefix('user-dropdown-header-email')}
245+
style={styles.headerEmail}
246+
>
247+
{getMappedUserProfileValue('email', mergedMappings, user)}
248+
</span>
249+
)}
250250
</div>
251251
</div>
252252
)}

0 commit comments

Comments
 (0)