diff --git a/src/app/App.tsx b/src/app/App.tsx index 7c6bf82..dc800bf 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -2,72 +2,44 @@ import { useState } from 'react' import reactLogo from '../assets/react.svg' import viteLogo from '/vite.svg' import './App.css' -import { Auth0Provider } from '@auth0/auth0-react' +import { useUserAPI } from '../providers/pond/userAPI' +import { useAuth0 } from '@auth0/auth0-react' import { or } from '../utils/types' -import AuthWrapper from '../providers/auth' -import HTTPProvider from '../providers/http' -// import { useUserAPI } from '../providers/pond/userAPI' -// import LoginButton from '../providers/LoginButton' function App() { const [count, setCount] = useState(0) - // const userAPI = useUserAPI(); + const userAPI = useUserAPI(); + const useAuth = useAuth0(); - let url: string | undefined = window.location.origin; - let audience: string | undefined; - if (window.location.origin === "https://staging.brandxtech.ca") { - url = import.meta.env.VITE_AUTH0_CLIENT_STAGING_DOMAIN; - audience = import.meta.env.VITE_AUTH0_STAGING_AUDIENCE; - } else { - url = import.meta.env.VITE_AUTH0_CLIENT_DOMAIN; - audience = import.meta.env.VITE_AUTH0_AUDIENCE; - } + let user_id = or(useAuth.user?.sub, "") +// console.log("User ID: ", user_id) - let client_id = import.meta.env.VITE_AUTH0_BXT_CLIENT_ID; - - console.log(url) - // console.log(audience) + if (user_id.length > 1) userAPI.getUser(user_id).then(resp => { + console.log(resp) + }) return ( - - - - - {/* */} -
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- The new Adaptive App -

-
-

+ <>

+ + Vite logo + + + React logo + +
+

Vite + React

+
+ +

+ The new Adaptive App +

+

Coming soon -

-
-
- -
+

+ ) } -export default App +export default App \ No newline at end of file diff --git a/src/app/AuthHTTPWrapper.tsx b/src/app/AuthHTTPWrapper.tsx new file mode 100644 index 0000000..47eea4b --- /dev/null +++ b/src/app/AuthHTTPWrapper.tsx @@ -0,0 +1,41 @@ +import { Auth0Provider } from '@auth0/auth0-react' +import { or } from '../utils/types' +import AuthWrapper from '../providers/auth' +import HTTPProvider from '../providers/http' +import App from './App' + +function AuthHTTPWrapper() { + + let url: string | undefined = window.location.origin; + let audience: string | undefined; + if (window.location.origin === "https://staging.brandxtech.ca") { + url = import.meta.env.VITE_AUTH0_CLIENT_STAGING_DOMAIN; + audience = import.meta.env.VITE_AUTH0_STAGING_AUDIENCE; + } else { + url = import.meta.env.VITE_AUTH0_CLIENT_DOMAIN; + audience = import.meta.env.VITE_AUTH0_AUDIENCE; + } + + let client_id = import.meta.env.VITE_AUTH0_BXT_CLIENT_ID; + + return ( + + + + + + + + ) +} + +export default AuthHTTPWrapper diff --git a/src/app/main.tsx b/src/app/main.tsx index 6f4ac9b..623521e 100644 --- a/src/app/main.tsx +++ b/src/app/main.tsx @@ -1,10 +1,10 @@ import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' -import App from './App.tsx' import './index.css' +import AuthHTTPWrapper from './AuthHTTPWrapper.tsx' createRoot(document.getElementById('root')!).render( - + , ) diff --git a/src/providers/auth.tsx b/src/providers/auth.tsx index 9f731aa..1ef11b5 100644 --- a/src/providers/auth.tsx +++ b/src/providers/auth.tsx @@ -4,7 +4,7 @@ import { PropsWithChildren, useEffect } from "react"; export default function AuthWrapper(props: PropsWithChildren<{}>) { const { children } = props; - const { isLoading, loginWithRedirect, isAuthenticated, user } = useAuth0(); + const { isLoading, loginWithRedirect, isAuthenticated } = useAuth0(); useEffect(() => { // console.log("Authenticated: ", isAuthenticated) diff --git a/src/providers/pond/pond.tsx b/src/providers/pond/pond.tsx index 95aea86..6eaac36 100644 --- a/src/providers/pond/pond.tsx +++ b/src/providers/pond/pond.tsx @@ -2,7 +2,7 @@ import { PropsWithChildren } from "react"; import UserProvider, { useUserAPI } from "./userAPI"; export const pondURL = (partial: string, demo: boolean = false): string => { - let url = process.env.REACT_APP_API_URL + (demo ? "/demo" : "") + partial; + let url = import.meta.env.REACT_APP_API_URL + (demo ? "/demo" : "") + partial; // if (isStaging()) url = process.env.REACT_APP_STAGING_API_URL + (demo ? "/demo" : "") + partial; return url; };