mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 14:43:24 +00:00
refactor: extract user badge role
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Badge,
|
||||
ScrollArea,
|
||||
Table,
|
||||
Text,
|
||||
@@ -14,6 +13,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { TbSearch } from 'react-icons/tb';
|
||||
import { Th } from '~/components/admin/users/th';
|
||||
import { sortData } from '~/components/admin/users/utils';
|
||||
import { UserBadgeRole } from '~/components/common/user_badge_role';
|
||||
import { DATE_FORMAT } from '~/constants';
|
||||
import { User } from '~/types/app';
|
||||
|
||||
@@ -71,15 +71,7 @@ export function UsersTable({
|
||||
<Table.Tr key={user.id}>
|
||||
<Table.Td>{user.fullname}</Table.Td>
|
||||
<Table.Td>
|
||||
{user.isAdmin ? (
|
||||
<Badge variant="light" color="red">
|
||||
{t('admin:admin')}
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="light" color="green">
|
||||
{t('admin:user')}
|
||||
</Badge>
|
||||
)}
|
||||
<UserBadgeRole user={user} />
|
||||
</Table.Td>
|
||||
<Table.Td>{user.collectionsCount}</Table.Td>
|
||||
<Table.Td>{user.linksCount}</Table.Td>
|
||||
|
||||
24
inertia/components/common/user_badge_role.tsx
Normal file
24
inertia/components/common/user_badge_role.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Badge } from '@mantine/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { PublicUser, User } from '~/types/app';
|
||||
|
||||
interface UserBadgeRoleProps {
|
||||
user: User | PublicUser;
|
||||
}
|
||||
|
||||
export function UserBadgeRole({ user }: UserBadgeRoleProps) {
|
||||
const { t } = useTranslation('common');
|
||||
return (
|
||||
<>
|
||||
{user.isAdmin ? (
|
||||
<Badge variant="light" color="red">
|
||||
{t('admin')}
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="light" color="green">
|
||||
{t('user')}
|
||||
</Badge>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
.header {
|
||||
height: rem(60px);
|
||||
padding-left: var(--mantine-spacing-md);
|
||||
padding-right: var(--mantine-spacing-md);
|
||||
border-bottom: rem(1px) solid
|
||||
light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user