+ const result = await fetch(import.meta.env.VITE_API_URL + '/inventory/' + params.itemId, {
+ method: 'PUT',
+ body: JSON.stringify(values),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
+
+ if (!result.ok) {
+ throw new Error('Failed to update inventory item');
+ }
+
+ // invalidate the queries so they pull updated information
+ // this is a prefix, so it covers both the query that pulls a list, and also `['inventory', itemId]` in this file
+ await queryClient.invalidateQueries({
+ queryKey: ['inventory']
+ });
+ }
+ })
+
+ useEffect(() => {
+ if (data) {
+ // Even if query.data changes, form will be initialized only once
+ form.initialize(data);
+ }
+ }, [data]);
+
if (isPending) return 'Loading...'
if (error) return 'An error has occurred: ' + error.message
return (
- <>
-
-
- Edit Item
- {isFetching ? 'Updating...' : ''}
- ID: {data.id}
-
-
-
-
-
-
- Replacement Cost: ${data.replacementCost}
-
+
+ );
}
-export default EditItem
\ No newline at end of file
+export default EditItem;
\ No newline at end of file
diff --git a/barkmanui/src/features/inventory/InventoryList.tsx b/barkmanui/src/features/inventory/InventoryList.tsx
index 8b796c0..1f3edec 100644
--- a/barkmanui/src/features/inventory/InventoryList.tsx
+++ b/barkmanui/src/features/inventory/InventoryList.tsx
@@ -1,6 +1,5 @@
import {useQuery} from "@tanstack/react-query";
import {InventoryItem} from "./types";
-import {BarkHeader} from "../../common/components/BarkHeader.tsx";
import {Flex, Table} from '@mantine/core';
import BarkButton from "../../common/components/BarkButton.tsx";
import {Link} from "react-router";
@@ -27,8 +26,6 @@ function InventoryList() {
return (
<>
-
-
-
Item Detail
{isFetching ? 'Updating...' : ''}
ID: {data.id}
diff --git a/barkmanui/src/pages/home.tsx b/barkmanui/src/pages/home.tsx
index 4550c01..c50456f 100644
--- a/barkmanui/src/pages/home.tsx
+++ b/barkmanui/src/pages/home.tsx
@@ -1,4 +1,3 @@
-import {BarkHeader} from "../common/components/BarkHeader.tsx";
import {Text} from "@mantine/core";
@@ -7,11 +6,7 @@ function Home() {
return (
<>
-
-
Bark productions: at the intersection of professionalism and degeneracy
-
-
>
)
}