Skip to content

Commit

Permalink
Add extra fields on user detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
kahummer committed Sep 10, 2024
1 parent 5417ab3 commit 980e972
Showing 1 changed file with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ export const UserDetails = (props: UserDetailProps) => {
},
}
);

// Extract phone number from Practitioner
const practitioner = practitionerDetails?.fhir?.practitioner?.[0];

Check failure on line 86 in packages/fhir-keycloak-user-management/src/components/UserList/Viewdetails/index.tsx

View workflow job for this annotation

GitHub Actions / test (22.x, ubuntu-latest)

Unnecessary optional chain on a non-nullish value
const phoneNumber = practitioner?.telecom?.find((telecom) => telecom.system === 'phone')?.value;

// Extract national ID from Practitioner
const nationalId = practitioner?.identifier?.find(
(identifier) =>
identifier.use === 'official' &&
identifier.type?.coding?.some((coding) => coding.code === 'NationalID')
)?.value;

const practDetailsByResName: PractitionerDetail['fhir'] = practitionerDetails?.fhir ?? {};

if (userIsLoading) {
Expand All @@ -100,14 +112,26 @@ export const UserDetails = (props: UserDetailProps) => {
}

const { id, firstName, lastName, username, email, emailVerified, enabled, attributes } = user;
const userDetails = {
[t('Id')]: id,
[t('First Name')]: firstName,
[t('Last Name')]: lastName,
[t('Username')]: username,
[t('Email')]: email,
[t('Verified')]: emailVerified ? t('True') : t('False'),
};
const userDetails =
phoneNumber && nationalId
? {
[t('Id')]: id,
[t('First Name')]: firstName,
[t('Last Name')]: lastName,
[t('National ID')]: nationalId,
[t('Phone Number')]: phoneNumber,
[t('Username')]: username,
[t('Email')]: email,
[t('Verified')]: emailVerified ? t('True') : t('False'),
}
: {
[t('Id')]: id,
[t('First Name')]: firstName,
[t('Last Name')]: lastName,
[t('Username')]: username,
[t('Email')]: email,
[t('Verified')]: emailVerified ? t('True') : t('False'),
};
const attributesArray = Object.entries(attributes ?? {});
const breadCrumbProps = {
items: [
Expand Down

0 comments on commit 980e972

Please sign in to comment.