Refactor TopBar displayName initialization logic.
Moved the `displayName` variable initialization inside the `TopBar` component and handled null checks consistently. This improves readability and ensures a safer default value handling for `me`.
This commit is contained in:
@@ -2,8 +2,6 @@ import React from "react";
|
|||||||
import { styles } from "../styles/styles";
|
import { styles } from "../styles/styles";
|
||||||
import { stylesTokens } from "../styles/theme";
|
import { stylesTokens } from "../styles/theme";
|
||||||
|
|
||||||
const displayName = (me?.display_name || "").trim() || me.email;
|
|
||||||
|
|
||||||
export default function TopBar({
|
export default function TopBar({
|
||||||
me,
|
me,
|
||||||
userMenuOpen,
|
userMenuOpen,
|
||||||
@@ -11,8 +9,12 @@ export default function TopBar({
|
|||||||
openPwModal,
|
openPwModal,
|
||||||
openDesignModal,
|
openDesignModal,
|
||||||
doLogout,
|
doLogout,
|
||||||
onOpenNewGame, // NEW
|
onOpenNewGame,
|
||||||
}) {
|
}) {
|
||||||
|
const displayName = me
|
||||||
|
? ((me.display_name || "").trim() || me.email)
|
||||||
|
: "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={styles.topBar}>
|
<div style={styles.topBar}>
|
||||||
<div>
|
<div>
|
||||||
@@ -47,7 +49,7 @@ export default function TopBar({
|
|||||||
borderBottom: "1px solid rgba(233,216,166,0.12)",
|
borderBottom: "1px solid rgba(233,216,166,0.12)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{me.email}
|
{me?.email || ""}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button onClick={openPwModal} style={styles.userDropdownItem}>
|
<button onClick={openPwModal} style={styles.userDropdownItem}>
|
||||||
|
|||||||
Reference in New Issue
Block a user