added notifications and redirect to edit item page

This commit is contained in:
2025-02-03 10:29:50 -06:00
parent ee4baa3d50
commit 730cbc6733
2 changed files with 25 additions and 2 deletions
+2 -1
View File
@@ -74,7 +74,8 @@ function AddItem() {
wrap="wrap">
<Title order={1}>Add Item</Title>
<NumberInput withAsterisk size="md" key={newItemForm.key('barcode')} label="Barcode"
placeholder="Barcode" {...newItemForm.getInputProps('barcode')}/>
<TextInput withAsterisk key={newItemForm.key('brand')} size="md" label="Brand"
placeholder="Brand" {...newItemForm.getInputProps('brand')}/>
<TextInput withAsterisk key={newItemForm.key('name')} size="md" label="Name"
+23 -1
View File
@@ -1,14 +1,17 @@
import {Button, Group, TextInput, Textarea, NumberInput, Container, Title, Flex} from '@mantine/core';
import {useForm} from '@mantine/form';
import {useParams} from "react-router";
import {useNavigate, useParams} from "react-router";
import {useMutation, useQuery, useQueryClient} from "@tanstack/react-query";
import {InventoryItem} from "./types.ts";
import {useEffect} from "react";
import {notifications} from "@mantine/notifications";
import {IconCheck, IconX} from "@tabler/icons-react";
type EditableInventoryItem = Omit<InventoryItem, 'id'>;
function EditItem() {
const params = useParams();
const navigate = useNavigate();
const editItemForm = useForm<EditableInventoryItem>({
mode: 'uncontrolled',
@@ -54,7 +57,26 @@ function EditItem() {
}
});
if (result.ok) {
notifications.show({
icon: <IconCheck size={20} />,
color:"teal",
title: "All good!",
message: "Item Updated",
position: 'top-center',
});
navigate("/inventory");
}
if (!result.ok) {
notifications.show({
icon: <IconX size={20} />,
color:"red",
title: "Bummer!",
message: "Something went wrong",
position: 'top-center',
});
throw new Error('Failed to update inventory item');
}