mirror of
https://github.com/docmost/docmost.git
synced 2026-08-30 02:25:01 +08:00
error notification
This commit is contained in:
@@ -8,6 +8,7 @@ import { useAtomValue } from "jotai";
|
|||||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||||
import { useCreatePersonalSpaceMutation } from "@/ee/personal-space/queries/personal-space-query";
|
import { useCreatePersonalSpaceMutation } from "@/ee/personal-space/queries/personal-space-query";
|
||||||
import { getSpaceUrl } from "@/lib/config.ts";
|
import { getSpaceUrl } from "@/lib/config.ts";
|
||||||
|
import { notifications } from "@mantine/notifications";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
name: z.string().trim().min(2).max(100),
|
name: z.string().trim().min(2).max(100),
|
||||||
@@ -35,9 +36,18 @@ export default function CreatePersonalSpaceModal({ opened, onClose }: Props) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = async (values: FormValues) => {
|
const handleSubmit = async (values: FormValues) => {
|
||||||
const createdSpace = await createMutation.mutateAsync({ name: values.name });
|
try {
|
||||||
|
const createdSpace = await createMutation.mutateAsync({
|
||||||
|
name: values.name,
|
||||||
|
});
|
||||||
onClose();
|
onClose();
|
||||||
navigate(getSpaceUrl(createdSpace.slug));
|
navigate(getSpaceUrl(createdSpace.slug));
|
||||||
|
} catch (err) {
|
||||||
|
notifications.show({
|
||||||
|
message: err?.response?.data?.message,
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user