From d6196cd7ac59dfae5919b83734bcb1871fbf0990 Mon Sep 17 00:00:00 2001 From: Ralf Engbers Date: Thu, 5 Sep 2024 17:19:07 +1200 Subject: [PATCH] fix(mobile-credential-online-presentation): various fixes (#169) * fix(mobile-credential-online-presentation): env loading and ui * fix: typo and tailwind class * fix: typo * fix: duplicate and * fix: typo * fix: redirect loading state --- .../src/app/page.tsx | 18 ++++++++---------- .../src/components/config.tsx | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/mobile-credential-online-presentation/src/app/page.tsx b/mobile-credential-online-presentation/src/app/page.tsx index fc32040..943cc21 100644 --- a/mobile-credential-online-presentation/src/app/page.tsx +++ b/mobile-credential-online-presentation/src/app/page.tsx @@ -23,13 +23,11 @@ export default function Home() { const [loading, setLoading] = useState(false); const [results, setResults] = useState(null); - // The apiBaseURl is the URL of a MATTR verifier tenant. This app is handling the same device + // The apiBaseUrl is the URL of a MATTR verifier tenant. This app is handling the same device // flow by loading the results directly after the redirect. If the apiBaseUrl is not provided - // via an environment variable, you can provide the URL in an input field and it is presisted + // via an environment variable, you can provide the URL in an input field and it is persisted // in localStorage. - const [apiBaseUrl, setApiBaseUrl] = useState( - process.env.NEXT_PUBLIC_API_BASE_URL || localStorage.getItem("apiBaseUrl"), - ); + const [apiBaseUrl, setApiBaseUrl] = useState(null); const [redirectUri, setRedirectUri] = useState(null); // The app allows the user to edit the credential query, see the CredentialConfig component. @@ -48,7 +46,7 @@ export default function Home() { // To request credentials, we need to // 1. initialise the SDK, - // 2. repare the request options, and + // 2. prepare the request options, and // 3. call the requestCredentials function // // The mode is optional. If it is not provided, the SDK will determine the mode by the user @@ -134,14 +132,14 @@ export default function Home() { setLoading(false); }, [apiBaseUrl]); - // In the same device flow, we check if URL contains a hash and and handle the + // In the same device flow, we check if URL contains a hash and handle the // redirect when the page loads useEffect(() => { - if (window.location.hash) { + if (window.location.hash && apiBaseUrl !== null) { setLoading(true); handleRedirect(); } - }, [handleRedirect]); + }, [handleRedirect, apiBaseUrl]); return (
@@ -209,7 +207,7 @@ export default function Home() {
-
+

Results

{!results && (

{loading ? "Loading results ..." : "No results yet."}

diff --git a/mobile-credential-online-presentation/src/components/config.tsx b/mobile-credential-online-presentation/src/components/config.tsx index 9057ef1..b36f680 100644 --- a/mobile-credential-online-presentation/src/components/config.tsx +++ b/mobile-credential-online-presentation/src/components/config.tsx @@ -31,7 +31,7 @@ export function CredentialConfig({