diff --git a/barkmanui/src/App.tsx b/barkmanui/src/App.tsx index 062b61c..2e871c0 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -4,6 +4,7 @@ import InventoryList from "./features/inventory/InventoryList.tsx"; import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import {createTheme, MantineProvider} from '@mantine/core'; import '@mantine/core/styles.css'; +import ItemDetail from "./features/inventory/ItemDetail.tsx"; // Create a client const queryClient = new QueryClient() @@ -34,6 +35,7 @@ function App() { } /> } /> + } /> diff --git a/barkmanui/src/features/inventory/InventoryList.tsx b/barkmanui/src/features/inventory/InventoryList.tsx index 3328e9c..8b796c0 100644 --- a/barkmanui/src/features/inventory/InventoryList.tsx +++ b/barkmanui/src/features/inventory/InventoryList.tsx @@ -3,7 +3,7 @@ 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"; function InventoryList() { @@ -53,6 +53,7 @@ function InventoryList() { Brand Item Status + Details @@ -62,6 +63,9 @@ function InventoryList() { {data.brand} {data.name} {data.status} + + Details + ))} diff --git a/barkmanui/src/features/inventory/ItemDetail.tsx b/barkmanui/src/features/inventory/ItemDetail.tsx new file mode 100644 index 0000000..5ba4bdc --- /dev/null +++ b/barkmanui/src/features/inventory/ItemDetail.tsx @@ -0,0 +1,48 @@ +import {Text} from "@mantine/core"; +import {BarkHeader} from "../../common/components/BarkHeader.tsx"; +import {useParams} from "react-router"; +import {InventoryItem} from "./types.ts"; +import {useQuery} from "@tanstack/react-query"; + + + +function ItemDetail() { + let params = useParams(); + + const { isPending, error, data, isFetching } = useQuery({ + queryKey: ['inventory', params.itemId], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/inventory/' + params.itemId, + ) + + if (!response.ok) throw new Error('Failed to fetch inventory ' + response.statusText) + + return await response.json() + }, +}); + +if (isPending) return 'Loading...' + +if (error) return 'An error has occurred: ' + error.message + + return ( + <> + + Item Detail +
{isFetching ? 'Updating...' : ''}
+ ID: {data.id} + Brand: {data.brand} + Name: {data.name} + Status: {data.status} + Serial Number: {data.serialNumber} + Rental Price: ${data.rentalPrice} + Replacement Cost: ${data.replacementCost} + Notes: {data.notes} + + + + ) +} + +export default ItemDetail \ No newline at end of file diff --git a/barkmanui/src/features/inventory/types.ts b/barkmanui/src/features/inventory/types.ts index f7d7264..62b5908 100644 --- a/barkmanui/src/features/inventory/types.ts +++ b/barkmanui/src/features/inventory/types.ts @@ -3,4 +3,9 @@ export interface InventoryItem { brand: string, name: string, status: string, + serialNumber: string, + rentalPrice: number, + replacementCost: number, + notes: string, + } diff --git a/barkmanui/src/pages/home.tsx b/barkmanui/src/pages/home.tsx index aa8a845..4550c01 100644 --- a/barkmanui/src/pages/home.tsx +++ b/barkmanui/src/pages/home.tsx @@ -9,7 +9,7 @@ function Home() { <> - ARFF ARFF BARK BARK + Bark productions: at the intersection of professionalism and degeneracy