mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
feat(console): hard code admin display name with username (#1348)
This commit is contained in:
parent
84aa0e866d
commit
496b17b527
1 changed files with 4 additions and 4 deletions
|
@ -18,14 +18,14 @@ const UserInfo = () => {
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
const anchorRef = useRef<HTMLDivElement>(null);
|
const anchorRef = useRef<HTMLDivElement>(null);
|
||||||
const [showDropDown, setShowDropdown] = useState(false);
|
const [showDropDown, setShowDropdown] = useState(false);
|
||||||
const [user, setUser] = useState<Pick<IdTokenClaims, 'sub' | 'name' | 'avatar'>>();
|
const [user, setUser] = useState<Pick<IdTokenClaims, 'sub' | 'username' | 'avatar'>>();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (isAuthenticated) {
|
if (isAuthenticated) {
|
||||||
const userInfo = getIdTokenClaims();
|
const userInfo = getIdTokenClaims();
|
||||||
setUser(userInfo ?? { sub: '', name: 'N/A' }); // Provide a fallback to avoid infinite loading state
|
setUser(userInfo ?? { sub: '', username: 'N/A' }); // Provide a fallback to avoid infinite loading state
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, [api, isAuthenticated, getIdTokenClaims]);
|
}, [api, isAuthenticated, getIdTokenClaims]);
|
||||||
|
@ -34,7 +34,7 @@ const UserInfo = () => {
|
||||||
return <UserInfoSkeleton />;
|
return <UserInfoSkeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { sub: id, name, avatar } = user;
|
const { sub: id, username, avatar } = user;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -47,7 +47,7 @@ const UserInfo = () => {
|
||||||
>
|
>
|
||||||
<img src={avatar || generateAvatarPlaceHolderById(id)} />
|
<img src={avatar || generateAvatarPlaceHolderById(id)} />
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
<div className={styles.name}>{name || t('users.unnamed')}</div>
|
<div className={styles.name}>{username}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
|
Loading…
Reference in a new issue