fixed stupid, also page redirect

This commit is contained in:
2025-01-29 20:33:37 -06:00
parent 73d58aea4f
commit a4a038f8bc
3 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ inventoryGroup.MapPut("/{id}", async (int id, InventoryItems updatedItem, BarkCo
inventoryGroup.MapPost("", async (InventoryItems newItemInput, BarkContext db) => inventoryGroup.MapPost("", async (InventoryItems newItemInput, BarkContext db) =>
{ {
var newItem = new InventoryItems(); var newItem = new InventoryItems();
newItemInput.Name = newItem.Name; newItem.Name = newItemInput.Name;
newItem.Brand = newItemInput.Brand; newItem.Brand = newItemInput.Brand;
newItem.SerialNumber = newItemInput.SerialNumber; newItem.SerialNumber = newItemInput.SerialNumber;
newItem.RentalPrice = newItemInput.RentalPrice; newItem.RentalPrice = newItemInput.RentalPrice;
+2 -2
View File
@@ -1,4 +1,4 @@
#Staging API #Staging API
VITE_API_URL=https://barkdev.ts.drewr.io #VITE_API_URL=https://barkdev.ts.drewr.io
#Local Dev API #Local Dev API
#VITE_API_URL=http://localhost:5145 VITE_API_URL=http://localhost:5145
@@ -2,9 +2,12 @@ import {Button, Group, TextInput, NumberInput, Container, Title, Flex} from '@ma
import {useForm} from '@mantine/form'; import {useForm} from '@mantine/form';
import {useMutation} from "@tanstack/react-query"; import {useMutation} from "@tanstack/react-query";
import {NewItem} from "./types.ts"; import {NewItem} from "./types.ts";
import { useNavigate} from "react-router";
function AddItem() { function AddItem() {
const navigate = useNavigate();
const newItemForm = useForm<NewItem>({ const newItemForm = useForm<NewItem>({
mode: 'uncontrolled', mode: 'uncontrolled',
initialValues: { initialValues: {
@@ -29,6 +32,10 @@ function AddItem() {
} }
}); });
if (result.ok) {
navigate("/inventory");
}
if (!result.ok) { if (!result.ok) {
throw new Error('Failed to update inventory item'); throw new Error('Failed to update inventory item');
} }