From f1921dc11549300fe06bf460864e8d4fb0bbf4fe Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Tue, 14 Jan 2025 09:15:51 -0600 Subject: [PATCH 1/7] Installed react query dev tools --- barkmanui/package-lock.json | 28 ++++++++++++++++++++++++++++ barkmanui/package.json | 1 + 2 files changed, 29 insertions(+) diff --git a/barkmanui/package-lock.json b/barkmanui/package-lock.json index 01b3487..b77fb8e 100644 --- a/barkmanui/package-lock.json +++ b/barkmanui/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "dependencies": { "@tanstack/react-query": "^5.64.1", + "@tanstack/react-query-devtools": "^5.64.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router": "^7.1.1", @@ -1385,6 +1386,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 +1412,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", diff --git a/barkmanui/package.json b/barkmanui/package.json index d4387c1..5629940 100644 --- a/barkmanui/package.json +++ b/barkmanui/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "@tanstack/react-query": "^5.64.1", + "@tanstack/react-query-devtools": "^5.64.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router": "^7.1.1", From d1e5f7c61c56caa61fc5907c605b53fe818ca0f4 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 15 Jan 2025 11:31:29 -0600 Subject: [PATCH 2/7] progress? --- barkmanui/package-lock.json | 100 ++++++++++++++++++++++++++++++ barkmanui/package.json | 1 + barkmanui/src/App.tsx | 7 ++- barkmanui/src/pages/inventory.tsx | 38 +++++++++++- 4 files changed, 143 insertions(+), 3 deletions(-) diff --git a/barkmanui/package-lock.json b/barkmanui/package-lock.json index b77fb8e..6848e14 100644 --- a/barkmanui/package-lock.json +++ b/barkmanui/package-lock.json @@ -10,6 +10,7 @@ "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", @@ -1865,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", @@ -1903,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", @@ -2096,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", @@ -2189,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", @@ -2590,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", @@ -2607,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", @@ -3080,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", @@ -3516,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 5629940..277fba1 100644 --- a/barkmanui/package.json +++ b/barkmanui/package.json @@ -12,6 +12,7 @@ "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..b268533 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -1,12 +1,14 @@ import { Routes, Route} from 'react-router'; import Home from './pages/home.tsx'; import Inventory from "./pages/inventory.tsx"; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; +// Create a client +const queryClient = new QueryClient() function App() { - - return ( + <> } /> @@ -15,6 +17,7 @@ function App() { + ) } diff --git a/barkmanui/src/pages/inventory.tsx b/barkmanui/src/pages/inventory.tsx index 639c031..1fb70cf 100644 --- a/barkmanui/src/pages/inventory.tsx +++ b/barkmanui/src/pages/inventory.tsx @@ -1,8 +1,24 @@ - +import {useQuery} from "@tanstack/react-query"; import {Link} from "react-router"; +import inventory from "./inventory.tsx"; +import { Key, ReactElement, JSXElementConstructor, ReactNode, ReactPortal } from "react"; function Inventory() { + const {isPending, error, data, isFetching} = useQuery({ + queryKey: ['inventory'], + queryFn: async () => { + const response = await fetch( + 'https://barkdev.ts.drewr.io/inventory', + ) + return await response.json() + }, + }) + + if (isPending) return 'Loading...' + + if (error) return 'An error has occurred: ' + error.message + return ( <> @@ -15,7 +31,27 @@ function Inventory() { +
{isFetching ? 'Updating...' : ''}
+ + + + + + + + + + + {data.map((data: { id: Key | null | undefined; brand: string | number | boolean | ReactElement> | Iterable | ReactPortal | null | undefined; name: string | number | boolean | ReactElement> | Iterable | ReactPortal | null | undefined; status: string | number | boolean | ReactElement> | Iterable | ReactPortal | null | undefined; }) => ( + + + + + + ))} + +
IDBrandItemStatus
{data.brand}{data.name}{data.status}
) } From 3f6104aa9d4375be06b2e8675b99c17367f3e339 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 15 Jan 2025 11:51:21 -0600 Subject: [PATCH 3/7] progress? pt2 --- barkmanui/src/pages/inventory.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/barkmanui/src/pages/inventory.tsx b/barkmanui/src/pages/inventory.tsx index 1fb70cf..0ea72b9 100644 --- a/barkmanui/src/pages/inventory.tsx +++ b/barkmanui/src/pages/inventory.tsx @@ -1,11 +1,10 @@ import {useQuery} from "@tanstack/react-query"; import {Link} from "react-router"; import inventory from "./inventory.tsx"; -import { Key, ReactElement, JSXElementConstructor, ReactNode, ReactPortal } from "react"; function Inventory() { - const {isPending, error, data, isFetching} = useQuery({ + const { isPending, error, data, isFetching } = useQuery({ queryKey: ['inventory'], queryFn: async () => { const response = await fetch( @@ -43,7 +42,7 @@ function Inventory() { - {data.map((data: { id: Key | null | undefined; brand: string | number | boolean | ReactElement> | Iterable | ReactPortal | null | undefined; name: string | number | boolean | ReactElement> | Iterable | ReactPortal | null | undefined; status: string | number | boolean | ReactElement> | Iterable | ReactPortal | null | undefined; }) => ( + {data.map((data) => ( {data.brand} {data.name} From ea40d6fc3c4b68e7a5e402ce531c823818c454b3 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 15 Jan 2025 15:40:59 -0600 Subject: [PATCH 4/7] progress? pt3 --- barkmanAPI/Program.cs | 2 +- barkmanui/src/pages/inventory.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 19d4ed2..2131b7d 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -12,7 +12,7 @@ builder.Services.AddSwaggerGen(c => var app = builder.Build(); -if (app.Environment.IsDevelopment()) +if (! app.Environment.IsProduction()) { app.UseSwagger(); app.UseSwaggerUI(c => diff --git a/barkmanui/src/pages/inventory.tsx b/barkmanui/src/pages/inventory.tsx index 0ea72b9..f339b45 100644 --- a/barkmanui/src/pages/inventory.tsx +++ b/barkmanui/src/pages/inventory.tsx @@ -1,6 +1,5 @@ import {useQuery} from "@tanstack/react-query"; import {Link} from "react-router"; -import inventory from "./inventory.tsx"; function Inventory() { From 524730a55925f2887632916f510acc87920c5e96 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 15 Jan 2025 16:18:31 -0600 Subject: [PATCH 5/7] it works --- barkmanui/src/pages/inventory.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/barkmanui/src/pages/inventory.tsx b/barkmanui/src/pages/inventory.tsx index f339b45..250ee6a 100644 --- a/barkmanui/src/pages/inventory.tsx +++ b/barkmanui/src/pages/inventory.tsx @@ -43,6 +43,7 @@ function Inventory() { {data.map((data) => ( + {data.id} {data.brand} {data.name} {data.status} From e2deae0d9aa504f66ff64d05437a2f6c45c4b843 Mon Sep 17 00:00:00 2001 From: Drew Rautenberg Date: Wed, 15 Jan 2025 20:36:03 -0600 Subject: [PATCH 6/7] Refactor inventory functionality and improve modularity. Relocated inventory page to features directory and renamed it for clarity. Introduced a reusable `Button` component and replaced inline buttons across components. Added type definitions for inventory items and environment variable support for API URL configuration. --- barkmanui/.env | 1 + barkmanui/src/App.tsx | 4 ++-- barkmanui/src/common/components/Button.tsx | 9 +++++++++ .../inventory/InventoryList.tsx} | 19 ++++++++++++------- barkmanui/src/features/inventory/types.ts | 6 ++++++ barkmanui/src/pages/home.tsx | 3 ++- 6 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 barkmanui/.env create mode 100644 barkmanui/src/common/components/Button.tsx rename barkmanui/src/{pages/inventory.tsx => features/inventory/InventoryList.tsx} (77%) create mode 100644 barkmanui/src/features/inventory/types.ts 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/src/App.tsx b/barkmanui/src/App.tsx index b268533..024fe46 100644 --- a/barkmanui/src/App.tsx +++ b/barkmanui/src/App.tsx @@ -1,6 +1,6 @@ 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 @@ -12,7 +12,7 @@ function App() { <> } /> - } /> + } /> 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/pages/inventory.tsx b/barkmanui/src/features/inventory/InventoryList.tsx similarity index 77% rename from barkmanui/src/pages/inventory.tsx rename to barkmanui/src/features/inventory/InventoryList.tsx index 250ee6a..fb6139b 100644 --- a/barkmanui/src/pages/inventory.tsx +++ b/barkmanui/src/features/inventory/InventoryList.tsx @@ -1,17 +1,23 @@ import {useQuery} from "@tanstack/react-query"; import {Link} from "react-router"; +import {InventoryItem} from "./types"; +import Button from "../../common/components/Button.tsx"; -function Inventory() { + +function InventoryList() { const { isPending, error, data, isFetching } = useQuery({ queryKey: ['inventory'], - queryFn: async () => { + queryFn: async (): Promise => { const response = await fetch( - 'https://barkdev.ts.drewr.io/inventory', + 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...' @@ -27,7 +33,7 @@ function Inventory() { ARFF ARFF BARK BARK

- +
{isFetching ? 'Updating...' : ''}
@@ -54,5 +60,4 @@ function Inventory() { ) } - -export default Inventory \ No newline at end of file +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

- + From 88d583ee4f6baaae9318d488af7f6062cbad260e Mon Sep 17 00:00:00 2001 From: Drew Rautenberg <8411007+DrewRautenberg@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:48:57 -0600 Subject: [PATCH 7/7] Update barkmanAPI/Program.cs Co-authored-by: Nix <3743825+NixFey@users.noreply.github.com> --- barkmanAPI/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barkmanAPI/Program.cs b/barkmanAPI/Program.cs index 8de39ad..e0e9a95 100644 --- a/barkmanAPI/Program.cs +++ b/barkmanAPI/Program.cs @@ -22,7 +22,7 @@ builder.Services.AddCors(options => }); var app = builder.Build(); -if (! app.Environment.IsProduction()) +if (!app.Environment.IsProduction()) { app.UseSwagger(); app.UseSwaggerUI(c =>