Skip to content

Commit

Permalink
fix: add null check for the user (#474)
Browse files Browse the repository at this point in the history
* fix: add null check for the user

* refactor: uplift condition statement
  • Loading branch information
dv-usama-ansari authored Aug 16, 2024
1 parent 18ebcd2 commit ed690a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/app/header/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export function UserMenu({ menu, user, color }: { menu: JSX.Element; user: strin
size={28}
variant="white"
>
{/*
// NOTE: @dv-usama-ansari: We would not need this fix when we upgrade to Mantine v7.11
// Extracting initials is a built-in feature in Mantine v7.11: https://mantine.dev/changelog/7-11-0/#avatar-initials
*/}

{user
.split(' ')
.map((name) => name[0])
Expand Down
2 changes: 1 addition & 1 deletion src/app/header/VisynHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function VisynHeader({
{components?.logo === undefined ? <DatavisynLogo color={backgroundColor === 'white' ? 'black' : 'white'} /> : components?.logo}
<Group gap={5}>
{components?.userAvatar === undefined ? (
user ? (
user && user.name ? (
<UserMenu menu={components?.userMenu} user={user.name} color={backgroundColor} />
) : null
) : (
Expand Down

0 comments on commit ed690a7

Please sign in to comment.