🚸 Improve UX on create user page

This commit is contained in:
Manuel
2023-07-29 20:12:49 +02:00
parent e273c830b4
commit ed23e388f9
6 changed files with 111 additions and 24 deletions

View File

@@ -48,7 +48,12 @@ const CreateNewUserPage = () => {
),
});
const { mutateAsync, isSuccess } = api.user.createUser.useMutation();
const context = api.useContext();
const { mutateAsync, isSuccess } = api.user.createUser.useMutation({
onSettled: () => {
void context.user.getAll.invalidate();
}
});
return (
<MainLayout>

View File

@@ -11,6 +11,7 @@ import {
Text,
Title,
} from '@mantine/core';
import { openContextModal } from '@mantine/modals';
import { IconPlus, IconTrash } from '@tabler/icons-react';
import Head from 'next/head';
import Link from 'next/link';
@@ -28,9 +29,9 @@ const ManageUsersPage = () => {
}
);
const [activePage, _] = useState(0);
const { mutateAsync: deleteUserMutateAsync } = api.user.deleteUser.useMutation();
console.log(data?.pages);
const [activePage, _] = useState(0);
return (
<MainLayout>
@@ -82,7 +83,20 @@ const ManageUsersPage = () => {
<Text>{user.name}</Text>
</Group>
<Group>
<ActionIcon color="red" variant="light">
<ActionIcon
onClick={() => {
openContextModal({
modal: 'deleteUserModal',
title: <Text weight="bold">Delete user ${user.name}</Text>,
innerProps: {
userId: user.id,
username: user.name ?? ''
}
});
}}
color="red"
variant="light"
>
<IconTrash size="1rem" />
</ActionIcon>
</Group>