diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2d27c99c..415b2faf 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -11,6 +11,7 @@ "bootstrap": "^5.3.3", "bootstrap-icons": "^1.11.3", "oidc-client-ts": "^3.0.1", + "openapi-fetch": "^0.10.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-oidc-context": "^3.1.0", @@ -2365,6 +2366,19 @@ "wrappy": "1" } }, + "node_modules/openapi-fetch": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/openapi-fetch/-/openapi-fetch-0.10.2.tgz", + "integrity": "sha512-GCzgKIZchnxZRnztiOlRTKk9tQT0NHvs5MNXYFtOwG7xaj1iCJOGDsTLbn/2QUP37PjGTT890qERFjvmjxzQMg==", + "dependencies": { + "openapi-typescript-helpers": "^0.0.9" + } + }, + "node_modules/openapi-typescript-helpers": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/openapi-typescript-helpers/-/openapi-typescript-helpers-0.0.9.tgz", + "integrity": "sha512-BO2TvIDAO/FPVKz1Nj2gy+pUOHfaoENdK5UP3H0Jbh0VXBf3dwYMs58ZwOjiezrbHA2LamdquoyQgahTPvIxGA==" + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 724233b7..d71fcade 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,19 +1,10 @@ -import React from "react"; import { useAuth } from "react-oidc-context"; -import { useState } from "react"; import "./App.css"; -import LinkDevice from "./Components/LinkDevice"; import Footer from "./Components/Footer"; import Navbar from "./Components/Navbar/Navbar"; -import Settings from "./Components/Settings"; -import CreatePetModal from "./Components/CreatePetModal"; -import PetPage from "./Components/PetPage"; -import type { paths } from "./web-backend-api"; -import createClient, { type Middleware } from "openapi-fetch"; function App() { const auth = useAuth(); - const [count, setCount] = useState(0); switch (auth.activeNavigator) { case "signinSilent": @@ -32,41 +23,13 @@ function App() { } if (auth.isAuthenticated) { - // Client initialisation - const authMiddleware: Middleware = { - async onRequest({ request }) { - // add Authorization header to every request - request.headers.set( - "Authorization", - `Bearer ${auth.user?.access_token}` - ); - return request; - }, - }; - - const client = createClient({ - baseUrl: "http://localhost:4000/backend", - }); - client.use(authMiddleware); - - // https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-fetch - (async () => { - // console.log("hi there!"); - // const { data, error } = await client.GET("/api/v1/devices/self", {}); - // console.log("data", data); - // console.log("error", error); - })(); - return (
- +
- {/*
- Hello USERNAME: {auth.user?.profile?.preferred_username || "User"} -
*/}
); diff --git a/frontend/src/Components/Footer.tsx b/frontend/src/Components/Footer.tsx index 2baf73a3..c00aefc2 100644 --- a/frontend/src/Components/Footer.tsx +++ b/frontend/src/Components/Footer.tsx @@ -1,5 +1,3 @@ -import React from "react"; - const Footer = () => (