diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 065e481..e0e9a95 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -21,7 +21,8 @@ builder.Services.AddCors(options => }); }); var app = builder.Build(); -if (! app.Environment.IsProduction()) + +if (!app.Environment.IsProduction()) { app.UseSwagger(); app.UseSwaggerUI(c => diff --git a/barkmanui/.env b/barkmanui/.env new file mode 100644 index 0000000..29a2dbd --- /dev/null +++ b/barkmanui/.env @@ -0,0 +1 @@ +VITE_API_URL=https://barkdev.ts.drewr.io \ No newline at end of file diff --git a/barkmanui/package-lock.json b/barkmanui/package-lock.json index 01b3487..6848e14 100644 --- a/barkmanui/package-lock.json +++ b/barkmanui/package-lock.json @@ -9,6 +9,8 @@ "version": "0.0.0", "dependencies": { "@tanstack/react-query": "^5.64.1", + "@tanstack/react-query-devtools": "^5.64.1", + "axios": "^1.7.9", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router": "^7.1.1", @@ -1385,6 +1387,16 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@tanstack/query-devtools": { + "version": "5.62.16", + "resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.62.16.tgz", + "integrity": "sha512-3ff6UBJr0H3nIhfLSl9911rvKqXf0u4B58jl0uYdDWLqPk9pCvYIbxC35cGxK2+8INl4IaFVUHb/IdgWrNkg3Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@tanstack/react-query": { "version": "5.64.1", "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.64.1.tgz", @@ -1401,6 +1413,23 @@ "react": "^18 || ^19" } }, + "node_modules/@tanstack/react-query-devtools": { + "version": "5.64.1", + "resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.64.1.tgz", + "integrity": "sha512-8ajcGE3wXYlb4KuJnkFYkJwJKc/qmPNTpQD7YTgLRMBPTGGp1xk7VMzxL87DoXuweO8luplUUblJJ3noVs/luQ==", + "license": "MIT", + "dependencies": { + "@tanstack/query-devtools": "5.62.16" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/react-query": "^5.64.1", + "react": "^18 || ^19" + } + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -1837,6 +1866,12 @@ "dev": true, "license": "Python-2.0" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, "node_modules/autoprefixer": { "version": "10.4.20", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.20.tgz", @@ -1875,6 +1910,17 @@ "postcss": "^8.1.0" } }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -2068,6 +2114,18 @@ "dev": true, "license": "MIT" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -2161,6 +2219,15 @@ "dev": true, "license": "MIT" }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -2562,6 +2629,26 @@ "dev": true, "license": "ISC" }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", @@ -2579,6 +2666,20 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fraction.js": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", @@ -3052,6 +3153,27 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3488,6 +3610,12 @@ "node": ">= 0.8.0" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/barkmanui/package.json b/barkmanui/package.json index d4387c1..277fba1 100644 --- a/barkmanui/package.json +++ b/barkmanui/package.json @@ -11,6 +11,8 @@ }, "dependencies": { "@tanstack/react-query": "^5.64.1", + "@tanstack/react-query-devtools": "^5.64.1", + "axios": "^1.7.9", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router": "^7.1.1", diff --git a/barkmanui/src/App.tsx b/barkmanui/src/App.tsx index 51ea472..024fe46 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -1,20 +1,23 @@ import { Routes, Route} from 'react-router'; import Home from './pages/home.tsx'; -import Inventory from "./pages/inventory.tsx"; +import InventoryList from "./features/inventory/InventoryList.tsx"; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; +// Create a client +const queryClient = new QueryClient() function App() { - - return ( + <> } /> - } /> + } /> + ) } diff --git a/barkmanui/src/common/components/Button.tsx b/barkmanui/src/common/components/Button.tsx new file mode 100644 index 0000000..f181445 --- /dev/null +++ b/barkmanui/src/common/components/Button.tsx @@ -0,0 +1,9 @@ +import {PropsWithChildren} from "react"; + +function Button({children}: PropsWithChildren) { + return ( + + ) +} + +export default Button \ No newline at end of file diff --git a/barkmanui/src/features/inventory/InventoryList.tsx b/barkmanui/src/features/inventory/InventoryList.tsx new file mode 100644 index 0000000..fb6139b --- /dev/null +++ b/barkmanui/src/features/inventory/InventoryList.tsx @@ -0,0 +1,63 @@ +import {useQuery} from "@tanstack/react-query"; +import {Link} from "react-router"; +import {InventoryItem} from "./types"; +import Button from "../../common/components/Button.tsx"; + + +function InventoryList() { + + const { isPending, error, data, isFetching } = useQuery({ + queryKey: ['inventory'], + queryFn: async (): Promise => { + const response = await fetch( + import.meta.env.VITE_API_URL + '/inventory', + ) + + 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 ( + <> +
+

Inventory

+
+

+ ARFF ARFF BARK BARK +

+ + + +
{isFetching ? 'Updating...' : ''}
+ + + + + + + + + + + + {data.map((data) => ( + + + + + + + ))} + +
IDBrandItemStatus
{data.id}{data.brand}{data.name}{data.status}
+ + ) +} +export default InventoryList; \ No newline at end of file diff --git a/barkmanui/src/features/inventory/types.ts b/barkmanui/src/features/inventory/types.ts new file mode 100644 index 0000000..f7d7264 --- /dev/null +++ b/barkmanui/src/features/inventory/types.ts @@ -0,0 +1,6 @@ +export interface InventoryItem { + id: number, + brand: string, + name: string, + status: string, +} diff --git a/barkmanui/src/pages/home.tsx b/barkmanui/src/pages/home.tsx index d5ed448..143aa39 100644 --- a/barkmanui/src/pages/home.tsx +++ b/barkmanui/src/pages/home.tsx @@ -1,4 +1,5 @@ import {Link} from "react-router"; +import Button from "../common/components/Button.tsx"; function Home() { @@ -13,7 +14,7 @@ function Home() { ARFF ARFF BARK BARK

- + diff --git a/barkmanui/src/pages/inventory.tsx b/barkmanui/src/pages/inventory.tsx deleted file mode 100644 index 639c031..0000000 --- a/barkmanui/src/pages/inventory.tsx +++ /dev/null @@ -1,23 +0,0 @@ - -import {Link} from "react-router"; - -function Inventory() { - - - return ( - <> -
-

Inventory

-
-

- ARFF ARFF BARK BARK -

- - - - - - ) -} - -export default Inventory \ No newline at end of file