Fix profile accordion error display

This commit is contained in:
ajnart
2024-05-10 20:02:57 +02:00
parent 6e2bd0ce11
commit 543bfc0835
5 changed files with 21 additions and 15 deletions

View File

@@ -33,11 +33,11 @@ export const userRouter = createTRPCRouter({
.input(validation.user.create)
.mutation(async ({ ctx, input }) => {
const user = await ctx.db.query.users.findFirst({
where: eq(users.name, input.username),
where: eq(users.name, input.username.toLowerCase()),
});
if (user !== undefined) {
throw new TRPCError({
code: "FORBIDDEN",
code: "CONFLICT",
message: "User already exists",
});
}
@@ -91,12 +91,12 @@ export const userRouter = createTRPCRouter({
.where(eq(users.id, input.userId))
.limit(1);
const existingUser = await ctx.db.query.users.findFirst({
where: eq(users.name, input.form.name),
where: eq(users.name, input.form.name.toLowerCase()),
});
if (existingUser !== undefined) {
throw new TRPCError({
code: "FORBIDDEN",
code: "CONFLICT",
message: `User ${input.form.name} already exists`,
});
}

View File

@@ -2,16 +2,14 @@ import type { NotificationData } from "@mantine/notifications";
import { notifications } from "@mantine/notifications";
import { IconCheck, IconX } from "@tabler/icons-react";
type CommonNotificationProps = Pick<NotificationData, "title" | "message">;
export const showSuccessNotification = (props: CommonNotificationProps) =>
export const showSuccessNotification = (props: NotificationData) =>
notifications.show({
...props,
color: "teal",
icon: <IconCheck size={20} />,
});
export const showErrorNotification = (props: CommonNotificationProps) =>
export const showErrorNotification = (props: NotificationData) =>
notifications.show({
...props,
color: "red",

View File

@@ -1108,6 +1108,9 @@ export default {
completed: {
title: "User created",
},
error: {
title: "User creation failed",
},
},
action: {
createAnother: "Create another user",