add users and fix modal
This commit is contained in:
52
frontend/src/components/Users/Row/index.tsx
Normal file
52
frontend/src/components/Users/Row/index.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { ActionIcon, Table, Tooltip } from "@mantine/core";
|
||||
import { t } from "@/config/i18n";
|
||||
import { IconEdit, IconX } from "@tabler/icons-react";
|
||||
import { type User, type UserInputs } from "@/services/resources/users";
|
||||
import { UserModal } from "@/components/Users/Modal";
|
||||
import { deleteUser, getUser } from "@/services/api";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
export type UserRowProps = {
|
||||
user: User;
|
||||
}
|
||||
|
||||
export default function UserRow({
|
||||
user,
|
||||
}: UserRowProps) {
|
||||
const deleteMutation = deleteUser();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Table.Tr key={user.id}>
|
||||
<Table.Td>{user.name}</Table.Td>
|
||||
<Table.Td>{user.email}</Table.Td>
|
||||
<Table.Td>
|
||||
<Tooltip label={t("edit user", {capfirst: true})}>
|
||||
<ActionIcon
|
||||
size="sm"
|
||||
mr="5"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(`/dashboard/users/${user.id}/edit`);
|
||||
}}
|
||||
>
|
||||
<IconEdit/>
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
<Tooltip label={t("remove user", {capfirst: true})}>
|
||||
<ActionIcon
|
||||
color="red"
|
||||
size="sm"
|
||||
mr="5"
|
||||
onClick={() => {
|
||||
deleteMutation.mutate(user.id);
|
||||
}}
|
||||
>
|
||||
<IconX/>
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user