From ec53c9700fc56ce6629dffd1a8ee3f8e28ec08ae Mon Sep 17 00:00:00 2001 From: Daniele Guido <1181642+danieleguido@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:34:25 +0100 Subject: [PATCH] Fix termsOfUse acceptance before getting the token --- src/components/TermsOfUseModal.tsx | 6 +++ src/components/TokenWrapper.tsx | 67 ++++++++++++++++++------------ 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/src/components/TermsOfUseModal.tsx b/src/components/TermsOfUseModal.tsx index 5647605..48efcc2 100644 --- a/src/components/TermsOfUseModal.tsx +++ b/src/components/TermsOfUseModal.tsx @@ -99,6 +99,12 @@ const TermsOfUseModal: React.FC<{ [wsStatus, token], ) + useEffect(() => { + // if this is just a login, just close it. + if (acceptedTermsDate && view === BrowserViewTermsOfUse) { + setView(null) + } + }, [acceptedTermsDate]) useEffect(() => { if (!enableAcceptTermsButton && isIntersecting) { setEnableAcceptTermsButton(true) diff --git a/src/components/TokenWrapper.tsx b/src/components/TokenWrapper.tsx index 2e78fd6..6eead60 100644 --- a/src/components/TokenWrapper.tsx +++ b/src/components/TokenWrapper.tsx @@ -73,8 +73,7 @@ const TokenWrapper: React.FC<{ delay?: number }> = ({ delay = 2000 }) => {

{status === "idle" && !isBusy && "Generate your API token"} - {isBusy && "Generating your API token..."} - {status === "pending" && " Almost there..."} + {(isBusy || status === "pending") && "Generating your API token..."} {status === "error" && errorIsFailure && !isBusy && @@ -82,19 +81,6 @@ const TokenWrapper: React.FC<{ delay?: number }> = ({ delay = 2000 }) => { {status === "success" && !isBusy && "Your Api token"}

- {showLoginForm && ( -
-

Please login to get your Api Token

- -
- )} - {errorIsFailure && ( = ({ delay = 2000 }) => { value="" >
- API access is always subject to the  - - .{" "} - {acceptTermsDate !== null && ( + {acceptTermsDate !== null ? (

- You accepted the Terms of Use{" "} + API access is always subject to the  + + . You accepted the Terms of Use{" "} {DateTime.fromISO(acceptTermsDate) .setLocale("en-GB") .toLocaleString(DateTime.DATETIME_FULL)}

+ ) : ( +

+ You have not accepted our Terms of Use yet. Please read the{" "} + entire terms of use document carefully and accept it before + using the token. +

)}
+ {acceptTermsDate === null && ( + + )} + {showLoginForm && ( +
+

Please login to get your Api Token

+ +
+ )} {isBusy && (
Loading...