diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 3e90fc1..5549237 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -87,7 +87,7 @@ inventoryGroup.MapPut("/{id}", async (int id, InventoryItems updatedItem, BarkCo inventoryGroup.MapPost("", async (InventoryItems newItemInput, BarkContext db) => { var newItem = new InventoryItems(); - newItemInput.Name = newItem.Name; + newItem.Name = newItemInput.Name; newItem.Brand = newItemInput.Brand; newItem.SerialNumber = newItemInput.SerialNumber; newItem.RentalPrice = newItemInput.RentalPrice; diff --git a/barkmanui/.env b/barkmanui/.env index 1104091..889752b 100644 --- a/barkmanui/.env +++ b/barkmanui/.env @@ -1,4 +1,4 @@ #Staging API -VITE_API_URL=https://barkdev.ts.drewr.io +#VITE_API_URL=https://barkdev.ts.drewr.io #Local Dev API -#VITE_API_URL=http://localhost:5145 \ No newline at end of file +VITE_API_URL=http://localhost:5145 \ No newline at end of file diff --git a/barkmanui/src/features/inventory/AddItem.tsx b/barkmanui/src/features/inventory/AddItem.tsx index ea0e843..6b1a0a0 100644 --- a/barkmanui/src/features/inventory/AddItem.tsx +++ b/barkmanui/src/features/inventory/AddItem.tsx @@ -2,9 +2,12 @@ import {Button, Group, TextInput, NumberInput, Container, Title, Flex} from '@ma import {useForm} from '@mantine/form'; import {useMutation} from "@tanstack/react-query"; import {NewItem} from "./types.ts"; +import { useNavigate} from "react-router"; function AddItem() { + const navigate = useNavigate(); + const newItemForm = useForm({ mode: 'uncontrolled', initialValues: { @@ -29,6 +32,10 @@ function AddItem() { } }); + if (result.ok) { + navigate("/inventory"); + } + if (!result.ok) { throw new Error('Failed to update inventory item'); }