mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-06-12 22:11:54 +00:00
added notifications and redirect to edit item page
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user