From e7fc558031a0bef3af7caf64170ddb8f504dfc5d Mon Sep 17 00:00:00 2001 From: garronej Date: Tue, 2 May 2023 02:52:24 +0200 Subject: [PATCH] Better temrms explainantion --- src/keycloak-theme/login/pages/Terms.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/keycloak-theme/login/pages/Terms.tsx b/src/keycloak-theme/login/pages/Terms.tsx index ce92a8a..c4744cd 100644 --- a/src/keycloak-theme/login/pages/Terms.tsx +++ b/src/keycloak-theme/login/pages/Terms.tsx @@ -26,21 +26,25 @@ export default function Terms(props: PageProps { - const resource = (() => { + const tos_url = (() => { switch (currentLanguageTag) { - case "fr": - return tos_fr_url; - default: - return tos_en_url; + case "fr": return tos_fr_url; + default: return tos_en_url; } })(); - // webpack5 (used via storybook) loads markdown as string, not url - if (resource.includes("\n")) return resource - const response = await fetch(resource); - return response.text(); - }, + if ("__STORYBOOK_ADDONS" in window) { + // NOTE: In storybook, when you import a .md file you get the content of the file. + // In Create React App on the other hand you get an url to the file. + return tos_url; + } + + const tosRawMarkdown = fetch(tos_url).then(response => response.text()); + + return tosRawMarkdown; + + } }); useRerenderOnStateChange(evtTermMarkdown);