added notifications

This commit is contained in:
2025-01-29 21:23:57 -06:00
parent a4a038f8bc
commit c11cf8cfe7
5 changed files with 137 additions and 10 deletions
+18 -1
View File
@@ -3,6 +3,8 @@ import {useForm} from '@mantine/form';
import {useMutation} from "@tanstack/react-query";
import {NewItem} from "./types.ts";
import { useNavigate} from "react-router";
import { IconX, IconCheck } from '@tabler/icons-react';
import { notifications } from '@mantine/notifications';
function AddItem() {
@@ -33,11 +35,26 @@ function AddItem() {
});
if (result.ok) {
notifications.show({
icon: <IconCheck size={20} />,
color:"teal",
title: "All good!",
message: "Item Created",
position: 'top-center',
});
navigate("/inventory");
}
if (!result.ok) {
throw new Error('Failed to update inventory item');
notifications.show({
icon: <IconX size={20} />,
color:"red",
title: "Bummer!",
message: "Something went wrong",
position: 'top-center',
});
throw new Error('Failed to create inventory item');
}
}