mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
fix(console): remove username admin tag (#2973)
This commit is contained in:
parent
ece866db7c
commit
b87b9def62
1 changed files with 4 additions and 10 deletions
|
@ -1,5 +1,4 @@
|
||||||
import type { UserWithRoleNames } from '@logto/schemas';
|
import type { User } from '@logto/schemas';
|
||||||
import { UserRole } from '@logto/schemas';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
@ -14,29 +13,24 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const UserName = ({ userId, isLink = false }: Props) => {
|
const UserName = ({ userId, isLink = false }: Props) => {
|
||||||
const { data, error } = useSWR<UserWithRoleNames, RequestError>(`/api/users/${userId}`);
|
const { data, error } = useSWR<User, RequestError>(`/api/users/${userId}`);
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
|
|
||||||
const isLoading = !data && !error;
|
const isLoading = !data && !error;
|
||||||
const name = data?.name ?? t('users.unnamed');
|
const name = data?.name ?? t('users.unnamed');
|
||||||
|
|
||||||
const isAdmin = data?.roleNames.includes(UserRole.Admin);
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.userName}>
|
<div className={styles.userName}>
|
||||||
{isLink && !isAdmin ? (
|
{isLink ? (
|
||||||
<Link to={`/users/${userId}`} target="_blank" className={styles.link}>
|
<Link to={`/users/${userId}`} target="_blank" className={styles.link}>
|
||||||
{name}
|
{name}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<span>
|
<span>{name}</span>
|
||||||
{name}
|
|
||||||
{isAdmin && <> ({t('admin_user')})</>}
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
<span className={styles.userId}>{userId}</span>
|
<span className={styles.userId}>{userId}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue